FB_IEC870_5_101ErrorFifo
IEC60870-5-10x error FIFO. The oldest entry is overwritten. The FIFO has a constant size, determined by the constant: IEC870_MAX_ERROR_FIFO_SIZE (default: 10 elements).
The function block features three tasks:
- AddError (adds a new error message to the FIFO);
- RemoveError (removes the oldest error message from the FIFO);
- Reset (clears all error messages and resets the FIFO);
Error messages are normally added to the FIFO via the internal IEC60870-5-10x device functions. The PLC application can read and analyse these error messages by calling the task: RemoveError.
VAR_INPUT
VAR_INPUT
putError : ST_IEC870_5_101ErrorFifoEntry;
END_VAR
putError: Error message to be added to the FIFO.
VAR_OUTPUT
VAR_OUTPUT
getError : ST_IEC870_5_101ErrorFifoEntry;
nErrors : UDINT; (* Error counter *)
bOk : BOOL; (* TRUE = new entry added or removed succesfully, FALSE = fifo empty *)
END_VAR
getError: Error message to be removed from the FIFO.
nErrors: Returns the current number of FIFO entries (error messages in the FIFO).
bOk: This variable becomes TRUE if a new entry was successfully added to or removed from the FIFO.
Example of call in ST:
In the following structured text example the device error FIFO is read, and the registered errors are written into the Windows Application Log.
PROGRAM P_LogErrors
VAR_IN_OUT
fbErrors : FB_IEC870_5_101ErrorFifo;
END_VAR
REPEAT
fbErrors.RemoveError();
IF fbErrors.bOk THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
'IEC60870-5-10x device error: 0x%s',
DWORD_TO_HEXSTR( fbErrors.getError.nErrId, 8, FALSE) );
END_IF
UNTIL NOT fbErrors.bOk
END_REPEAT
Requirements
Development Environment | Target System | PLC libraries to include |
---|---|---|
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) |