I would like to get some clarifications about the expected behavior of the BrowseName when creating an instance of an object.
Suppose I have multiple namespaces:
- 0: OPC foundation
- 1: My server namespace
- 2: Another namespace with type definitions
Instances are created into the namespace with index 1.
Suppose I create an object from a type definition from namespace with index 2.
The created object will have a node ID where the namespace index will be 1. What should be the namespace index in the BrowseName of that object instance:
- Should it be also the index of the namespace where the instance is created (1 in the example)?
- Should it be the index of the namespace where the type is defined (2 in the example)?
- It does not matter?
If you create a standalone instance of an object or variable the you give it a new BrowseName with an index in any namespace that is appropriate (i.e. if you create an instance of PropertyType to represent the well-known Property "NodeVersion" on a Node then the namespace index is 0).
You should use the NodeId namespace the the BrowseName is not defined in another model.
If you create an instance while instantiating the tree under a new object or variable the BrowseName namespace is exactly the same as the InstanceDeclaration in the ObjectType or VariableType.
Regarding your last statement about instantiating the tree under a new object, I would like to take an example to illustrate.
Suppose I defined an object type MyObjectType in the namespace with index 2. This object type has:
- a child variable MyVariable
- and a child object MyOtherObject with object type MyOtherObjectType defined into the namespace index say 3.
In addition, the object type MyOtherObjectType has a child variable MyOtherVariable.
Now I create an object instance MyObject into the namespace with index 1 from the object type MyObjectType. The resulting BrowseName in the instance object tree would be:
- MyObject has BrowseName "1:MyObject" (node ID being "ns=1;something)
- MyVariable has BrowseName "2:MyVariable" (node ID being "ns=1;something else) since the corresponding InstanceDeclaration is in namespace 2
- MyOtherObject has BrowseName "2:MyOtherObject" (node ID being "ns=1;something else) since the corresponding InstanceDeclaration is in namespace 2
- MyOtherVariable has BrowseName "3:MyOtherVariable" (node ID being "ns=1;something else) since the corresponding InstanceDeclaration is in namespace 3
Is this what you meant with your last statement?