This project aims to provide an Azure IoT Edge module for publishing PLC Tags values to Azure IoT Edge and Azure IoT Hub.
This project is moved to : https://github.com/iot-edge-foundation/iot-edge-plc-publisher/
To use the module, you need to deploy the following Azure IoT Edge module:
"PlcPublisher": {
"restartPolicy": "always",
"settings": {
"image": "ghcr.io/kbeaugrand-org/azure-iotedge-plc-publisher:latest",
"createOptions": "{}"
},
"status": "running",
"type": "docker"
}
"routes": {
"PlcPublisherToUpstream": "FROM /messages/modules/PlcPublisher/* INTO $upstream",
},
It can be one of the following values:
ControlLogix
: Control Logix-class PLCPlc5
: PLC/5 PLCSlc500
: SLC 500 PLCLogixPccc
: Control Logix-class PLC using the PLC/5 protocolMicro800
: Micro 800 PLCMicroLogix
: Micro Logix PLCOmron
: Omron PLC
It can be one of the following values:
BOOL
: BooleanSINT
: Signed 8-bit integerINT
: Signed 16-bit integerDINT
: Signed 32-bit integerLINT
: Signed 64-bit integerLREAL
: Signed 64-bit floating pointREAL
: Signed 32-bit floating pointSTRING
: StringARRAY_BOOL
: Array of booleanARRAY_SINT
: Array of signed 8-bit integerARRAY_INT
: Array of signed 16-bit integerARRAY_DINT
: Array of signed 32-bit integerARRAY_LINT
: Array of signed 64-bit integerARRAY_LREAL
: Array of signed 64-bit floating pointARRAY_REAL
: Array of signed 32-bit floating pointARRAY_STRING
: Array of string
This module exposes the following direct methods:
ListTags
: List all the tags available in the PLC.ListUdtTypes
: List all the UDT types available in the PLC.ListPrograms
: List all the programs available in the PLC.ReadTag
: Read a tag value.ReadArray
: Read an array value.
For the ListTags
, ListUdtTypes
and ListPrograms
methods, the payload is a JSON object with the following structure:
{
"gateway": "`<the gateway ip or hostname>`",
"path": "<the path to the PLC>",
"plcType": "<the PLC type>",
}
For ReadTag
, the payload is a JSON object with the following structure:
{
"gateway": "`<the gateway ip or hostname>`",
"path": "<the path to the PLC>",
"plcType": "<the PLC type>",
"tagName": "<the tag name>",
"tagType": "<the tag type>"
}
For ReadArray
, the payload is a JSON object with the following structure:
{
"gateway": "`<the gateway ip or hostname>`",
"path": "<the path to the PLC>",
"plcType": "<the PLC type>",
"tagName": "<the tag name>",
"tagType": "<the tag type>",
"arrayLength": "<the array size>",
}
The module accepts the following properties in the module twin:
{
"properties": {
"desired": {
"tags": [
{
"gateway": "`<the gateway ip or hostname>`",
"path": "<the path to the PLC>",
"plcType": "<the PLC type>",
"tagName": "<the tag name>",
"tagType": "<the tag type>",
"pollingInterval": "<the polling interval in milliseconds>"
"arrayLength": "<OPTIONAL - the array size if reading an array>",
"transform": "<OPTIONAL - the transform to apply to the value>"
}
]
}
}
}
When polling values, the module can transform the value before sending it to Azure IoT Hub. The transformation is done using the JMESPath query language.
Note: the transformation uses https://github.com/WorkMaze/JUST.net.
Ex:
{
"gateway": "<PLC_IP>",
"path": "1,0",
"plcType": "ControlLogix",
"tagType": "ARRAY_DINT",
"tagName": "MY_ARRAY",
"arrayLength": 10,
"pollingInterval": 1000,
"transform": {
"VALUE_1": "#valueof($.input[0])",
"VALUE_2": "#valueof($.input[1])",
"VALUE_3": "#valueof($.input[2])",
"VALUE_4": "#valueof($.input[3])",
"VALUE_5": "#valueof($.input[4])",
"VALUE_6": "#valueof($.input[5])",
...
}
}
This project leverages on https://github.com/libplctag/libplctag.NET to provide connectivity to the PLC devices.
This project is licensed under the MIT License (see ./LICENSE.md) for more details.