Public Member Functions

sc_history Class Reference

Spacecraft history. More...

List of all members.

Public Member Functions

void store_matrix (double ts, const ml_matrix &data)
 Store a time-tagged matrix.
double start_time ()
 Retrieve the first timestamp stored.
double end_time ()
 Retrieve the last stored timestamp.
bool data_for_time (double &ts, ml_matrix &data)
 Retrieve the data for a specific timestamp.
bool data_after_time (double &ts, ml_matrix &data)
 Retrieve the first data point after a specific timestamp.
void clear_data_until (double ts)
 Remove old historical data.

Detailed Description

Historical data storage and retrieval.

This class allows for arbitrary historical matrix storage and retrieval. It is optimized for sequential access patterns with random start and stop points. Data must be added in-order, and old data must be dropped in order.


Member Function Documentation

void sc_history::store_matrix ( double  ts,
const ml_matrix &  data 
)

Store a matrix with a timestamp.

The timestamp must be larger than the most recent stored timestamp.

Parameters:
tsThe timestamp of the matrix to be stored
dataThe matrix to be stored

References sc_history_segment::data, sc_history_segment::data_count, sc_history_segment::first_time, sc_history_segment::last_time, sc_history_segment::next, and sc_history_segment::timestamps.

double sc_history::start_time (  )

Retrieve the first timestamp contained in the history.

Returns:
The first stored timestamp

References sc_history_segment::first_time.

double sc_history::end_time (  )

Retrieve the last timestamp contained in the history.

Returns:
The last stored timestamp

References sc_history_segment::last_time.

bool sc_history::data_for_time ( double &  ts,
ml_matrix &  data 
)

Retrieve the data associated with a specific timestamp.

If that timestamp is not available, the first data with a larger timestamp will be returned. If no data with a larger timestamp exists, the most recent data stored in the history will be returned.

Parameters:
tsWhen called, the timestamp to lookup. Upon return, this will hold the actual timestamp of the data found.
dataUpon return, this will hold the found data.
Returns:
false if no data is stored in the history and therefore no data could be returned; otherwise true.

References sc_history_segment::data, sc_history_segment::data_count, sc_history_segment::first_time, sc_history_segment::last_time, and sc_history_segment::timestamps.

bool sc_history::data_after_time ( double &  ts,
ml_matrix &  data 
)

Retrieve the first data with a timestamp greater than the provided timestamp.

Parameters:
tsWhen the function is called, this parameter will hold the timestamp after which the returned data should be found. Upon return, this will hold the actual timestamp of the data found.
dataUpon return, this will hold the found data.
Returns:
false if no data is stored in the history with a timestamp greater than ts; otherwise true.

References sc_history_segment::data, sc_history_segment::data_count, sc_history_segment::first_time, sc_history_segment::last_time, and sc_history_segment::timestamps.

void sc_history::clear_data_until ( double  ts )

Remove all data from the history with a timestamp <= ts.

Parameters:
tsThe timestamp through which all data should be removed.

References sc_history_segment::data, sc_history_segment::data_count, sc_history_segment::first_time, sc_history_segment::last_time, sc_history_segment::next, and sc_history_segment::timestamps.