-
Notifications
You must be signed in to change notification settings - Fork 2
/
PumpState.h
56 lines (43 loc) · 1.03 KB
/
PumpState.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* (C) 2016 Onwrikbaar <onwrikbaar@hotmail.com>
*/
class PumpState
{
private:
unsigned long timeMark = 0UL; // The start time of an interval.
// unsigned long millisecondsDelay;
protected:
float alphaRMA = 1.0; // The running moving average of alpha.
bool waited(unsigned long milliseconds);
void closeValve();
void openValve();
public:
virtual void enter();
virtual void leave();
virtual PumpState *nextState();
virtual float predictPressure(float basePr, float predPr, float prevPr, float lastPr) { return lastPr; };
};
class PS_Idle : public PumpState
{
public:
void enter();
PumpState *nextState();
};
class PS_Pump : public PumpState
{
public:
void enter();
PumpState *nextState();
};
class PS_Warn : public PumpState
{
public:
void enter();
PumpState *nextState();
};
class PS_Hold : public PumpState
{
public:
PumpState *nextState();
float predictPressure(float basePr, float predPr, float prevPr, float lastPr);
};