Analyzes the readings from distance sensor to determine if the water level is increasing, decreasing or stationary. Permits also to detect sensor failure if the readings appear to be random.
More...
|
| ReadingsAnalyzer (void) |
| Default constructor.
|
|
void | begin (void) |
| Initializes this instance.
|
|
void | addReading (const float64_t reading) |
| Adds a measurement to the statistic.
|
|
uint8_t | getAnalysis (void) |
| Checks the measurements and gives a response.
|
|
void | get_debug_values (uint16_t &dec, uint16_t &inc) |
| Get current counters values for debug purpose.
|
|
|
static const uint8_t | UNKNOWN = 0U |
| Unknown analysis result (initialization value).
|
|
static const uint8_t | STATIONARY = 1U |
| Water level is stationary.
|
|
static const uint8_t | DECREASING = 2U |
| Water level is decreasing.
|
|
static const uint8_t | INCREASING = 3U |
| Water level is increasing.
|
|
static const uint8_t | NOISY = 4U |
| Water level is not stable (possible sensor fault).
|
|
|
static uint16_t | increase (const uint16_t val, const uint16_t by=1U) |
| Increase the value val by by and returns it.
|
|
static uint16_t | decrease (const uint16_t val, const uint16_t by=1U) |
| Decrease the value val by by and returns it.
|
|
|
static const int32_t | INCREASING_COUNTER_THRESHOLD = 2 |
| Difference between increasing and decreasing counter to detect an "increasing" water tank level.
|
|
static const int32_t | DECREASING_COUNTER_THRESHOLD = -2 |
| Difference between increasing and decreasing counter to detect a "decreasing" water tank level.
|
|
Analyzes the readings from distance sensor to determine if the water level is increasing, decreasing or stationary. Permits also to detect sensor failure if the readings appear to be random.
◆ ReadingsAnalyzer()
ReadingsAnalyzer::ReadingsAnalyzer |
( |
void | | ) |
|
|
inline |
Default constructor.
Creates and instance of this class.
◆ addReading()
void ReadingsAnalyzer::addReading |
( |
const float64_t | reading | ) |
|
|
inline |
Adds a measurement to the statistic.
- Parameters
-
[in] | reading | The distance measurement. |
◆ begin()
void ReadingsAnalyzer::begin |
( |
void | | ) |
|
|
inline |
Initializes this instance.
◆ decrease()
static uint16_t ReadingsAnalyzer::decrease |
( |
const uint16_t | val, |
|
|
const uint16_t | by = 1U ) |
|
inlinestaticprivate |
Decrease the value val
by by
and returns it.
- Parameters
-
[in] | val | The value to decrease. |
[in] | by | The value to sum. |
- Returns
- The value of
val
- by
or 0 if by
>= val
.
◆ get_debug_values()
void ReadingsAnalyzer::get_debug_values |
( |
uint16_t & | dec, |
|
|
uint16_t & | inc ) |
|
inline |
Get current counters values for debug purpose.
- Parameters
-
[out] | dec | The decreasing readings counter. |
[out] | inc | The increasing readings counter. |
◆ getAnalysis()
uint8_t ReadingsAnalyzer::getAnalysis |
( |
void | | ) |
|
|
inline |
◆ increase()
static uint16_t ReadingsAnalyzer::increase |
( |
const uint16_t | val, |
|
|
const uint16_t | by = 1U ) |
|
inlinestaticprivate |
Increase the value val
by by
and returns it.
- Parameters
-
[in] | val | The value to increase. |
[in] | by | The value to sum. |
- Returns
- The value of
val
+ by
or UINT16_MAX in case of overflow.
◆ DECREASING
const uint8_t ReadingsAnalyzer::DECREASING = 2U |
|
static |
Water level is decreasing.
◆ DECREASING_COUNTER_THRESHOLD
const int32_t ReadingsAnalyzer::DECREASING_COUNTER_THRESHOLD = -2 |
|
staticprivate |
Difference between increasing and decreasing counter to detect a "decreasing" water tank level.
◆ INCREASING
const uint8_t ReadingsAnalyzer::INCREASING = 3U |
|
static |
Water level is increasing.
◆ INCREASING_COUNTER_THRESHOLD
const int32_t ReadingsAnalyzer::INCREASING_COUNTER_THRESHOLD = 2 |
|
staticprivate |
Difference between increasing and decreasing counter to detect an "increasing" water tank level.
◆ is_noisy
bool ReadingsAnalyzer::is_noisy |
|
private |
◆ last_reading
◆ n_decreasing_readings
uint16_t ReadingsAnalyzer::n_decreasing_readings |
|
private |
Number of "decreasing" readings.
◆ n_increasing_readings
uint16_t ReadingsAnalyzer::n_increasing_readings |
|
private |
Number of "increasing" readings.
◆ NOISY
const uint8_t ReadingsAnalyzer::NOISY = 4U |
|
static |
Water level is not stable (possible sensor fault).
◆ NOISY_THRESHOLD
const float64_t ReadingsAnalyzer::NOISY_THRESHOLD = 5.0 |
|
private |
Difference in cm between readings to detect the noisy condition.
◆ READING_STEP
const float64_t ReadingsAnalyzer::READING_STEP = 0.2 |
|
private |
The minimum step in cm to detect an increasing or decreasing water tank level.
◆ STATIONARY
const uint8_t ReadingsAnalyzer::STATIONARY = 1U |
|
static |
Water level is stationary.
◆ UNKNOWN
const uint8_t ReadingsAnalyzer::UNKNOWN = 0U |
|
static |
Unknown analysis result (initialization value).
The documentation for this class was generated from the following file: