Max Ivanov
Max Ivanov

Reputation: 6561

Can I read a value using a path in OPC UA?

Consider this OPC UA tree (from a publicly available server at opc.tcp://opcuaserver.com:48010):

enter image description here

From what I understand, one can read values from the OPC UA server, using a Node ID (which uniquely identifies the node):

const dataValue = await session.read({
  nodeId: "ns=3;s=AirConditioner_1.Temperature",
  attributeId: AttributeIds.Value
});
console.log(" Temperature = ", dataValue.toString());

Can I read the value programmatically by providing a path? If yes, how? Maybe it can be done in a few steps?

const dataValue = await session.somehowReadTheValueFromPath(
  "Views.AirConditionerView.AirConditioner_1.Temperature.Value"
);
console.log(" Temperature = ", dataValue.toString());

I've seen some mentions of makeBrowsePath and translateBrowsePath but it's all new to me and I can't wrap my head around how these can be used.

Examples are using node-opcua client. If you can provide advice in a language other than Node.js I'd appreciate that too!

Upvotes: 1

Views: 2169

Answers (1)

Kevin Herron
Kevin Herron

Reputation: 6985

TranslateBrowsePathToNodeIds is generally used when programming against type definitions where you know what the path of BrowseNames will be because they are defined by the type definition of each node in the path.

You need to have an idea of the reference type between each BrowsePath component and the namespace index of the BrowseName of each component. There is no service to turn a generic looking path such as the one in your 2nd example into a NodeId.

Upvotes: 1

Related Questions