'OpcUA address space
I'm working the first time on a project that requires an OpcUA connection.
I'm using the Qt wrapper (Qt OPCUA) with the open62541 backend.
The manufacturer of the PLC that hosts the server told me the list of the variables I can access:
MT_MAX_SETUP (qreal)
MT_ALARM (bool)
...
and several others.
Using the example Qt OPC UA Viewer Example I discovered the nodeId of those variables, for example:
`ns=4;s=MT_MAX_SETUP`
so I can retrieve its value after connection in this way:
_opcNode = _opcUaClient->node("ns=4;s=MT_MAX_SETUP");
connect(_opcNode, &QOpcUaNode::attributeRead, this, &MyOPC::handleAttributes);
connect(_opcNode, &QOpcUaNode::attributeUpdated, this, &MyOPC::handleAttributes);
_opcNode->readAttributes(QOpcUa::NodeAttribute::Value);
Is it correct this approach? Should the manufacturer have told me also the namespace ns=4?
Solution 1:[1]
Is it correct this approach? Should the manufacturer have told me also the namespace ns=4?
You should probably ask them yourself. Otherwise, you'll have to search for these variables yourself which may or may not be a challenge.
If you need a user-facing tool to help you navigate through UA while developing, I'd recommend using UAExpert
Solution 2:[2]
Yes, you should know the NamespaceUri and then preferably find the respective NamespaceIndex from the NamespaceArray that the server provides. Often, you can trust that the NamespaceIndex is fixed, but not always, so this will play it safe for you.
You can read the NamespaceArray (under Server object) with UaExpert or Prosys OPC UA Browser and find the NamespaceUri from there yourself, too.
Or if your library supports providing the NodeId as ExpandedNodeId, you could simply use the NamespaceUri in it instead. This would then look in the XML string representation something like "nsu=urn:the_namespace_uri;s=MT_MAX_SETUP".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dtc |
| Solution 2 | Jouni Aro |
