Based on node-opcua all kudos due
This script will let you simulate a PLC by entering tags on the tags.json file.
[
{
"nodeId": "s=010",
"browseName": "your tag name",
"dataType": "Int32", // any valid OPC-UA data type
"func": "seed + 1", // a string containing a function that will generate the nodeId value
"seed": 100 // a seed to the function 'func' above
}
...
]
- clone
- set three env vars, one called HOSTNAME (set it to your OPC-UA IP or FQDN), one called PORT (the port you want your OPC-UA clients to connect) and one for your OPC UA resource path called RESOURCEPATH (e.g /myRA)
- edit the tags.json
- start the script (DEBUG=* if you want to see what the server is doing)
- clone
- build
- docker run -p: -e hostname= -e port= -e lucarv.azurecr.io/simple_opcua_server
- Use the Dockerfile in this repo to create your image
- Push it to Azure
- Create one (or more) Container Instances (below is an example)
az container create --resource-group YOUR_RG_NAME ddmstatusapp --image YOUR_IMAGE_LOCATION_IN_ITS_REGISTRY --cpu 1 --memory 1 --registry-login-server YOUR_REGISTRY_URL --registry-username YOUR_REGISTRY_USERNAME --registry-password YOUR_REGISTRY_PASSWORD --dns-name-label A_LABEL_FOR_DNS --environmental-variables HOSTNAME=THE_DNS_LABEL_YOU_CHOSE.azurecontainer.io RESOURCEPATH=A_FOLDER_FOR_YOUR_TAGS
e.g. az container create --resource-group lucaRG ddmstatusapp --image lucarv.azurecr.io/simple_opcua_server --cpu 1 --memory 1 --registry-login-server lucarv.azurecr.io --registry-username lucarv --registry-password {this is a password but not the real one} --dns-name-label luca-opcua-sim --environmental-variables HOSTNAME=luca-opcua-sim.azurecontainer.io RESOURCEPATH=/lucaPLC
if you want to change the tags.json without having to rebuild the image, you can mount an external volume when creating the container instance like shown here# sensehat-opcua