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 Live OPC Connection

More
02 Apr 2014 08:18 #1810 by support
Thank you for explanation. I understand the need, and in fact having something like this is on the wish-list already, but it has not made it into the product yet.

If you already have the value being read back on the subscription, why don't you use its "status" to enable/disable the commands in UI? You can monitor whether the incoming item change notification has null or non-null Exception property, and act accordingly.

Alternatively (this really is a workaround, I know), you can even subscribe to *any* (even unrelated) readable item from the OPC server, and do the same.

Just to be completely clear, you should not look at the Quality (inside the VTQ): This information comes from the server itself, and the quality might perfectly be Bad even when the connection with the server is OK. But a non-null value in the Exception property indicates that the Value/Timestamp/Quality could not be obtained at all, meaning a serious problem between the client and the server.

Best regards,

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

  • netasp
  • Topic Author
  • Visitor
  • Visitor
01 Apr 2014 16:52 - 01 Apr 2014 16:53 #1807 by netasp
Replied by netasp on topic Checking Live OPC Connection
We fully understand hiding the details of connecting/reconnecting to save code however, it would be helpful if on our interface we can place an indication to the operator about their connection status with the OPC server so they can tell when they are online/offline.

We have an interface on which the operator initiates a few commands that causes a change in state of a number of values being read back. We would like to disable those commands controls when the OPC server is unavailable so the operator is not left wondering why there is no change of state.
Last edit: 01 Apr 2014 16:53 by netasp.

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

More
01 Apr 2014 16:22 #1805 by support
This is by design.

By calling Subscribe, you declare an intent to be subscribed, and receive the status and values. By calling Unsubscribe, you declare that you are no longer interested in these.

The server or the item may go down at any time. Or. they may not be available at the time of calling - it doesn't matter. The component will try - and keep trying to - to fulfill the "subscription intent" for the time of its duration (i.e. until you unsubscribe).

After you Subscribe, you receive a first notification. It will be either successful (.Exception == null), or unsuccessful (.Exception != null). This is how you get the result. If the server is not available at the time of initial subscription, the first update will be with some .Exception, but after a (configurable) period, the component will retry, and then you may get a success.

The end result is, that you do not have to write any re-connection code, or handle the server failure in a special way.

Let's consider this use case: You are writing an "HMI" kind of application, where the values form the server should be continuously updates on the screen. With this design, you just call Subscribe for each item, and then with each notification, display whatever status or value you receive. That's it. No extra to code handle "what happens if the server is not running at the moment I first try to subscribe", or "what to do if it succeeded initially but then crashed", etc.

Your usage case may be similar, or different. If it's different and you are not sure how to handle it, please explain what you are trying to achieve.

Best regards

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

  • netasp
  • Topic Author
  • Visitor
  • Visitor
01 Apr 2014 16:13 #1804 by netasp
Checking Live OPC Connection was created by netasp
Hi,
I have a client (vb.net) connecting to an OPC server; I can't seem to find where to check for live connection? although I shut down the OPC server, the client still subscribing to the server and returning a successful IDs! my code is below:
Public Sub SubscribeMultipleItems(ByRef Tags As Tags, ByRef UpdateRate As Integer)
 
        Dim argumentArray As DataAccess.DAItemGroupArguments() = New DataAccess.DAItemGroupArguments(Tags.Count - 1) {}
        Dim groupParameter As OpcLabs.EasyOpc.DataAccess.DAGroupParameters = New OpcLabs.EasyOpc.DataAccess.DAGroupParameters(UpdateRate)
        Dim handleResult As Integer()
 
        For i As Integer = 0 To Tags.Count - 1
 
            argumentArray(i) = New DataAccess.DAItemGroupArguments(m_OPCServerId, Tags.Item(i).Address, groupParameter, Tags.Item(i))
 
        Next i
 
        handleResult = m_opcClient.SubscribeMultipleItems(argumentArray)
 
        For i As Integer = 0 To Tags.Count - 1
 
            Tags.Item(i).Handle = handleResult(i)        ' this line always returns good 
      	                                                 ' values even when the opc server is down
            Tags.Item(i).ErrorCode = 0
            Tags.Item(i).ErrorMsg = ""
 
        Next i
 
    End Sub

Is there an error code we check to monitor the status/connection of the OPC server?

Thanks

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

Moderators: support
Time to create page: 0.057 seconds