The example shows the formatting code for a CSV log file.
This sample is based on KW_Watcher_log.cfg.
Log file: file1
Data points (data format, address): datapoint1 (INT, DT100), datapoint2 (UINT, DT101), datapoint3 (INT, DT102), datapoint4 (UINT, DT103)
#This is a user defined log file configuration for KW Watcher
%DEF_TITLE="KW Watcher" #Mandatory: This title will be shown in the configurator.
%DEF_SEPARATOR="," #Overwrites the setting in the configurator.
%DEF_FILENAME="%F(%y%m%d_%H%M%S_TRG).csv" #case-sensitive ISO 8601 format
%DEF_DATE="%Y/%m/%d" #case-sensitive ISO 8601 format
%DEF_TIME="%H:%M:%S" #case-sensitive ISO 8601 format
%DEF_INT="S16"
%DEF_UINT="US16"
%DEF_WORD="HEX4"
%DEF_BIN="BITS"
%DEF_DINT="S32"
%DEF_UDINT="US32"
%DEF_DWORD="HEX8"
%DEF_REAL="FLT"
%DEF_REALEXP="FLT"
%DEF_ASCII="CHAR2"
%HEADER="Date","Time",%COLUMNS
%HEADER+=,,%NAMES
%HEADER+=,,%COMS #e.g. COM1 [Unit no.10]
%HEADER+=,,%REGISTERS #e.g. DT100
%HEADER+=,,%TYPES #Momentary or difference value
%HEADER+=,,%DATAFORMATS #INT, DINT, etc.
%HEADER+=,,%UNITS #ISO units
%LOGDATA=%DATE,%TIME,%VALUES
When a new file is created, a header with seven rows is placed before the first record.
Date, Time, 1, 2, 3, 4 #Row1
,,datapoint1, datapoint2, datapoint3, datapoint4 #Row2
,,COM1,COM1,COM1,COM1 #Row3
,,DT100,DT101,DT102,DT103 #Row4
,,INT,UINT,INT,UINT #Row5
,,S16,US16,S16,US16 #Row6
,,,,, #Row7
2020/01/21,14:55:30,0,0,0,0 #Row8
%DEF_SEPARATOR=","
The separator is a comma.
%DEF_FILENAME="%F(%y%m%d_%H%M%S_TRG).csv"
%F creates the file name from the log file name set in
. Date and time in the specified format as well as the string "_TRG" are included in parentheses and the file extension .csv is added.Example: file1(200121_145530_TRG).csv
%DEF_INT="S16"
to %DEF_ASCII="CHAR2"
Used to specify the data format.
%HEADER="Date","Time",%COLUMNS
User-defined text ("Date", "Time") is followed by the column numbers for all data points (row 1: 1 to 4 for datapoint1 to datapoint4).
%HEADER+=,,%NAMES
%NAMES
returns the names of the data points (row 2).
%HEADER+=,,%COMS
%COMS
returns the COM port used to read the data (row 3).
%HEADER+=,,%REGISTERS
%REGISTERS
returns the data register of each data point (row 4).
%HEADER+=,,%TYPES
%TYPES
returns the data type of each data point (row 5).
%HEADER+=,,%DATAFORMATS
%DATAFORMATS
returns the data type format as specified by %DEF_INT
to %DEF_ASCII
(row 6).
%HEADER+=,,%UNITS
%UNITS
returns the unit of each data point (e.g. °C, kg). In the example no unit is defined (row 7).
%LOGDATA=%DATE,%TIME,%VALUES
This is the first row of the logged data. It starts with the date specified with %DEF_DATE
and the time specified with %DEF_TIME
, followed by the data point values.