a

Dependencies:   mbed

Fork of HelloWorld by Vincent Cheung

Committer:
kevinmadethis
Date:
Sat Oct 29 22:51:31 2016 +0000
Revision:
5:402ac8c92d76
Parent:
4:fb75731983cd
z;

Who changed what in which revision?

UserRevisionLine numberNew 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(){
kevinmadethis 4:fb75731983cd 9 int p_pacingState = 0;
kevinmadethis 4:fb75731983cd 10 int 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 //Ventricle
oopakhooo 3:641eefd1110b 15 double p_vPaceAmp = 3500.0;
oopakhooo 3:641eefd1110b 16 double p_vPaceWidth = 0.4;
oopakhooo 3:641eefd1110b 17 int p_VRP = 320;
oopakhooo 3:641eefd1110b 18 //Atrium (change defaults)
oopakhooo 3:641eefd1110b 19 double p_aPaceAmp = 3500.0;
oopakhooo 3:641eefd1110b 20 double p_aPaceWidth = 0.4;
oopakhooo 3:641eefd1110b 21 int p_ARP = 320;
oopakhooo 3:641eefd1110b 22 }
Judorunner 2:e2ae43e8acab 23
oopakhooo 3:641eefd1110b 24 int PaceHeart::get_p_pacingState()
Judorunner 2:e2ae43e8acab 25 {
Judorunner 2:e2ae43e8acab 26 return p_pacingState;
Judorunner 2:e2ae43e8acab 27 }
oopakhooo 3:641eefd1110b 28 int PaceHeart::get_p_pacingMode()
Judorunner 2:e2ae43e8acab 29 {
Judorunner 2:e2ae43e8acab 30 return p_pacingMode;
Judorunner 2:e2ae43e8acab 31 }
kevinmadethis 5:402ac8c92d76 32 void Pace::set_p_pacingMode(int mode)
kevinmadethis 5:402ac8c92d76 33 {
kevinmadethis 5:402ac8c92d76 34 p_pacingMode = mode;
kevinmadethis 5:402ac8c92d76 35 return;
kevinmadethis 5:402ac8c92d76 36 }
oopakhooo 3:641eefd1110b 37 int PaceHeart::get_p_hysteresis()
Judorunner 2:e2ae43e8acab 38 {
oopakhooo 3:641eefd1110b 39 return p_hysteresis;
Judorunner 2:e2ae43e8acab 40 }
kevinmadethis 5:402ac8c92d76 41 void PaceHeart::set_p_hysteresis(int hysteresis)
Judorunner 2:e2ae43e8acab 42 {
kevinmadethis 5:402ac8c92d76 43 p_hysteresis = hysteresis;
Judorunner 2:e2ae43e8acab 44 return;
Judorunner 2:e2ae43e8acab 45 }
oopakhooo 3:641eefd1110b 46 int PaceHeart::get_p_hysteresisInterval()
Judorunner 2:e2ae43e8acab 47 {
oopakhooo 3:641eefd1110b 48 return p_hysteresisInterval;
Judorunner 2:e2ae43e8acab 49 }
kevinmadethis 5:402ac8c92d76 50 void PaceHeart::set_p_hysteresisInterval(int hysteresisInterval)
Judorunner 2:e2ae43e8acab 51 {
kevinmadethis 5:402ac8c92d76 52 p_hysteresisInterval = hysteresisInterval;
Judorunner 2:e2ae43e8acab 53 return;
Judorunner 2:e2ae43e8acab 54 }
oopakhooo 3:641eefd1110b 55 int PaceHeart::get_lowrateInterval()
Judorunner 2:e2ae43e8acab 56 {
Judorunner 2:e2ae43e8acab 57 return lowrateInterval;
Judorunner 2:e2ae43e8acab 58 }
kevinmadethis 5:402ac8c92d76 59 void PaceHeart::set_lowrateInterval(int lowrateInterval)
Judorunner 2:e2ae43e8acab 60 {
kevinmadethis 5:402ac8c92d76 61 lowrateInterval = lowrateInterval;
Judorunner 2:e2ae43e8acab 62 return;
Judorunner 2:e2ae43e8acab 63 }
oopakhooo 3:641eefd1110b 64 //Ventricle
oopakhooo 3:641eefd1110b 65 double PaceHeart::get_p_vPaceAmp()
oopakhooo 3:641eefd1110b 66 {
oopakhooo 3:641eefd1110b 67 return p_vPaceAmp;
oopakhooo 3:641eefd1110b 68 }
kevinmadethis 5:402ac8c92d76 69 void PaceHeart::set_p_vPaceAmp(double vPaceAmp)
oopakhooo 3:641eefd1110b 70 {
kevinmadethis 5:402ac8c92d76 71 p_vPaceAmp = vPaceAmp;
oopakhooo 3:641eefd1110b 72 return;
oopakhooo 3:641eefd1110b 73 }
kevinmadethis 4:fb75731983cd 74
oopakhooo 3:641eefd1110b 75 double PaceHeart::get_p_vPaceWidth()
Judorunner 2:e2ae43e8acab 76 {
Judorunner 2:e2ae43e8acab 77 return p_vPaceWidth;
Judorunner 2:e2ae43e8acab 78 }
kevinmadethis 5:402ac8c92d76 79 void PaceHeart::set_p_vPaceWidth(double vPaceWidth)
Judorunner 2:e2ae43e8acab 80 {
kevinmadethis 5:402ac8c92d76 81 p_vPaceWidth = vPaceWidth;
Judorunner 2:e2ae43e8acab 82 return;
Judorunner 2:e2ae43e8acab 83 }
kevinmadethis 4:fb75731983cd 84
oopakhooo 3:641eefd1110b 85 int PaceHeart::get_p_VRP()
Judorunner 2:e2ae43e8acab 86 {
Judorunner 2:e2ae43e8acab 87 return p_VRP;
Judorunner 2:e2ae43e8acab 88 }
kevinmadethis 5:402ac8c92d76 89 void PaceHeart::set_p_VRP(int VRP)
Judorunner 2:e2ae43e8acab 90 {
kevinmadethis 5:402ac8c92d76 91 p_VRP = VRP;
Judorunner 2:e2ae43e8acab 92 return;
oopakhooo 3:641eefd1110b 93 }
oopakhooo 3:641eefd1110b 94 //Atrium
oopakhooo 3:641eefd1110b 95 double PaceHeart::get_p_aPaceAmp()
oopakhooo 3:641eefd1110b 96 {
oopakhooo 3:641eefd1110b 97 return p_aPaceAmp;
oopakhooo 3:641eefd1110b 98 }
kevinmadethis 5:402ac8c92d76 99 void PaceHeart::set_p_aPaceAmp(double aPaceAmp)
oopakhooo 3:641eefd1110b 100 {
kevinmadethis 5:402ac8c92d76 101 p_aPaceAmp = aPaceAmp;
oopakhooo 3:641eefd1110b 102 return;
oopakhooo 3:641eefd1110b 103 }
kevinmadethis 4:fb75731983cd 104
oopakhooo 3:641eefd1110b 105 double PaceHeart::get_p_aPaceWidth()
oopakhooo 3:641eefd1110b 106 {
oopakhooo 3:641eefd1110b 107 return p_aPaceWidth;
oopakhooo 3:641eefd1110b 108 }
kevinmadethis 5:402ac8c92d76 109 void PaceHeart::set_p_aPaceWidth(double aPaceWidth)
oopakhooo 3:641eefd1110b 110 {
kevinmadethis 5:402ac8c92d76 111 p_aPaceWidth = aPaceWidth;
oopakhooo 3:641eefd1110b 112 return;
oopakhooo 3:641eefd1110b 113 }
kevinmadethis 4:fb75731983cd 114
oopakhooo 3:641eefd1110b 115 int PaceHeart::get_p_ARP()
oopakhooo 3:641eefd1110b 116 {
oopakhooo 3:641eefd1110b 117 return p_ARP;
oopakhooo 3:641eefd1110b 118 }
kevinmadethis 5:402ac8c92d76 119 void PaceHeart::set_p_ARP(int ARP)
oopakhooo 3:641eefd1110b 120 {
kevinmadethis 5:402ac8c92d76 121 p_ARP = ARP;
oopakhooo 3:641eefd1110b 122 return;
oopakhooo 3:641eefd1110b 123 }
oopakhooo 3:641eefd1110b 124
oopakhooo 3:641eefd1110b 125
oopakhooo 3:641eefd1110b 126
oopakhooo 3:641eefd1110b 127 void PaceHeart::pace_A(double amp, double wid,int pin)
kevinmadethis 4:fb75731983cd 128 {
oopakhooo 3:641eefd1110b 129 output_pin_A = !output_pin_A ;
oopakhooo 3:641eefd1110b 130 wait(1);
kevinmadethis 4:fb75731983cd 131
kevinmadethis 4:fb75731983cd 132
kevinmadethis 4:fb75731983cd 133
oopakhooo 3:641eefd1110b 134 return;
oopakhooo 3:641eefd1110b 135 }
oopakhooo 3:641eefd1110b 136
oopakhooo 3:641eefd1110b 137 void PaceHeart::pace_A()
oopakhooo 3:641eefd1110b 138 {
oopakhooo 3:641eefd1110b 139 double amplitude = get_p_aPaceAmp();
oopakhooo 3:641eefd1110b 140 double width = get_p_aPaceWidth();
oopakhooo 3:641eefd1110b 141 // int output_pin = hardware.get_output_pin; //include the hardware module
oopakhooo 3:641eefd1110b 142 pace_A(amplitude,width,output_pin_A);
oopakhooo 3:641eefd1110b 143 return;
oopakhooo 3:641eefd1110b 144 }
oopakhooo 3:641eefd1110b 145
oopakhooo 3:641eefd1110b 146
kevinmadethis 5:402ac8c92d76 147 void PaceHeart::pace_V(double amp, double wid, int output_pin_V)
oopakhooo 3:641eefd1110b 148 {
oopakhooo 3:641eefd1110b 149 output_pin_V = !output_pin_V ;
oopakhooo 3:641eefd1110b 150 wait(2);
kevinmadethis 4:fb75731983cd 151
oopakhooo 3:641eefd1110b 152 return;
oopakhooo 3:641eefd1110b 153 }
oopakhooo 3:641eefd1110b 154
oopakhooo 3:641eefd1110b 155 void PaceHeart::pace_V()
oopakhooo 3:641eefd1110b 156 {
oopakhooo 3:641eefd1110b 157 double amplitude = get_p_vPaceAmp();
oopakhooo 3:641eefd1110b 158 double width = get_p_vPaceWidth();
oopakhooo 3:641eefd1110b 159 // int output_pin = hardware.get_output_pin; //include the hardware module
oopakhooo 3:641eefd1110b 160 pace_V(amplitude,width,output_pin_V);
oopakhooo 3:641eefd1110b 161 return;
oopakhooo 3:641eefd1110b 162 }
oopakhooo 3:641eefd1110b 163
oopakhooo 3:641eefd1110b 164
oopakhooo 3:641eefd1110b 165 void PaceHeart::pace(int mode)
oopakhooo 3:641eefd1110b 166 {
kevinmadethis 5:402ac8c92d76 167 set_p_pacingMode(mode);
oopakhooo 3:641eefd1110b 168 switch(mode){
oopakhooo 3:641eefd1110b 169 case 1: //AOO
oopakhooo 3:641eefd1110b 170 pace_A();
oopakhooo 3:641eefd1110b 171 case 2: //VOO
oopakhooo 3:641eefd1110b 172 pace_V();
oopakhooo 3:641eefd1110b 173 }
oopakhooo 3:641eefd1110b 174 return;
oopakhooo 3:641eefd1110b 175 }
oopakhooo 3:641eefd1110b 176
oopakhooo 3:641eefd1110b 177 void PaceHeart::pace()
oopakhooo 3:641eefd1110b 178 {
oopakhooo 3:641eefd1110b 179 int mode = get_p_pacingMode();
oopakhooo 3:641eefd1110b 180 pace(mode);
oopakhooo 3:641eefd1110b 181 return;
oopakhooo 3:641eefd1110b 182 }
kevinmadethis 4:fb75731983cd 183
kevinmadethis 4:fb75731983cd 184 bool PaceHeart::amp_inRange(double x)
kevinmadethis 4:fb75731983cd 185 {
kevinmadethis 4:fb75731983cd 186 if (x>=500 && x<=7000)
kevinmadethis 4:fb75731983cd 187 {
kevinmadethis 4:fb75731983cd 188 return true;
kevinmadethis 4:fb75731983cd 189 }
kevinmadethis 4:fb75731983cd 190 else
kevinmadethis 4:fb75731983cd 191 {
kevinmadethis 4:fb75731983cd 192 return false;
kevinmadethis 4:fb75731983cd 193 }
kevinmadethis 4:fb75731983cd 194 }
kevinmadethis 4:fb75731983cd 195
kevinmadethis 4:fb75731983cd 196 bool PaceHeart::dur_inRange(double x)
kevinmadethis 4:fb75731983cd 197 {
kevinmadethis 4:fb75731983cd 198 if (x>=0.1 && x<=1.9)
kevinmadethis 4:fb75731983cd 199 {
kevinmadethis 4:fb75731983cd 200 return true;
kevinmadethis 4:fb75731983cd 201 }
kevinmadethis 4:fb75731983cd 202 else
kevinmadethis 4:fb75731983cd 203 {
kevinmadethis 4:fb75731983cd 204 return false;
kevinmadethis 4:fb75731983cd 205 }
kevinmadethis 4:fb75731983cd 206 }
kevinmadethis 4:fb75731983cd 207
kevinmadethis 4:fb75731983cd 208 bool PaceHeart::width_inRange(int x)
kevinmadethis 4:fb75731983cd 209 {
kevinmadethis 4:fb75731983cd 210 if (x>=150 && x<=500)
kevinmadethis 4:fb75731983cd 211 {
kevinmadethis 4:fb75731983cd 212 return true;
kevinmadethis 4:fb75731983cd 213 }
kevinmadethis 4:fb75731983cd 214 else
kevinmadethis 4:fb75731983cd 215 {
kevinmadethis 4:fb75731983cd 216 return false;
kevinmadethis 4:fb75731983cd 217 }
kevinmadethis 4:fb75731983cd 218 }