Structure
This folder represents the "Structure" node [i=22] and contains PLC types that map its subtypes. "Structure" itself does not have an equivalent PLC type. Concrete OPC UA structure types derived from "Structure" can be mapped as PLC data types:
Mapping of an OPC UA structure type as a PLC data type:
Requirements
- The data structure in the PLC matches the OPC UA data structure. In particular:
- Sequence of fields
- Data types
- The PLC type definition contains the OPC UA type information as attributes.
The TwinCAT OPC UA Server requires these attributes in order to assign the PLC data type to the correct OPC UA data type. Simple PLC data types do not require these attributes.
The required attributes can be written manually above the instance or type declaration or retrieved for copying via the TwinCAT OPC UA Nodeset Editor.
Step-by-step with the Nodeset Editor:
1 - Finding and opening the structure type.
5 - Creating the DUT in TwinCAT.
2 – Selection and copying of all names and DataType BrowseNames of the fields
5 - Insert in TwinCAT between STRUCT and END_STRUCT
3 - Opening of the pragmas for the type
4 - Copying the pragmas
5 - Inserting in TwinCAT above TYPE
6 - Replacing the DataType BrowseNames with the appropriate PLC types
(e.g. Boolean => "Tc3_OpcUa.UA_Boolean" or "BOOL").
Missing (structure) types may also need to be created.


Meaning of the attributes:
- OPC.UA.DA
Activates the provision of the data type and any sub-elements via OPC UA. - OPC.UA.DA.StructuredType
Identifies the type as a structured OPC UA data type. - OPC.UA.AdditionalStructuredType.NamespaceName
Specifies the NamespaceUri of the data type from the nodeset. - OPC.UA.AdditionalStructuredType.Id
Contains the NodeId of the OPC UA data type, in this case i=3007. - pack_mode := '1'
Ensures that the memory layout of the structure is defined and compatible.