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
How to find a node by it's path?
September 11, 2013
7:04, EEST
Avatar
Daniel
New Member
Members
Forum Posts: 2
Member Since:
September 11, 2013
sp_UserOfflineSmall Offline

I have the following code:
—–
final String[] pathParts = “Objects.Server”.split(“\\.”);
for (String pathPart : pathParts)
{
pathElements.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(pathPart)));
}
final RelativePath relativePath = new RelativePath(pathElements.toArray(new RelativePathElement[pathElements.size()]));
final BrowsePathResult[] pathResults = addressSpace().translateBrowsePathsToNodeIds(Identifiers.RootFolder, relativePath);
—–

But it only works for Numeric nodeId’s, when nodeId type is String I get an error: The requested operation has no match to return.
I’m using UnifiedAutmation OPC UA Server for the test and when I request “Objects.Server” everything is fine, but when I try to resolve “Objects.MyDemoObject” an error is occurred.
What is the proper way to get a nodeId by it’s path?

September 11, 2013
8:05, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

The reason why Objects.Server works, is because it is in standard namespace (namespaceIndex is 0). The constructor for QualifiedName(String) makes the QualifiedName with 0 as namespaceIndex. The standard namespace is only for UA specification Nodes (e.g. the Server object and default types). The MyDemoObject is not in that namespace, therefore not found.

For nodes not in standard namespace, QualifiedName(namespaceIndex, name) should be used. NamespaceIndex can be obtained from Server using NamespaceTable if you know the NamespaceUri for it, by using addressSpace.getNamespaceTable().getIndex(namespaceUri). For UA specification nodes this is “http://opcfoundation.org/UA/”. Seems the uri for namespace where MyDemoObject is is “DemoNodeManager”

September 11, 2013
9:56, EEST
Avatar
Daniel
New Member
Members
Forum Posts: 2
Member Since:
September 11, 2013
sp_UserOfflineSmall Offline

Thanks for the reply.
But how to obtain a namespaces for each path node? Or I better browse all path nodes manually?

September 11, 2013
10:22, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

The translateBrowsePathsToNodeIds is used for known paths, e.g. if you have object instance of known type that has some hierarchy you can use the translation to find e.g. a Property from the structure only by knowing the NodeId of the instance. So you need to know the path and use .getIndex(…) for each (or use the namespaceIndex directly if you know it and know that it wont change) path element (usually they all have same namespace, but standard Properties have 0 as NamespaceIndex in their BrowseName).

If you don’t know the AddressSpace of the Server, you need to browse it. If you know a NodeId beforehand, you can also use UaClient’s methods(e.g. readXXX, writeXXX) that take NodeId as a parameter

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1