7:04, EEST
September 11, 2013
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?
8:05, EEST
April 3, 2012
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”
9:56, EEST
September 11, 2013
10:22, EEST
April 3, 2012
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
Most Users Ever Online: 1919
Currently Online:
53 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: 738
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettingerModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1