logCreateMem (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

ALL

Firmware version:

1.50.00


logCreateMem creates a new Datalogger in memory. This is useful for data that does not need to be persistent and is written often, as it can not be worn out.

To save the data persistently, logSaveToFile can be used to store the log on the filesystem.

 
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 1 MB.

 

Input:

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 log.

5

- The requested size is too large.

7

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

 

 

Declaration:

FUNCTION logCreateMem : INT;
VAR_INPUT
  key        : DINT;
  rec_size   : SINT;
  rec_count  : DINT;
  handle     : ACCESS SYSHANDLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  handle:SYSHANDLE;
  rc:INT;
END_VAR;
BEGIN
  ...
  // Initialize log system to contain 20 bytes per record, and room for 1000 records, keyvalue is 1234
  logCreateMem(handle:=handle, key:=1234, rec_size:=20, rec_count:=1000);
  ...
END;
 
END_PROGRAM;