Skip to main content

Mapping of OPC UA Types to IEC Types

Mapping of base data types

Table 1. Base data types

OPC UA

IEC

Description

Basic types

Boolean

BOOL

Byte

BYTE

SByte

SINT

Int16

INT

UInt16

UINT

INT32

DINT

UInt32

UDINT

Int64

LINT

UInt64

ULINT

FLOAT

REAL

Double

LREAL

Duration

LREAL

DateTime

LDATEANDTIME

UtcTime

LTIME

String

STRING

Simple strings are converted to IEC strings.

The length of the IEC string can be changed afterwards and can be chosen without restriction.

LocalizedText

STRING

Locatable strings are mapped to an IEC string.

Special types:

NodeId

Bytestring

XmlElement

Guid

ExpandedNodeId

StatusCode

QualifiedName

LocalizedText

ExtensionObject

DataValue

DiangosticInfo

Mapping to the corresponding type from the OPC UA specification: OpcUA_<name>.

Example: OpcUA_NodeId

These are data types from the OPC UA specification which require special handling in the PLC application.

Only read access is supported.

Inheritance

Inheritance is allowed for all OPC UA types. For example, new types can also be derived from String and Int32.

Note: In the case of derivations of base types, the base type is used as the basis for the mapping. As a result, the derived OPC UA type is no longer available in IEC.

_cds_img_opc_ua_map_object_inheritance.png

BaseObjectType as data type

See description

If more than one specific object type is allowed for a variable in an information model and it is up to the user of the model to select the specific type, then simply BaseObjectType is specified as the type of the variable. Normally, CODESYS generates its own function block in this case and inserts any existing child elements there. However, the user may delete this function block and also use another object type in the declaration. The only restriction is that it has to be an object type from the same information model.

VariableType

See description

In addition to a data type, a variable in OPC UA can also reference a VariableType by means of a HasTypeDefinition. This is often used to decorate a variable with additional metadata (AnalogItemType, EngineeringUnits, etc.)

Because a variable can only ever have exactly one type in IEC, a structure is generated which:

  • Contains a variable named "value " for the actual value of the data type

  • Contains a variable named "properties" which can be used to access the other metadata.

For an OPC UA Client, this generated structure is invisible. As expected, it only sees the correct data type at the variable and the metadata as child elements.

_comm_img_opc_ua_variabletype.png


Mapping of object types

Tip

All declarations are declared altogether as local variables between VAR and END_VAR. The user can change the declarations as needed in VAR_INPUT and VAR_OUTPUT.

Table 2. Object types

OPC UA

IEC

Description

OPC UA object types

Function blocks

Interfaces and add-ins

Function Block

The members of the interface are members of the function block.

Example:

_cds_img_opc_ua_map_interfaces.png

Inheritance

Instead of generating multiple function blocks with "Extends", a flat hierarchy is generated.

Example:

_cds_img_opc_ua_map_object_inheritance.png

Folder

A separate type for each instance of a folder in an OPC UA object type

The user may add the instances on his own by editing the declaration of the IEC POUs. However, function blocks have to be used which originate from an OPC UA companion.

All instances of function blocks below the folder are exported. Semantic checks based on NodeSet2.xml are not possible.

Initially, a folder is set as an object type in OPC UA. However, it is not enough to generate a FolderType.

_cds_img_opc_ua_map_folder.png

The user is responsible for adding appropriate elements to the folder.

BaseObjectType a as folder

See description

(as for folder)

OPC UA defines an individual data type for folders: the FolderType (see above: Folder). However, there is also the possibility to declare only BaseObjectType in an instance instead of this type and then use this type like a folder. From the OPC UA side, there are no restrictions regarding what is allowed as child elements. The mapping to IEC in this case looks the same as for a FolderType.



Mapping of structured data types

Table 3. Structured data types

OPC UA

IEC

Structure

DUT

Union

Not currently supported

Optional member

Not currently supported

Inheritance

Implementation as for the object types



Mapping of OPC UA reference types

Table 4. OPC UA reference types

OPC UA

Meaning in OPC UA

Mapping in IEC

Organizes

Normally only the derivations of this type are relevant. The exception is when folders are mapped directly to IEC (see Mapping of OPC UA Types to IEC Types).

HasSubtype

See Mapping of OPC UA Types to IEC Types

HasTypeDefinition

  • Used to collect all elements of a type when the UA types are compiled according to IEC

  • Declarations of instances in IEC are then referenced again by the OPC UA Server with this reference to the type in the information model.

  • HasTypeDefinition for OPC UA variables is currently supported only for the special case when the variable type has the same members as the data type. Then the single access to the individual variables of the DUT instance is allowed in IEC.

HasComponent

Variables and objects are mapped in IEC as variables. Therefore, each HasComponent reference becomes an variable declaration in IEC. Methods also become methods of the function block in IEC.

The user has to apply the modeling rules in the information model editor before the IEC POUs are generated. Optional members can be selected or deselected and concrete members can be generated for placeholders.

HasProperty

In OPC UA, properties have the character of additional meta-information for process data. They can be of static nature, for example engineering units. But they can also change when the server is running.

In IEC, this reference is handled exactly like HasComponent. As a result, variables are also created for this at the function block. An unresolved issue is the handling of properties at variables in UA (by means of the detour of HasTypeDefinition and VariableType). In IEC, the variable of type INT would have to be structured once again and have children. Currently, properties at variables in OPC UA are ignored and cannot be reached from IEC.



For more information, see: Using OPC UA Information Models