Enums

Enumerations in OPC UA always have the data type Int32. However, the IEC 61131-3 standard allows the definition of larger data types than Int32. To ensure that these enumerations are handled properly, the TwinCAT OPC UA Server offers the configuration option <ImportBigEnumsNumeric>, which can be enabled in its Data Access configuration file.

This option is set to FALSE by default. This means that a status code exception BadOutOfRange is triggered if the enumeration value is outside the Int32 range.

If the option is set to TRUE, enumerations with data types greater than Int32 are treated as regular variables with this particular data type.

Let's assume we have the following enumeration definitions in our PLC code:

TYPE E_Enum_Normal :
(
  enum_member_0 := 0,
  enum_member_1 := 1,
  enum_member_2 := 2
);
END_TYPE

TYPE E_Enum_NotSoBig :
(
  enum_member_0 := 0,
  enum_member_1 := 1,
  enum_member_2 := 2
) UINT;
END_TYPE

TYPE E_Enum_VeryBig :
(
  enum_member_0 := 0,
  enum_member_1 := 1,
  enum_member_2 := 2
) LINT;
END_TYPE

If the above configuration option is activated, instances of E_Enum_VeryBig are treated as regular variables of data type Int64 in the server namespace, while instances of E_Enum_Normal and E_Enum_NotSoBig are treated as OPC UA enumeration (with data type Int32):

Enums 1: