Usually, RAW values are included in the payload without any encoding (Literal), alternatively they may use the standard JSON representation; and in other cases the value might be encoded as a binary value (e.g., sending MODBUS registers).
Literal
The value is encoded as a simple string.
{
"data": {
"stringValue": "FooBar",
"booleanValue": "true",
"integerValue": "123456",
"floatValue": "123.456"
}
}
The system automatically converts the incoming string values according to the target metric types. Pay attention to configure the right metric type, the value maybe discarded during data ingestion in the case it cannot be converted to the target type (e.g. partInt("fooBar")).
When sending values to the remote products, it is suggested to use the Literal (JSON) encoding, if possible.
Literal (JSON)
This encoding is automatically supported when receiving RAW data, but can be explicitly defined when sending data to the remote things (e.g. configuration parameter). By using this encoding, boolean and number values are encoded with the standard JSON encoding.
{
"data": {
"stringValue": "FooBar",
"booleanValue": true,
"integerValue": 123456,
"floatValue": 123.456
}
}
In case of numbers, the values -INF, INF or NA cannot be sent, even if supported by the JSON specification. The presence of these values will cause the message to be discarded.
Binary Int / Binary Hex
The value is encoded by using a binary representation, which can be an integer or a hex string.
From the binary encoded value, you can also specify to extract a single bit or a sub-sequence of bits.
For example, if you have a MODBUS register that provides several boolean flags, the metric will be of type BOOLEAN and the binary encoding will have to read only one bit at a given position (e.g., position=3, length=1).
To do this, you can specify:
- Binary position: the position of the initial bit to be read.
- Binary length: the number of bits to be read.
- Binary byte order: the order in which the bytes are to be read (Little Endian or Big Endian).
Comments
0 comments
Please sign in to leave a comment.