OPC UA Structured Data Variables

Concept

For the usage of OPC UA structured data variables (SDV) within WinCC OA they must be mapped to JSON strings.

The reasons why WinCC OA does not provide a direct mapping of the structured data to a WinCC OA DP are the following:

  1. A SDV must be handled as a unit, which is very difficult if it is mapped to several DPEs.
  2. Addressing would be very complex because a separate peripheral address for be required each element.
  3. SDV can use data types, which cannot be mapped to WinCC OA DP, e.g. an array of structures.

In principle using a JSON string an intermediate step and the final representation of an SDV in WinCC OA is a mapping variable.

This means, that the DPE containing the address of an SDV is of type string and the content is a JSON string. This allows the application to easily convert the data to a mapping variable for comfortable processing while the mapping is flexible enough to represent arbitrary SDV.

OPC UA Structured Data Variable Mapping

A simple example of an OPC UA DataType Vector is given below. This Vector has the following elements:

X: double
Y: double
Z: double

In WinCC OA this will correspond to a mapping:

mapping m;
m["X"] = 10.0;
m["Y"] = 20.0;
m["Z"] = 30.0;

To write this to an SDV the mapping must be converted into a JSON string (jsonEncode()) and written to a string DPE, with a configured address of the SDV.

For input direction the driver will provide a JSON string on the DPE, which could be converted to a mapping using the function jsonDecode().

This can also be used for very complex nested structures. If there is an array of structures in OPC UA you map this to a dyn_mapping in WinCC OA. If the OPC UA data type has a nested structure the WinCC OA mapping has an nested mapping.

For example, imagine an OPC UA data type, which consists of a build in type string and the Vector type above:

Name: string
V: Vector

You build the corresponding mapping as followed:

mapping m1, m;
m1["X"] = 10.0;
m1["Y"] = 20.0;
m1["Z"] = 30.0;
m["Name"] = "Vector Name";
m["V"] = m1;
Note: It is important that a nested mapping is used and not one mapping with the keys that also represent the hierarchy.

Restrictions

The following restrictions must be considered:

  • The OPC UA server must provide a DataType Dictionary for the structured DataTypes. It is not supported if the UA server provides the structure definition only by DataType attribute DataTypeDefinition.
  • Union or OptionSet DataTypes are not supported