With any communication server for collecting process data, there has to be a reliable mechanism built-in for dealing with error responses from the underlying devices. This is true even for OmniServer as a user-configurable communication server.
Continuing our "OmniServer Did You Know?" blog series, this blog post focuses on how to use error messages and notification items in an OmniServer protocol to properly handle error responses or conditions received from your non-standard process devices.
In an ideal world, your devices would always communicate reliably and have no issues carrying out their designated purposes, whether that is collecting weight data, printing product labels or other important tasks. However, as we are all aware, eventually a device will inevitably get into an error state, at some point. So most protocols account for the potential error conditions that may be possible by providing a message or messages that the device will send in such a situation.
If you missed our any of our other "OmniServer Did You Know?" posts, get caught up here!
This is why OmniServer protocols have a component referred to as an "Error Message" where such message formats can be implemented and, when they are received from the device, OmniServer can proceed appropriately.
In the example below, OmniServer sends out a command/request message to get the value of DATA (using the READ_PV message). The instrument can potentially send back a NAK signal if, for some reason, the device cannot complete the request.
With the implementation in this example, OmniServer will record this in the three different ERROR items, then attempt to make a correction by issuing the INITIALIZE command/request message. Should that INITIALIZE message also fail, OmniServer will alert the client via the NOTIFY_ERROR host message.
Here is how it works:
Once you have tags in your client application associated with the five items in the protocol, OmniServer will send out the READ_PV message in order to get the DATA item. As per normal "Read" operations, it will continue to send this message as long as the client is connected and requesting the items for that message.
However, if the NAK response is received (as described in the NAK_RECEIVED message), OmniServer will look at the Action selected in the error message. The action tells OmniServer to "Fail" the message, in which case OmniServer proceeds to the "On Failure" chain of the READ_PV message. This then processes the INITIALIZE message.
And, if the INITIALIZE message fails, it will be captured by the NAK_ON_INIT message, which fails the message and processes the NOTIFY_ERROR message which results in the "Received_Error" tag in the client being set to 1/True indicating the error.
So here are all the possible combinations of behavior for the protocol items:
Many instruments will send a error condition in response to an inquiry by OmniServer, or even send out alert signals in case of a detected problem with the device.
Using OmniServer's Error Messages, Notification Items and message Failure Chains, you can design your protocol in such a way that OmniServer will not only inform your client program what error has occurred, but also take corrective measures that attempt to resolve the communication issue without interrupting communications, when possible.
You do have to be careful of "endless loops". For example, if we changed the "On Failure" chain for the command/request message INITIALIZE from NOTIFY_ERROR to INITIALIZE, that would create an endless loop.
The logic is this: If INITIALIZE does not get back the appropriate response, then NAK_ON_INIT will execute. It tells OmniServer to issue a Fail for the INITIALIZE message.
OmniServer will then execute the On Failure message for INITIALIZE, which is INITIALIZE. So everything starts back at the beginning. And since there is no way to stop the process (since the odds are that if the device failed once on INITIALIZE it will fail again), OmniServer will be put into an endless loop. Usually the only way out is to restart the OmniServer runtime or to reboot the computer.
Also, this post assumes that the manufacturer of the device designed the protocol with error handling. While this is typically the case, it's unheard of for a protocol to not have error messages as part of the protocol. In those situations, the technique used above won't be applicable.
Would you like to start handling your device's error messages in OmniServer? As always, we're happy to help answer questions you may have.
Email us at support@softwaretoolbox.com with your questions and subscribe to our blog for more quick and easy OmniServer tutorials and tips. Then, make sure to download the latest OmniServer trial to try it yourself for free.