TCP CSV Data Collector
The JEDI One TCP CSV data collector implements a TCP server that is capable of automatically parsing comma-separated values (CSV) data. This is a common format used by device servers that takes a serial data stream from a sensor, device or machine and encapsulate that in TCP packets.
In this example let's assume the device server sends out the following string on a regular basis:
"Engine3,3500,50\n"
- Engine3 is the TARGET ID of the sender. JEDI One will use this as the ID for the node.
- 3500 is the RPM of the engine.
- 50 is the Oil Pressure in PSI.
- \n is the termination character (new line); indicating the record is complete.
Setup a JEDI One data collector to consume this information:
Here are the steps:
A name is given to the collector: CSV listener on port 9001
The type is selected: TCP CSV
The IP to listen on is selected: Any (the local port or the IP address where JEDI One is running can be selected instead)
The Listen Port is specified: 9001 (The sending device will send data to this port)
And finally the Data format string is input. This gives JEDI One an understanding of the data that will be coming in. Using the example of incoming data above, the data format is:
n:TARGETID;ty:string,n:RPM; ty:number,n:Pressure;ty:number
It looks a little complex but it is just telling JEDI One that the first value is a string with the metric name, the second value is a number representing RPM, and the third value is a number representing Pressure.
Save the new Data Collector.
In lieu of an actual device server, the TCP CSV capability can be tested with a simple Python script which can be run on any computer on the network. For this example, let's assume that JEDI One is running on a machine with the IP of 192.168.1.6. The code looks like this:
#!/usr/bin/python3
import socket
TCP_IP = '192.168.1.6'
TCP_PORT = 9001
MESSAGE = 'Engine3,3500,50\n'.encode("ascii")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect_ex((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
Now when adding a new chart to JEDI One, "Engine3" shows up as a source for data:
And adding this chart, the data sent can be seen (RPM = 3500):
A chart can also be created for the pressure property.
Additional details:
The Data Format String
The Data Format string is used to decode and label the fields in the incoming CSV over TCP data stream. Decoder format:
n: <field-name> to assign a name to a field
use n:TARGETID to specify a field as device ID
ty: <field-type> to assign a type to a field.
Supported types:
ty:timestamp for timestamps in ISO8601 format
ty:number
ty:string
ty:bool (field value must be “true” or “false”)