Skip to main content

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​

WordMeaning
remote serverThe OPC UA server that the connection reads.
sourceThe node of the remote server.
destinationThe node of the gateway that gets the data.
bindingA mapping type. The value of a destination Variable follows the value of a source Variable.
copyA mapping type. The gateway makes a new Variable under the destination Object.
replicatA 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.

TypeDestinationResult
bindingAn existing VariableThe gateway updates the Variable with the value of the source Variable.
copyAn ObjectThe gateway makes a Variable under the Object, with the same data type as the source Variable. The Variable follows the source.
replicatAn ObjectThe 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​

  1. Add the types of the remote server to namespaces: and imports:. See "How to get the types of the remote server".
  2. Make the destination Variable in instances:.
  3. Add the connection to brownfieldDevices.opcuaConnections: with a name: and an endpointUrl:.
  4. In mapping: of the connection, add an entry with type: binding.
  5. Set source: to the browse path of the Variable in the remote server.
  6. Set destination: to the browse path of the Variable in the gateway.
  7. 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 BoilerTempWater of the remote server to BoundVariable. The gateway samples the source every 1000 ms.
  • The second entry replicates CoffeeMachineA and its child nodes into the DeviceSet folder.
  • The third entry makes a new Variable for BoilerTempWater under ProcessValues.

This example comes from example/config-coffee-machine.yaml of the package.

Keys of a mapping entry​

KeyRequiredDefaultMeaning
sourceRequirednoneThe node in the remote server: a browse path, or a node id.
destinationRequirednoneThe node in the gateway: a browse path, or a node id.
typeOptionalbindingbinding, copy or replicat.
samplingIntervalOptionalnoneThe 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.

  1. For a standard companion specification, add its alias to namespaces:.
  2. For a custom model, get the NodeSet2.xml file from the vendor of the remote server.
  3. 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.

MessageMeaningFix
cannot resolve target destination=...The gateway cannot find the destination.Correct the browse path in destination:.
binding target node must be a variableA binding entry has an Object as destination.Use a Variable, or use copy or replicat.
cannot resolve source nodeIdThe gateway cannot find the source in the remote server.Correct the browse path in source:.