record_time_seek()

record_time_seek()

Description

In order to use this function, library named <record_parser> must be included.

This function searches the records in module internal memory that are not yet confirmed, starting from the oldest one, for the first record whose system time is equal to or later than time, and stores that record's sensor information in sensor_array. Read the sensors from it with GetSensor(), the same way as after ReadRecord().

Syntax

record_time_seek(PARSE_RECORD, sensor_array[], time, sizeof(sensor_array));

Parameters

Variable

Input

Variable

Input

PARSE_RECORD

This is command and stays always the same - PARSE_RECORD

sensor_array[]

User defined array into which data is going to be stored. Recommended initial array size is 1000 elements, as for ReadRecord().

time

Time to seek to, in the units of SENSOR_SYSTEM_TIME. The first record with a time equal to or later than this one is returned.

sizeof(sensor_array)

Size of sensor_array in elements. Must always be passed, unlike in ReadRecord().

Returns

Return value

Return explanation

Return value

Return explanation

1

A record was found and stored in sensor_array.

0

No unconfirmed record has a time equal to or later than time.

SCRIPT_PARAM_INVALID

Fewer than four arguments were passed, sizeof(sensor_array) is too small for the sensor information or larger than 16383, or an argument is outside script memory.

Function call example

Example of seeking a record
#include <io> #include <read> #include <define> #include <record_parser> new sensor_buffer[1000]; new seek_time = 0; new tmp = 0; main() { seek_time = get_val(SENSOR_SYSTEM_TIME) - 3600; // One hour ago if (record_time_seek(PARSE_RECORD, sensor_buffer, seek_time, sizeof(sensor_buffer)) == 1) { GetSensor(sensor_buffer, SENSOR_SYSTEM_TIME, tmp); // Time of the record found } for(;;) { Delay(1000); } }

Notes and Warnings

  • Every call starts again from the oldest unconfirmed record.

  • After a record is found, reading continues from it: ReadRecord(PARSE_RECORD, sensor_array, 1) returns the next record, and ConfirmRecord() erases every record read so far, including the one found.

  • This function uses lots of memory, include library only if you're going to use this function.

Used in Examples

Records guide