Template base Class for doing FFTs. More...

#include "rdm_time_series_fft.h"

Inheritance diagram for RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >:
Inheritance graph

Public Member Functions

uint8_t * serialize (uint8_t *buffer)
uint8_t * unserialize (uint8_t *buffer)
void reset (void)
Reset this object. More...
RDM_RETCODE flush_value (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
RDM_RETCODE flush_stats (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
template<class SOURCE_VALUE_T >
RDM_RETCODE put_value (SOURCE_VALUE_T *source_value, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving a data value. More...
template<class SOURCE_STATS_T >
RDM_RETCODE put_stats (SOURCE_STATS_T *source_stats, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving statistics. More...

Static Public Member Functions

constexpr static int get_serialize_size (void)
Get the size of a buffer for serialization to hold its state. More...

Protected Member Functions

virtual RDM_RETCODE doFft (void)=0
uint32_t init_tables_to_write_lock (RDM_TABLE_ID *tables)
ID of the tables where rows are inserted. More...
uint32_t init_tables_to_read_lock (RDM_TABLE_ID *tables)
IDs of the tables where rows are read. More...
void unput (void)
Undo a previous put operation. More...
void unflush (void)
Undo a previous flush operation. More...
RDM_RETCODE init (RDM_DB db)
Initialize this object. More...

Static Protected Member Functions

constexpr static int number_of_tables_to_write_lock (void)
Number of tables where rows are inserted. More...
constexpr static int number_of_tables_to_read_lock (void)
Number of tables where rows are read. More...

Protected Attributes

INDATA_T in_data [N]
RANGE_T aggregate_range
uint32_t n

Friends

template<class ANY_NEXT >
class RDM::DB::transaction
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
class split
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
class collect
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
class fft
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
class mean
template<class ANY_RATIO , class ANY_NEXT >
class scale
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
class stats
template<uint32_t ANY_N, class ANY_NEXT >
class downsample
template<class ANY_NEXT >
class custom

Detailed Description

template<uint32_t N, class RANGE_T, class INDATA_T, class NEXT>
class RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >

Template base Class for doing FFTs.

Template base class for FFT of data values, ranges, or statistics. What is received will be collected and used for doing FFT computations. The result of those computations will be forwarded as a range to the next class in the chain.

This class is incomplete as it does not have the code for doing the actual FFT computation. Use one of the following derived classes:

Template Parameters
N The number of data points for each FFT computation. In the case ranges are received, then N must fit its size.
RANGE_T The aggregate FFT class for which objects will be passed to the next class.
INDATA_T The type of the data that is passed to this class.
NEXT The class in the chain to receive the result of the ranges.

Member Function Documentation

doFft()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
virtual RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::doFft ( void )
protectedpure virtual

flush_stats()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::flush_stats ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush what has been collected so far. A threshold can also be provided. All the data collected for those statistics will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
286 {
287RDM_RETCODE rc = next.flush_range (threshold, transactional);
288
289return rc;
290 }

flush_value()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::flush_value ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush what has been collected so far. A threshold can also be provided. All the data collected for those values will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
252 {
253RDM_RETCODE rc = next.flush_range (threshold, transactional);
254
255return rc;
256 }

get_serialize_size()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
constexpr static int RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::get_serialize_size ( void )
inlinestaticconstexpr

Get the size of a buffer for serialization to hold its state.

Get the size needed for a buffer to hold the state of this object.

174 {
175return sizeof(in_data) + sizeof(aggregate_range) + sizeof(n) + NEXT::get_serialize_size ();
176 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::aggregate_range, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::in_data, and RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n.

init()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::init ( RDM_DB db )
inlineprotected

Initialize this object.

Call this method before sending it any data values or statistics.

Return values
sOKAY Normal, successful return.
eINVARG Invalid argument.
eDBNOTOPEN Database not open.
eCURSORDB Cursor is associated with a different database.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
Parameters
db [IN] Use this database for chained classes that need to insert rows
157 {
158RDM_RETCODE rc = next.init (db);
159
160if (rc == sOKAY)
161 {
162n = 0;
163 }
164
165return rc;
166 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n, and sOKAY.

Referenced by RDM::TIME_SERIES::fft_rdm< N, RANGE_T, INDATA_T, NEXT >::init().

Here is the caller graph for this function:

init_tables_to_read_lock()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
uint32_t RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::init_tables_to_read_lock ( RDM_TABLE_ID * tables )
inlineprotected

IDs of the tables where rows are read.

Use this method to initialize an array of table IDs. This array can then be used to start a transaction where those tables are specified.

118 {
119return next.init_tables_to_read_lock (tables);
120 }

init_tables_to_write_lock()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
uint32_t RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::init_tables_to_write_lock ( RDM_TABLE_ID * tables )
inlineprotected

ID of the tables where rows are inserted.

Use this method to initialize an array of table IDs. This array can then be used to start a transaction where those tables are specified.

97 {
98return next.init_tables_to_write_lock (tables);
99 }

number_of_tables_to_read_lock()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
constexpr static int RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::number_of_tables_to_read_lock ( void )
inlinestaticconstexprprotected

Number of tables where rows are read.

Constant expression method used to statically calculate the size of the array needed for table locking.

107 {
108return NEXT::number_of_tables_to_read_lock ();
109 }

number_of_tables_to_write_lock()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
constexpr static int RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::number_of_tables_to_write_lock ( void )
inlinestaticconstexprprotected

Number of tables where rows are inserted.

Constant expression method used to statically calculate the size of the array needed for table locking.

86 {
87return NEXT::number_of_tables_to_write_lock ();
88 }

put_stats()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class SOURCE_STATS_T >
RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::put_stats ( SOURCE_STATS_T * source_stats,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving statistics.

Receive one statistic and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_first', 'time_stamp_last', 'n', 'value_sum', and 'value_sum2' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE stats
(
time_stamp_first UINT64 NOT NULL,
time_stamp_last UINT64 PRIMARY KEY,
n UINT64 NOT NULL,
value_sum DOUBLE NOT NULL,
value_sum2 DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_STATS_T The actual type of the statistic received.
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_stats The source statistics sent to this class
transactional [IN] Is the put required to be transactional
417 {
418RDM_RETCODE rc = sOKAY;
419
420if (n == 0)
421 {
422aggregate_range.time_stamp_first =
423 source_stats->time_stamp_first;
424 }
425if (n == N - 1)
426 {
427aggregate_range.time_stamp_last =
428 source_stats->time_stamp_last;
429 }
430
431in_data[n] = source_stats->value_sum / source_stats->n;
432
433if (n == N - 1)
434 {
435 rc = doFft ();
436if (rc == sOKAY)
437 {
438 rc = next.put_range (&aggregate_range, transactional);
439 }
440if (rc == sOKAY)
441 {
442n = 0;
443 }
444 }
445else
446 {
447n++;
448 }
449
450return rc;
451 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::aggregate_range, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::doFft(), RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::in_data, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n, and sOKAY.

Here is the call graph for this function:

put_value()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class SOURCE_VALUE_T >
RDM_RETCODE RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::put_value ( SOURCE_VALUE_T * source_value,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving a data value.

Receive one data value and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_current' and 'value_current' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE measurement
(
time_stamp_current UINT64 PRIMARY KEY,
value_current DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_VALUE_T The actual type of the source values received
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_value The source value sent to this class
transactional [IN] Is the put required to be transactional
335 {
336RDM_RETCODE rc = sOKAY;
337
338if (n == 0)
339 {
340aggregate_range.time_stamp_first =
341 source_value->time_stamp_current;
342 }
343if (n == N - 1)
344 {
345aggregate_range.time_stamp_last =
346 source_value->time_stamp_current;
347 }
348
349in_data[n] = source_value->value_current;
350
351if (n == N - 1)
352 {
353 rc = doFft ();
354if (rc == sOKAY)
355 {
356 rc = next.put_range (&aggregate_range, transactional);
357 }
358if (rc == sOKAY)
359 {
360n = 0;
361 }
362 }
363else
364 {
365n++;
366 }
367
368return rc;
369 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::aggregate_range, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::doFft(), RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::in_data, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n, and sOKAY.

Here is the call graph for this function:

reset()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
void RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::reset ( void )
inline

Reset this object.

Call this method to discard all internally kept data values, ranges, and statistics that have not yet been persisted and start over from scratch.

219 {
220 next.reset ();
221n = 0;
222 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n.

serialize()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
uint8_t* RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::serialize ( uint8_t * buffer )
inline
185 {
186 memcpy (buffer, &in_data, sizeof (in_data));
187 buffer += sizeof (in_data);
188 memcpy (buffer, &aggregate_range, sizeof (aggregate_range));
189 buffer += sizeof (aggregate_range);
190 memcpy (buffer, &n, sizeof (n));
191 buffer += sizeof (n);
192return next.serialize (buffer);
193 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::aggregate_range, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::in_data, and RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n.

unflush()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
void RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::unflush ( void )
inlineprotected

Undo a previous flush operation.

140 {
141 next.unflush ();
142 }

unput()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
void RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::unput ( void )
inlineprotected

Undo a previous put operation.

125 {
126if (n == 0)
127 {
128 next.unput ();
129n = N - 1;;
130 }
131else
132 {
133n--;
134 }
135 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n.

unserialize()

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
uint8_t* RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::unserialize ( uint8_t * buffer )
inline
202 {
203 memcpy (&in_data, buffer, sizeof (in_data));
204 buffer += sizeof (in_data);
205 memcpy (&aggregate_range, buffer, sizeof (aggregate_range));
206 buffer += sizeof (aggregate_range);
207 memcpy (&n, buffer, sizeof (n));
208 buffer += sizeof (n);
209return next.unserialize (buffer);
210 }

References RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::aggregate_range, RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::in_data, and RDM::TIME_SERIES::fft< N, RANGE_T, INDATA_T, NEXT >::n.

Friends And Related Function Documentation

collect

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
friend class collect
friend

custom

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class ANY_NEXT >
friend class custom
friend

downsample

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<uint32_t ANY_N, class ANY_NEXT >
friend class downsample
friend

fft

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
friend class fft
friend

mean

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
friend class mean
friend

RDM::DB::transaction

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class ANY_NEXT >
friend class RDM::DB::transaction
friend

scale

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class ANY_RATIO , class ANY_NEXT >
friend class scale
friend

split

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
friend class split
friend

stats

template<uint32_t N, class RANGE_T , class INDATA_T , class NEXT >
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
friend class stats
friend

Field Documentation

aggregate_range

in_data

n


The documentation for this class was generated from the following files:
RANGE_T aggregate_range
Definition: rdm_time_series_fft.h:65
virtual RDM_RETCODE doFft(void)=0
uint32_t n
Definition: rdm_time_series_fft.h:66
@ sOKAY
Definition: rdmretcodetypes.h:100
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
INDATA_T in_data[N]
Definition: rdm_time_series_fft.h:63