Skip to content

PackML Event Handler

Overview

This function block is used as a component usually at the machine level. This component will listen to the TcEvents and add them to the Pack ML Admin tags as needed.

Function Block

1
FUNCTION_BLOCK FB_Component_PackML_EventHandler EXTENDS FB_ListenerBase2 IMPLEMENTS I_ComponentBase

Methods

Name Return Type Description
Initialize BOOL This will subscribe the instance of the FB to the Monitor TcAlarms
CyclicLogic This is the method called by the list of components
Execute HRESULT This is the work to monitor errors, time zone and event changes. This is called in CyclicLogic once it is InitComplete
EventListener HRESULT This is called to subscribe and unsubscribe to Monitor TcAlarms
OnAlarmCleared HRESULT Callback for when TcAlarms are cleared
OnAlarmConfirmed HRESULT Callback for when TcAlarms are confirmed
OnAlarmRaised HRESULT Callback for when TcAlarms are raised
Reset BOOL Clear all alarms in PackMLEventHandlerAlarms
GetMsgInfos ST_PackML_aEventInfo This returns the statistics about Alarm events
AllowHMIControl Not Used only a part of I_ComponenetBase
BlockHMIControl Not Used only a part of I_ComponenetBase

Properties

Name Type Access Description
AdminTag REFERENCE TO Tc3_PackML_V2.ST_PMLa W This is a reference to the admin tag of the Pack ML tags
AlarmToStopReason BOOL W
Busy BOOL R Busy if subscribed
CurrentAlarmSeverity SPT_BaseTypes.TcEventSeverity R
Error BOOL R
ErrorID UDINT R
InitComplete BOOL R This is set true once the Component is subscribed to the events
InSimulation BOOL R This component does not use simulation. This is just part of the Interface
InternalErrorAck BOOL R/W
Name STRING R/W Name of component
ParentResponseDefinitions ARRAY [0..4] OF SPT_BaseTypes.E_AlarmResponse R/W
WarningToStopReason BOOL W

DUTs

ST_EventInfo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
TYPE ST_EventInfo :
    STRUCT
        eSeverity           : TCEVENTSEVERITY;
        EventClass          : GUID;
        EventId             : UDINT;
        ipArguments         : I_TcArguments;
        fbRequestEventText  : FB_RequestEventText;
        EventText           : STRING;
        Source              : STRING;
        TimeRaised          : ARRAY[0..6] OF DINT;
        TimeConfirmed       : ARRAY[0..6] OF DINT;
        TimeCleared         : ARRAY[0..6] OF DINT;
    END_STRUCT
END_TYPE

ST_PackML_aEventInfo

1
2
3
4
5
6
7
8
TYPE ST_PackML_aEventInfo :
    STRUCT
        Warning       : ST_PackML_aMsgState; // Warning Informatins
        Alarm         : ST_PackML_aMsgState; // Alarm Informations
        StopReason    : ST_PackML_aMsgState; // StopReason Informations
        HistorizedMsg : UDINT;           // Number of historized Messages
    END_STRUCT
END_TYPE

ST_PackML_aMsgState

1
2
3
4
5
6
7
8
TYPE ST_PackML_aMsgState :
    STRUCT
        Active          : BOOL;  // a unconfirmed Message is pending
        NumberActive    : UDINT; // Number of active Messages
        NumberConfirmed : UDINT; // Number of confirmed Messages            
        NumberCleared   : UDINT; // Number of Cleared Messages in History
    END_STRUCT
END_TYPE

FB_ListenerBase2

Beckhoff Infosys FB_ListenerBase2

Use Component

Since this function is a component, all that is needed to be done is declare it and initialize it.

Declaration

Define the instance of the hanlder in the PackML module as needed. You can name it anything you would like.

1
2
//Components
PackML_EventHandler : FB_Component_PackML_EventHandler := (Name := 'PackML Event Handler');

Initialization

Code like below must be used in the PackML module initialize routine that is using the FB_PackML_EventHandler.

1
2
3
//Register your Sub modules and 
RegisterComponent(PackML_EventHandler);
PackML_EventHandler.AdminTag REF= _PackTags.Admin;