LogHandling (FB)

FUNCTION_BLOCK LogHandling EXTENDS AbbLConCA

This function block Logs datasets in files *.csv - format) from FIFOin to a file, e.g. in case of communications failure and read datasets on command or return of communication from the file to FIFOout Logging of universal datasets in files as *.csv - format from SRAM FIFOin of the data logger to a FILE FIFO, e.g. in case of communications failure and read datasets on command or return of communication from the FILE FIFO into RAM FIFOout

Depending on the selected mode this function block is used to

  • Directly transfer data messages in IEC60870 format or in generic format from SRAM_FIFOin to the RAM_FIFOout in case of an existing communication.

  • Store datasets in IEC60870 format or in generic format in files on flashdisk or SD-card for other use or because a communication line is broken.

  • Provide these logged datasets at the RAM_FIFOout output in case of recurring communica- tion with higher priority than the current data traffic or via FTP server of the PLC

../../../../../_images/LogHandling.jpg
Depending on the mode the function block can have three main working states

  • State 1: Existing communication (Connect) and empty FILE-FIFO: Datasets are written into SRAM_FIFOin (First In First Out), which are either from LogIec60870_Input or LogGeneric_Input (cannot be mixed), and are transported to RAM_FIFOout (First In First Out). There they are either
    • Decoded by LogIec60870_Output and transmitted or

    • Decoded by LogGeneric_Output and provided on its outputs as real data for further transmission (dependant on the chosen input variant: IEC or generic).

  • State 2: Communication failure (Disconnect): Datasets, which were written either by LogIec60870_Input or LogGeneric_Input (cannot be mixed) into the SRAM_FIFOin, will be transmitted into the FILE-FIFO (First In First Out) and stored.

  • State 3: Write/Read Modes and FTP Modes. There are following operating modes available.
    • Mode 0/1: Buffer and disposal in chronologic order
      • Mode 0: Limited storage (keeps oldest, but stops if full)

      • Mode 1: Endless (ring buffer) operation modes (deletes oldest)

    • Mode 2: Buffer and disposal via FTP, Log file(s) copied to ftp server area for further use

    • Mode 3: Events Recorder, logs data before and after an event.

This Function Block realises writing and reading of maximum 999 files with maximum 65535 datasets in a FIFO principle. Data storage can be either the Flashdisk, or an SDCARD. In case of SDCARD it must be ensured that after main power failure, for approximately 3…5 sec the 24 V supply is maintained (input extPower = FALSE), in order to close open files properly.

InOut:

Scope

Name

Type

Initial

Comment

Input

Connected

BOOL

2: Connected with telecontrol/scada. It is irrelevant in FTP Mode (Mode 2/3) because in FTP Mode no data is send by the Function Block to the control station

BreakConnect

BOOL

3: Input to simulate connecting break. TRUE indicates to the Function Block that the connection to the other station is interrupted.

This is irrelevant in Mode 2 and 3 because in FTP Mode no data is send by the Function Block to telecontrol/scada

ExternalPower

BOOL

4: For external Power-Unit, normal TRUE, in case of Poweralert will be FALSE. the Function Block completes the last write and read actions, closes all open files and goes to an idle-state.

This is signaled at the Done output. On the output State the text “zLOG_NO_EXTERNAL_POWER“ is given out

CleanAll

BOOL

5: Reset origin - delete all buffer, level, historical data, Filepointer. CleanAll set the complete Handling to zero. This is only active when Enable = TRUE

FormatDisk1

BOOL

7: Format disk1 - is not supported in V3

FormatDisk2

BOOL

8: Format disk2 - is not supported in V3

MoveFile

BOOL

9: Close and save the File and move it to FTP. Only active in Mode 2 and Mode 3. At an 0/1 edge on input MoveFile the file is closed and moved (Mode 2)

or multiple files (Mode 3) currently written on primary DISK1 into the folder FTP of the secondary DISK2 (both DISKs can be identical). The folder FTP is created automatically. The files are renamed. After read-out via FTP client the moved and renamed files can be deleted on the FTP server by the user. during the action the output State shows the text “zLOG_MOVE_COPY_ACTIVE“. The end of this action is signaled with another State

NameDisk1

STRING

