SoftFilters  0.1.0
Arduino framework and library of software data filters.
FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC > Class Template Reference

A flow rate filter measures the flow rate of incoming data. More...

#include <SoftFilters.h>

Inheritance diagram for FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >:
Collaboration diagram for FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >:

Public Member Functions

virtual bool update (void const *const input) override
 Internally update the filter output based on the given input. More...
 
double get_flow_rate ()
 Calculate the data rate in "frames per second". More...
 
unsigned long get_count ()
 
TS_T get_duration_in_ticks ()
 
double get_duration_in_seconds ()
 
- Public Member Functions inherited from Filter
bool push (void const *const input, void *const output)
 Push a new data through the filter. More...
 

Private Attributes

unsigned long total_count
 total data count
 
TS_T first_ts
 timestamp of first data
 
TS_T last_ts
 timestamp of latest data
 

Additional Inherited Members

- Protected Member Functions inherited from PassThroughFilter< T >
virtual void const *const get_output_val_ptr () override
 Read-only access to the internal output memory. More...
 
virtual void copy_to_client (void *const output) override
 Copy the output to client memory.
 
- Protected Attributes inherited from PassThroughFilter< T >
T const * ptr
 Pointer to the latest data that passed through.
 

Detailed Description

template<typename T, typename TS_T, TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
class FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >

A flow rate filter measures the flow rate of incoming data.

Template Parameters
TThe type of the data that is passing through.
TS_TThe type of timestamp. Defaults to unsigned long as per documentation of the Arduino millis and micros functions.
time_funA timestamp function that takes no input parameter and returns a timestamp in the unit of number of ticks.
TICKS_PER_SECNumber of ticks (unit of the timestamp) per second.

Member Function Documentation

◆ get_count()

template<typename T , typename TS_T , TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
unsigned long FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >::get_count ( )
inline
Returns
The total number of data that have passed through this filter.

◆ get_duration_in_seconds()

template<typename T , typename TS_T , TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
double FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >::get_duration_in_seconds ( )
inline
Returns
The total number of seconds since arrival of the first data.

◆ get_duration_in_ticks()

template<typename T , typename TS_T , TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
TS_T FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >::get_duration_in_ticks ( )
inline
Returns
The total number of clock "ticks" (platform-dependent) since arrival of the first data.

◆ get_flow_rate()

template<typename T , typename TS_T , TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
double FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >::get_flow_rate ( )
inline

Calculate the data rate in "frames per second".

Essentially the "framerate" is calculated as the total number of data devided by the total duration in seconds since arrival of the first data.

Returns
The data per second in double precision.

◆ update()

template<typename T , typename TS_T , TS_T(*)() time_fun, TS_T TICKS_PER_SEC>
virtual bool FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >::update ( void const *const  input)
inlineoverridevirtual

Internally update the filter output based on the given input.

This method behaves similarly to the public Filter::push method, but without copying the output to the client memory. This method is for internal workings of the filter framework.

Reimplemented from PassThroughFilter< T >.


The documentation for this class was generated from the following file: