Converting an absolute path to a node Id|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Converting an absolute path to a node Id
Avatar
Dolton Knief
New Member
Members
Forum Posts: 2
Member Since:
12/01/2022
sp_UserOfflineSmall Offline
1
12/01/2022 - 07:46
sp_Permalink sp_Print

Hello!

I'm trying convert an absolute path to a node id instead of a relative path in .NET, but I can't seem to figure out how to do that.

For example, the path for a node I'm trying to read is Root\Objects\EC\WT\13\WGRI1\Gri1\WMeas\mag

But when I try the below code, it doesn't work, although the starting node is Objects folder. 

var browsePathCollection = new BrowsePathCollection

{
    new BrowsePath
    {
        RelativePath = RelativePath.Parse(@"EC\WT\13\WGRI1\Gri1\WMeas\mag", this._session.TypeTree),
        StartingNode = ObjectIds.ObjectsFolder
    }
};

var paths = await this._session.TranslateBrowsePathsToNodeIdsAsync(null, browsePathCollection , new CancellationToken());

Can you someone guide me in the right direction please?

Thank you.

Avatar
Randy Armstrong
Admin
Forum Posts: 1445
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
12/02/2022 - 05:24
sp_Permalink sp_Print sp_EditHistory

The path you show is not complete. Each element in the path has a namespace that qualifies the name.

If you express the path using the NamespaceIndex (from the Server.NamespaceArray Property)

0:Root/0:Objects/1:EC/1:WT/1:13/1:WGRI1/2:Gri1/2:WMeas/2:mag

Then TranslateBrowsePathsToNodeIdsAsync should works as expected.

Avatar
Zbynek Zahradnik
Member
Members
Forum Posts: 62
Member Since:
02/24/2014
sp_UserOfflineSmall Offline
3
12/02/2022 - 06:30
sp_Permalink sp_Print

Also, you should use '/' instead of '\'.

Avatar
Dolton Knief
New Member
Members
Forum Posts: 2
Member Since:
12/01/2022
sp_UserOfflineSmall Offline
4
12/09/2022 - 05:40
sp_Permalink sp_Print

Thank you Randy and Zbyněk, it worked successfully with your suggestions.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 14
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1347
Posts: 4567