Example ResultMessage
This sample shows the use of the TwinCAT 3 EventLogger with function blocks. Firstly, it demonstrates how an output on a function block can be utilized in order to use the event information as an extended return. On the other hand, it demonstrates how a parameterization can be carried out in order to output the messages via the TwinCAT 3 EventLogger only in certain cases.
Download the sample: https://github.com/Beckhoff/Tc3Eventlogger_Samples/tree/main/PLC/Tc3EventLogger_ResultMessageSample
The example consists of two function blocks:
- FB_MathCalculation: This function block offers two methods and two properties that always output messages at the output ipResultMessage and additionally send them via the EventLogger if a trace level is exceeded.
- Method Addition(): Adds two numbers and sends a message in case of overflow
- Method Divison(): Divides two numbers after checking. Sends a message in case of division by 0.
- Property bTraceLevelDefault: Indicates whether the trace level is to be observed locally on the function block or whether to use a trace level library, which exists in the GVL in the sample.
- Property eTraceLevel: The methods only send the message via the EventLogger if the severity is greater than or equal to this property.
- FB_Control: This function block shows the use of the FB_MathCalculation function block within another function block. The Execute method of the FB_Control thereby uses the FB_MathCalculation.Divison() and handles the message further itself as error code.