OPC UA mapping
Use an OPC UA mapping to bring the data of a remote OPC UA server into the address space of the gateway. The remote server is a device of the gateway. A mapping entry connects one node of the remote server to one node of the gateway.
An OPC UA mapping is in brownfieldDevices:, under opcuaConnections[].mapping.
There is no top-level mapping: form for an OPC UA connection.
Words on this page
| Word | Meaning |
|---|---|
| remote server | The OPC UA server that the connection reads. |
| source | The node of the remote server. |
| destination | The node of the gateway that gets the data. |
binding | A mapping type. The value of a destination Variable follows the value of a source Variable. |
copy | A mapping type. The gateway makes a new Variable under the destination Object. |
replicat | A mapping type. The gateway makes a copy of a whole sub-tree under the destination Object. |
The mapping types
Set type: to one of these three values.
Write them exactly as shown: binding, copy, replicat.
Without type:, the type is binding.
| Type | Destination | Result |
|---|---|---|
binding | An existing Variable | The gateway updates the Variable with the value of the source Variable. |
copy | An Object | The gateway makes a Variable under the Object, with the same data type as the source Variable. The Variable follows the source. |
replicat | An Object | The gateway replicates the source node and its child nodes under the Object. |
The source of a binding and of a copy must be a Variable.
The destination of a binding must exist before the mapping starts.
Make it with instances.
How to bind a Variable of a remote server
- Add the types of the remote server to
namespaces:andimports:. See "How to get the types of the remote server". - Make the destination Variable in
instances:. - Add the connection to
brownfieldDevices.opcuaConnections:with aname:and anendpointUrl:. - In
mapping:of the connection, add an entry withtype: binding. - Set
source:to the browse path of the Variable in the remote server. - Set
destination:to the browse path of the Variable in the gateway. - Optional: set
samplingInterval:in ms.
A complete example
namespaces:
- di
- commercialKitchenEquipment
brownfieldDevices:
opcuaConnections:
- name: S1
endpointUrl: opc.tcp://opcuademo.sterfive.com:26541
mapping:
- source: /di:DeviceSet/1:CoffeeMachineA/commercialKitchenEquipment:Parameters/commercialKitchenEquipment:BoilerTempWater
destination: /ua:Objects/ProcessValues/BoundVariable
samplingInterval: 1000
type: binding
- source: /di:DeviceSet/1:CoffeeMachineA
destination: /ua:Objects/di:DeviceSet
type: replicat
- source: /di:DeviceSet/1:CoffeeMachineA/commercialKitchenEquipment:Parameters/commercialKitchenEquipment:BoilerTempWater
destination: /ua:Objects/ProcessValues
type: copy
instances:
- browseName: ProcessValues
typeDefinition: ua:FolderType
organizedBy: /ua:Objects
- browseName: BoundVariable
componentOf: ProcessValues
dataType: ua:Double
minimumSamplingInterval: 1000
- The first entry binds
BoilerTempWaterof the remote server toBoundVariable. The gateway samples the source every 1000 ms. - The second entry replicates
CoffeeMachineAand its child nodes into theDeviceSetfolder. - The third entry makes a new Variable for
BoilerTempWaterunderProcessValues.
This example comes from example/config-coffee-machine.yaml of the package.
Keys of a mapping entry
| Key | Required | Default | Meaning |
|---|---|---|---|
source | Required | none | The node in the remote server: a browse path, or a node id. |
destination | Required | none | The node in the gateway: a browse path, or a node id. |
type | Optional | binding | binding, copy or replicat. |
samplingInterval | Optional | none | The sampling interval of the source, in ms. |
The key reference is in opcuaConnections.
How to write the source and the destination
Write source: in the context of the remote server.
Write destination: in the context of the gateway.
A namespace index of a node id is not the same in the two servers.
To avoid this problem, use an aliased browse path, for example /di:DeviceSet/1:CoffeeMachineA/commercialKitchenEquipment:Parameters/commercialKitchenEquipment:BoilerTempWater.
Do not use a node id (ns=2;i=1234).
The gateway has a list of namespace aliases, and it imports all the namespaces of the remote server.
The gateway can therefore translate an aliased browse path from one server to the other.
If samplingInterval: is absent, the gateway uses the minimumSamplingInterval of the destination Variable.
How to get the types of the remote server
The gateway must have all the types that the remote server uses.
- For a standard companion specification, add its alias to
namespaces:. - For a custom model, get the NodeSet2.xml file from the vendor of the remote server.
- Add the file to
imports:.
If the vendor gives no NodeSet2.xml file, the Sterfive tool opcua-toolbox can extract it from the remote server.
Contact Sterfive support to use it.
opcua-toolbox nodeset --endpoint opc.tcp://opcuademo.sterfive.com:26541 --output folder
Errors
A mapping entry that fails does not stop the connection or the gateway.
The gateway writes a mapping failed: line in its log.
If the destination is a Variable, its value gets a bad status.
| Message | Meaning | Fix |
|---|---|---|
cannot resolve target destination=... | The gateway cannot find the destination. | Correct the browse path in destination:. |
binding target node must be a variable | A binding entry has an Object as destination. | Use a Variable, or use copy or replicat. |
cannot resolve source nodeId | The gateway cannot find the source in the remote server. | Correct the browse path in source:. |