![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
07/04/2022
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hello,
this is my first post here, so first a short introduction:
We are developing measurement devices for our inhouse R&D. The devices contain mostly a PLC from B&R Automation and we used in the past their Automation PVI/NET for our development. But this is not compatible with the actual .NET, only with .NET Framework. Therefore we looked for an alternative and found the OPC UA and the .NET Standard package.
Now to my questions.
I started with a small demo (.NET 6) but run into some trouble ...
The PLC create the following address space (here for a variable "counter" from the task "Program"):
Root => Objects => PLC => Modules => "<Default>" => Program => counter
I tried to get the NodeIds with the Session.TranslateBrowsePathsToNodeIdsAsync method. If I use the free UaExpert program, I can see that my counter variable has this NodeId.Identifer: "::Program:counter". (The "::" is shown as the browse name from the "<Default>" Node?) If I try that as BrowsePath.RealtivePath, I got a ServiceResultException: Cannot parse relative path: '::Program:counter' with an inner exception: FormatException: Input string was not in a correct format.
I have to use "/6:Program/6:counter". The 6 is the namespace index of the "Modules" object. With that string the TranslateBrowsePathsToNodeIds gives me a "good" result with a BrowseParseTarget with the same TargetId.Identifier "::Program:counter" which I see in the UaExpert program.
Now I want to get a bigger list of variables, not only one variable at a time, but how can I find my variable? The relative path is my input and the Identifier is the output of the method? I can - of course - do some string manipulation, but this has a "bad smell" 😉
What would be the best practice here?
Thanks,
Mike
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
NodeIds are unique identifiers for Nodes.
BrowseNames are non-unique programmatic names for Nodes.
The TranslateBrowsePathsToNodeIdsAsync service allows to navigate multiple hops at once by specifying a BrowseName and a ReferenceType for each hop. The response is a NodeId for each Node found.
NodeIds are used in subsequent calls like Read.
The fact that a NodeId might "look like" a BrowseName is an artifact of some Server implementations. You should never assume there is a relationship between the BrowseName and the NodeId. They are independent attributes of Nodes.
Can you explain what problem you need to solve?
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
07/04/2022
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hi Randy,
sorry, I was completely on the wrong track. Maybe I made a mistake during my first tests, but this works now:
NodeId counterNodeId = new NodeId("::Program:counter", 6);
DataValue counterValue = session.ReadValue(counterNodeId);
I thought, I can't access a node directly and have to browse for them. <shame/>
1 Guest(s)