[SOLVED] Create Variables for an Object ...

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
falko.wiese
Hero Member
Hero Member
Posts: 26
Joined: 04 Oct 2012, 17:56

[SOLVED] Create Variables for an Object ...

Post by falko.wiese »

Hi guys,
I have a question regarding the creation of variable nodes for an object node. Let me describe it a bit deeper ... First of all I created the type declaration objects (instances of UaObjectTypeSimple and BaseDataVariableType), the type nodes. After that, I created the 'real nodes', the object nodes (instances of UaObjectBase and UserDataBase). I created for sure my own subtypes, but that's not my problem.
Now I want to create multiple instances of object nodes, those things can be done if I use different names for the objects I want to create. If I want create for all the different objects also the appropriate 'instance variables', then it seems to me, that I have to create also a new 'declaration' for every new 'instance variable' (the above mentioned type nodes for variables). Due to, I can only give those nodes different names. Maybe I missed something, maybe I'm right, I don't know. If I shall tell you the truth, it destroys my metapher of Types/Classes and Objects, and Declarations and Definitions, respectively. It looks really a bit strange, if I have a look in the Types Tree of my created types with a standard UA Client as UaExpert. The rest of the application is working properly.
I ask this question to be save about my way to do such things. If you don't understand my issue, feel free to give me hint. I'll spend then a bit more time for a better description.

Any help is really appreciated. Thanks in advance,
Falko.

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

Re:Create Variables for an Object ...

Post by Support Team »

Hi Falko,

Here is some information that may help you to get a better understanding of OPC UA and to (hopefully) clarify your question:

OPC UA defines the two node attributes NodeId and BrowseName which are relevant for your question.

The BrowseName is the qualified name of a node and like you expect from object oriented programming, the name of a class member is the same like the name on the instance. See following example.

MyObjectType (ObjectType)
- Variable1 (Variable - instance declaration)
- Variable2 (Variable - instance declaration)
- Method1 (Method - instance declaration)

MyObjectInstance1 (Object instance of MyObjectType)
- Variable1 (Variable)
- Variable2 (Variable)
- Method1 (Method)

MyObjectInstance2 (Object instance of MyObjectType)
- Variable1 (Variable)
- Variable2 (Variable)
- Method1 (Method)

The BrowseName for instance variable created based on a type definition like Variable1 MUST have the same BrowseName like the instance declaration.

The NodeId is a unique identifier for a node. It can be a numeric value, a string or a GUID. Every object and variable created, also the instances based on the ObjectType MyObjectType MUST have a unique identifier. This can be done by using the path as NodeId like MyObjectInstance1.Variable1 as NodeId for Variable1 on Object MyObjectInstance.
In object oriented programming the NodeId would be something like a pointer/reference to the object or variable and must be unique as well.

MyObjectType (NodeId = MyObjectType BrowseName = MyObjectType)
- Variable1 (NodeId = MyObjectType.Variable1 BrowseName = Variable1)
- Variable2 (NodeId = MyObjectType.Variable2 BrowseName = Variable2)
- Method1 (NodeId = MyObjectType.Method1 BrowseName = Method1)

MyObjectInstance1 (NodeId = MyObjectInstance1 BrowseName = MyObjectInstance1)
- Variable1 (NodeId = MyObjectInstance1.Variable1 BrowseName = Variable1)
- Variable2 (NodeId = MyObjectInstance1.Variable2 BrowseName = Variable2)
- Method1 (NodeId = MyObjectInstance1.Method1 BrowseName = Method1)

MyObjectInstance2 (NodeId = MyObjectInstance2 BrowseName = MyObjectInstance2)
- Variable1 (NodeId = MyObjectInstance2.Variable1 BrowseName = Variable1)
- Variable2 (NodeId = MyObjectInstance2.Variable2 BrowseName = Variable2)
- Method1 (NodeId = MyObjectInstance2.Method1 BrowseName = Method1)

I assume you mixed up the concepts of BrowseName and NodeId.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

falko.wiese
Hero Member
Hero Member
Posts: 26
Joined: 04 Oct 2012, 17:56

Re:Create Variables for an Object ...

Post by falko.wiese »

Thanks, it helped a lot.

-Falko

Post Reply