10: Name of the primary drive (“flashdisk” or “sdcard” or “userdisk”) which is used for File FIFO buffer. DISK1 and DISK2 can be identical.

Internally the primary drive is used with “file1…file999…” (Mode 0/1/3) or with “file1” (Mode 2) which the Function Block automatically creates and deletes

NameDisk2

STRING

11: Name of the secondary drive (“flashdisk” or “sdcard” or “userdisk”) which is used for File FIFO FTP Server. DISK1 and DISK2 can be identical

Disk2Extension

BOOL

12: Extension Switch for the naming of the files to be moved to the FTP folder: “FALSE” = “02281448.593” or “TRUE” = “02281448.csv”

ATTENTION: when the TIME between 2 files is too short and you try to move the next file with the same Timestamp, then MOVE will overwrite the older file

Mode

BYTE

13: Different Modes of operation
  • MODE 0: Without overwrite older Files, when all Files full then Overflow - write datasets to “strFileName1..999” and read datasets from “strFileName1..999” and delete read files”strFileName1..n”

  • MODE 1: with overwrite older Files, when all Files full then Overwrite the oldest File - write datasets to “strFileName1..999” and read datasets from “strFileName1..999” and delete read files”strFileName1..n”

  • MODE 2: Increase only one write File until it is full or it is close or every Time in case of Input “MoveFile” - and move this File to FTP with Timestamp-Name. (02281448.593 - means February-28, 14.48hour 59s 3 10tel/s or 02281448.csv )

  • MODE 3: Only WRITE in File, with overwrite older Files, when all Files full then Overwrite the oldest File - write datasets to “strFileName1..999”). Move this Files in case of Input “MoveFile” to FTP with Timestamp-Name (02281448.593 - means February-28, 14.48hr 59s 3 10th/s)

! the mode must NOT be changed WHILE the logger is in operation. The mode should be changed when Enable = OFF. After Enable = ON, please also carry out a CleanAll so that the data logger is reset TO its basic state

ReleaseHistory

BOOL

14: External release for reading out the saved data from storage. This input is necessary when using IEC60870 logging. After communication is established again,

the input keeps historical data back until control station sends a general interogation to get the current status. For generic logging set permanent TRUE

SecureReadTime

DINT

15: Time in Number of msec, go back Numbers of “PossibleSecureReadDatasets” (counted while xx-Time)back in FIFO direct after Connection Fault and write this Numbers into FILE again

Estimation of time (in ms) which passes after the failure of a connection until this failure is detected. Under circumstances a communication failure can only be detected after a longer time without data transfer. Therefore in normal operation a measurement should be done for getting the average number of datasets arriving to the SRAM-FIFOin by SecureReadTime. In case of Connection fault this amount of datasets in the SRAM-FIFOin is taken from past and additionally stored into the FILE-FIFO, in order to avoid data losses by the delayed Connection fault recognition. At “0” no SecureRead is done. A regular ping to Telecontrol / Scada can significantly shorten the time it takes to detect a broken connection. In this case, a shorter SecureReadTime can be selected

MaxNumDatasetFile

DINT

16: Maximum number of Datasets per file 0…65535. After reaching this limit the file is closed and a new file is opened. The configurable upper limit is 65535.

An error is created if the input value is higher. A change of this value after start of the Datalogger is not allowed and will lead to faults in Mode 0 and Mode 1 when reading back values.

MaxNumFiles

DINT

17: Maximum number of Files - 1…999

After reaching this limit no further datasets can be stored. If further datasets are arriving Overflow is signaled. The adjustable limit is 999. An error will be created if the input value is higher. A change of this value after start of the Datalogger is not allowed and will lead to faults in Mode 0 and Mode 1 when reading back values. An exception is Mode 3, no values are read back and therefore a change in operation is allowed, e.g. to obtain flexible timing

Output

ErrorID

ERROR_ID

NO_ERROR

3: Shows error, Refer ERROR_ID enumeration for details of the error

FileError

FILE.ERROR

4: Error details of CAA-File Library - see CAA_File Library for error coding

State

zLOG_ENUM_STATE

zLOG_IDLE

5: Actual State of LogHandling, enumeration of Type zLOG_ENUM_STATE

Overflow

BOOL

FALSE

6: Overflow, FifoIN is full, datasets are rejected.

