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: 523
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: 523
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: 267

Currently Online:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 100

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 37

Rainer Versteeg: 32

Thomas Reuther: 26

Member Stats:

Guest Posters: 0

Members: 1058

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 981

Posts: 4145

Newest Members:

mats989, Sebastien Petitrenaud, sting2005, Ron Hoppe, Seb, p.devito, g.ilengo, MohamedLazrek, brittr83165991, martintinsley9

Moderators: Jouni Aro: 846, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 523, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 18, Matti Siponen: 31, Lusetti: 0

Administrators: admin: 0