-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInflatable.cpp
62 lines (45 loc) · 939 Bytes
/
Inflatable.cpp
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
56
57
58
59
60
61
/*
* (C) 2016 Onwrikbaar <onwrikbaar@hotmail.com>
*/
#include "Inflatable.h"
// Constructor.
Inflatable::Inflatable(const PressureLimits *pl)
{
limits = pl;
resetLimits();
lastPressure = 0.0;
}
void Inflatable::resetLimits()
{
thresholdLo = limits->loMin;
thresholdHi = limits->hiMin;
}
void Inflatable::updatePressure(float pressure)
{
lastPressure = pressure;
}
float Inflatable::pressure()
{
return lastPressure;
}
float Inflatable::pressureOverMin()
{
return (lastPressure - thresholdLo);
}
float Inflatable::pressureOverMax()
{
return (lastPressure - thresholdHi);
}
bool Inflatable::cycleDone(float step)
{
if ((thresholdHi += step) > limits->hiMax) {
resetLimits();
return true;
}
if ((thresholdLo += step) > limits->loMax) thresholdLo = limits->loMax;
return false;
}
float Inflatable::flowRate()
{
return (lastPressure / limits->hiMax);
}