UA Node IDs are strings that can be handled in the same way as OPC DA Item IDs and Xi Instance IDs.
However there is one complication. The UA Node ID string contains a namespace index that may be different when a client reconnects to the server at a later time. Applications that browse the nodes in each session always get the correct current Node IDs from the server.
Applications with predefined Node IDs may have namespace indices are not valid anymore.
OPCDA.NET-UA has an internal namespace index mapping mechanism that hides this UA behavior and allows the application to handle UA Node IDs as constant strings in the same way as OPC DA Item IDs. For this functionality OPCDA.NET-UA needs the namespace URI table that matches the persisted UA Node IDs. This table can be provided in two ways:
a) NamespaceURIs XML File
When a UA server is connected OPCDA.NET-UA loads the XML file for this server or creates the file if it doesn't exist.
The file is in the same directory as the application executable (aaa.exe) and has the name aaa.url.XML
The url part of the filename is the UA server URL without the leading xxx://
The XML file created when the Node IDs are determined and persisted must preserved. It must be copied with the application executable and the file name needs to be adapted in case the server URL is changed. A newly created file doesn't necessarily match the Node IDs persisted in the application.
The XML file mechanism is convenient and fully automatic but has risks. The application may fail if the XML file was deleted, was not copied or the filename was not adapted to a changed URL.
b) NamespaceURI table within the application
Preserving the namspaceURI table within the application eliminates the risks involved with NamespaceURIs XML files.
OPCDA.NET-UA doesn't load or create a namespaceURI XML file if the application defines a namspaceURI table.
Sample code to define the namspaceURI table:
OpcServer
srv = new OpcServer();
srv.UaDaNamespaceURIs =
new string[] {"http://opcfoundation.org/UA/SDK/COMInterop",
"opc.com://localhost/Advosol.SimDAServer.1/DA",
"opc.com://localhost/Advosol.SimAEServer.1/AE",
"opc.com://localhost/Advosol.HDA.PE.Net4.Test.4/HDA",
"http://opcfoundation.org/UA/Diagnostics"
};
srv.Connect(cbOPCServers.Text);
dbind.Subscribe( "ns=2;s=0:SimulatedData.Signal", this.Checkbox1 );
The DA3TestClientUA can be used to determine the Node IDs and the namespace URI table to be coded into the developed application. Copy a branch or items in the browse result to the Read tab to see the Node ID string. The Namespace URI table can be retrieved from the generated XML file for the accessed UA server.
IMPORTANT: Make sure that a previously created Namespace URI XML file for this UA server is deleted before the test client session is started.