Larus glider flight sensor system 3.9.2024
Software-In-The-Loop test and validation system
Loading...
Searching...
No Matches
trigger.h
Go to the documentation of this file.
1/***********************************************************************/
25#ifndef TRIGGER_H_
26#define TRIGGER_H_
27
30{
31public:
33 : hysteresis( _hysteresis),
34 minimax(ZERO),
35 going_up(true)
36 {}
37 bool initialize( float value, bool _going_up=true)
38 {
39 minimax = value;
40 going_up=_going_up;
41 return true;
42 }
43 bool process( float value)
44 {
45 if( going_up)
46 {
47 if( value > minimax)
48 {
49 minimax=value;
50 }
51 else
52 {
53 if( value < minimax - hysteresis)
54 {
55 minimax=value;
56 going_up=false;
57 return true;
58 }
59 }
60 return false;
61 }
62 else
63 {
64 if( value < minimax)
65 {
66 minimax=value;
67 }
68 else
69 {
70 if( value > minimax + hysteresis)
71 {
72 minimax=value;
73 going_up=true;
74 return true;
75 }
76 }
77 return false;
78 }
79 }
80private:
81 float hysteresis;
82 float minimax;
83 bool going_up;
84};
85
86
87
88#endif /* TRIGGER_H_ */
Hysteresis-based triggering on input data.
Definition trigger.h:30
bool process(float value)
Definition trigger.h:43
bool initialize(float value, bool _going_up=true)
Definition trigger.h:37
trigger(float _hysteresis)
Definition trigger.h:32
mathematical vector of arbitrary type and size
Definition vector.h:40
#define ZERO