FB_IEC870_5_101TableEventHandler

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

FB_IEC870_5_101TableEventHandler 1:

Reading of the events is optional, i.e., the PLC application does not necessarily have to instance this block. This functionality is currently only supported by the IEC 60870-5-104 master!

FB_IEC870_5_101TableEventHandler 2:

This function block enables the PLC application to detect certain changes in the IEC application object database and respond accordingly, if required. The changes are referred to as events. Each event type is managed in a separate internal list. The PLC application can read the pending events from one of the lists by calling the block actions. The events are counted internally since several events may occur during a PLC cycle. The counter is incremented whenever an event occurs. At the block output only the last value and the counter reading is issued.

 

The following events are registered by the function block:

The function block features two tasks:

VAR_IN_OUT

VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR

hTable: Application object database handle (hash table handle). The table handle must be initialized once with the function F_iecCreateTableHnd before it can be used.

VAR_OUTPUT

VAR_OUTPUT
    bOk     : BOOL := FALSE;
    getObj  : ST_IEC870_5_101AOGen;
    getCfg  : ST_IEC870_5_101AOCfg;
    nEvents : DWORD := 0;
END_VAR

bOk: This variable becomes TRUE if a new event was read successfully. If FALSE, the event list read last is empty.

getObj: The current value of the data unit (ASDU).

getCfg: The current configuration parameters of the data unit (ASDU).

nEvents: Event counter (multiplier). Value range: (0 to 16#FFFFFFFF). Incrementation stops when the maximum value is reached.

 

Example in ST:

In the following program section, the pending events are read via REPEAT loops and written to the Windows Application log. The associated data points have already been configured as hash table entries. See function description: F_iecAddTableEntry.

PROGRAM P_LogEvents
VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR
VAR
    fbHandler : FB_IEC870_5_101TableEventHandler;
END_VAR
REPEAT
    fbHandler.RemoveOnChangeEvent( hTable := hTable );
    IF fbHandler.bOk THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'RemoveOnChangeEvent(), IOA: %s', 
            DWORD_TO_STRING( fbHandler.getObj.info.objAddr ) );
    END_IF
UNTIL NOT fbHandler.bOk
END_REPEAT


REPEAT
    fbHandler.RemoveOnCreateEvent( hTable := hTable );
    IF fbHandler.bOk THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'RemoveOnCreateEvent(), IOA: %s', 
            DWORD_TO_STRING( fbHandler.getObj.info.objAddr ) );
    END_IF
UNTIL NOT fbHandler.bOk
END_REPEAT

 

Requirements

Development Environment

Target System

PLC Libraries to include

TwinCAT v2.10.0 Build >= 1301

PC or CX (x86, ARM)

TcIEC870_5_101.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib;  are included automatically )