VQT messages
Currently there are two versions of the MQTT message formats that are supported in APIS.
VQT Version 1
Version 1 for MQTT messages is a simple JSON object that contains the following keys:
- Message type
- Message version
- Value
- Quality
- Timestamp
All the values defined in a VQT1 message will have the same timestamp. If timestamp is not defined, the values will be associated with the current time on the system.
VQT1 Example
{
"messagetype": "vqt",
"version": 1,
"t": "2022-09-22T06:06:28.891+00:00",
"Tag1": 43,
"Tag2": 58,
"Tag3": 80,
"q": 0
}
User can define the text strings for the time,value and quality of an item. The text strings for Time id, Value id and Quality id in a message must match the Time id, Value id and Quality id for the value items in the property editor. Note: Timezone information needs to be provided in the timsestamps.
For the above example message, the properties for a value items in APIS should be set as follows:
Value item | Value id | Time id | Quality id |
---|---|---|---|
Tag 1 | Tag1 | t | q |
Tag 2 | Tag2 | t | q |
Tag 3 | Tag3 | t | q |
Mandatory Fields in message:
- messagetype
- version
- value id string
Quality Codes
The quality codes for the value items in VQT 1 messages are as follows:
Quality | Codes |
---|---|
Good | 0 |
Bad | Anything other than 0 |
VQT Version 2
Version 2 for MQTT messages is a simple JSON object that contains the following keys:
- Message type
- Message version
- Quality
- Timestamp
- Payload
Payload is the content of the message. It is an array/list of JSON objects for value items and has the following attributes:
- k (Key)
- v (Value id)
- t (Time id)
- q (Quality id)
All these attributes for value items shall be represented as key:value pairs in the payload.
Timestamp can be defined for the entire message or inside the payload object for every item separately.
With VQT2, it is also possible to have multiple timestamped values associated with a value item in a message i.e there can be multiple JSON objects for a single value item by including multiple timestamps inside the payload.
If timestamp is not defined, the values will be associated with the current time on the system.
VQT2 Example
{
"messagetype": "vqt",
"version": 2,
"payload":
[
{
"k": "Tag1",
"v": 10,
"t": "2022-09-22T06:06:32.913554+00:00",
"q": 192
},
{
"k": "Tag1",
"v": 3,
"t": "2022-09-23T05:56:36.930429+00:00",
"q": 192
},
{
"k": "Tag2",
"v": 70,
"q": 192
},
{
"k": "Tag3",
"v": 98,
}
]
}
The text strings for value id, time id and quality id are fixed in this version to "v", "q" and "t" respectively and must be defined accordingly in the message.
For the above example message, the properties for a value items in APIS should be set as follows:
Value item | Key |
---|---|
Tag 1 | Tag1 |
Tag 2 | Tag2 |
Tag 3 | Tag3 |
Mandatory Fields in message:
- messagetype
- version
- payload
- k (key)
- v (value)
Quality Codes
The quality codes for the value items in VQT 2 messages are as follows:
Quality | Codes |
---|---|
Good | 192 |
Local override | 216 |
Bad | 0 |
Config error | 4 |
Not connected | 8 |
Device failure | 12 |
Sensor failure | 16 |
Last known | 20 |
Comm failure | 24 |
Out of service | 28 |
Waiting for initial data | 32 |
Uncertain | 64 |
Last usable | 68 |
Sensor cal | 80 |
EGU exceeded | 84 |
Sub normal | 88 |