OPC-UA

Capabilities

Capability

Support

Comment

OPC-DA protocol

Supported feature

See OPC-DA

Connection state with a OPC-UA device

Supported feature

See Device connection state

Reading value by subscription from OPC-UA device

Supported feature

See Reading values with subscription

Reading value by polling from OPC-UA device

Supported feature

See Reading values with polling

Writing value from OPC-UA device

Supported feature

See Writing values

Trigger a method using polling to read from OPC-UA device

Supported feature

See Trigger method to read a value

Trigger method to write from OPC-UA device

Supported feature

See Trigger method to write a value

Examples

Connect an OPC UA client to read, write and use methods from a server.

Concept

Overview

OnSphere allows you to easily read (Reading values with polling) and write (Writing values) data on a OPC-UA device. The status of connection between OnSphere and the OPC-UA device is also monitored. OPC-UA also implements the notion of methods thus you can trigger a method to get its result (Trigger method to read a value) or trigger a method to write the content of a value (Trigger method to write a value).

Everything in OPC-UA is stored as a hierarchy through Folders and Nodes. This means that when you will read, write or call a method on a OPC-UA device you will have to specify the nodeIdentifier path. If you want to define a custom root folder you can in the device.opc-ua file.

NodeIds

In OPC UA (Open Platform Communications Unified Architecture), a NodeId is a unique identifier that is used to address and reference individual nodes (objects, variables, methods, etc.) in the OPC UA server’s address space. The NodeId provides a way for clients and servers to refer to specific data points, objects, or services in a standardized and structured way.

A NodeId consists of two parts:

Namespace (ns or nsu). It Defines the scope or context of the identifier. It helps avoid conflicts between identifiers by allowing multiple parties to define their own nodes in different namespaces:
  • ns (Namespace Index): Numeric namespace index that links to a nsu.

  • nsu (Namespace URI) : Namespace URI (a textual representation of the namespace).

Identifier. The actual unique identifier of the node within the namespace. There are four types of identifiers:
  • i: Integer identifier.

  • s: String identifier.

  • g: Globally unique identifier (GUID).

  • b: ByteString identifier.

You can declare a nodeId of owner.opc-ua or output.opc-ua as follow (raw string or json object):
  • “nodeId”: “nsu=http://example.com/FactoryNamespace/;s=TemperatureSensor”

  • “nodeId”: “ns=3;s=TemperatureSensor”

  • “nodeId”: { "ns"=3, "s"="TemperatureSensor" }

  • “nodeId”: { "nsu"="http://example.com/FactoryNamespace/", "s"="TemperatureSensor" }

In OnSphere, the server is query to resolve an nsu to an ns before building the NodeId.

OnSphere Type transformation

Opc Ua Type

OnSphere Type

String

TEXT

ByteString

TEXT

LocalizedText

TEXT

Boolean

BOOLEAN

Int16

NUMBER

UInt16

NUMBER

Int32

NUMBER

UInt32

NUMBER

Int64

NUMBER

UInt64

NUMBER

Float

DECIMAL

Double

DECIMAL

Note

If the type is not in the table above it is not officially supported but it does not mean it won’t work.

Device connection state

Concept

The connection state between the OPC-UA device and a device can be read as a BOOLEAN value from the OPC-UA device in the OnSphere hierarchy (i.e. root.opc_ua.device1 for example). If the connection is not working the state will be set to false.

Usage

A typical use case would be to monitor the status of a device.

Examples

Device connection

Using certificate

The connection between the device and the OPC-UA device often requires certificates to create a secure connection. You can declare a clientCertificate in the configuration of your OPC-UA device (device.opc-ua)

Warning

Certificates have an URI in the subject alternative names part of it. It is primordial that this URI is the same in the certificate and in the clientURI parameter. This is available inside clientCertificate in the configuration of your OPC-UA device. As the default certificate used is the certificate of the OPC-UA module, the default clientUri is urn:swissdotnet:onsphere.

Reading values with polling

Concept

Values are updated using a polling frequency (defaults to 10 seconds), meaning that the value will take at most pollingFrequency to detect an error reading the value and report it. The module allows you to read a node by defining a owner.

Note

OnSphere handles reading periodically. Every changes in-between readings are lost.

Usage

A typical use case would be to monitor a temperature of a boiler.

Reading values with subscription

Concept

In contrast to permanently reading information (polling), OPC UA provides a more elegant functionality, a so called Subscription. OnSphere let’s you subscribe to data changes of Variable Values (Value attribute of a Variable). The module allows you to subscribe on a node by defining a owner.

A UA server may support queuing of data samples or events. The queue size, i.e. the maximum number of values which can be queued, can be configured for each monitored item.

Usage

A typical use case would be to monitor a temperature of a boiler.

Writing values

Concept

The module allows you to write on an OPC-UA device on demand. OnSphere allows OPC-UA writing through callbacks: define your output and simply reference it in a callback.

Examples

You can refer to this example Connect an OPC UA client to read, write and use methods from a server. for a working example

Usage

A typical use case would be to control the speed of a motor.

Trigger method to read a value

Concept

A method can be used to extract a value and use it inside OnSphere.

Note

OnSphere handles reading periodically. Every changes in-between readings are lost.

Usage

A typical use case would be to monitor a temperature of a boiler.

Trigger method to write a value

Concept

OnSphere allows you to write on an OPC-UA device on demand. OnSphere allows OPC-UA writing through callbacks: define your output and simply reference it in a callback.

Warning

You can only pass one argument to methods you call.

Usage

A typical use case would be to start a boiler.