Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Netzwork Network scan.
    Image Removed
    Image Added

  • Insert an Alarm configuration in the device tree.
    Here the Error, Info, and Warning alarm classes are created automatically, as well as the AlarmStorage object.In addition, a AlarmManagerTask is also created.

    Image Removed
    Image Added

  • Create a global variable list GVL with the variable g_sAlarmID.
    Image Removed
    Image Added

  • Create a new FB named FB_AlarmNotifiable and implement the interface AlarmManager.IAlarmNotifiable.

    Image AddedImage Removed

    The method the Execute method is created automatically with the FB:
    Image Removed
    Image Added

  • Adapt the Execute method as follows:


    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    //{warning 'add method implementation '}
    (* Executes the action.*)
    METHOD Execute
    VAR_INPUT
        (* The currently processed alarm state transition. This will be
     evaluated in order to determine, whether the action has to be
     executed or not*)
        eCurrTransition    : ALARMMANAGER.AlarmStateTransition;
        (* The alarm, for which the action has to be performed*)
        itfAlarm    : ALARMMANAGER.IAlarm;
        (* An optional pointer to a structure variable containing
     additional parameter*)
        pbyAdditionalData    : POINTER TO BYTE;
    END_VAR
    VAR
        itfAlarmGroup : ALARMMANAGER.IAlarmGroup;
    END_VAR




    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    itfAlarmGroup := itfAlarm.GetAlarmGroup();
    GVL.g_sAlarmID := itfAlarmGroup.GetStringID(itfAlarm.GetID());




...

  • Adapt the POU PLC_PRG as follows:


    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    VAR
        xAlarm              :    BOOL;
        fbAlarmNotifiable   : FB_AlarmNotifiable;
    END_VAR




    Section
    Column
    width7

    Implementierung

    Column
    width93
    Code Block
    themeConfluence
    // no implementation





  • Insert a new alarm group in the Alarm configuration and configure an alarm as follows:

    Image Added

    In order for the fbAlarmNotifiable instance to also be called at an alarm, the Error alarm class must still be notified about it.


    Image Added

  • Load the project to the controller and start it.
    Set the xAlarm variable to TRUE in the POU PLC_PRG.
    Now the global variable GVL.g_sAlarmID will pass the MyAlarmId that was set up in the alarm configuration.


    Image Addedldkglöd