![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Track the persistence of a threshold. More...
#include <PersistenceTracker.hpp>
Public Member Functions | |
| PersistenceTracker (uint8 required=N) | |
| ~PersistenceTracker () | |
| void | pushValue (T value) |
| Add a value to the persistence tracker. | |
| bool | greaterThan (T value) |
| Checks if the required number of values tracked is greater than the input. | |
| bool | lessThan (T value) |
| Checks if the required number of values tracked is less than the input. | |
| bool | inRange (T min, T max) |
| Check if required values lie inside range between min and max. | |
| bool | outsideRange (T min, T max) |
| Check if required values lie outside range between min and max. | |
Protected Attributes | |
| CircularBuffer< T, N > | _values |
| uint8 | _required = 0 |
Track the persistence of a threshold.
The Persistence Tracker is a simple class designed to make tracking values for which some persistence is required to trigger an event (i.e. we want to see pressure greater than some threshold twice before we deploy main chute, etc.)
The class takes two templated parameters, the type T and the number of values to track, N, at declaration. On construction, the class takes an optional input, which is the number of required values which must meet the "tested" threshold, defined by the functions herein. The default behavior is that all N values must meet the threshold.
The class comes with a number of functions, lessThan, greaterThan, etc. which are called for comparison and return simple booleans.
Simple example: PersistenceTracker<float, 3> tester; tester.pushValue(1.0); tester.pushValue(2.1); tester.pushValue(3.0); tester.greaterThan(0.0) --> Will return true tester.greaterThan(2.0) --> Will return false tester.pushValue(2.0) --> At this point 1.0 falls off tester.greaterThan(2.0) --> Will now return true
Example with reduced test: PersistenceTracker<float, 3> tester(2); --> Requires 2/3 values meet test tester.pushValue(1.0); tester.pushValue(2.1); tester.pushValue(3.0); tester.greaterThan(0.0) --> Will return true tester.greaterThan(2.0) --> Will return true in this case tester.pushValue(0.0) --> At this point 1.0 falls off tester.pushValue(0.0) --> At this point 2.1 falls off tester.greaterThan(2.0) --> Will now return false (1/3 greater than)
|
inline |
|
inline |
| bool clockwerk::PersistenceTracker< T, N >::greaterThan | ( | T | value | ) |
Checks if the required number of values tracked is greater than the input.
| value | The check point. Check is true greater than and is not inclusive of value |
| bool clockwerk::PersistenceTracker< T, N >::inRange | ( | T | min, |
| T | max ) |
Check if required values lie inside range between min and max.
| min | The bottom check point. Check is not inclusive of value |
| max | The top check point. Check is not inclusive of value |
| bool clockwerk::PersistenceTracker< T, N >::lessThan | ( | T | value | ) |
Checks if the required number of values tracked is less than the input.
| value | The check point. Check is true less than and is not inclusive of value |
| bool clockwerk::PersistenceTracker< T, N >::outsideRange | ( | T | min, |
| T | max ) |
Check if required values lie outside range between min and max.
| min | The bottom check point. Check is not inclusive of value |
| max | The top check point. Check is not inclusive of value |
|
inline |
Add a value to the persistence tracker.
| value | The value to add |
|
protected |
|
protected |