A OPC UA server that can serve a custom list of OPCUA.Types.UAReal.Double valued variable nodes


The OPCUA Library comes with a OPC UA server that can be used to serve a custom list of OPCUA.Types.UAReal.Double valued variable nodes. The nodes are created in a flat structure in the local server namespace (corresponding to namespace index 1) and have string based id's. They are both readable and writable. The server executable varserver is located in a platform specific subfolder of the Resource/Library folder:

  • Windows: win64 or win32
  • macOS: aarch64-darwin or darwin64
  • Linux: linux64 or linux32

The server could for example be used to communicate between two System Modeler simulations, on possibly different computers. One simulation would write data to the varserver and the other simulation reads it.

Another use case, is to combine it with the OPCClassic library and have one simulation, on the OPC Classic server computer, relaying data to the varserver, there by tunneling the OPC Classic traffic through OPC UA and avoid all of the potential problems with configuring remote access to OPC Classic servers.

varserver [-p PORT] nodeId1 nodeId2 ... nodeIdN
  • PORT: The port to start the OPC UA server on (optional, default is 16664).
  • nodeIdN: String id of node N.
Press Ctrl-C to stop the server. To use any of the OPCUA.Blocks.SamplerReal blocks to read or write data from one of the nodes the following needs to be specified in the Node Identifier group:
  • nodeIDType: OPCUA.Types.UANodeIdType.StringId (nodes have string based id's).
  • nodeID: the node id specified on the command line within double quotes, e.g. "temperature".
  • nodeNamespace: 1 (nodes are created in the local server namespace corresponding to namespace index 1).
In addition to that all write blocks need to set uaRealType to OPCUA.Types.UAReal.Double in the Parameters group.
varserver pumpSpeed temperature
This will start the varserver on the default port serving the variable nodes pumpSpeed and temperature. The server will output log messages to the standard output about the startup procedure, the server is ready to be used when the message TCP network layer listening on ... is shown.
[04/01/2022 13:43:16.169] info/server  Adding variable pumpSpeed
[04/01/2022 13:43:16.169] info/server  Adding variable temperature
[04/01/2022 13:43:16.169] info/network TCP network layer listening on opc.tcp://computername.local:16664

Wolfram Language