Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Converting relative browse paths to node ids and validating them

More
14 Nov 2024 09:32 #13276 by support
Yes,
the stringParsingError comes out null in that example. That is what the example is meant to show.

Which QuickOPC version are you using? I will install it on a new machine and test the example out of the box.

Regards

Please Log in or Create an account to join the conversation.

More
13 Nov 2024 13:28 #13273 by Cwardltu
I am using the exact code.

Are you sure stringParsingError is null? for me it is populated with the error mentioned below.

Please Log in or Create an account to join the conversation.

More
13 Nov 2024 05:28 #13272 by support
Hello.
I do not not understand your post.

The example works for me without error. Are you saying that it does not work for you?

Or, if you are using a different code, post the code here.

Regards

Please Log in or Create an account to join the conversation.

More
12 Nov 2024 21:25 #13271 by Cwardltu
So I found UABrowsePathParser.TryParseRelative. The example in the documentation says it accepts a browse path like "/Data.Dynamic.Scalar.CycleComplete". However when I use a structure like that I get an error: "A namespace delimiter was expected". I cant find in the documentation why this would not work the example is clear, what am i missing?

Example: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User's...0relative%20browse%20path.html

Please Log in or Create an account to join the conversation.

More
07 Nov 2024 13:40 #13267 by support
Hello.

I do not know what you mean by NamespaceId, no such term is used in OPC UA.

The proper way way is to specify namespaces in OPC UA is using their namespace URIs. Unfortunately, the Web is full of examples that use namespace indexes, which (except for namespaces 0 and 1) is server free to shuffle between sessions, so all these examples are technically wrong. Also, the "standard" OPC UA browse path syntax uses namespace indexes, so it is not usable without having a context - which index corresponds to which URI.

In the code I provided, there are three example with equivalent effect. The first one, and the subsequent (commented out) one use namespace URIs.
The last one uses namespace indexes. It is close to what you have asked for in your original post, and you are free to use it, but be that "namespace with index 2" is not a stable thing. The first two examples do not have this problem.


Regards

Please Log in or Create an account to join the conversation.

More
07 Nov 2024 13:18 #13266 by Cwardltu
Is there a way to use the NamespaceId. Namespaces can be fluid. I cant hard code it right?

Please Log in or Create an account to join the conversation.

More
07 Nov 2024 11:59 #13265 by support
Hello.

In QuickOPC, nodes can be specified either by their node ID, or by an absolute browse path (a combination of a starting node, and a relative browse path). The conversion from the browse path to the node Id happens automatically inside QuickOPC, you do not call anything extra.

Example:

 
// This example shows how to read the node using a browse path.
//
// Find all latest examples here: opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
 
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.Navigation;
using OpcLabs.EasyOpc.UA.OperationModel;
 
namespace UADocExamples._EasyUAClient
{
partial class Read
{
public static void BrowsePath()
{
UAEndpointDescriptor endpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
// or "opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
// or "opcua.demo-this.com:51212/UA/SampleServer/"
 
// Instantiate the client object.
var client = new EasyUAClient();
 
// Create the node descriptor by parsing an absolute browse path.
// The syntax below specifies a common default namespace URI for the elements of the browse path.
UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/Data/Dynamic/Scalar/FloatValue", "test.org/UA/Data/");
 
// Alternatively, the namespace URIs can be specified with each element of the browse separately.
//UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/[nsu=http://test.org/UA/Data/;Data]/[nsu=http://test.org/UA/Data/;Dynamic]/[nsu=http://test.org/UA/Data/;Scalar]/[nsu=http://test.org/UA/Data/;FloatValue]", null);
 
// Alternatively, the namespaces can be specified by indexes, separately with each element.
//UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/2:Data/2:Dynamic/2:Scalar/2:FloatValue", null);
 
// Obtain attribute data. By default, the Value attribute of a node will be read.
UAAttributeData attributeData;
try
{
attributeData = client.Read(endpointDescriptor, nodeDescriptor);
}
catch (UAException uaException)
{
Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
return;
}
 
// Display results
Console.WriteLine($"Value: {attributeData.Value}");
Console.WriteLine($"ServerTimestamp: {attributeData.ServerTimestamp}");
Console.WriteLine($"SourceTimestamp: {attributeData.SourceTimestamp}");
Console.WriteLine($"StatusCode: {attributeData.StatusCode}");
}
}
}
 
 

I hope this helps
Best regards

Please Log in or Create an account to join the conversation.

More
06 Nov 2024 19:32 #13263 by Cwardltu
Hello, I have a relative browse path like "2:Data Type Examples/2:8 Bit Device/2:K Registers/2:Float3" that i need to convert into a nodeId, then validate it.

I am looking for a c# code snipit to do such a thing.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.221 seconds