How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Questions regarding the use of UaModeler

Moderator: uamodeler

Post Reply
ChSch
Hero Member
Hero Member
Posts: 21
Joined: 07 Oct 2012, 11:18

How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Post by ChSch »

I tried BaseDataTyp, but than I get compiler errors like this:
"Fehler: »class UaVariant« hat kein Element namens »toVariant«"

Do you have a solution for me?
I know its pretty hard to handle the Variant Typ in the uaModeler, but I need it for my model.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3069
Joined: 18 Mar 2011, 15:09

Re:How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Post by Support Team »

I think you try to add a property to the Server object like in your last post.
The code examples in this post will be useful for exactly this.

BaseDataType is abstract, so normally you should not use it. If you want to use it anyway you can call

Code: Select all

defaultValue.clear();
or
delete the line with "toVariant" and call

Code: Select all

pVariableType->setDataType(OpcUaId_BaseDataType);
Kind Regards, Support Team
Best regards
Unified Automation Support Team

ChSch
Hero Member
Hero Member
Posts: 21
Joined: 07 Oct 2012, 11:18

Re:How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Post by ChSch »

Ok, good to know.

Unfortunately, I didn' t mention that I created a subtype of "DeviceType" (from OPC UA Part DI) and this subtype has a method "Transfer".
The signature should look like this:

Transfer(
[in] String CommunicationRelationId,
[in] Variant[] SendData,
[out] Variant[] ReceiveData,
[out] Integer ServiceError);

I think I need the Variant[] Typ during the modeling process.
I had used a simpler DataTyp e.g. Int32 during the modeling time. After that I tried to change the type in the generated code, but there are to many dependence on the previous DataTyp Int32.

Do you have an idea/hint what I can do?

Thank you for your efforts

ChSch
Hero Member
Hero Member
Posts: 21
Joined: 07 Oct 2012, 11:18

Re:How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Post by ChSch »

Mmmm I don't know why, but the form put some extra text after the first
"Do you have an idea/hint what I can do?" If I use the Edit mode, I see the right message. The extra text occurs only in the preview and the final view.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3069
Joined: 18 Mar 2011, 15:09

Re:How I can use the Built-in DataTyp “Variant” or “Variant[]” ?

Post by Support Team »

Hi ChSch,

Can you update the UaModeler to version 1.2? This might fix the compile errors.

Note that the implementation class of the Type (.cpp) will not be overwritten when generating code. So you have to delete the file before generating code.

Kind Regards
Best regards
Unified Automation Support Team

Post Reply