-
Notifications
You must be signed in to change notification settings - Fork 0
Streampool
As one of the managers, this component is responsible for the TCP, UDP and serial connections.
Manage all the (incoming) TCP, UDP and serial connections and provide an interface through telnet.
- Connect to TCP servers, UDP servers and serial ports (real and virtual)
- Auto reconnect if a connection is lost (or idle)
- Keep track if a connection becomes idle
- Act as interface between the other components and the streams
- Execute commands based on triggers (stream connection opened,closed or idle)
To get a list of all available commands, type streams:? or ss:? in telnet. The resulting xml section will look like this
<streams>
<stream id="unique_name" type="tcp"> <!-- type of stream, other option are: udp (server or client), serial -->
<address>192.168.1.1:1025</address> <!-- IP:Port if TCP/UDP client, <port> if UDP server or COMx/ttySx for serial -->
<label>label</label> <!-- Will be used to determine the BaseWorker method -->
<eol>crlf</eol> <!-- What signifies the end of a message (line), other options: cr, lf,lfcr -->
<ttl>5s</ttl> <!-- Time before the device is considered unresponsive, -1 means never -->
<!-- Less common options -->
<cmd trigger="open">calc:clock</cmd> <!-- command to be issued on a trigger, eg. when the stream is (re)opened -->
<log>false</log> <!-- This disables the logging of raw data from this stream, default is true -->
<priority>1</priority> <!-- For redundancy devices, this can be added here. Default is 1 -->
</stream>
<!-- Serial ports -->
<stream id="unique_name2" type="serial">
<port>COM1</port> <!-- or ttyS1 (/dev/ is prepended) -->
<serialsettings>19200,8,1,none</serialsettings> <!-- baudrate, databits,stopbits,parity -->
<!-- all the rest is the same as tcp eol,ttl,label,log,cmd ... -->
</stream>
</streams>
This allows for certain actions to initiate any command or send data.
Current command triggers:
- opened, when the connection is (re)opened do something
- idle, when the connection has been idle longer than ttl, do something
- closed, when the connection is closed, do something
Current data send triggers:
- welcome, when the connection is (re)opened send the data
- waiting, when the connection was idle send the data
To give a possible use case:
<stream id="tempsensor">
<cmd trigger="welcome">give data please?</cmd> <!-- Send the command that starts the sampling process -->
<cmd trigger="idle">email:send,admin,Tempsensor stopped sending data,Is it dead?</cmd> <!-- warn the admin -->
</stream>
- Adding the connection ss:addtcp,name,192.168.1.5:1234,generic:genid
- Altering the eol chars from \r\n to \r or cr ss:alter,name,eol:cr
- Requesting the raw data via telnet raw:id:name
Add new streams
ss:addtcp,id,ip:port,label -> Add a TCP stream to xml and try to connect
ss:addudp -> Add a UDP stream to xml and connect
ss:addserial,id,port:baudrate,label -> Add a serial stream to xml and try to connect
ss:addlocal,id,label,source -> Add a internal stream that handles internal data
Info about streams
ss:labels -> get active labels.
ss:buffers -> Get confirm buffers.
ss:status -> Get streamlist.
ss:requests -> Get an overview of all the datarequests held by the streams
Interact with stream objects
ss:recon,id -> Try reconnecting the stream
ss:reload,id -> Reload the stream or 'all' for all from xml.
ss:store,id -> Update the xml entry for this stream
ss:alter,id,parameter:value -> Alter the given parameter options label,baudrate,ttl
Route data from or to a stream
ss:forward,source,id -> Forward the data from a source to the stream, source can be any object that accepts a writable
ss:connect,id1,id2 -> Data is interchanged between the streams with the given id's
ss:echo,id -> Toggles that all the data received on this stream will be returned to sender
Send data to a stream
Option 1
- Get the index of the streams with ss or streams
- Use S<index>:data to send data to the given stream (eol will be added)
Option 2
- ss:send,id,data -> Send data to the stream with that id and append eol characters
Note: All the commands can also be used in a Task
- Getting to know dcafs
- Filterforward
- MathForward
- EditForward (todo)
- Combining
- TaskManager
- LabelWorker
- CommandPool
- DebugWorker
- Realtimevalues
- IssuePool