weeb grammers
/
Assignment2
something
Fork of HelloWorld by
PaceHeart.cpp@5:45d58f8a5912, 2016-11-14 (annotated)
- Committer:
- weebgrammers
- Date:
- Mon Nov 14 21:36:01 2016 +0000
- Revision:
- 5:45d58f8a5912
- Parent:
- 3:641eefd1110b
anything;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Judorunner | 2:e2ae43e8acab | 1 | #include "PaceHeart.h" |
oopakhooo | 3:641eefd1110b | 2 | #include "mbed.h" |
oopakhooo | 3:641eefd1110b | 3 | #include "Hardware.h" |
oopakhooo | 3:641eefd1110b | 4 | using namespace std; |
oopakhooo | 3:641eefd1110b | 5 | |
oopakhooo | 3:641eefd1110b | 6 | |
Judorunner | 2:e2ae43e8acab | 7 | |
oopakhooo | 3:641eefd1110b | 8 | PaceHeart::PaceHeart(){ |
weebgrammers | 5:45d58f8a5912 | 9 | |
oopakhooo | 3:641eefd1110b | 10 | p_pacingState = 0; |
oopakhooo | 3:641eefd1110b | 11 | p_pacingMode = 0; |
oopakhooo | 3:641eefd1110b | 12 | int p_hysteresis = 0; |
oopakhooo | 3:641eefd1110b | 13 | int p_hysteresisInterval = 300; |
oopakhooo | 3:641eefd1110b | 14 | int lowrateInterval = 1000; |
oopakhooo | 3:641eefd1110b | 15 | int uprateInterval = 500; //upper rate limit |
oopakhooo | 3:641eefd1110b | 16 | //Ventricle |
oopakhooo | 3:641eefd1110b | 17 | double p_vPaceAmp = 3500.0; |
oopakhooo | 3:641eefd1110b | 18 | double p_vPaceWidth = 0.4; |
oopakhooo | 3:641eefd1110b | 19 | int p_VRP = 320; |
oopakhooo | 3:641eefd1110b | 20 | //Atrium (change defaults) |
oopakhooo | 3:641eefd1110b | 21 | double p_aPaceAmp = 3500.0; |
oopakhooo | 3:641eefd1110b | 22 | double p_aPaceWidth = 0.4; |
oopakhooo | 3:641eefd1110b | 23 | int p_ARP = 320; |
oopakhooo | 3:641eefd1110b | 24 | } |
Judorunner | 2:e2ae43e8acab | 25 | |
weebgrammers | 5:45d58f8a5912 | 26 | PaceHeart::PaceHeart(int mode){ |
weebgrammers | 5:45d58f8a5912 | 27 | p_pacingState = 0; |
weebgrammers | 5:45d58f8a5912 | 28 | p_pacingMode = mode; |
weebgrammers | 5:45d58f8a5912 | 29 | int lowrateInterval = 1000; //30-50->5 50-90->1 90-175->5 ppm |
weebgrammers | 5:45d58f8a5912 | 30 | int uprateInterval = 500; //upper rate limit 50-175->5 ppm |
weebgrammers | 5:45d58f8a5912 | 31 | int maxSensorRate = 500; //50-175->5 ppm |
weebgrammers | 5:45d58f8a5912 | 32 | |
weebgrammers | 5:45d58f8a5912 | 33 | //Ventricle |
weebgrammers | 5:45d58f8a5912 | 34 | double p_vPaceAmp = 3750.0; //3750 can change to 0, 1250, 2500, 3750, 5000 |
weebgrammers | 5:45d58f8a5912 | 35 | double p_vPaceWidth = 0.4; //0.05->no change 0.1-1.9 0.1 |
weebgrammers | 5:45d58f8a5912 | 36 | |
weebgrammers | 5:45d58f8a5912 | 37 | int p_activityThresh = 4; //1-7 print out string with level ie. Med |
weebgrammers | 5:45d58f8a5912 | 38 | int p_reactionTime = 30; //10-50->10 |
weebgrammers | 5:45d58f8a5912 | 39 | int p_responseFactor = 8; //1-16->1 |
weebgrammers | 5:45d58f8a5912 | 40 | int p_recoveryTime = 5; //2-16->1 |
weebgrammers | 5:45d58f8a5912 | 41 | } |
oopakhooo | 3:641eefd1110b | 42 | int PaceHeart::get_p_pacingState() |
Judorunner | 2:e2ae43e8acab | 43 | { |
Judorunner | 2:e2ae43e8acab | 44 | return p_pacingState; |
Judorunner | 2:e2ae43e8acab | 45 | } |
oopakhooo | 3:641eefd1110b | 46 | int PaceHeart::get_p_pacingMode() |
Judorunner | 2:e2ae43e8acab | 47 | { |
Judorunner | 2:e2ae43e8acab | 48 | return p_pacingMode; |
Judorunner | 2:e2ae43e8acab | 49 | } |
oopakhooo | 3:641eefd1110b | 50 | int PaceHeart::get_p_hysteresis() |
Judorunner | 2:e2ae43e8acab | 51 | { |
oopakhooo | 3:641eefd1110b | 52 | return p_hysteresis; |
Judorunner | 2:e2ae43e8acab | 53 | } |
oopakhooo | 3:641eefd1110b | 54 | void PaceHeart::set_p_hysteresis(int x) |
Judorunner | 2:e2ae43e8acab | 55 | { |
Judorunner | 2:e2ae43e8acab | 56 | p_hysteresis = x; |
Judorunner | 2:e2ae43e8acab | 57 | return; |
Judorunner | 2:e2ae43e8acab | 58 | } |
oopakhooo | 3:641eefd1110b | 59 | int PaceHeart::get_p_hysteresisInterval() |
Judorunner | 2:e2ae43e8acab | 60 | { |
oopakhooo | 3:641eefd1110b | 61 | return p_hysteresisInterval; |
Judorunner | 2:e2ae43e8acab | 62 | } |
oopakhooo | 3:641eefd1110b | 63 | void PaceHeart::set_p_hysteresisInterval(int x) |
Judorunner | 2:e2ae43e8acab | 64 | { |
oopakhooo | 3:641eefd1110b | 65 | p_hysteresisInterval = x; |
Judorunner | 2:e2ae43e8acab | 66 | return; |
Judorunner | 2:e2ae43e8acab | 67 | } |
oopakhooo | 3:641eefd1110b | 68 | int PaceHeart::get_lowrateInterval() |
Judorunner | 2:e2ae43e8acab | 69 | { |
Judorunner | 2:e2ae43e8acab | 70 | return lowrateInterval; |
Judorunner | 2:e2ae43e8acab | 71 | } |
oopakhooo | 3:641eefd1110b | 72 | void PaceHeart::set_lowrateInterval(int x) |
Judorunner | 2:e2ae43e8acab | 73 | { |
Judorunner | 2:e2ae43e8acab | 74 | lowrateInterval = x; |
Judorunner | 2:e2ae43e8acab | 75 | return; |
Judorunner | 2:e2ae43e8acab | 76 | } |
oopakhooo | 3:641eefd1110b | 77 | int PaceHeart::get_uprateInterval() |
Judorunner | 2:e2ae43e8acab | 78 | { |
oopakhooo | 3:641eefd1110b | 79 | return uprateInterval; |
Judorunner | 2:e2ae43e8acab | 80 | } |
oopakhooo | 3:641eefd1110b | 81 | void PaceHeart::set_uprateInterval(int x) |
Judorunner | 2:e2ae43e8acab | 82 | { |
oopakhooo | 3:641eefd1110b | 83 | uprateInterval = x; |
Judorunner | 2:e2ae43e8acab | 84 | return; |
Judorunner | 2:e2ae43e8acab | 85 | } |
oopakhooo | 3:641eefd1110b | 86 | //Ventricle |
oopakhooo | 3:641eefd1110b | 87 | double PaceHeart::get_p_vPaceAmp() |
oopakhooo | 3:641eefd1110b | 88 | { |
oopakhooo | 3:641eefd1110b | 89 | return p_vPaceAmp; |
oopakhooo | 3:641eefd1110b | 90 | } |
oopakhooo | 3:641eefd1110b | 91 | void PaceHeart::set_p_vPaceAmp(double x) |
oopakhooo | 3:641eefd1110b | 92 | { |
oopakhooo | 3:641eefd1110b | 93 | p_vPaceAmp = x; |
oopakhooo | 3:641eefd1110b | 94 | return; |
oopakhooo | 3:641eefd1110b | 95 | } |
oopakhooo | 3:641eefd1110b | 96 | |
oopakhooo | 3:641eefd1110b | 97 | double PaceHeart::get_p_vPaceWidth() |
Judorunner | 2:e2ae43e8acab | 98 | { |
Judorunner | 2:e2ae43e8acab | 99 | return p_vPaceWidth; |
Judorunner | 2:e2ae43e8acab | 100 | } |
oopakhooo | 3:641eefd1110b | 101 | void PaceHeart::set_p_vPaceWidth(double x) |
Judorunner | 2:e2ae43e8acab | 102 | { |
Judorunner | 2:e2ae43e8acab | 103 | p_vPaceWidth = x; |
Judorunner | 2:e2ae43e8acab | 104 | return; |
Judorunner | 2:e2ae43e8acab | 105 | } |
oopakhooo | 3:641eefd1110b | 106 | |
oopakhooo | 3:641eefd1110b | 107 | int PaceHeart::get_p_VRP() |
Judorunner | 2:e2ae43e8acab | 108 | { |
Judorunner | 2:e2ae43e8acab | 109 | return p_VRP; |
Judorunner | 2:e2ae43e8acab | 110 | } |
oopakhooo | 3:641eefd1110b | 111 | void PaceHeart::set_p_VRP(int x) |
Judorunner | 2:e2ae43e8acab | 112 | { |
Judorunner | 2:e2ae43e8acab | 113 | p_VRP = x; |
Judorunner | 2:e2ae43e8acab | 114 | return; |
oopakhooo | 3:641eefd1110b | 115 | } |
oopakhooo | 3:641eefd1110b | 116 | //Atrium |
oopakhooo | 3:641eefd1110b | 117 | double PaceHeart::get_p_aPaceAmp() |
oopakhooo | 3:641eefd1110b | 118 | { |
oopakhooo | 3:641eefd1110b | 119 | return p_aPaceAmp; |
oopakhooo | 3:641eefd1110b | 120 | } |
oopakhooo | 3:641eefd1110b | 121 | void PaceHeart::set_p_aPaceAmp(double x) |
oopakhooo | 3:641eefd1110b | 122 | { |
oopakhooo | 3:641eefd1110b | 123 | p_aPaceAmp = x; |
oopakhooo | 3:641eefd1110b | 124 | return; |
oopakhooo | 3:641eefd1110b | 125 | } |
oopakhooo | 3:641eefd1110b | 126 | |
oopakhooo | 3:641eefd1110b | 127 | double PaceHeart::get_p_aPaceWidth() |
oopakhooo | 3:641eefd1110b | 128 | { |
oopakhooo | 3:641eefd1110b | 129 | return p_aPaceWidth; |
oopakhooo | 3:641eefd1110b | 130 | } |
oopakhooo | 3:641eefd1110b | 131 | void PaceHeart::set_p_aPaceWidth(double x) |
oopakhooo | 3:641eefd1110b | 132 | { |
oopakhooo | 3:641eefd1110b | 133 | p_aPaceWidth = x; |
oopakhooo | 3:641eefd1110b | 134 | return; |
oopakhooo | 3:641eefd1110b | 135 | } |
oopakhooo | 3:641eefd1110b | 136 | |
oopakhooo | 3:641eefd1110b | 137 | int PaceHeart::get_p_ARP() |
oopakhooo | 3:641eefd1110b | 138 | { |
oopakhooo | 3:641eefd1110b | 139 | return p_ARP; |
oopakhooo | 3:641eefd1110b | 140 | } |
oopakhooo | 3:641eefd1110b | 141 | void PaceHeart::set_p_ARP(int x) |
oopakhooo | 3:641eefd1110b | 142 | { |
oopakhooo | 3:641eefd1110b | 143 | p_ARP = x; |
oopakhooo | 3:641eefd1110b | 144 | return; |
oopakhooo | 3:641eefd1110b | 145 | } |
oopakhooo | 3:641eefd1110b | 146 | |
oopakhooo | 3:641eefd1110b | 147 | |
oopakhooo | 3:641eefd1110b | 148 | |
oopakhooo | 3:641eefd1110b | 149 | void PaceHeart::pace_A(double amp, double wid,int pin) |
oopakhooo | 3:641eefd1110b | 150 | { |
oopakhooo | 3:641eefd1110b | 151 | output_pin_A = !output_pin_A ; |
oopakhooo | 3:641eefd1110b | 152 | wait(1); |
oopakhooo | 3:641eefd1110b | 153 | |
oopakhooo | 3:641eefd1110b | 154 | |
oopakhooo | 3:641eefd1110b | 155 | |
oopakhooo | 3:641eefd1110b | 156 | return; |
oopakhooo | 3:641eefd1110b | 157 | } |
oopakhooo | 3:641eefd1110b | 158 | |
oopakhooo | 3:641eefd1110b | 159 | void PaceHeart::pace_A() |
oopakhooo | 3:641eefd1110b | 160 | { |
oopakhooo | 3:641eefd1110b | 161 | double amplitude = get_p_aPaceAmp(); |
oopakhooo | 3:641eefd1110b | 162 | double width = get_p_aPaceWidth(); |
oopakhooo | 3:641eefd1110b | 163 | // int output_pin = hardware.get_output_pin; //include the hardware module |
oopakhooo | 3:641eefd1110b | 164 | pace_A(amplitude,width,output_pin_A); |
oopakhooo | 3:641eefd1110b | 165 | return; |
oopakhooo | 3:641eefd1110b | 166 | } |
oopakhooo | 3:641eefd1110b | 167 | |
oopakhooo | 3:641eefd1110b | 168 | |
oopakhooo | 3:641eefd1110b | 169 | void PaceHeart::pace_V(double amp, double wid, int pin) |
oopakhooo | 3:641eefd1110b | 170 | { |
oopakhooo | 3:641eefd1110b | 171 | output_pin_V = !output_pin_V ; |
oopakhooo | 3:641eefd1110b | 172 | wait(2); |
oopakhooo | 3:641eefd1110b | 173 | |
oopakhooo | 3:641eefd1110b | 174 | return; |
oopakhooo | 3:641eefd1110b | 175 | } |
oopakhooo | 3:641eefd1110b | 176 | |
oopakhooo | 3:641eefd1110b | 177 | void PaceHeart::pace_V() |
oopakhooo | 3:641eefd1110b | 178 | { |
oopakhooo | 3:641eefd1110b | 179 | double amplitude = get_p_vPaceAmp(); |
oopakhooo | 3:641eefd1110b | 180 | double width = get_p_vPaceWidth(); |
oopakhooo | 3:641eefd1110b | 181 | // int output_pin = hardware.get_output_pin; //include the hardware module |
oopakhooo | 3:641eefd1110b | 182 | pace_V(amplitude,width,output_pin_V); |
oopakhooo | 3:641eefd1110b | 183 | return; |
oopakhooo | 3:641eefd1110b | 184 | } |
oopakhooo | 3:641eefd1110b | 185 | |
oopakhooo | 3:641eefd1110b | 186 | |
oopakhooo | 3:641eefd1110b | 187 | void PaceHeart::pace(int mode) |
oopakhooo | 3:641eefd1110b | 188 | { |
oopakhooo | 3:641eefd1110b | 189 | switch(mode){ |
oopakhooo | 3:641eefd1110b | 190 | case 1: //AOO |
oopakhooo | 3:641eefd1110b | 191 | pace_A(); |
oopakhooo | 3:641eefd1110b | 192 | case 2: //VOO |
oopakhooo | 3:641eefd1110b | 193 | pace_V(); |
oopakhooo | 3:641eefd1110b | 194 | } |
oopakhooo | 3:641eefd1110b | 195 | return; |
oopakhooo | 3:641eefd1110b | 196 | } |
oopakhooo | 3:641eefd1110b | 197 | |
oopakhooo | 3:641eefd1110b | 198 | void PaceHeart::pace() |
oopakhooo | 3:641eefd1110b | 199 | { |
oopakhooo | 3:641eefd1110b | 200 | int mode = get_p_pacingMode(); |
oopakhooo | 3:641eefd1110b | 201 | pace(mode); |
oopakhooo | 3:641eefd1110b | 202 | return; |
oopakhooo | 3:641eefd1110b | 203 | } |
weebgrammers | 5:45d58f8a5912 | 204 | int PaceHeart::get_activityThresh() |
weebgrammers | 5:45d58f8a5912 | 205 | { |
weebgrammers | 5:45d58f8a5912 | 206 | return p_activityThresh; |
weebgrammers | 5:45d58f8a5912 | 207 | } |
weebgrammers | 5:45d58f8a5912 | 208 | int PaceHeart::get_reactionTime() |
weebgrammers | 5:45d58f8a5912 | 209 | { |
weebgrammers | 5:45d58f8a5912 | 210 | return p_reactionTime; |
weebgrammers | 5:45d58f8a5912 | 211 | } |
weebgrammers | 5:45d58f8a5912 | 212 | int PaceHeart::get_responseFactor() |
weebgrammers | 5:45d58f8a5912 | 213 | { |
weebgrammers | 5:45d58f8a5912 | 214 | return p_responseFactor; |
weebgrammers | 5:45d58f8a5912 | 215 | } |
weebgrammers | 5:45d58f8a5912 | 216 | int PaceHeart::get_recoveryTime() |
weebgrammers | 5:45d58f8a5912 | 217 | { |
weebgrammers | 5:45d58f8a5912 | 218 | return p_recoveryTime; |
weebgrammers | 5:45d58f8a5912 | 219 | } |
weebgrammers | 5:45d58f8a5912 | 220 | void PaceHeart::set_activityThresh(int x) |
weebgrammers | 5:45d58f8a5912 | 221 | { |
weebgrammers | 5:45d58f8a5912 | 222 | p_activityThresh=x; |
weebgrammers | 5:45d58f8a5912 | 223 | return; |
weebgrammers | 5:45d58f8a5912 | 224 | } |
weebgrammers | 5:45d58f8a5912 | 225 | void PaceHeart::set_reactionTime(int x) |
weebgrammers | 5:45d58f8a5912 | 226 | { |
weebgrammers | 5:45d58f8a5912 | 227 | p_reactionTime=x; |
weebgrammers | 5:45d58f8a5912 | 228 | return; |
weebgrammers | 5:45d58f8a5912 | 229 | } |
weebgrammers | 5:45d58f8a5912 | 230 | void PaceHeart::set_responseFactor(int x) |
weebgrammers | 5:45d58f8a5912 | 231 | { |
weebgrammers | 5:45d58f8a5912 | 232 | p_responseFactor=x; |
weebgrammers | 5:45d58f8a5912 | 233 | return; |
weebgrammers | 5:45d58f8a5912 | 234 | } |
weebgrammers | 5:45d58f8a5912 | 235 | void PaceHeart::set_recoveryTime(int x) |
weebgrammers | 5:45d58f8a5912 | 236 | { |
weebgrammers | 5:45d58f8a5912 | 237 | p_recoveryTime=x; |
weebgrammers | 5:45d58f8a5912 | 238 | return; |
weebgrammers | 5:45d58f8a5912 | 239 | } |