Skip to main content

Example: Event Manager

Product: CODESYS Control

This example shows how to send and receive system events, such as start, stop, login, and logout.

Description

There are two kinds of registration. One is the registration of an interface function and the other one is the registration of an ordinary function. The registration is done within the FB_Init method.

  • EventCallbackFB:

    The function block uses the EventCallback method to implement the ICmpEventCallback interface. After the function block has been created, the EventCallback method and the Start and Stop events are registered in the FB_Init method. If the function block is deleted, then the FB_Exit method is called, which unregisters from the event. When the stop event occurs, the method saves the cause of the event in the g_ulStopReason variable.

  • EventCallbackFunctionFB:

    This function block uses the EventCallbackFunction function to register login and logout events. Every time one of the two events occurs the function is called.

  • EventCallbackFunction:

    The function counts the occurred events.

  • Main:

    In the program, a logout event is generated manually. This event is also captured by the EventCallbackFunction function and increments the counter by one.

System requirements and restrictions

Programming system

CODESYS Development System (version 3.5.14.0 or higher)

Runtime system

CODESYS Control Win (version 3.5.14.0)

Add-on components

-

Note

_example_icon.png DOWNLOAD Project