LogMultifile
(FB)
FUNCTION_BLOCK LogMultifile EXTENDS AbbLConC2
Function block is used for Logging of universal datasets in separate files/instance as *.csv, format with flexible header and any number of columns
Logging can be executed in cyclic operation based on defined number of cycles or with triggers using input SingleTrig. Based on configuration, data will be moved from buffer to temporary files and from temporary files to *.csv files Datasets can be stored in either sdcard or userdisk or flashdisk.
- Multilogger functionality can be operated in two modes
- Mode 2
Enable = TRUE, Cyclic = TRUE or SingleTrig = TRUE
Datasets will be collected in the buffer every time numcycles is reached, once the MaxNumDatasetsBuffer is reached, copied to temporary csv file.
Once the temporary file is full based on input MaxNumDatasetFile, datasets is moved from temporary file to .timestamp file or .csv file
User can manually also move from buffer to temporary file by triggering input WriteBufferToFile = TRUE. Also, from temporary file to permanent file using MoveFile = TRUE
- Mode 3
Enable = TRUE, Cyclic = TRUE
Only the newest “MaxNumDatasetsBuffer” values are written to the temporary file, first in first out, older values are deleted.
This number of values are the “preliminary round” of the event logger, they always run in a circle or ring. e.g. MaxNumDatasetsBuffer = 5, only the newest 5 datasets are kept in the temporary file.
If an event now occurs (BacklogEvent=TRUE), the limitation is removed, from now on all values are saved until MoveFile = TRUE. This number of saved data records are the “follow-up” of the event logger.
If the saved datasets exceed the limit value for datasets/file defined in “MaxNumDatasetFile”, a new file is created automatically.
With MoveFile = TRUE, all these files are moved and saved, the eventlogging action is finished.
While the event logger runs the “preliminary round” again and waits for a new event.
Note
Multiple instance of this function block can be used to log different set of data, user must make sure same INOUT variable Token is connected to all instances and LogFileDelete.
- InOut:
Scope
Name
Type
Initial
Comment
Input
CleanAll
BOOL
2: Reset origin - delete all buffer, level, historical data, Filepointer. CleanAll set the complete function block to zero. This is only active when Enable = TRUE
OperationMode
BYTE
- 3: Mode of operation:
- MODE 2: increase only one temporary File until it is full (MaxNumDatasetFile) or use input “MoveFile” - and move this File with Timestamp-Name
(02281448.593 - means February-28, 14.48 hr, 59s 3msec or 02281448.csv )
- MODE 3: EventLogger with backlog-functionality, normally rotary stack (tempfile) on disk with MaxNumDatasetsBuffer. when EVENTLOG trigger active,
then the round runner function is deactivated, and all following data will be stored in tempfile. To MoveFile is triggered or MaxNumDatasetFile is reached. Then the temporary file is stored as timestamp file, and a new rotary stack will be created
SingleTrig
BOOL
4: Load one dataset in csv-byte-array
Cyclic
BOOL
5: Perform a cyclic entry after Number of cycles
NumCycles
UDINT
6: Number of cycles, which are awaited before a new entry is made
BacklogEvent
BOOL
7: Start backlog in Mode 3: Eventlogging with backlog functionality
WriteBufferToFile
BOOL
8: External write the active csv-byte-array to file
MaxNumDatasetsBuffer
UDINT
- 9: Maximum number of datasets in the buffer
Mode 2: write automatically in file, when this number of datasets reached in Buffer 1 or Buffer 2
Mode 3: save at least these number datasets as backlog
MoveFile
BOOL
10: MoveFile = TRUE, data is moved from temporary file to timestamp file or csv file
MaxNumDatasetFile
UDINT
11: Maximum number of datasets in the temporary file, once reached move data to timestamp-file
FilePath
CAA.FILENAME
12: FilePath including complete path: diskname/FilePath or diskname/FilePath/tempfilename
TimeFileExtension
BOOL
- 13: Extension for timestamp files: “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 Timestampname, then move will refuse the new file
NumLineFileInfo
UINT
14: Number of all used rows for File information 0…n
ADRfileinfo
POINTER TO STRING(255)
15: File information Header as string array, defined with length 255, via ADR-operator
NumColumns
UINT
16: Number of all used columns 0…n
ADRheader
POINTER TO STRING
17: Column Header as string array, defined with standard length 80, via ADR-operator
ADRdata
POINTER TO STRING
18: Userdata as string array, defined with standard length 80, via ADR-operator
BufferSize
UDINT
- 19: Maximum number of bytes, match the end of bytearray on BUFFER1/2 OUT (array[0..999] = 1000 on input).
Warning: the number must not be greather than the final value of the array length configured
ADRbuffer1
POINTER TO BYTE
20: Via ADR-operator - byte array, write data to the first array, when full then change to the second array
ADRbuffer2
POINTER TO BYTE
21: Via ADR-operator - byte array, write data to the second array, when full then change to the first array
Inout
Token
UINT
22: Token, is the same variable for all participants of the same type, every function block set it’s participant number in Token, when active
Output
ErrorID
NO_ERROR
4: ErrorID is always accompanied by an error and abort of the function block processing, Refer ERROR_ID enumeration for details of the error
FileError
FILE.ERROR
FILE.ERROR.NO_ERROR
5: File operation error details, see CAA_File Library for error details
Message
zLOG_IDLE
6: Messages of the processing of the function block, block is not aborted only a detailed message is provided from enumeration LOG_ENUM_STATE
CurrentAction
zLOG_IDLE
7: Current action, shows what is currently being processed in the function block, details from Enumeration LOG_ENUM_STATE
Overflow
BOOL
FALSE
8: TRUE, Overflow of data from the buffer
NumOverflow
UDINT
0
9: Number of datasets overflowed
DatasetStored
BOOL
FALSE
10: TRUE, Actual dataset is converted in csv
NumUnsavedDatasets
UDINT
0
11: Number of datasets which is in buffer at the moment and not saved
NumTempSavedDatasets
UDINT
0
12: Number of saved datasets
FileMoved
BOOL
FALSE
13: TRUE, File has been moved with strTimeFilepath - the output is a transfer parameter for the optional Function block LogFileReduce
MovedFilename
STRING
‘’
14: Timestamp file including path: FilePath + filename at the moment of shifting. The output is a transfer parameter for the optional function block LogFileReduce
MyToken
UINT
0
15: Token number automatically assigned in first cycle for each function block of the same type, which identifies it in the token ring. This is necessary that several function blocks cannot execute file operations at the same time during CAA file handling, only function block that has token is allowed to do
Methods:
B_CyclicAction
D_AbortAction
E_ResetAction
Structure: