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.

Checking if node exists on server

More
16 Aug 2019 09:39 #7631 by support
First, as a note, I am not sure that what you refer to as "browse path" is an actual OPC UA browse path - that term has its specific meaning. Browse paths includes a starting node, and a sequence of browse names and references. See e.g. opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...wse%20Paths%20in%20OPC-UA.html . I think you are probabling referring to an OPC UA node ID with a string identifier that "looks" similar to some kind of browse path.

To the question: You can read an attribute of a node to see if it exists, and check for errors. You should read an attribute that *all* nodes have - I suggest, the UAAttributeId.NodeClass. If you get an exception, you need to test whether it represent a non-exist node, or some other kind of error. To do, you can use the following method:

        static private bool IndicatesNonExistentNode(Exception exception)
        {
            switch (exception)
            {
                case UAStatusCodeException statusCodeException 
                    when
                        // The syntax of the node id is not valid.
                        (statusCodeException.StatusCode.CodeBits == UACodeBits.BadNodeIdInvalid) ||
                        // The node id refers to a node that does not exist in the Server address space.
                        (statusCodeException.StatusCode.CodeBits == UACodeBits.BadNodeIdUnknown):
                case UAServiceException serviceException 
                    when (serviceException.ServiceResult == UACodeBits.BadNoMatch):
                    return true;
                default:
                    return false;
            }
        }
Note that if the read is done using one of the multiple-operand methods, the exception I am talking about is in the .Exception property of the ValueResult object returned. If you have used a single -operand method, it would throw, and the exception I am talking about will be the .InnerException of the UAException thrown.

We plan to expose a "helper method" to perform such checking in future QuickOPC version.

Best regards

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

More
15 Aug 2019 12:55 #7628 by gtan14
Is there a way to see if a node exists given a browse path such as this - Data Type Examples.16 Bit Device.R Registers.Double2? QuickOPC for DA has a method ReadItem() where I can pass in the machine, server and itemid, and for the item id, I'm just passing in that browse path. Does UA have something similar?

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

Moderators: support
Time to create page: 0.051 seconds