FB_IEC870_5_101TableEventHandler
From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.
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! |
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:
- OnCreate events are reported whenever a new application object (single point, double point, measured value...) was added to the application database.
- OnChange events are reported when an application object is received by the lower transport layer (Rx frames) or sent (Tx frames), irrespective of whether the value of the information object has changed or not. For a direct command, e.g., C_SC_NA_1, in control direction (master->slave), events are usually reported for the following causes of transmission: eIEC870_COT_ACT (activation), eIEC870_COT_ACT_CON (confirmation of activation) and eIEC870_COT_TERM (completion of activation). For a data point in monitoring direction (slave->master), e.g., M_SP_NA_1, events may be reported for the following causes of transmission: eIEC870_COT_SPONTAN, eIEC870_COT_INROGEN, eIEC870_COT_BACKGROUND etc.
The function block features two tasks:
- RemoveOnCreateEvent (reads an entry from the OnCreate event list);
- RemoveOnChangeEvent (reads an entry from the OnChange event list);
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 |