logCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

ALL

Firmware version:

1.50.00


logCreate creates a new Datalogger in a file on the file system.

 
The number of records requested can be set to 0, which in turn will set the number of records to the maximum number available.

The maximum size of a datalogger is 64MB.

 

Input:

filename : STRING

The path to the file to create. The file must be placed in the B:\SYSTEM\DATALOGS\ folder.

 

rec_size : INT

The maximum size of each record in bytes. This does not include the data for the timestamp, tag and other fixed data.

 

rec_count : DINT

Number of records that should be contained in the Datalogger (before wrap-around).

If 0 is specified on the number of records will be the maximum number available (depends on the "rec_size").

 

key : DINT

User-defined key-value.

 

Output:

handle : SYSHANDLE

A handle to the created datalogger.

 

Returns: INT

0

- Successful.

1

- Failed to create the file.

5

- Requested size and count is loo large.

7

- The log could not be created, too many logs are open.

8

- The drive is not writable.

9

- Invalid drive. Trying to write to an external media or the Project drive.

10

- Invalid folder.

 

 

Declaration:

FUNCTION logCreate : INT;
VAR_INPUT
  filename   : STRING;
  key        : DINT;
  rec_size   : SINT;
  rec_count  : DINT;
  handle     : ACCESS SYSHANDLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  handle:SYSHANDLE;
  rc:INT;
  name: STRING := "B:\SYSTEM\DATALOGS\log.bin";
END_VAR;
BEGIN
  ...
  // Initialize log system to contain 20 bytes per record, and room for 1000 records, keyvalue is 1234
  logCreate(handle:=handle, filename:=name, key:=1234, rec_size:=20, rec_count:=1000);
  ...
END;
 
END_PROGRAM;