Using OmniServer, How do I read a string of numbers separated by commas?
I am trying to use OmniServer to read a data stream from an Analyzer. This string is output from the RS232 port in ASCII code on the device every minute or so. I can read the whole string into one string variable, however I would like to separate the string into the actual numbers it sends.
This is a sample of the string:
10,8/7/01,10:10:00,.01,.001,.002,2.2,2700.002,CRLF...where the numbers represent:
Stream,Date,Time,Level1,Level2,Level3,Level4,Level5,CRLFHow do I separate this incoming string using the commas as separators?
(Version 2.0 and above)
Using your Protocol Editor, you would first define an Item for each data. For the purposes of this example, we will use the item names Stream, Date, Time, Level1, Level2, Level3, Level4, Level5 (all of them set to their respective data types).
Next, you will need to pattern your message in the Received section of an Unsolicited Message. The message will be set up like this:
{Stream},{Date},{Time},{Level1},{Level2},{Level3},{Level4},{Level5}{$CR}{$LF}
Notice that the commas are outside the curly-que brackets, which means OmniServer will expect a comma between each data item.
(Version 1.x)
Using your Protocol Editor, you would first define an Item for each data. For the purposes of this example, we will use the item names Stream, Date, Time, Level1, Level2, Level3, Level4, Level5 (all of them set to their respective data types).
Next, you will need to define your Fields. Since all you need to define is one field for each data type, we will define only three fields. IntVal for Integers; StrVal for Strings, and RealVal for Reals.
Next, you will need to pattern your message in the Received section of an Unsolicited Message. The message will be set up like this:
{IntVal},{StrVal},{StrVal},{RealVal},{RealVal},{RealVal},{RealVal},{RealVal}{$CR}{$LF}
Notice that the commas are outside the curly-que brackets, which means OmniServer will expect a comma between each data field.
Finally, in the Item Assignment box, assign the items (in order) to the fields. So, in this case, the order assigned will be: IntVal = Stream; StrVal=Date; StrVal=Time; RealVal=Level1; RealVal=Level2; RealVal=Level3; RealVal=Level4; RealVal=Level5.