time_series_stat.cpp

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

#include "rdmtimeseries.h"
#include "time_series_stat_structs.h"
#include <math.h>
static RDM_RETCODE timeSeriesStatOfSineCurve (RDM_DB db)
{
using namespace RDM_CPP::TIME_SERIES_STAT;
using namespace RDM::TIME_SERIES;
stat <32, MEASUREMENT_STAT1,
stat <32, MEASUREMENT_STAT1,
/* Place holder for something to come: */
dead_end>>ts_chain;
RDM_RETCODE rc = ts_chain.init (db);
for (uint64_t time_stamp = 0; rc == sOKAY && time_stamp < 1024; time_stamp++)
{
const double tau = 6.283185307179586;
const double signal = sin (tau * time_stamp / 50);
MEASUREMENT measurement = {time_stamp, signal};
rc = ts_chain.put_value (&measurement);
}
return rc;
}