This page describes how the Connectware can act as an OPC UA server. The Connectware can also act as a OPC UA client.
To run an OPC UA server, the commissioning file must contain a server resource of type Cybus::Server::Opcua. This will start an OPC UA server that can be accessed by OPC UA clients. From the OPC UA client, this server is reachable by the following address:
opc.tcp://<connectwareHost>:4841<resourcePath>
The OPC UA server provided by the Connectware uses the non-standard port number 4841 (whereas standard OPC UA uses port 4840) in order to avoid port number collisions on computers where another OPC UA server is already running. Also note: The Connectware can run exactly one instance of an OPC UA server, not multiple instances.
If your Connectware instance is running on a system that is reachable by a DNS hostname, this hostname must be specified in the hostname property, so that the server is reachable from outside of the Connectware docker network. The value localhost is not valid in this case, as localhost refers to the local Docker container but not the host itself, which means this name is not reachable from other containers or the host system.
Additionally, the property resourcePath is important when when connecting to the OPC UA server. This property defines the prefix of the connection string and defaults to the value /UA/CybusOpcuaServer. Please note that this string has to be added to the URL when connecting from a client to the OPC UA Server. Otherwise the client might not be able to connect successfully.
The server configuration is specified by the properties of the server resource. The actual data points (nodes in OPC UA) are specified by defining resources of type Cybus::Node::Opcua, one resource for each node. The nodes are structured in a tree-like hierarchy. There must be exactly one root node, which has its parent property set as a reference to the server object. All other nodes reference either the root node or other intermediate nodes as parent, forming a tree of nodes on the OPC UA Server.
Nodes can be defined within the same service as the OPC UA server, or also in other services using inter-service referencing using the service-id. It is thus possible to add or remove nodes while the OPC UA server is running, by adding more service commissioning files.
---description:> This is a fixture showing server resource functionalitymetadata:name:OPC UA Server exampleversion:1.0.0icon:https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svgprovider:cybushomepage:https://www.cybus.ioparameters:influxPort:type:integerdefault:8086title:Influx Database PortretentionTime:type:integerdefault:356title:Retention Timedefinitions:databaseName:opcuaHistoryresources:influxdb:type:Cybus::Containerproperties:image:influxdb:1.8-alpineports: - !sub'${influxPort}:8086/tcp'volumes: - !sub'${influxdbVolume}:/var/lib/influxdb'environment:INFLUXDB_DB:!refdatabaseNameINFLUXDB_HTTP_FLUX_ENABLED:trueinfluxdbVolume:type:Cybus::VolumeopcuaServer:type:Cybus::Server::Opcuaproperties:database:host:172.17.0.1name:!refdatabaseNameretention:!refretentionTimeallowAnonymous:falsecertificateFile:/connectware_certs/cybus_server.crtprivateKeyFile:/connectware_certs/cybus_server.keyparentNodeRoot:type:Cybus::Node::Opcuaproperties:browseName:parentNodeRootnodeId:ns=1;s=parentNodeRootparent:!refopcuaServernodeType:ObjectparentNode1:type:Cybus::Node::Opcuaproperties:browseName:parentNode1nodeId:ns=1;s=parentNode1parent:!refparentNodeRootnodeType:ObjectparentNode2a:type:Cybus::Node::Opcuaproperties:browseName:parentNode2anodeId:ns=1;s=parentNode2aparent:!refparentNode1nodeType:ObjectparentNode2b:type:Cybus::Node::Opcuaproperties:browseName:parentNode2bnodeId:ns=1;s=parentNode2bparent:!refparentNode1nodeType:ObjectdataNodeRoot1:type:Cybus::Node::Opcuaproperties:browseName:dataNodeRoot1nodeId:ns=1;s=dataNodeRoot1parent:!refparentNodeRootnodeType:Variableoperation:serverProvidesdataType:BooleandataNodeRoot2:type:Cybus::Node::Opcuaproperties:browseName:dataNodeRoot2nodeId:ns=1;s=dataNodeRoot2parent:!refparentNodeRootnodeType:Variableoperation:serverReceivesdataType:DateTimedataNodeRoot3:type:Cybus::Node::Opcuaproperties:browseName:dataNodeRoot3nodeId:ns=1;s=dataNodeRoot3parent:!refparentNodeRootnodeType:VariableinitialValue:42.0operation:serverProvidesAndReceivesdataType:Floathistorize:truedataNode1:type:Cybus::Node::Opcuaproperties:browseName:dataNode1nodeId:ns=1;s=dataNode1parent:!refparentNode1nodeType:Variableoperation:serverReceivesdataType:Int32dataNode2a:type:Cybus::Node::Opcuaproperties:browseName:dataNode2anodeId:ns=1;s=dataNode2aparent:!refparentNode2anodeType:Variableoperation:serverProvidesdataType:Doublehistorize:truedataNode2b:type:Cybus::Node::Opcuaproperties:browseName:dataNode2bnodeId:ns=1;s=dataNode2bparent:!refparentNode2bnodeType:Variableoperation:serverProvidesdataType:Stringmapping:type:Cybus::Mappingproperties:mappings: - publish:topic:my/opcuaData/dataNode1subscribe:endpoint:!refdataNode1 - publish:endpoint:!refdataNode2asubscribe:topic:my/opcuaData/dataNode2a
Output Format
If the server receives data from an external OPC UA client, the output on the internal MQTT broker will be provided as JSON object:
{ 'timestamp':'<unix timestamp in ms>','value':'value' }
Input Format
If the server should provide data to an external OPC UA client, the message on the internal MQTT broker must be published in this format:
{ 'value':'<value>' }
Note: If 64-bit integers are being used (which are unsupported in JSON, but are supported in Javascript by the BigInt class), the value must be given as a string that contains the decimal number.