RALARM (FB)

 

FUNCTION_BLOCK RALARM

The RALARM function block is used to receive alarm information of alarms from a PROFIBUS DP or a PROFINET IO subsystem.

Code-Example: receive Alarm

PROGRAM PLC_PRG
VAR
   ralarm : CommFB.RALARM;
   alarm : CommFB.AINFO_TYPE;
   convertID : CommFB.ID_TO_ADDR;
   addr : CommFB.ADDR_TYPE;
   message : STRING;
END_VAR


ralarm.EN := TRUE;
ralarm.MODE := CommFB.RALARM_MODE.ALL_ALARMS;       // receive all alarms from all devices connected to the controller
ralarm.F_ID := PN_Controller.MasterID;              // Filter ID, if MODE = ALL_ALARMS use MasterID here, else the ID of a slot/subslot

ralarm(ainfo := alarm);
WHILE(ralarm.NEW) DO

   convertID(EN := TRUE, ID := ralarm.ID, ADDR := addr);
   IF(convertID.ENO) THEN
       IF(addr.SYSTEM = CommFB.IO_SYSTEM_TYPE.PROFINET_IO) THEN
            message := 'Station ';
           message := concat(message, addr.PN.D.STATIONNAME);
            message := concat(message, ' (Slot = ');
           message := concat(message, TO_STRING(addr.PN.SLOT));
            message := concat(message, ') sends an alarm !');

           //Log Alarm to PLC-Logger
            CmpLog.LogAdd2(CmpLog.LogConstants.LOG_STD_LOGGER, 555, CmpLog.LogClass.LOG_WARNING, 0, 0, message);
       END_IF
   END_IF

   ralarm(ainfo := alarm);     // exec-again
END_WHILE

InOut:

Scope

Name

Type

Comment

Input

EN

BOOL

Enable

MODE

INT

Function specifier, see RALARM_MODE enum

F_ID

DWORD

Slot / subslot identification to filter the alarms to receive. | If MODE = RALARM_­MODE.ALL_ALARMS user MasterID

Output

ENO

BOOL

Function enabled, no error

NEW

BOOL

New alarm received

STATUS

DWORD

Host Controller interface status

ID

DWORD

Identifier of the slot / subslot the alarm is received from (see: AddressConcept)

LEN

INT

Length of the received data record

Inout

AINFO

AINFO_TYPE

Alarm data that has been received