A MQTT message has two parts - the payload and the topic. (Behind the scenes there are also some flags and control values but these are not important to us.)
A payload can be anything - text, an image, JSON, binary. The MQTT broker does not know what the payload is and does not care. The broker does not change or alter the payload. It just relays the payload on to subscribers. Publishers and Subscribers must agree on what the payload is.
LabTime uses two formats of payloads - JSON and the Influx Line Protocol
JSON Format
The JSON (JavaScript Object Notation) is an industry accepted way to encode a hierarchical array into a string where it can then be transmitted to another application and then easily converted back into the original array.
Example:
{
"rsp":"requestStatus",
"clientId":"administrator",
"userId":"Frodo",
"mqttClientId": "administrator_tst_a1fbf"
} InfluxDB Line Protocol
The InfluxDB Line Protocol is the native format used in the InfluxDB. It is a simple format with 2 or 3 fields to a line.
Example:
F,MetricId=Desk_Top_OW_F,ActionId=inp,ProjectId=cb value=73.9625 1716056699593The fields in this example are:
Measurement name and tags
The first value 'F' is the measurement name, LabTime uses the Units field for this. This determines which InfluxDB table the record will be stored in.The remainder of this field is the tags. These are used in the Historian to filter, sort, and group the data.
- MetricId=Desk_Top_OW_F
- ActionId=inp
- ProjectId=cb
- Values
In this example there is only one value labeled 'value'. There can be many values for measurements with multiple values being acquired at the same time. - Time
Linux system time in milliseconds - 1716056699593
The fields are separated by a space. To simplify things LabTime dictates that no name or value can have a space. (By enclosing strings with spaces with quotes embedded spaces can be used but it's tedious.)