Skip to main content

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

  1. Create an alarm group.

  2. Define an alarm of the observation type Event (API) in the alarm group.

  3. 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

  1. Set the cursor at the program position where the function-block call should take place.

  2. Use the RaiseEvent function from the AlarmManager library:

    Enter "AlarmManager" followed by a period.

    A window opens containing a list of all insertable elements ("List components" function).

    _cds_img_autocomplete_alarms.png
  3. Select AlarmGlobals and enter a period.

  4. In the same way, insert the elements g_AlarmHandler and RaiseEvent.

    You get the following line: Alarmmanager.AlarmGlobals.g_AlarmHandler.RaiseEvent.

  5. Now define the transfer variables AlarmGroup_ID and Alarm_ID. To do this, enter an opening parenthesis.

    A tooltip appears, showing information about the transfer variables

  6. Press F2

    The Input Assistant opens

  7. On the Categories tab (_3_r.png), select the category Variables (_4_r.png).

    _cds_img_input_assistant_alarms.png
  8. Select the desired group ID variable (_1_r.png).

    The variable is applied into the program line.

  9. 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

Example 54. Example
_visu_alarm_group_template_example_raise_event.png

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');