Event class

Event classes are groups of events (possibly for a topic) and, in the sense of the TwinCAT type system, data types that can be used in different modules. For this reason they are created as data types in the TwinCAT type system (System > Type System > Event Classes).

Event class 1:

All known event classes are listed on the Event Classes tab in the TwinCAT type system. The TMC editor, in which the event classes can be defined and edited, can be opened via the context menu commands Edit and New.

In addition to the project event classes, TwinCAT also provides further event classes such as ADS return codes and system events.

Properties of event classes

Event class 2:

Name

Description

Name

This name designates the event class, for example in the generated source code.

Namespace

Like all data types, event classes may also belong to a namespace.

Display Text

This text is used for the event class for the display. It can be internationalized (see Internationalization/translations).

Guid

Like all data types it identifies the currently described event class. It is calculated automatically and changes in the event of changes within the event class.

Optional properties

By setting properties, the behavior of the event classes can be changed:

  • Name "plcAttribute_to_string" to Value "1" an attribute "to_string" is created in the PLC, which is described here.
  • "HideNeedlessArguments" on Value "1" suppresses the output of unnecessary arguments in the event texts.

Event classes in PLC libraries

If event classes are used in a PLC library, they should also be part of the library in order to ensure that the data types are contained in the TwinCAT type system of every application that uses the PLC library.

To make this possible the event classes must be "pinned" in the PLC library. To do this, select in the PLC library object in the context menu Add the command Add Global Data Type ... (in TwinCAT 3.1 4024: External Types -> Pin Global Data Type).

Event class 3:

Select the data type of the event class:
Event class 4:

Event classes in C++ projects

Analogous to the other TwinCAT data types there is a possibility for C++ projects to define event classes locally in the C++ project.

Event class 5:

The event classes are declared for use in the corresponding C++ modules (irrespective of where they were defined). If an event class is added to a C++ module, it is automatically embedded in the TMC file of the module.

Event class 6: