Kevin Chen
/
HelloWorld
a
Fork of HelloWorld by
PaceHeart.cpp@3:641eefd1110b, 2016-10-26 (annotated)
- Committer:
- oopakhooo
- Date:
- Wed Oct 26 21:17:17 2016 +0000
- Revision:
- 3:641eefd1110b
- Parent:
- 2:e2ae43e8acab
- Child:
- 4:fb75731983cd
hk;
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(){ |
oopakhooo | 3:641eefd1110b | 9 | p_pacingState = 0; |
oopakhooo | 3:641eefd1110b | 10 | p_pacingMode = 0; |
oopakhooo | 3:641eefd1110b | 11 | int p_hysteresis = 0; |
oopakhooo | 3:641eefd1110b | 12 | int p_hysteresisInterval = 300; |
oopakhooo | 3:641eefd1110b | 13 | int lowrateInterval = 1000; |
oopakhooo | 3:641eefd1110b | 14 | int uprateInterval = 500; //upper rate limit |
oopakhooo | 3:641eefd1110b | 15 | //Ventricle |
oopakhooo | 3:641eefd1110b | 16 | double p_vPaceAmp = 3500.0; |
oopakhooo | 3:641eefd1110b | 17 | double p_vPaceWidth = 0.4; |
oopakhooo | 3:641eefd1110b | 18 | int p_VRP = 320; |
oopakhooo | 3:641eefd1110b | 19 | //Atrium (change defaults) |
oopakhooo | 3:641eefd1110b | 20 | double p_aPaceAmp = 3500.0; |
oopakhooo | 3:641eefd1110b | 21 | double p_aPaceWidth = 0.4; |
oopakhooo | 3:641eefd1110b | 22 | int p_ARP = 320; |
oopakhooo | 3:641eefd1110b | 23 | } |
Judorunner | 2:e2ae43e8acab | 24 | |
oopakhooo | 3:641eefd1110b | 25 | int PaceHeart::get_p_pacingState() |
Judorunner | 2:e2ae43e8acab | 26 | { |
Judorunner | 2:e2ae43e8acab | 27 | return p_pacingState; |
Judorunner | 2:e2ae43e8acab | 28 | } |
oopakhooo | 3:641eefd1110b | 29 | int PaceHeart::get_p_pacingMode() |
Judorunner | 2:e2ae43e8acab | 30 | { |
Judorunner | 2:e2ae43e8acab | 31 | return p_pacingMode; |
Judorunner | 2:e2ae43e8acab | 32 | } |
oopakhooo | 3:641eefd1110b | 33 | int PaceHeart::get_p_hysteresis() |
Judorunner | 2:e2ae43e8acab | 34 | { |
oopakhooo | 3:641eefd1110b | 35 | return p_hysteresis; |
Judorunner | 2:e2ae43e8acab | 36 | } |
oopakhooo | 3:641eefd1110b | 37 | void PaceHeart::set_p_hysteresis(int x) |
Judorunner | 2:e2ae43e8acab | 38 | { |
Judorunner | 2:e2ae43e8acab | 39 | p_hysteresis = x; |
Judorunner | 2:e2ae43e8acab | 40 | return; |
Judorunner | 2:e2ae43e8acab | 41 | } |
oopakhooo | 3:641eefd1110b | 42 | int PaceHeart::get_p_hysteresisInterval() |
Judorunner | 2:e2ae43e8acab | 43 | { |
oopakhooo | 3:641eefd1110b | 44 | return p_hysteresisInterval; |
Judorunner | 2:e2ae43e8acab | 45 | } |
oopakhooo | 3:641eefd1110b | 46 | void PaceHeart::set_p_hysteresisInterval(int x) |
Judorunner | 2:e2ae43e8acab | 47 | { |
oopakhooo | 3:641eefd1110b | 48 | p_hysteresisInterval = x; |
Judorunner | 2:e2ae43e8acab | 49 | return; |
Judorunner | 2:e2ae43e8acab | 50 | } |
oopakhooo | 3:641eefd1110b | 51 | int PaceHeart::get_lowrateInterval() |
Judorunner | 2:e2ae43e8acab | 52 | { |
Judorunner | 2:e2ae43e8acab | 53 | return lowrateInterval; |
Judorunner | 2:e2ae43e8acab | 54 | } |
oopakhooo | 3:641eefd1110b | 55 | void PaceHeart::set_lowrateInterval(int x) |
Judorunner | 2:e2ae43e8acab | 56 | { |
Judorunner | 2:e2ae43e8acab | 57 | lowrateInterval = x; |
Judorunner | 2:e2ae43e8acab | 58 | return; |
Judorunner | 2:e2ae43e8acab | 59 | } |
oopakhooo | 3:641eefd1110b | 60 | int PaceHeart::get_uprateInterval() |
Judorunner | 2:e2ae43e8acab | 61 | { |
oopakhooo | 3:641eefd1110b | 62 | return uprateInterval; |
Judorunner | 2:e2ae43e8acab | 63 | } |
oopakhooo | 3:641eefd1110b | 64 | void PaceHeart::set_uprateInterval(int x) |
Judorunner | 2:e2ae43e8acab | 65 | { |
oopakhooo | 3:641eefd1110b | 66 | uprateInterval = x; |
Judorunner | 2:e2ae43e8acab | 67 | return; |
Judorunner | 2:e2ae43e8acab | 68 | } |
oopakhooo | 3:641eefd1110b | 69 | //Ventricle |
oopakhooo | 3:641eefd1110b | 70 | double PaceHeart::get_p_vPaceAmp() |
oopakhooo | 3:641eefd1110b | 71 | { |
oopakhooo | 3:641eefd1110b | 72 | return p_vPaceAmp; |
oopakhooo | 3:641eefd1110b | 73 | } |
oopakhooo | 3:641eefd1110b | 74 | void PaceHeart::set_p_vPaceAmp(double x) |
oopakhooo | 3:641eefd1110b | 75 | { |
oopakhooo | 3:641eefd1110b | 76 | p_vPaceAmp = x; |
oopakhooo | 3:641eefd1110b | 77 | return; |
oopakhooo | 3:641eefd1110b | 78 | } |
oopakhooo | 3:641eefd1110b | 79 | |
oopakhooo | 3:641eefd1110b | 80 | double PaceHeart::get_p_vPaceWidth() |
Judorunner | 2:e2ae43e8acab | 81 | { |
Judorunner | 2:e2ae43e8acab | 82 | return p_vPaceWidth; |
Judorunner | 2:e2ae43e8acab | 83 | } |
oopakhooo | 3:641eefd1110b | 84 | void PaceHeart::set_p_vPaceWidth(double x) |
Judorunner | 2:e2ae43e8acab | 85 | { |
Judorunner | 2:e2ae43e8acab | 86 | p_vPaceWidth = x; |
Judorunner | 2:e2ae43e8acab | 87 | return; |
Judorunner | 2:e2ae43e8acab | 88 | } |
oopakhooo | 3:641eefd1110b | 89 | |
oopakhooo | 3:641eefd1110b | 90 | int PaceHeart::get_p_VRP() |
Judorunner | 2:e2ae43e8acab | 91 | { |
Judorunner | 2:e2ae43e8acab | 92 | return p_VRP; |
Judorunner | 2:e2ae43e8acab | 93 | } |
oopakhooo | 3:641eefd1110b | 94 | void PaceHeart::set_p_VRP(int x) |
Judorunner | 2:e2ae43e8acab | 95 | { |
Judorunner | 2:e2ae43e8acab | 96 | p_VRP = x; |
Judorunner | 2:e2ae43e8acab | 97 | return; |
oopakhooo | 3:641eefd1110b | 98 | } |
oopakhooo | 3:641eefd1110b | 99 | //Atrium |
oopakhooo | 3:641eefd1110b | 100 | double PaceHeart::get_p_aPaceAmp() |
oopakhooo | 3:641eefd1110b | 101 | { |
oopakhooo | 3:641eefd1110b | 102 | return p_aPaceAmp; |
oopakhooo | 3:641eefd1110b | 103 | } |
oopakhooo | 3:641eefd1110b | 104 | void PaceHeart::set_p_aPaceAmp(double x) |
oopakhooo | 3:641eefd1110b | 105 | { |
oopakhooo | 3:641eefd1110b | 106 | p_aPaceAmp = x; |
oopakhooo | 3:641eefd1110b | 107 | return; |
oopakhooo | 3:641eefd1110b | 108 | } |
oopakhooo | 3:641eefd1110b | 109 | |
oopakhooo | 3:641eefd1110b | 110 | double PaceHeart::get_p_aPaceWidth() |
oopakhooo | 3:641eefd1110b | 111 | { |
oopakhooo | 3:641eefd1110b | 112 | return p_aPaceWidth; |
oopakhooo | 3:641eefd1110b | 113 | } |
oopakhooo | 3:641eefd1110b | 114 | void PaceHeart::set_p_aPaceWidth(double x) |
oopakhooo | 3:641eefd1110b | 115 | { |
oopakhooo | 3:641eefd1110b | 116 | p_aPaceWidth = x; |
oopakhooo | 3:641eefd1110b | 117 | return; |
oopakhooo | 3:641eefd1110b | 118 | } |
oopakhooo | 3:641eefd1110b | 119 | |
oopakhooo | 3:641eefd1110b | 120 | int PaceHeart::get_p_ARP() |
oopakhooo | 3:641eefd1110b | 121 | { |
oopakhooo | 3:641eefd1110b | 122 | return p_ARP; |
oopakhooo | 3:641eefd1110b | 123 | } |
oopakhooo | 3:641eefd1110b | 124 | void PaceHeart::set_p_ARP(int x) |
oopakhooo | 3:641eefd1110b | 125 | { |
oopakhooo | 3:641eefd1110b | 126 | p_ARP = x; |
oopakhooo | 3:641eefd1110b | 127 | return; |
oopakhooo | 3:641eefd1110b | 128 | } |
oopakhooo | 3:641eefd1110b | 129 | |
oopakhooo | 3:641eefd1110b | 130 | |
oopakhooo | 3:641eefd1110b | 131 | |
oopakhooo | 3:641eefd1110b | 132 | void PaceHeart::pace_A(double amp, double wid,int pin) |
oopakhooo | 3:641eefd1110b | 133 | { |
oopakhooo | 3:641eefd1110b | 134 | output_pin_A = !output_pin_A ; |
oopakhooo | 3:641eefd1110b | 135 | wait(1); |
oopakhooo | 3:641eefd1110b | 136 | |
oopakhooo | 3:641eefd1110b | 137 | |
oopakhooo | 3:641eefd1110b | 138 | |
oopakhooo | 3:641eefd1110b | 139 | return; |
oopakhooo | 3:641eefd1110b | 140 | } |
oopakhooo | 3:641eefd1110b | 141 | |
oopakhooo | 3:641eefd1110b | 142 | void PaceHeart::pace_A() |
oopakhooo | 3:641eefd1110b | 143 | { |
oopakhooo | 3:641eefd1110b | 144 | double amplitude = get_p_aPaceAmp(); |
oopakhooo | 3:641eefd1110b | 145 | double width = get_p_aPaceWidth(); |
oopakhooo | 3:641eefd1110b | 146 | // int output_pin = hardware.get_output_pin; //include the hardware module |
oopakhooo | 3:641eefd1110b | 147 | pace_A(amplitude,width,output_pin_A); |
oopakhooo | 3:641eefd1110b | 148 | return; |
oopakhooo | 3:641eefd1110b | 149 | } |
oopakhooo | 3:641eefd1110b | 150 | |
oopakhooo | 3:641eefd1110b | 151 | |
oopakhooo | 3:641eefd1110b | 152 | void PaceHeart::pace_V(double amp, double wid, int pin) |
oopakhooo | 3:641eefd1110b | 153 | { |
oopakhooo | 3:641eefd1110b | 154 | output_pin_V = !output_pin_V ; |
oopakhooo | 3:641eefd1110b | 155 | wait(2); |
oopakhooo | 3:641eefd1110b | 156 | |
oopakhooo | 3:641eefd1110b | 157 | return; |
oopakhooo | 3:641eefd1110b | 158 | } |
oopakhooo | 3:641eefd1110b | 159 | |
oopakhooo | 3:641eefd1110b | 160 | void PaceHeart::pace_V() |
oopakhooo | 3:641eefd1110b | 161 | { |
oopakhooo | 3:641eefd1110b | 162 | double amplitude = get_p_vPaceAmp(); |
oopakhooo | 3:641eefd1110b | 163 | double width = get_p_vPaceWidth(); |
oopakhooo | 3:641eefd1110b | 164 | // int output_pin = hardware.get_output_pin; //include the hardware module |
oopakhooo | 3:641eefd1110b | 165 | pace_V(amplitude,width,output_pin_V); |
oopakhooo | 3:641eefd1110b | 166 | return; |
oopakhooo | 3:641eefd1110b | 167 | } |
oopakhooo | 3:641eefd1110b | 168 | |
oopakhooo | 3:641eefd1110b | 169 | |
oopakhooo | 3:641eefd1110b | 170 | void PaceHeart::pace(int mode) |
oopakhooo | 3:641eefd1110b | 171 | { |
oopakhooo | 3:641eefd1110b | 172 | switch(mode){ |
oopakhooo | 3:641eefd1110b | 173 | case 1: //AOO |
oopakhooo | 3:641eefd1110b | 174 | pace_A(); |
oopakhooo | 3:641eefd1110b | 175 | case 2: //VOO |
oopakhooo | 3:641eefd1110b | 176 | pace_V(); |
oopakhooo | 3:641eefd1110b | 177 | } |
oopakhooo | 3:641eefd1110b | 178 | return; |
oopakhooo | 3:641eefd1110b | 179 | } |
oopakhooo | 3:641eefd1110b | 180 | |
oopakhooo | 3:641eefd1110b | 181 | void PaceHeart::pace() |
oopakhooo | 3:641eefd1110b | 182 | { |
oopakhooo | 3:641eefd1110b | 183 | int mode = get_p_pacingMode(); |
oopakhooo | 3:641eefd1110b | 184 | pace(mode); |
oopakhooo | 3:641eefd1110b | 185 | return; |
oopakhooo | 3:641eefd1110b | 186 | } |