Hello, I have a question about NodeIds.
I want to use the device set nodes so I am loading in the xml file from
http://opcfoundation.org/UA/schemas/DI/ ... deSet2.xml
In this XML file it specifies the node Id of the device set is "ns=1;i=5001"
When I create a model in UaModeler and load in the Device set model it also shows the Device Set Node Id as "1:5001".
I then tried to get the node in my code with .getNode(new NodeId(1, 5001)); and this failed.
When I browsed my server with UaExpert I saw that the Device Set Node Id was "2:5001" and I could get the node in my server code with .getNode(new NodeId(2, 5001));
Now I understand from another forum post that NodeIds can change when the server is restarted or other nodes are added but how then do I lookup the DeviceSet node or other nodes from my server code when I cannot rely on the NodeId?
Thankyou for your help.
Shaun
NodeId Question
Moderator: uasdkjava
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: NodeId Question
Hello Shauney,
The Server will have a NamespaceArray below the "Server" node, this is fixed on NS=0 (OPCFoundation namespace), which every UA Server must have. In this array you will find the mapping of NamespaceURI and NamespaceIndex. Therefore a Client should never persist (or hard code) any NamespaceIndex, you always need to resolve the mapping again when connecting to the particular Server a second time. The only namespace you can rely on being at the same index every time is the NS=0.
With the UaModeler the DI namespace and the PLCopen and maybe other "companion" standard namespaces, are typically treated different because they are "in-built" in the SDK (and the known to UaModeler). With the UaModeller you would normally create "your own" model, rather that create models that already exist.
Best Regards
Support Team
The Server will have a NamespaceArray below the "Server" node, this is fixed on NS=0 (OPCFoundation namespace), which every UA Server must have. In this array you will find the mapping of NamespaceURI and NamespaceIndex. Therefore a Client should never persist (or hard code) any NamespaceIndex, you always need to resolve the mapping again when connecting to the particular Server a second time. The only namespace you can rely on being at the same index every time is the NS=0.
With the UaModeler the DI namespace and the PLCopen and maybe other "companion" standard namespaces, are typically treated different because they are "in-built" in the SDK (and the known to UaModeler). With the UaModeller you would normally create "your own" model, rather that create models that already exist.
Best Regards
Support Team