What is the significance of "ns=2;s=" in an OPC node path?
Asked Answered
O

2

15

I have noticed that all OPC tag Ids are prefixed with ns=2;s=.

Some examples of possible NodeId values would be:

  • ns=2;s=AcquisitionTimeRemaining
  • ns=2;s=Status
  • ns=2;s=Time

I am wondering what the significance of this prefix is.


Research:

Someone else asked this question on a forum. The answer given was that ns prefix specifies the namespace index a NodeId belongs to. The answer-er goes on to state:

For weird historical reasons, we assume ns=1 if it’s not explicitly present. Kepware’s Nodes are all in ns=2, so, it must be specified.

I am not using "Kepware's Nodes" and my namespace is still set to 2... Will this always be 2? I could not find any information on what the s in the prefix represents.

Obsessive answered 19/8, 2019 at 19:40 Comment(0)
L
20

ns=2 is indicating namespace index 2.

s=foo is indicating it's a String type NodeId with value "foo".

There are 4 types of NodeId:

  1. Numeric (value is a UInteger)
  2. String (value is a String)
  3. Guid (value is a Guid/UUID)
  4. Opaque (value is ByteString)

This syntax is borrowed from the syntax used to encode a NodeId in the OPC UA XML encoding:

ns=<namespaceindex>;<type>=<value>

What namespace nodes appear in and how many namespaces there are depends on the server you are connected to.

Lizzettelizzie answered 19/8, 2019 at 19:51 Comment(3)
It should be noted that the specification allows for namespace indices to change in between sessions. As such, saving the numeric namespace index should be considered unsafe and bad (even if wide-spread) practice as it is only guaranteed to be valid in the context of the current session.Madalena
I understand that "ns" is for a "namespace index", but what does that mean? Why is it always 2? Why not 3? Or 154742? What is the purpose of this number, and how do you figure out what it should be?Rieger
@Rieger namespaces are identified by a URI. The index represents its position in the server’s NamespaceArray variable. You don’t really “figure it out” ahead of time - you either browse the server and identify the Nodes you are interested in, and store the NodeId however makes sense for your client, or you are provided a list of NodeIds out of band and take them as given.Lizzettelizzie
C
6

The namespace values are only depending of your OPC UA Server and its configuration. What is mandatory is that 0 is reserved for OPC UA default namespace.

You can read/subscribe to the OPC UA Node which value describe your OPC UA Server Namespace configuration at "ns=0;i=2255" (Server_NamespaceArray). The Node value is an array of all the Namespace available at this Server

Cervical answered 20/8, 2019 at 6:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.