|
1-phase PV router
|
Template class for implementing a sliding average. More...
#include <movingAvg.h>

Public Member Functions | |
| void | addValue (const T &_value) |
| Add a value. | |
| void | clear () |
| Reset everything. | |
| void | fillValue (const T &_value) |
| auto | getAverage () const |
| Get the sliding average. | |
| auto | getElement (uint8_t idx) const |
| constexpr uint8_t | getSize () const |
Private Member Functions | |
| void | _addValue (const T &_value) |
| void | _clear_sub () |
| auto | _getAverage () const |
Private Attributes | |
| T | _ar [DURATION_IN_MINUTES] {} |
| uint8_t | _idx { 0 } |
| T | _sub_ar [VALUES_PER_MINUTE] {} |
| uint8_t | _sub_idx { 0 } |
| conditional< is_floating_point< T >::value, T, int32_t >::type | _sub_sum { 0 } |
| conditional< is_floating_point< T >::value, T, int32_t >::type | _sum { 0 } |
Static Private Attributes | |
| static constexpr float | invD { 1.0 / VALUES_PER_MINUTE } |
| static constexpr float | invN { 1.0 / DURATION_IN_MINUTES } |
Template class for implementing a sliding average.
| T | Type of values to be stored |
| DURATION_IN_MINUTES | Size of main array |
| VALUES_PER_MINUTE | Size of sub array |
Drawback of this method: the average is updated only every minutes !
Definition at line 40 of file movingAvg.h.
|
inlineprivate |
Definition at line 171 of file movingAvg.h.
References _ar, _idx, and _sum.
Referenced by addValue().

|
inlineprivate |
Definition at line 152 of file movingAvg.h.
References _sub_ar, _sub_idx, _sub_sum, i, and integral_constant< bool, is_same< float, remove_cv_t< T > >::value||is_same< double, remove_cv_t< T > >::value >::value.
Referenced by clear().

|
inlineprivate |
Definition at line 184 of file movingAvg.h.
References _sub_sum, and invD.
Referenced by addValue(), and getAverage().

|
inline |
Add a value.
| _value | Value to be added |
Definition at line 81 of file movingAvg.h.
References _addValue(), _getAverage(), _sub_ar, _sub_idx, and _sub_sum.

|
inline |
Reset everything.
Definition at line 47 of file movingAvg.h.
References _ar, _clear_sub(), _idx, _sum, i, and integral_constant< bool, is_same< float, remove_cv_t< T > >::value||is_same< double, remove_cv_t< T > >::value >::value.

|
inline |
|
inline |
Get the sliding average.
Definition at line 115 of file movingAvg.h.
References _getAverage(), _sum, and invN.

|
inline |
Definition at line 133 of file movingAvg.h.
References _ar, and integral_constant< bool, is_same< float, remove_cv_t< T > >::value||is_same< double, remove_cv_t< T > >::value >::value.
|
inlinenodiscardconstexpr |
Definition at line 146 of file movingAvg.h.
|
private |
Definition at line 196 of file movingAvg.h.
Referenced by _addValue(), clear(), fillValue(), and getElement().
|
private |
Definition at line 190 of file movingAvg.h.
Referenced by _addValue(), clear(), and fillValue().
|
private |
Definition at line 195 of file movingAvg.h.
Referenced by _clear_sub(), and addValue().
|
private |
Definition at line 191 of file movingAvg.h.
Referenced by _clear_sub(), and addValue().
|
private |
Definition at line 193 of file movingAvg.h.
Referenced by _clear_sub(), _getAverage(), and addValue().
|
private |
Definition at line 192 of file movingAvg.h.
Referenced by _addValue(), clear(), fillValue(), and getAverage().
|
staticconstexprprivate |
Definition at line 198 of file movingAvg.h.
Referenced by _getAverage().
|
staticconstexprprivate |
Definition at line 199 of file movingAvg.h.
Referenced by getAverage().