Managing Data Log Files

Introduction

One function block, LogRecord, is provided for writing text string entries to the data log file. This function block stores the input string in an internal buffer. When this buffer reaches 80 % of capacity, it is moved to the real file on the controller. You can force this save mechanism by using the Dump function block.

When power is removed, you may lose the data in the internal buffer or increase the cycle time until the buffer is emptied.

NOTICE

LOSS OF DATA

oDo not remove power to the controller until all internal buffer information has been moved to the actual file system.

oIf the data being recorded is important to your application, configure your internal buffer size to 1.

Failure to follow these instructions can result in equipment damage.

Adding a Record with the LogRecord Function Block

This function block is available for logging a UNICODE string in a specific log:

G-SE-0001545.1.gif-high.gif

 

 

Input Parameters

Parameter

Type

Comment

xExecute

BOOL

The function is executed on the rising edge of this input.

NOTE: When xExecute is set to TRUE at the first task cycle in RUN after a cold or warm reset, the rising edge is not detected.

wsRecord

WSTRING

This user-specified UNICODE text string is written to the data log file.

NOTE: The WSTRING type is available in the Standard64.lib library that is automatically inserted when the data log manager is added to the application.

Output Parameters

Parameter

Type

Comment

xDone

BOOL

This output is set to TRUE when the record is successfully saved to the internal buffer without error messages.

xBusy

BOOL

This output remains TRUE while LogRecord is busy (until the transfer to the buffer is complete).

xError

BOOL

This output is set to TRUE when an error occurs (for example, when the internal buffer is full).

eError

ERROR

This output contains the error code when xError is TRUE:

oNO_ERROR

oINIT_ERROR

oDUMP_ERROR

oBUFFER_FULL_ERROR

oFILE_FULL_ERROR

oDUMP_INCOMPLETED

oINPUT_ERROR

oFILE_OPEN_ERROR

oFILE_SETPOINTER_ERROR

oFILE_WRITE_ERROR

oFILE_CLOSE_ERROR

NOTE: If the record exceeds the configured length, it is truncated.

The xDone and xError outputs remain TRUE as long as xExecute is TRUE. When xExecute is set to FALSE before xDone or xError is set to TRUE (xBusy is still TRUE), one of each is set to TRUE when the function block is completed during one controller cycle so that the application detects this end:

G-SE-0003662.1.gif

 

1   One cycle as Ex is FALSE.

The LogRecord function block includes an instance that corresponds to each configured data log file.

NOTE: Do not explicitly declare an instance of the function block because the instance is declared automatically. If you explicitly declare an instance of the function block, a message is displayed (2 time variable declaration) and the function block is rendered inoperable.

Add the function block to your POU and specify the appropriate data log file instance with input help (see Adding LogRecord).

Forcing a Save with the Dump Method

You can use the Dump method (a method can be regarded as sub-function of a function block, in this case LogRecord) to force the application data to move stored records in the internal buffer to the real file in the controller's file system:

G-SE-0001546.1.gif-high.gif

 

 

Parameters

Input

Type

Comment

xExecute

BOOL

The save function is executed on the rising edge of this input.

NOTE: When xExecute is set to 1 at first controller task cycle, the rising edge is not detected.

Output

Type

Comment

xDone

BOOL

This output is set to TRUE when the records are successfully saved without error messages.

xBusy

BOOL

This output remains TRUE while Dump is busy (until the file is completely written).

xError

BOOL

This output is set to TRUE when an error is detected (for example, when the data log file is full).

eError

ERROR

This output contains the error code when xError is TRUE:

oNO_ERROR

oINIT_ERROR

oDUMP_ERROR

oBUFFER_FULL_ERROR

oFILE_FULL_ERROR

oDUMP_INCOMPLETED

oINPUT_ERROR

oFILE_OPEN_ERROR

oFILE_SETPOINTER_ERROR

oFILE_WRITE_ERROR

oFILE_CLOSE_ERROR

Refer to Adding a Dump Method for the Dump method implementation.

Automatic Save to Data Log File

When the LogRecord function block is used, the system automatically moves the data from the internal buffer to the data log file when this buffer is 80 % full. The Dump function block allows you to force this move before reaching the 80 %. This 80 % limit allows the write process to begin before the buffer is full and while a new record is added.

This table shows the number of records to which the file is stored for a given configured buffer size (80% of buffer size rounded down to the nearest integer):

Buffer Size

80 % Limit

Comment

1

1

The save to the data log file is activated as soon as a record is added with an additional slot available for a new record that arrives during this save.

2

1

The save to the data log file is activated when the buffer reaches 80% with an additional slot available for a new record that arrives during this save.

3

2

4

3

5

4

The save to the data log file is activated when the buffer reaches 80% with additional slots available for new records that arrive during this save.

6

4

7

5

8

6

...

 

In the case of either an explicit (Dump) or automatic (80 %) save, the data log file closes after each record (or record group) in case there is a subsequent external power failure.