Firmware
Public Types | Public Member Functions | List of all members
SimpleAnalyzer Class Reference

SimpleAnalyzer. More...

#include <mavlink_simple_analyzer.h>

Public Types

enum  Mode { AVERAGE = 0, MIN, MAX }
 

Public Member Functions

 SimpleAnalyzer (Mode mode, float window=60.0f)
 Constructor. More...
 
void reset ()
 Reset the analyzer to the initial state.
 
void add_value (float val, float update_rate)
 Add a new value to the analyzer and update the result according to the mode. More...
 
bool valid () const
 Returns true if at least one value has been added to the analyzer.
 
float get () const
 Get the current result of the analyzer.
 
float get_scaled (float scalingfactor) const
 Get the scaled value of the current result of the analyzer. More...
 
void get_scaled (uint8_t &ret, float scalingfactor) const
 Get the rounded scaled value casted to the input template type. More...
 
void get_scaled (int8_t &ret, float scalingfactor) const
 

Detailed Description

SimpleAnalyzer.

Class used for simple analysis of data streams. The data can be analyzed in the following three modes:

AVERAGE: The average value is computed at the beginning. Based on the number of analyzed values, the update rate and the window size the switch to the moving average is determined.

MIN: The minimum value is tracked.

MAX: The maximum value is tracked.

Constructor & Destructor Documentation

§ SimpleAnalyzer()

SimpleAnalyzer::SimpleAnalyzer ( Mode  mode,
float  window = 60.0f 
)

Constructor.

Defines the mode of the analyzer and the window size in case of the averaging mode.

Parameters
[in]modeThe mode of the analyzer
[in]windowThe window size in seconds. Only used in the averaging mode.

Member Function Documentation

§ add_value()

void SimpleAnalyzer::add_value ( float  val,
float  update_rate 
)

Add a new value to the analyzer and update the result according to the mode.

Parameters
[in]valThe value to process
[in]update_rateThe update rate in [1/s] for which new value are added. Used in the averaging mode to determine when to switch from averaging to the moving average.

§ get_scaled() [1/2]

float SimpleAnalyzer::get_scaled ( float  scalingfactor) const

Get the scaled value of the current result of the analyzer.

Parameters
[in]scalingfactorThe factor used to scale the result.

§ get_scaled() [2/2]

void SimpleAnalyzer::get_scaled ( uint8_t &  ret,
float  scalingfactor 
) const
inline

Get the rounded scaled value casted to the input template type.

Should only be used to return integer types.

Parameters
[out]retThe scaled and rounded value of the current analyzer result. [in] scalingfactor: The factor which is used to scale the result.

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