-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpseudocode.cpp
82 lines (74 loc) · 1.66 KB
/
pseudocode.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <Arduino.h>
# define INSPIRATION_TIME 1000
# define ESPIRATION_TIME 4000
// Measurements
float volmax;
float presmax;
float o2insp;
float limitO2;
float co2esp;
float limitCO2;
float volumeentry;
float volumeexit;
int ppeak = 23;
int pplat = 18;
int peep = 5;
// Parameters
int weight = 70; // kg
float volc = 300.0; // weight * 6u8 (mL)
int rpm = 15; // breaths per minute
int voli = volc * rpm;
int timep; // good to have, pause
unsigned long inspiration = 0; // (s)
unsigned long espiration = 0; // (s)
// Alerts (pending validation):
// High pressure alert
// Low pressure alert
// Compliance alert
// O2 alert
// CO2 alert
// Leak alert
void openEntryEV(){}
int getMetricPpeak(){}
int getMetricPplat(){}
int calculateResistance (int ppeak, int pplat) {
return ppeak - pplat;
}
int getMetricPeep(){}
void closeEntryEV(){}
void openExitEV(){}
float getMetricVolumeExit(){}
void checkLeak(float volc, float volExit){}
int calculateCompliance (int pplat, int peep) {
return pplat - peep;
}
void closeExitEV(){}
float getMetricVolMax(){}
float getMetricPresMax(){}
void setup() {
Serial.begin(115200);
}
void loop() {
openEntryEV()
if(millis() >= inspiration + INSPIRATION_TIME){
inspiration +=INSPIRATION_TIME;
Serial.println("Insp");
}
ppeak = getMetricPpeak();
pplat = getMetricPplat();
calculateResistance(ppeak, pplat);
if (ppeak > 40){
Serial.println("PRESSURE ALERT");
}
int peep = getMetricPeep();
closeEntryEV();
openExitEV();
if(millis() >= inspiration + ESPIRATION_TIME){
inspiration +=ESPIRATION_TIME;
Serial.println("Esp");
}
float volExit = getMetricVolumeExit();
checkLeak(volc, volExit);
calculateCompliance(pplat, peep);
closeExitEV();
}