.. _user/protocols/opcuaServer:
***************
OPC UA (Server)
***************
OPC UA (**O**\pen **P**\latform **C**\ommunications **- U**\nified
**A**\rchitecture) is a machine-to-machine (M2M) communication protocol
developed by the `OPC Foundation `_. It is widely
used for communication with industrial equipment and systems for data collection
and control.
This page describes how the Connectware can act as an OPC UA server. The
Connectware can also act as a :ref:`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 a 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://:4841`
Note: 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.
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 :ref:`service-id
`. It is thus possible to add or remove nodes while
the OPC UA server is running, by adding more service commissioning files.
.. _user/protocols/opcua_server:
.. include:: ../protocolSchemas/OpcuaServer.rst
.. _user/protocols/opcua_dataNode:
.. include:: ../protocolSchemas/OpcuaNode.rst
Example Commissioning File
==========================
Download: :download:`opcua-server-example.yml`
.. literalinclude:: opcua-server-example.yml
:language: yaml
:linenos:
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:
.. code:: json
{
"timestamp": "",
"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:
.. code:: json
{
"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.