Output will be TRUE, if an overflow occurs. On this output a rising edge (FALSE -> TRUE) shows that communication/logging request occurred too fast and therefore the SRAM-FIFOin is full

Break

BOOL

FALSE

7: Break the History reading, when xConnect and RAM-FIFO - Level nearly full

Active, while available connection and while reading of historical values the SRAM-FIFOin is nearly full with new datasets. If Break is active, the SRAM-FIFOin data will be written to FILE-FIFO despite xConnect, in order to widely avoid Overflow of the SRAM-FIFOin. If incoming datasets arrive faster as they can be written to files, the system will reach a limit. Then an Overflow cannot be avoided, Overflow-Datasets are lost

ReadFileWhileBreak

BOOL

FALSE

8: Safety function: Output will be active, if all available files are full during Connect and Break.

In this case primarily the oldest file of the FILE-FIFO is read out, regardless of Overflow.

FifoInEmpty

BOOL

FALSE

9: Input FIFO is empty

FifoInFull

BOOL

FALSE

10: Input FIFO is full

FifoInLevel

DINT

0

11: Input FIFO Level

FifoInMaxLevel

DINT

0

12: Input FIFO maximum reached Level - Maximum FIFOin filling level since Enable=TRUE

FifoInMaxLimit

DINT

0

13: Input FIFO maximum Limit - Standard value 161

FifoOutEmpty

BOOL

FALSE

14: Output FIFO is empty

FifoOutFull

BOOL

FALSE

15: Output FIFO is full

FifoOutLevel

DINT

0

16: Output FIFO Level

FifoOutMaxLevel

DINT

0

17: Output FIFO maximum reached Level - Maximum FIFOout filling level since Enable=TRUE

FifoOutMaxLimit

DINT

0

18: Output FIFO maximum Limit - Standard value 161

WriteFileNumber

DINT

0

19: Number of the actual write File (1…999)

WriteFileName

STRING

‘’

20: Name of the actual write File

WriteFileLevel

DINT

0

21: Level of the actual write File (max.zLogGvlConstant.zLOG_CONST_DSproFILE=65535 possible

FileNextWritePosition

DINT

0

22: Next write position in the actual write File

ReadFileNumber

DINT

0

23: Number of the actual read File (1…999)

ReadFileName

STRING

‘’

24: Name of the actual read File

ReadFileLevel

DINT

0

25: Level of the actual read File (max.zLogGvlConstant.zLOG_CONST_DSproFILE=65535 possible

FileNextReadPosition

DINT

0

26: Next read position from the actual read File

FtpFileName

STRING

‘’

27: Name of the actual moved FTP-File

Complete current path and name of the file which will be transferred to the folder FTP (e.g. “flashdiskFTP02141149.545”) in Mode 2 in the following cases: file 1 is full / communication returns / per external trigger by setting the input MOVE_FILE In Mode 3 the move is triggered only by setting input MOVE_FILE.

NumberUsedFiles

DINT

0

28: Number of currently used FILEs

FilesEmpty

BOOL

FALSE

29: All Files are empty

FilesFull

BOOL

FALSE

30: All Files are full

DiskNoSpace

BOOL

FALSE

31: Disk is full, no free space on SDcard or Flashdisk - is not supported in V3

NumberDirectSendDatasets

DINT

0

32: Number of direct sent datasets (communication ok and and all historical data is sent)

WriteTimeDatablocksInFile

DINT

0

33: Time in [ms] - speed write Dataset in FILE

ReadTimeDatablocksFromFile

DINT

0

34: Time in [ms] - speed read Dataset from FILE

MaxWriteTimeDatablocksInFile

DINT

0

35: Time in [ms] - maximum speed write Dataset into FILE

MaxReadTimeDatablocksFromFile

DINT

0

36: Time in [ms] - maximum speed read Dataset from FILE

PossibleSecureReadDatasets

DINT

0

37: The “PossibleSecureReadDatasets” means the available Number of filled Datasets in FILE

Number of datasets delivered to SRAM-FIFOin (during the time indicated on input “SecureReadTime” in ms). In case of connection fault this number of past datasets in FIFOin are taken additionally into account for writing to FILE-FIFO in order to avoid data losses caused by the delayed connection fault recognition.

Methods:

B_CyclicAction

D_AbortAction

E_ResetAction

Structure: