Skip to content
  • There are no suggestions because the search field is empty.

Reading both Strings and Reals in one Data Type

We are monitoring the output of an atmosphere analyzer (RS232). The data that is returned is either as a Real number (example: 5.02) or a String (example: ERR04). I can read in the items fine if they are defined as a STRING type. However, I need these to be REAL datatype. REAL works fine if the instrument gives me numeric values, but when the instrument outputs a string ("ERR04" or "ERR03"), all of the items stop working. I can't use string datatype as the output, because I need to feed this to an HMI application and it won't take datatype strings as input for Analog inputs. Is there a way for me to handle this error, or convert the datatype within OmniServer?

What you will have to do is create a new unsolicited message and new items to take care of the ERR errors.

  1. Make your current items "Real". These will take care of the data that comes in as "Real" data.
  2. Create new items, each integer, to take care of the ERR messages.
  3. Create a new unsolicited message that looks EXACTLY like the original message EXCEPT that it contains the "ERR" message. For example, if the original message was "Data={RealNumber}{$CR}", the new message will be "Data=ERR{IntegerNumber){$CR}".

What will happen is that on the messages that come in and contain the "ERR" text, they will skip the first normal one for the good data, but this new unsolicited message will pick them up and the 2 digit code that comes after the ERR in the error message will end up getting stuffed into the appropriate "IntegerNumber" tag.