dc_GenStream

Purpose:

Continuously retrieve data from a device that is sending data repeatedly without additional commands. The streamed data can then be accessed with the getStream command(s) that are defined in the spec file.

Enter:

dc_GenStream [spec_file=filename]

Where:

spec_file

Optional. Specify the spec filename to read and configure the task.

Example:

dc_GenStream /specs/hydrometer.spec &

Notes:

You can change the size of a message by changing the environmental variable streamSize in the terminal, default is 1023.

Also normally used in conjunction with devcom_mon task to run the commands.

A sample spec file can be found at cyflex/specs.def/ called genstream.spec.

A sample devcom_mon can be found at cyflex/specs.def/ called genstream_mon.spec.

$Device  
# serail port:baud,bits,stobits,parity,flow control(HW,XON,NONE$-$HW default)  
#IP:port  
#192.168.83.20:502  
/dev/ttyS0:9600,8,1,N,NONE  
 
# maximum message rate is 1000 messages per second.  
$MaxMsgRate  
250  
 
$Debug  
true  
 
$Timeout  
# default timeout in milliseconds  
#want to be higher than the amount it takes to get a message, usually 2 to 3 times higher  
2000  
 
#Name task will attach to, or key name so multiple device of same type can be supported.  
$Instrument  
OPTI  
 
#Protocol  
$Protocol  
 #GenSync – general asynchronous (streams data) serial/socket protocol  
GenStream  
 
#message structure  
$CmdStruct  
 #Structure  
 
# This section shows the sequence of message elements  
# H = header string  
# S = station identifier  
# M = message  
# T = trailer string  
# C = crc  
MT
# response structure if any response expected  
$RspStruct  
 MT
$Header  
-1  
 
# trailer  
$Trailer  
 <CR><LF>

# NOTE: NONE supported at this time 7/1/10, will be added as needed.
$CRC  
-1  
 
 #put True if you want to replaces commas, will not work in ReplaceItems 
$ReplaceComma  
 
#not including commas because that is what seperates the list  
 #example: :,;,*,/  to replace : ; * and / all with spaces  
#note: does not work with the $ symbol  
 
$ReplaceItems  
:,;,!  
 
 #Command formats  
 #Command format Response format [timeout]  
 
$CmdDef  
 #Control Commands have no data response  
#CommandString formats AK_Command [Timeout(msec)]  
 #comma or tab delmited  
#Command key, [command arguments],[response],[timeout]  
 
#The getStream command is how you retrieve data from a device that is  streaming information.

#You can have multiple getStream commands for  different formats, but you need to add numbers #at the end of the original command. Example: #getStream1, getStream2, etcldots  
#the format for the getStream command, you must find out what the device  
#output looks like. Once you have that, you must separate the output into  
#segments by spaces and tabs separating the segments. This includes the  
#spaces from the ReplaceItems.  

#Example:
#A device is streaming   tds:mv=.45 dp=31 ret54d1
#Before any replacements there are three segments. tds:mv=.45 , dp=31 ,  
#and ret54d1. If we wanted the tds and the .45 from the first segment, we  
#would put ‘:’ for or ReplaceItems list and it would split the 1st segment  
#into 2 segments, tds and mv=.45 for a total of 4 segments now. To get  
#the .45 and 31, we do not need to replace anything additionally. The  
#format %f is smart enough to parse the first number it sees. However,  
#that would not be enough to parse the last segment, so if we wanted  
#certain data there, we would need to parse further. So with the first  
#parse, %s %f %f %s would be enough if we did not need anything from the  
#last segment.  
 
getStream, -,%s %f %f %s  
 
# this section should end with a $ 

$

See Also: