Skip to content

Event Logger

The event logger is large topic that is comprised of many pieces. The documentation covers many situations that are not necessary to start using the event logger. The SPT Framework library provides code that can help manage alarms and messages within a project.

Alt text

Events can be messages or alarms

TraceLog

FB_TraceLog

Uses FB_TcMessage from the Tc3_EventLogger library and adds further information including a time stamp, and the location (MM, EM, Component) where the message was created.
There is already an instance of FB_TraceLog within FB_BaseFB; therefore, no additional instances are needed.
Any function block that has a CyclicLogic method will also have a Trace method.

The logged messages are best used for debugging purposes. For example, at the end of the CASE statement in the Initialize method.

Be careful that the Trace method is only called once, otherwise the message will be logged every cycle.

1
2
3
4
    50:
        THIS^.Trace('Init Complete');  
        Initialize := TRUE;  
END_CASE

Alt text

Logged Trace Message

TMC Editor

Event Classes are groups of events (possibly for a theme e.g. SubMoulde or Component). Create Events using the TMC Editor in the Type System. The specific text of each event created within the TMC Editor can be customized; however, only one instance of an event can be active at a given time. For messages this is not an issue, but for alarms that will be raised and cleared it is important to note that only one alarm can be active at a time. For multiple alarms, each will need an entry within the TMC Editor.

The VFFS Demo project uses and Event Class for each Module, Submodule, and Component.

Drawing
Machine Module Events
Drawing
Submodule Events
Drawing
Component Events

Each of the above examples have a few standard events along with custom events that are specific to the module.
It is important to note that the first event in each, the 'InitReferenceEvent' is used to initialize the event class. This event is used by the CreateEvents method of the modules and is required by the SPT Framework.

Alarms

It is important to understand that while all alarms must be raised, their status must be checked in order for them to prevent any given functionality. Therefore, a raised alarm that requires no confirmation can also be used to log information. However, if the alarm is not cleared, then it will lock that Event Class and not allow any other alarms to be raised for it.

Alt text

Alarms can be Raised and Cleared

Alt text

Alarms can also require Confirmation

F_CreateAllEventsInClass

Initializes all instances of FB_TcAlarm within Alarms

Called from the CreateEvents method of MM, EMs, and Components as needed.

Accepts:

  • an ARRAY if FB_TcAlarm
  • the Name of the MM or EM to be added to the Alarm text
  • the Name of the data type from the TMC Module Class
  • InitReferenceEvent *This one is required*

1
2
3
4
5
6
F_CreateAllEventsInClass(Alarms     := MachineAlarms,
                         ClassSize  := SIZEOF(TC_Events.VFFSDemo),
                         pInitEvent := ADR(TC_EVENTS.VFFSDemo.InitReferenceEvent),
                         Prefix     := Name);

SUPER^.CreateEvents();
Note: It is important to call the CreateEvents method of the base class in order to also create those events.


F_GetMaxSeverityRaised

Returns the highest severity level of any events currently raised within Alarms

For EMs (Submodules) called from CyclicLogic method
For MM called from SubModuleMonitor method

Accepts

  • an ARRAY if FB_TcAlarm the same array as F_CreateAllEventsInClass

1
_CurrentAlarmSeverity := F_GetMaxSeverityRaised(Alarms := UnwindAlarms, CurrentSeverity := _CurrentAlarmSeverity);



F_RaiseAlarmWithStringParameters

Raises event associated with Alarm and passes String_n as arguments for contextual information.

Called from any method that needs to raise an alarm

Accepts

  • an instance of FB_TcAlarm passed in as a VAR_IN_OUT to the method
  • the Name of the data type from the TMC Module Class
  • 2 strings for further details
1
2
3
4
F_RaiseAlarmWithStringParameters(Alarm    := Alarm,
                                 String_1 := Name,
                                 String_2 := String_1,
                                 String_3 := String_2);




Dig into the source Messages are logged events that are not alarms. They are used to provide status information to the user. They can be used to log the start and end of a state, or to log the start and end of a transition. Using Tc3_EventLogger.lib, an instance of the FB_TcMessage can be used to send messages to the event logger. Declare an instance of FB_TcMessage
1
fbInfoMsg       : FB_TcMessage; 
Call the CreateEx method to create the message. The first parameter is the event name, the second parameter is an interface to the source information. The source information is optional and can be left as 0.
1
2
3
4
IF Init then
    Init := FALSE;
    fbInfoMsg.CreateEx(TC_EVENTS.MyTestEventClass.MyInfoMessage, 0); 
END_IF
Finally, call the Send method to send the message to the event logger. The parameter is a time stamp, 0 will use the current time.
1
2
3
4
If SendMsg then
    SendMsg := FALSE;
    fbInfoMsg.Send(0);
END_IF

Raise/Clear Alarms

AlarmRaiseClear.png

The alarms are similar to messages, but they are used to indicate a problem that needs to be addressed. The alarm will be raised when the problem occurs, and then cleared/confirmed by the operator when the problem is resolved. Declare an Instance of FB_TcAlarm;

1
2
fbError     : FB_TcAlarm;
fbCritical  : FB_TcAlarm; 
Call the CreateEx method to create the alarm message. The first parameter is the event name, the 2nd parameter is used to set the alarm as needing to be cleared by the operator. The last parameter is an interface to the source information. The source information is optional and can be left as 0.
1
2
3
4
5
IF Init THEN
    Init := FALSE; 
    fbError.CreateEx(TC_EVENTS.MyTestEventClass.MyErrorMessage,FALSE, 0);
    fbCritical.CreateEx(TC_EVENTS.MyTestEventClass.MyCriticalMessage,TRUE, 0);
END_IF