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 "rdm_db_insert_row.h"
#include "rdm_time_series_collect.h"
#include "rdm_time_series_mean.h"
#include "time_series_range_structs.h"
{
RDM_RETCODE rc;
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,
insert_row <TABLE_MEASUREMENT_RANGE>>> ts_chain;
double factor = 1.0442737824;
double adjust = 1.0;
rc = ts_chain.init (db);
{
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.
Template Class for collecting data values into ranges.
Definition: rdm_time_series_collect.h:56
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