IEC 61131-3 structure data types are mapped as subtypes of the OPC UA DataType Structure. OPC UA servers must explicitly describe how structured DataTypes are encoded / decoded and provide this information to the client which is using it while reading / writing structure data.
The following example of an IEC 61131-3 structure data type declaration (using Structured Text) will be used for further illustrations. This structure data type comprises three structure elements of different elementary data types.
TYPE ExampleIEC611313Structure:
STRUCT
IntStructureElement: INT;
RealStructureElement: REAL;
BoolStructureElement: BOOL;
END_STRUCT;
END_TYPE
The following Figure 22 shows the deprecated mapping of the above example. This mapping is deprecated since it is deprecated in OPC UA V1.04.
Figure 22 – Deprecated Mapping of structure data types
Ctrl servers must support the binary encoding (“Default Binary”). Additionally, other encodings may be provided (not shown in above figure). A Server may provide, for backward compatibility, the deprecated DataTypeDictionary Variable describing all necessary DataTypes. Each DataType is represented by a DataTypeDescription Variable. Optionally, a Property DictionaryFragment may be available, allowing clients not to read the complete DataTypeDictionary in order to get the information about only a single DataType (not shown in above figure).
Figure 23 – Mapping of structure data types
Ctrl servers shall support the binary encoding (“Default Binary”). Additionally, other encodings may be provided (not shown in above figure). Since OPC UA V1.04 a structured DataType provides the new attribute DataTypeDefinition. This attribute is defined in OPC 10000-6 – F.12. Implementations shall use this new attribute instead of the deprecated DataTypeDictionary.
A Server provides on a structured DataType Node the DataTypeDefinition attribute describing all elements and their order in this structure.
The Value of the DataTypeDefinition Attribute for a DataType Node describing ExampleIEC611313Structure is shown in Table 32.
Table 32 – Value of the DataTypeDefinition
Name |
Type |
Description |
defaultEncodingId |
NodeId |
NodeId of the “ExampleIEC611313Structure_Encoding_DefaultBinary” Node. |
baseDataType |
NodeId |
“i=22” [Structure] |
structureType |
StructureType |
Structure_0 [Structure without optional fields] |
fields [0] |
StructureField |
|
name |
String |
“IntStructureElement” |
description |
LocalizedText |
Description of IntStructureElement |
dataType |
NodeId |
“i=4” [Int16] |
valueRank |
Int32 |
-1 (Scalar) |
isOptional |
Boolean |
False |
fields [1] |
StructureField |
|
Name |
String |
“RealStructureElement“ |
Description |
LocalizedText |
Description of RealStructureElement |
dataType |
NodeId |
“i=10” [Float] |
valueRank |
Int32 |
-1 (Scalar) |
isOptional |
Boolean |
false |
fields [2] |
StructureField |
|
name |
String |
“BoolStructureElement“ |
description |
LocalizedText |
Description of BoolStructureElement |
dataType |
NodeId |
“i=1” [Boolean] |
valueRank |
Int32 |
-1 (Scalar) |
isOptional |
Boolean |
false |
It is strongly recommended for Ctrl servers to provide additionally the structured data as a set of sub variables (components of the variable) providing the structure as several separated values. This allows clients that do not support complex data to access the scalar values. The following Figure 24 shows an example (instances based on the above type descriptions).
Figure 24 – Mapping of structure data types to Variable components
If a structure element is not an elementary data type, it has to be divided again into sub variables.
It is recommended that Ctrl servers do support complex data. If a server does not support complex data it provides only sub variables for structure variables. The structured variable would be a Folder object in this case.