Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Is There A Way to Get The NodeId From A String Path To Node?
January 25, 2024
2:25, EET
Avatar
bill.lyon@weco.com
Member
Members
Forum Posts: 3
Member Since:
January 20, 2024
sp_UserOfflineSmall Offline

Hello,

Is there a way to get the NodeId from a path to the node? In their C# client Traegar will let you get to the node with something like “ns=2;s=WI_OPC/Database.FreeSpace” and I’m hoping for something similar. If I browse to the previous example in your ProsysOPCUAClient, it shows up as:
Root > Objects > WI_OPC
Nodes
——————————————————————————
Database.FreeSpace

I know I can get to it by calling
NodeId rootNodeId = Identifiers.RootFolder;
List references = client.getAddressSpace().browse(rootNodeId);
List references2 = client.getAddressSpace().browse(references.get(0).getNodeId()); // Objects
List references3 = client.getAddressSpace().browse(references2.get(1).getNodeId()); // WI_OPC
NodeId freeSpaceNodeId = references3.get(222).getReferenceTypeId(); // Database.FreeSpace
UaNode node = client.getAddressSpace().getNode(freeSpaceNodeId);
but that seems awfully clumsy, so I assume I’m missing the correct way to do it.

Bill

January 25, 2024
9:11, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 349
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

In general, there is no way to get a NodeId from a “String path” to the Node. Some Nodes in some OPC UA Servers might use this type of convention for their NodeIds, but the NodeIds could be just numbers or GUID so you can’t assume this type of logic would always work.

However, there is TranslateBrowsePathsToNodeIds Service(see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.4). Various overloads of translateBrowsePathsToNodeIds are available in the com.prosysopc.ua.client.AddressSpace class that can be accessed by calling the getAddressSpace method of UaClient instance. These methods require you to know the BrowsePath to the Node, but if you do know these, then you could use these methods to get the NodeIds. And do note that these Methods can return multiple NodeIds if there are multiple Nodes that match the BrowsePath.

But, it seems to me that you already know that the NodeId is “ns=2;s=WI_OPC/Database.FreeSpace”. Thus, you can just use

NodeId freeSpaceNodeId = new NodeId(2, “WI_OPC/Database.FreeSpace”);

or

NodeId freeSpaceNodeId = NodeId.parse(“ns=2;s=WI_OPC/Database.FreeSpace”);

to generate the NodeId and then call

UaNode node = client.getAddressSpace().getNode(freeSpaceNodeId);

to get the Node. If you already know the NodeId, there is no need to get it by browsing the AddressSpace starting from the root. Or am I missing something?

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 731

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1