time_series_range.cpp

Example for RDM::TIME_SERIES template classes. This example needs a compiled schema, time_series_range.sdl.

This example shows usage of the RDM::TIME_SERIES template classes with a single chain. First, values are collected into ranges by the RDM::TIME_SERIES::collect class, then a number of ranges are averaged using the RDM::TIME_SERIES::geometric_mean class, and finally rows are inserted using the RDM::DB::insert_row class.

#include <math.h>
#include "time_series_range_structs.h"
static RDM_RETCODE timeSeriesRange (RDM_DB db)
{
using namespace RDM_CPP::TIME_SERIES_RANGE;
using namespace RDM::TIME_SERIES;
using namespace RDM::DB;
const double tau = 6.283185307179586;
collect <16, MEASUREMENT_RANGE,
geometric_mean <16, MEASUREMENT_RANGE, double,
double factor = 1.0442737824;
double adjust = 1.0;
rc = ts_chain.init (db);
for (uint64_t time_stamp = 0; rc == sOKAY && time_stamp < 256; time_stamp++)
{
const double signal = adjust * (sin (tau * time_stamp / 16) * 0.1 + 1);
RDM_CPP::TIME_SERIES_RANGE::MEASUREMENT measurement = {time_stamp, signal};
rc = ts_chain.put_value (&measurement);
adjust *= factor;
}
return rc;
}
Time series for mean template classes.
Time series for collect template class.
The RDM Time Series Namespace.
Definition: rdm_time_series.h:32
@ sOKAY
Definition: rdmretcodetypes.h:100
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
The RDM Database Namespace.
Definition: rdm_db.h:31
Template Class for inserting a row.
Definition: rdm_db_insert_row.h:39
Template Class for collecting data values into ranges.
Definition: rdm_time_series_collect.h:56
struct RDM_DB_S * RDM_DB
Definition: rdmtypes.h:346
Template Class for doing an arithmetic mean.
Definition: rdm_time_series_mean.h:676
Time series for insert_row template class.
RDM_RETCODE init(RDM_DB p_db)
Initialize this object.
Definition: rdm_db_insert_row.h:152