Link is the service that sends data to an MQTT server. Different types of CygNet data can be published by Link.
When configured to publish realtime point data from a CygNet UIS service, Link will continually poll the UIS service based on the polling frequency configured for each provided point tag. On each poll, if the point value, point type, or primary units have changed since the last poll, or if the Link service has never polled the point previously, Link will publish the point value and metadata to all connected endpoints.
DynaCard data can be published from both the DDS and VHS. Link will continually poll the VHS or DDS service based on the polling frequency configured for each provided DynaCard. On the initial poll, only DynaCards that were stored within the specified time for the defaultPollingFreq of the endpoint will be published. On subsequent polls, only new DynaCards since the last poll will be published. If new DynaCard points are added to the PNT service while Link is running, Link will query the PNT service at the frequency specified by the pointDiscoveryFreq option of the VHS endpoint. Once these new DynaCard points are discovered, the VHS will begin to publish their values.
This behavior is also true for a Link service restart. If Link is stopped for an extended time period and CygNet / Foresite continue to store DynaCards, the stored cards will be published when Link restarts. To return to the initial polling state, a user can delete the Link metadata prior to restarting the service.
In MQTT, a topic is a string identifier that categorizes, identifies, or describes the data and is used by the MQTT server to filter messages for each connected client. The payload is the actual message content. Payload data is a simple array of bytes. Metrics are published only when they have changed since the last time of publication.
Topics and payloads will differ according to the dataFormat type specified in the appsettings file.
Connect a CygNet endpoint to a Sparkplug endpoint to publish data to an MQTT server using the Sparkplug format. For more information about the Sparkplug specification, refer to the Sparkplug Specification document online.
Link constructs MQTT topics for data using the following Sparkplug specification model:
|
spBv1.0/<groupId>/<message_type>/<gatewayNodeId>/<facilityId> |
where <groupId> and <gatewayNodeId> refer to the corresponding properties in the appsettings.gateway.json file, and <facilityId> refers to the facility ID portion of the point tag being polled.
The Sparkplug format supports node and device rebirth using the NCMD and DCMD message type (<message_type> in the Sparkplug specification model). The payload must contain the correct metric name for rebirth ("Node Control/Rebirth" or "Device Control/Rebirth"). See the Sparkplug Specification document for additional details.
The following is an example of an MQTT Sparkplug payload decoded to json format for a realtime data poll of two UDCs (ACC00 and ACC01):
|
{ "timestamp":1539791916341, "metrics":[{ "name":"ACC00", "timestamp":1539791878101, "dataType":"String", "properties":{"Unit":{"type":"String","value":""}}, "value":"My point value" },{ "name":"ACC01", "timestamp":1539791894655, "dataType":"Double", "properties":{"Unit":{"type":"String","value":"m3"}}, "value":45.247 }], "seq":1 } |
When the compression setting for a Sparkplug endpoint in the appsettings.gateway.json file is set to a value other than "none", Link will compress the payload using the specified format. Link will then package the compressed data into the body of the payload and append information to describe the content, as shown in the following example:
|
{ "timestamp":1548284403066, "metrics": [{ "name": "CygNet/Type", "dataType": "String", "value": "Points/Current" },{ "name": "algorithm", "dataType": "String", "value": "GZIP" }], "seq":2 "uuid": "SPBV1.0_COMPRESSED", "body": "H4sIAJDeSlwA/+P4PWPBmg5dISEuVkdnZwMDibv7N6/u0FXgsmAEALKL9IobAAAA" } |
Note: The above example is a payload for the compression setting of "gzip". If the compression setting is "zlib", the metric named "algorithm" will not be present, as zlib is the default compression format for Sparkplug.
Connect a CygNet endpoint to an AWS endpoint to publish data to an MQTT server using the AWS format.
Link constructs MQTT topics for data using the following AWS format:
|
<groupId>/<gatewayNodeId>/<facilityId> |
where <groupId> and <gatewayNodeId> refer to the corresponding properties in the appsettings.gateway.json file, and <facilityId> refers to the facility ID portion of the point tag being polled.
When using the AWS format, the payload is sent as a json string.
A command can be issued to Link to publish all current values, rather than only the values that have changed since the last poll.
To have Link publish all current values for all devices (facilityId) on the node, a command can be published to the topic <groupId>/<gatewayNodeId>/COMMAND with a payload similar to:
|
{ "timestamp": <Epoch ms>, "metrics": [{ "name": "Node Control/Publish", "timestamp": <Epoch ms>, "dataType": "Boolean", "value": false }] } |
To have Link publish just for a single device (facilityId), a command can be published to the topic <groupId>/<gatewayNodeId>/<facilityId>/COMMAND with a payload similar to:
|
{ "timestamp": <Epoch ms>, "metrics": [{ "name": "Device Control/Publish", "timestamp": <Epoch ms>, "dataType": "Boolean", "value": false }] } |