OPC-UA¶
Capabilities¶
Capability |
Support |
Comment |
---|---|---|
OPC-DA protocol |
See OPC-DA |
|
Connection state with a OPC-UA device |
||
Reading value by subscription from OPC-UA device |
||
Reading value by polling from OPC-UA device |
||
Writing value from OPC-UA device |
See Writing values |
|
Trigger a method using polling to read from OPC-UA device |
||
Trigger method to write from OPC-UA device |
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.
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.
The value to read is determined by a namespaceIndex
and a nodeIdentifier
.
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 value to read is determined by a namespaceIndex
and a nodeIdentifier
. 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.
Once this is done when the value is updated it will be written on the defined namespaceIndex
and nodeIdentifier
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. The method used is determined by a namespaceIndex
, methodIdentifier
and methodObjectIdentifier
.
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.
Once this is done when the value is updated it will be written on the defined namespaceIndex
, methodIdentifier
and methodObjectIdentifier
.
Warning
You can only pass one argument to methods you call.
Usage¶
A typical use case would be to start a boiler.