Skip to main content

Format-types

Some of the VILLASnode node-types are transports which can exchange arbitrary payloads. Examples for these node-types are: MQTT, AMQP and Socket.

The format of the payload for these node-types is configurable. New formats can be added via plugins.

Currently, the following formats are supported:

TypeDescriptionStatus
csvComma-separated valuesstable
iotagent-ulFIWARE IoTAgent Ultralight 2.0 Protocolstable
json.kafkaKafka Schema/Payload Javascript Object Notationstable
jsonJavascript Object Notationstable
opal.asyncipOPAL-RT AsyncIP example formatstable
protobufGoogle Protobufstable
rawRaw binary valuesstable
tsvTabulator-separated valuesstable
valueSingle value textstable
villas.binaryCustom VILLAS Binarystable
villas.humanCustom VILLAS Human Readablestable

Configuration

To use one of the format-types above, a setting named format must be present in the configuration of the respective node instance. The value of the format setting can be eiter a simple string identifying one of the available format-types from the table above. Alternatively, a JSON dictionary can be used to provide additional configuration settings to the payload format. Please see below for examples of both approaches.

If the format-type is provided as an argument to a VILLASnode command-line tool (see Usage), also both variants are supported:

# Simple
villas signal -f json -v 5 sine

# Advanced
villas signal -f '{ "type": "json", "indent": 4, "precision": 4 }' -v 5 sine

Please note, that depending on you system configuration not all format-types might be available. Use the following command to get a list of all available types on your system: villas node -h.

All format-types share the following common options:

real_precision
integer
Default: 17

Output all real numbers with at most n digits of precision. The valid range for this setting is between 0 and 31 (inclusive), and other values result in an undefined behavior.

By default, the precision is 17, to correctly and losslessly encode all IEEE 754 double precision floating point numbers.

ts_origin
boolean
Default: true

If set, include the origin timestamp in the output.

ts_received
boolean
Default: true

If set, include the received timestamp in the output.

sequence
boolean
Default: true

If set, include the sequence number in the output.

data
boolean
Default: true

If set, include the data in the output.

offset
boolean
Default: true

If set, include the offset between origin and received timestamp in the output.

{
  • "real_precision": 17,
  • "ts_origin": true,
  • "ts_received": true,
  • "sequence": true,
  • "data": true,
  • "offset": true
}

Example

Simple

nodes = {
udp_json_node = {
type = "socket"
layer = "udp"

format = "json"

...
}
}

Advanced

nodes = {
udp_json_node = {
type = "socket"
layer = "udp"
format = {
"type": "json",

"precision": 4,
"indent": 4
}

...
}
}

Abstract format-types

Thanks to C++ inheritance some format-types are well-suited as a base for other more specific format types: