Calling Alarm Events in the Program
The Event (API) observation type is provided for defining an alarm in the alarm group, among other things. In contrast to the observation types in which the alarm is triggered depending on conditions, with this observation type the alarm can be triggered by calling a function block instance.
Defining the event alarm in the alarm group
Create an alarm group.
Define an alarm of the observation type Event (API) in the alarm group.
In the Class column, select an alarm class with the ACK acknowledgment method or create a new alarm class.
Program call to trigger the event alarm
Set the cursor at the program position where the function-block call should take place.
Use the
RaiseEvent
function from theAlarmManager
library:Enter "AlarmManager" followed by a period.
A window opens containing a list of all insertable elements ("List components" function).
Select
AlarmGlobals
and enter a period.In the same way, insert the elements
g_AlarmHandler
andRaiseEvent
.You get the following line:
Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEvent
.Now define the transfer variables
AlarmGroup_ID
andAlarm_ID
. To do this, enter an opening parenthesis.A tooltip appears, showing information about the transfer variables
Press F2
The Input Assistant opens
On the Categories tab (
), select the category Variables (
).
Select the desired group ID variable (
).
The variable is applied into the program line.
Enter a comma and insert the desired alarm ID variable (2) in the same way as in Step 7. Input a closing parenthesis and a semicolon.
You get the following program line:
Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEvent(Alm_AlarmConfiguration_Alarmgroup_IDs.ID_AlarmGroup1, Alm_AlarmGroup1_Alarm_IDs.ID_0);
Raising events from alarm template instances
Events from alarm instances can be raised by passing the address of the instance to where the alarm belongs.
When the event is raised, the latch variable which points to the instance is automatically written correctly.
The IAlarmHandler7
interface with the following functions is provided in the AlarmManager
library for this purpose.
RaiseEventAlarmInstance
RaiseEventAlarmInstanceByName

MyalarmFB
function block with RaiseEvent
method
FUNCTION_BLOCK MyAlarmFB VAR_INPUT xCondition : BOOL; END_VAR
METHOD RaiseEvent : BOOL VAR_INPUT END_VAR
Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEventAlarmInstance(THIS, Alm_AlarmGroupTemplate_Alarm_IDs.ID_3);
Program: PLC_PRG
PROGRAM PLC_PRG VAR // Alarm Instances myInst : MyAlarmFB; myInst2 : MyAlarmFB; END_VAR
Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEventAlarmInstance(ADR(myInst), Alm_AlarmGroupTemplate_Alarm_IDs.ID_3); Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEventAlarmInstanceByName(ADR(pouInst), Alm_AlarmGroupTemplate2_Alarm_IDs.ID_0, 'AlarmGroupTemplate2');