- Create a "Standard project" and select CODESYS Control Win V3 as the device.
- Define the target system by means of the Netzwork scan.
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.- Create a global variable list GVL with the variable g_sAlarmID.
- Create a new FB named FB_AlarmNotifiable and implement the interface AlarmManager.IAlarmNotifiable.
The method the Execute method is created automatically with the FB:
Adapt the Execute method as follows:
Declaration
//{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
Implementation
itfAlarmGroup := itfAlarm.GetAlarmGroup(); GVL.g_sAlarmID := itfAlarmGroup.GetStringID(itfAlarm.GetID());
Adapt the POU PLC_PRG as follows:
Declaration
VAR xAlarm : BOOL; fbAlarmNotifiable : FB_AlarmNotifiable; END_VAR
Implementierung
// no implementation
ldkglöd