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
EventCallbackmethod to implement theICmpEventCallbackinterface. After the function block has been created, theEventCallbackmethod and theStartandStopevents are registered in theFB_Initmethod. If the function block is deleted, then theFB_Exitmethod is called, which unregisters from the event. When the stop event occurs, the method saves the cause of the event in theg_ulStopReasonvariable.EventCallbackFunctionFB:This function block uses the
EventCallbackFunctionfunction 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
EventCallbackFunctionfunction 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
DOWNLOAD Project