A cross-platform, cloud-based OPC UA command & control reference implementation leveraging MQTT and Kafka. It runs in a Docker container on-premises (on Docker or Kubernetes) and executes OPC UA commands, reads and writes OPC UA variables and supports Historical Data Access (HDA) for on-premises OPC UA servers, executed from the cloud.
The following environment variables are REQUIRED:
<deviceID>/<moduleID>
<YourTopicName>/#
. Read
, Write
and Command
must be sub-topics of this topic. For IoT Hub, the topic is $iothub/methods/POST/#
$iothub/methods/res/
<brokername>/<clientname>/?api-version=2018-06-30
The following environment variables are optional:
Execute:
docker run --env-file .env.local ghcr.io/opcfoundation/ua-cloudcommander:main
from a Docker-enabled PC or Linux box. Use .env.local with suitable values.
Alternatively, deploy it as an Azure IoT Edge module from the Azure portal.
From an broker client, commands can be sent to a broker UA Commander has been configured for. UA Commander subscribes to the configured broker topic to receive commands, executes them and reports command execution status via the configured broker response topic.
The topic must include either Read, Write or Command as well as a request ID in the form {broker topic path}/{command name}/?$rid={request id}, for example /myUAServer/Read/?$rid=123.
UA Commander will respond via the configured broker response topic in the form {broker topic path}/{status code}/?$rid={request id}, for example /myUAServer/response/200/?$rid=123. In this message, the request ID will match the one in the original command message.
Read
Command PayloadReads a UA Node on an OPC UA server that must be in the UA Cloud Commander's network, example parameters:
{
"Command": "Read",
"CorrelationId": "D892A987-56FB-4724-AF14-5EC6A7EBDD07", // a GUID
"TimeStamp": "2022-11-28T12:01:00.0923534Z", // sender timestamp in UTC
"Endpoint": "opc.tcp://myopcserver.contoso/UA/",
"NodeId": "http://opcfoundation.org/UA/Station/;i=123"
}
HistoricalRead
Command (HDA) PayloadReads the histroy for a UA Node on an OPC UA server that must be in the UA Cloud Commander's network, example parameters:
{
"Command": "HistoricalRead",
"CorrelationId": "D892A987-56FB-4724-AF14-5EC6A7EBDD07", // a GUID
"TimeStamp": "2022-11-28T12:01:00.0923534Z", // sender timestamp in UTC
"Endpoint": "opc.tcp://myopcserver.contoso/UA/",
"NodeId": "http://opcfoundation.org/UA/Station/;i=123"
"StartTime": "2022-11-28T12:00:00.0923534Z" // start time for historical values
"EndTime": "2022-11-28T12:01:00.0923534Z" // end time for historical values
}
Write
Command PayloadWrites a UA Node on an OPC UA server that must be in the UA Cloud Commander's network, example parameters:
{
"Command": "Write",
"CorrelationId": "D892A987-56FB-4724-AF14-5EC6A7EBDD07", // a GUID
"TimeStamp": "2022-11-28T12:01:00.0923534Z", // sender timestamp in UTC
"Endpoint": "opc.tcp://myopcserver.contoso/UA/",
"NodeId": "http://opcfoundation.org/UA/Station/;i=123",
"ValueToWrite": {
"Type": 6,
"Body": 123
}
}
The Body is the value and the associated Type can be looked-up in the table here.
MethodCall
Command PayloadExecutes a command on an OPC UA server that must be in the UA Cloud Commander's network, example parameters:
{
"Command": "MethodCall",
"CorrelationId": "D892A987-56FB-4724-AF14-5EC6A7EBDD07", // a GUID
"TimeStamp": "2022-11-28T12:01:00.0923534Z", // sender timestamp in UTC
"Endpoint": "opc.tcp://myopcserver.contoso/UA/",
"MethodNodeId": "http://opcfoundation.org/UA/Station/;i=124",
"ParentNodeId": "http://opcfoundation.org/UA/Station/;i=120",
"Arguments": [
{
"Type": 6,
"Body": 123
},
{
"Type": 12,
"Body": "hello"
},
{
"Type": 10,
"Body": 0.4
}
]
}
Again, the Body is the value and the associated Type can be looked-up in the table here.
UA Cloud Commander will match the correlation ID of the request, update the timestamp (in UTC) and give a status message on failure.
{
"CorrelationId": "D892A987-56FB-4724-AF14-5EC6A7EBDD07",
"TimeStamp": "2022-11-28T12:01:00.0923534Z",
"Success": TRUE,
"Status": ""
}