Firmware
|
#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 |
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.
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.
[in] | mode | The mode of the analyzer |
[in] | window | The window size in seconds. Only used in the averaging mode. |
void SimpleAnalyzer::add_value | ( | float | val, |
float | update_rate | ||
) |
Add a new value to the analyzer and update the result according to the mode.
[in] | val | The value to process |
[in] | update_rate | The 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. |
float SimpleAnalyzer::get_scaled | ( | float | scalingfactor | ) | const |
Get the scaled value of the current result of the analyzer.
[in] | scalingfactor | The factor used to scale the result. |
|
inline |
Get the rounded scaled value casted to the input template type.
Should only be used to return integer types.
[out] | ret | The scaled and rounded value of the current analyzer result. [in] scalingfactor: The factor which is used to scale the result. |