OPC UA (Server)

OPC UA (Open Platform Communications - Unified Architecture) 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 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://<connectwareHost>:4841<resourcePath>

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 service-id. It is thus possible to add or remove nodes while the OPC UA server is running, by adding more service commissioning files.

Custom Server Properties

port (integer)

Port of the listening socket

Default: 4841

resourcePath (string)

Path of the opcua server

Default: "/UA/CybusOpcuaServer"

alternateHostname (string)

Alternative Hostname

Default: "localhost"

applicationUri (string)

The application URI

Default: "urn:cybus:opcua:server:1"

allowAnonymous (boolean)

Allows anonymous access

Default: false

certificateFile (string)

Absolute path to the server certificate file

Default: "/connectware_certs/cybus_server.crt"

privateKeyFile (string)

Absolute path to the server private key file

Default: "/connectware_certs/cybus_server.key"

securityPolicies (array)

Defines the list of OPC UA securityPolicies that will be available on the server

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • Basic256Sha256

  • None

Default:

[
  "Basic256Sha256"
]

nodesetFiles (array)

Nodeset files to load on startup.

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • standard

  • di

  • machinery

  • machineTool

  • packML

  • robotics

securityModes (array)

Defines the list of OPC UA security modes which an OPC client can use to establish a connection to the Cybus OPC UA server

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • Invalid

  • None

  • Sign

  • SignAndEncrypt

Default:

[
  "SignAndEncrypt"
]

database (object)

Definition of the database for historical access of the data. If this property exists, historical access is enabled, otherwise it is not enabled.

Properties of the database object:

type (string, enum)

Type of the history database

This element must be one of the following enum values:

  • influx

Default: "influx"

host (string)

Database Host

port (integer)

Port of the database server

Default: 8086

name (string)

Database Name

retention (integer)

Data older than the specified number of days will be automatically discarded

Custom Node Properties

browseName (string, required)

The browse name (not path) of this node

nodeId (string)

Specific node id

nodeType (string, enum, required)

Node Type

This element must be one of the following enum values:

  • Object

  • Variable

historize (boolean)

Whether to accumulate an historian for this node

Default: false

interpolation (string, enum)

The displayed interpolation mode

This element must be one of the following enum values:

  • stepped

  • sloped

Default: "sloped"

maxTimeInterval (integer)

Specifies the maximum interval between data points in the history repository regardless of their value change [ms]

Default: 10000

minTimeInterval (integer)

Specifies the minimum interval between data points in the history repository regardless of their value change [ms]

Default: 500

dataType (string, enum)

The data type of that node

This element must be one of the following enum values:

  • Boolean

  • Byte

  • ByteString

  • DataValue

  • DateTime

  • DiagnosticInfo

  • Double

  • ExpandedNodeId

  • ExtensionObject

  • Float

  • Guid

  • Int16

  • Int32

  • Int64

  • LocalizedText

  • NodeId

  • Null

  • QualifiedName

  • SByte

  • StatusCode

  • String

  • UInt16

  • UInt32

  • UInt64

  • Variant

  • XmlElement

valueRank (integer, enum)

The rank of the transported data, default is scalar (-1), use 1 for array of scalars

This element must be one of the following enum values:

  • -3

  • -2

  • -1

  • 0

  • 1

  • 2

Default: -1

arrayDimensions (array)

An array reflecting the size in every dimension

The object is an array with all elements of the type number.

Example Commissioning File

Download: opcua-server-example.yml

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
description: >

  This is a fixture showing server resource functionality

metadata:

  name: OPC UA Server example
  version: 1.0.0
  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
  provider: cybus
  homepage: https://www.cybus.io

parameters:

  influxPort:
    type: integer
    default: 8086
    title: Influx Database Port

  retentionTime:
    type: integer
    default: 356
    title: Retention Time

definitions:

  databaseName: opcuaHistory

resources:

  influxdb:
    type: Cybus::Container
    properties:
      image: influxdb:1.8-alpine
      ports:
        - !sub '${influxPort}:8086/tcp'
      volumes:
        - !sub '${influxdbVolume}:/var/lib/influxdb'
      environment:
        INFLUXDB_DB: !ref databaseName
        INFLUXDB_HTTP_FLUX_ENABLED: true

  influxdbVolume:
    type: Cybus::Volume

  opcuaServer:
    type: Cybus::Server::Opcua
    properties:
      database:
        host: 172.17.0.1
        name: !ref databaseName
        retention: !ref retentionTime
      allowAnonymous: false
      certificateFile: /connectware_certs/cybus_server.crt
      privateKeyFile: /connectware_certs/cybus_server.key

  parentNodeRoot:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNodeRoot
      nodeId: ns=1;s=parentNodeRoot
      parent: !ref opcuaServer
      nodeType: Object

  parentNode1:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode1
      nodeId: ns=1;s=parentNode1
      parent: !ref parentNodeRoot
      nodeType: Object

  parentNode2a:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode2a
      nodeId: ns=1;s=parentNode2a
      parent: !ref parentNode1
      nodeType: Object

  parentNode2b:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode2b
      nodeId: ns=1;s=parentNode2b
      parent: !ref parentNode1
      nodeType: Object

  dataNodeRoot1:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot1
      nodeId: ns=1;s=dataNodeRoot1
      parent: !ref parentNodeRoot
      nodeType: Variable
      operation: serverProvides
      dataType: Boolean

  dataNodeRoot2:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot2
      nodeId: ns=1;s=dataNodeRoot2
      parent: !ref parentNodeRoot
      nodeType: Variable
      operation: serverReceives
      dataType: DateTime

  dataNodeRoot3:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot3
      nodeId: ns=1;s=dataNodeRoot3
      parent: !ref parentNodeRoot
      nodeType: Variable
      initialValue: 42.0
      operation: serverProvidesAndReceives
      dataType: Float
      historize: true

  dataNode1:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode1
      nodeId: ns=1;s=dataNode1
      parent: !ref parentNode1
      nodeType: Variable
      operation: serverReceives
      dataType: Int32

  dataNode2a:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode2a
      nodeId: ns=1;s=dataNode2a
      parent: !ref parentNode2a
      nodeType: Variable
      operation: serverProvides
      dataType: Double
      historize: true

  dataNode2b:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode2b
      nodeId: ns=1;s=dataNode2b
      parent: !ref parentNode2b
      nodeType: Variable
      operation: serverProvides
      dataType: String

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - publish:
            topic: my/opcuaData/dataNode1
          subscribe:
            endpoint: !ref dataNode1

        - publish:
            endpoint: !ref dataNode2a
          subscribe:
            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>"
}