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.

Error handling

More
01 Nov 2018 15:06 #6813 by support
Replied by support on topic Error handling
Hello.

There is some existing documentation to this - please see, among others:
In addition, there will be new texts in the documentation for QUiOPC 2013 version. For OPC UA, I made a snaphsot of this new text available here: www.opclabs.com/forum/feature-requests-product-improvement-i...550-error-handling-opc-ua#6812 .

For OPC Classic, the snapshot is here below. I hope it helps. Note: The formatting is gone - and then slightly restored.

OPC Classic Errors

OPC Classic is based on Microsoft COM/DCOM, and as such, the vast majority of exceptions you encounter is of type COMException (or derived from it). The HResult and ErrorCode properties of the COMException contain a numeric identification of the problem, which you can use to distinguish between the specific error causes. These exceptions can be
•Errors generated by the target OPC Classic server. It can be a standard error code defined in the OPC specifications, or a custom error code defined by the server vendor.
•Errors from the COM/DCOM infrastructure, either on the computer where the OPC Classic server runs, or on the client computer.
•Errors detected on the client side and generated by %%ProductName%%.

A comprehensive list of possible error code cannot be given. Your program must always be ready to handle any error code that it does not explicitly know about. In most cases, you will be treating all errors the same way. In some cases, you may need to have a special handling for one or a few specific errors.

Some Common Errors

Note: The error texts are for illustration only. They are subject to change without notice. Your program should never rely on the error texts; use the ErrorCode to distinguish between specific errors.

The addressed OPC Classic Server is not installed

In this case, you will typically receive a COMException "Invalid class string" (localized) with ErrorCode/HResult of -2147221005 (0x800401F3), symbolically CO_E_CLASSSTRING. Of course, you will get the same exception if the intended OPC server is actually installed, but you have misspelled its ProgId.

The remote computer cannot be reached

In this case, you will typically receive a COMException "The RPC server is unavailable" (localized) with ErrorCode/HResult of -2147023174 (0x800706BA). Of course, you will get the same exception if the intended computer is actually running and accessible, but you have misspelled its name or IP address.

The item you are trying to access does not exist

In this case, you will typically receive a COMException "The item is no longer available in the server address space." (possibly localized) with ErrorCode/HResult of -1073479673 (0xC0040007), symbolically OPC_E_UNKNOWNITEMID. Of course, you will get the same exception if the intended item actually exists, but you have misspelled its Item ID. This error is returned by the OPC server if the syntax of the Item ID conforms to the server's requirements, but the item does not exist. If even the syntax of the Item ID is incorrect, you will receive "The item ID does not conform to the server's syntax." (possibly localized) instead, with ErrorCode/HResult of -1073479672 (0xC0040008), symbolically OPC_E_INVALIDITEMID.

Reading an item that is not readable, or writing an item that is not writeable

In this case, you will typically receive one of the following COMException-s:
•"Access rights of the topic do not allow reading." with ErrorCode/HResult -1073430522 (0xC004C006).
•"Access rights of the topic do not allow writing." with ErrorCode/HResult -1073430521 (0xC004C007).

The above exceptions come from the client side, where %%ProductName%% is pre-checking the access rights of the item before it actually attempts to perform the operation. If these checks succeed, but the operation is nevertheless rejected by the server, you will typically receive
•"The item's access rights do not allow the operation." (possibly localized) with ErrorCode/HResult of -1073479674 (0xC0040006L), symbolically OPC_E_BADRIGHTS.

Bad or Uncertain Quality of the Data
Caution Box:

Except in methods that return the value alone (and not the DAVtq object), bad or uncertain quality is considered a normal operational situation, and does not throw or return an exception. You are responsible for testing the quality (either directly using the Quality Property, or indirectly using the HasValue property) in your code before accessing the Value Property of the DAVtq Class, because in most cases when the quality is bad, the Value is not defined (and is actually a null reference). Uncertain quality usually has some value carried with the data, although its usability is questionable. For more information, see Always test the HasValue property before accessing DAVtq.Value or UAAttributeData.Value.

The methods that do not have data quality in their results, and therefore must return an error instead of the value when the value is not present, include:
•ReadMultipleItemValues
•ReadItemValue
The following user(s) said Thank You: SZL

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

More
31 Oct 2018 13:14 - 31 Oct 2018 13:14 #6807 by SZL
Replied by SZL on topic Error handling
Hello,

I would like to get the answer for DA and UA too because we develop an application for both types.

Thanks!
Last edit: 31 Oct 2018 13:14 by SZL.

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

More
31 Oct 2018 12:49 #6806 by support
Replied by support on topic Error handling
Hello,

before I start answering, please confirm that your question is about "Classic" OPC (COM/DCOM), as that is the forum category where you have posted the question. The specifics of the answer would be different for OPC UA, so I want to be sure that I am answering the right question.

Regards

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

More
31 Oct 2018 12:24 #6805 by SZL
Error handling was created by SZL
Hello,

We have a question to develop our OPC application properly.

How can we separate the different error types during reading or writing value(s)?

How can we identify from .NET source code when
- the OPC server not exists?
- the OPC server exists, but stopped?
- the requested tag not exists?
- the requested tag exists but not accessible?
- the requested tag exists and accessible, but it contains bad value?
- any other error types.

Thank you for the answer!

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

Moderators: support
Time to create page: 0.065 seconds