weeb grammers / Mbed 2 deprecated Assignment2_ver6

Dependencies:   MotionSensor mbed

Fork of Assignment2_ver5 by weeb grammers

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PaceHeart.cpp Source File

PaceHeart.cpp

00001 #include "PaceHeart.h"
00002 #include "mbed.h"
00003 #include "Hardware.h"
00004 using namespace std;
00005 
00006 
00007 
00008 PaceHeart::PaceHeart(){
00009     
00010     p_pacingState = 0;
00011     p_pacingMode = 0;
00012     p_hysteresis = 0;
00013     p_hysteresisInterval = 300;
00014     p_lowrateInterval = 1000.0;
00015     p_uprateInterval = 500.0; //upper rate limit
00016 //Ventricle
00017     p_vPaceAmp = 3500.0;
00018     p_vPaceWidth = 0.4;
00019     p_VRP = 320;
00020 //Atrium (change defaults)
00021     p_aPaceAmp = 3500.0;
00022     p_aPaceWidth = 0.4;
00023     p_ARP = 320;
00024 }
00025 
00026 PaceHeart::PaceHeart(int mode){
00027     p_pacingState = 0;
00028     p_pacingMode = mode;
00029     p_lowrateInterval = 1000.0; //30-50->5 50-90->1 90-175->5 ppm
00030     p_uprateInterval = 2000.0; //upper rate limit 50-175->5 ppm
00031     p_maxSensorRate = 2000.0; //50-175->5 ppm
00032     
00033 //Ventricle
00034     p_vPaceAmp = 3500.0; //3500->0.1
00035     p_vPaceWidth = 0.4; //0.05->no change 0.1-1.9 0.1
00036 
00037     p_activityThresh = 4; //1-7 print out string with level ie. Med
00038     p_reactionTime = 30000; //10-50->10 seconds
00039     p_responseFactor = 8; //1-16->1
00040     p_recoveryTime = 300000; //2-16->1 minutes
00041 }
00042 int PaceHeart::get_p_pacingState()
00043 {
00044     return p_pacingState;
00045 }
00046 
00047 void PaceHeart::set_p_pacingMode(int x)
00048 {
00049     p_pacingMode = x;
00050     return;
00051 }
00052 
00053 int PaceHeart::get_p_pacingMode()//lets make it string in future
00054 {
00055     return p_pacingMode;
00056 }
00057 int PaceHeart::get_p_hysteresis()
00058 {
00059     return p_hysteresis;
00060 }
00061 void PaceHeart::set_p_hysteresis(int x)
00062 {
00063     p_hysteresis = x;
00064     return;
00065 }
00066 int PaceHeart::get_p_hysteresisInterval()
00067 {
00068     return p_hysteresisInterval;
00069 }
00070 void PaceHeart::set_p_hysteresisInterval(int x)
00071 {
00072     p_hysteresisInterval = x;
00073     return;
00074 }
00075 double PaceHeart::get_p_lowrateInterval()
00076 {
00077     return p_lowrateInterval;
00078 }
00079 void PaceHeart::set_p_lowrateInterval(double x)
00080 {
00081     if (p_pacingMode == 1) {
00082             
00083         if (dir ==1) // Change values to take into account for user inputs
00084         {
00085             if (p_lowrateInterval >=833.33 && p_lowrateInterval<=1483.33)
00086             {
00087                 p_lowrateInterval += 16.67;
00088             }
00089             else if (p_lowrateInterval >2833.33)
00090             {
00091                 return;
00092             }
00093             else
00094             {
00095                 p_lowrateInterval += 83.33;
00096             }
00097         }
00098         else if (dir==0)
00099         {
00100             if (p_lowrateInterval >=850 && p_lowrateInterval<=1500)
00101             {
00102                 p_lowrateInterval -= 16.67;
00103             }
00104             else if (p_lowrateInterval<583.33)
00105             {
00106                 return;
00107             }
00108             else
00109             {
00110                 p_lowrateInterval -= 83.33;
00111             }
00112         }
00113     }
00114     else {
00115         p_lowrateInterval = x;
00116     }
00117     return;
00118 }
00119 double PaceHeart::get_p_uprateInterval()
00120 {
00121     return p_uprateInterval;
00122 }
00123 void PaceHeart::set_p_uprateInterval(double x)
00124 {
00125     if (p_pacingMode == 1) {
00126         if (dir ==1) // Change values to take into account for user inputs
00127         {
00128             if (p_uprateInterval >=833.33 && p_uprateInterval<=2833.33)
00129             {
00130                 p_uprateInterval += 83.33;
00131             }
00132             else if (p_uprateInterval >2833.33)
00133             {
00134                 return;
00135             }
00136         }
00137         else if (dir==0)
00138         {
00139             if (p_uprateInterval >=916.67 && p_uprateInterval<=2916.67)
00140             {
00141                 p_uprateInterval -= 83.33;
00142             }
00143             else if (p_uprateInterval<916.67)
00144             {
00145                 return;
00146             }
00147         }
00148     }
00149     else {
00150         p_uprateInterval = x;
00151     }
00152     return;
00153 }
00154 double PaceHeart::get_p_maxSensorRate(){
00155     return p_maxSensorRate;
00156 }
00157 void PaceHeart::set_p_maxSensorRate(double x)
00158 {
00159     if (p_pacingMode == 1) {
00160         if (dir ==1) // Change values to take into account for user inputs
00161         {
00162             if (p_maxSensorRate >=833.33 && p_maxSensorRate<=2833.33)
00163             {
00164                 p_maxSensorRate += 83.33;
00165             }
00166             else if (p_maxSensorRate >2833.33)
00167             {
00168                 return;
00169             }
00170         }
00171         else if (dir==0)
00172         {
00173             if (p_maxSensorRate >=916.67 && p_maxSensorRate<=2916.67)
00174             {
00175                 p_maxSensorRate -= 83.33;
00176             }
00177             else if (p_maxSensorRate<916.67)
00178             {
00179                 return;
00180             }
00181         }
00182     }
00183     else {
00184         p_maxSensorRate = x;
00185     }
00186     return;
00187 }
00188 //Ventricle
00189 double PaceHeart::get_p_vPaceAmp()
00190 {
00191     return p_vPaceAmp;
00192 }
00193 void PaceHeart::set_p_vPaceAmp(double x)
00194 {
00195     if (p_pacingMode == 1) {
00196             
00197        if (dir ==1) // Change values to take into account for user inputs
00198         {
00199             if (p_vPaceAmp >=500 && p_vPaceAmp<=3100)
00200             {
00201                 p_vPaceAmp += 100;
00202             }
00203             else if (p_vPaceAmp >= 3500 && p_vPaceAmp<=6500)
00204             {
00205                 p_vPaceAmp += 500;
00206             }
00207             else
00208             {
00209                 return;
00210             }
00211         }
00212         else if (dir==0)
00213         {
00214             if (p_vPaceAmp >=600 && p_vPaceAmp<3200)
00215             {
00216                 p_vPaceAmp -= 100;
00217             }
00218             else if (p_vPaceAmp >= 4000 && p_vPaceAmp<=7000)
00219             {
00220                 p_vPaceAmp -= 500;
00221             }
00222             else
00223             {
00224                 return;
00225             }
00226         }
00227     }
00228     else {
00229     p_vPaceAmp = x;
00230     }
00231     return;
00232 }
00233  
00234 double PaceHeart::get_p_vPaceWidth()
00235 {
00236     return p_vPaceWidth;
00237 }
00238 void PaceHeart::set_p_vPaceWidth(double x)
00239 {
00240     if (p_pacingMode == 1) {
00241         if (p_vPaceWidth == 0.05) {
00242             p_vPaceWidth = 0.4;   
00243         }
00244         if (dir ==1){
00245             if (p_vPaceWidth >= 0.1 && p_vPaceWidth <= 1.8){
00246                 p_vPaceWidth += 0.1;
00247             }
00248             else {
00249                 return;
00250             }
00251         }
00252         else if (dir ==0) {
00253             if (p_vPaceWidth >= 0.2 && p_vPaceWidth <= 1.9){
00254                 p_vPaceWidth -= 0.1;
00255             }
00256             else {
00257                 return;
00258             }
00259         }
00260     }
00261     else {
00262         p_vPaceWidth = x;
00263     }
00264     return;
00265 }
00266  
00267 int PaceHeart::get_p_VRP()
00268 {
00269     return p_VRP;
00270 }
00271 void PaceHeart::set_p_VRP(int x)
00272 {
00273     p_VRP = x;
00274     return;
00275 }
00276 //Atrium
00277 double PaceHeart::get_p_aPaceAmp()
00278 {
00279     return p_aPaceAmp;
00280 }
00281 void PaceHeart::set_p_aPaceAmp(double x)
00282 {
00283     p_aPaceAmp = x;
00284     return;
00285 }
00286  
00287 double PaceHeart::get_p_aPaceWidth()
00288 {
00289     return p_aPaceWidth;
00290 }
00291 void PaceHeart::set_p_aPaceWidth(double x)
00292 {
00293     p_aPaceWidth = x;
00294     return;
00295 }
00296  
00297 int PaceHeart::get_p_ARP()
00298 {
00299     return p_ARP;
00300 }
00301 void PaceHeart::set_p_ARP(int x)
00302 {
00303     p_ARP = x;
00304     return;
00305 }
00306 
00307 
00308 
00309 void PaceHeart::pace_A(double amp, double wid)
00310 {   
00311     Output_A(amp,wid);
00312     return;
00313 }
00314 
00315 void PaceHeart::pace_A()
00316 {
00317     double amplitude = get_p_aPaceAmp();
00318     double width = get_p_aPaceWidth();
00319     pace_A(amplitude,width);
00320     return;
00321 }
00322 
00323 
00324 void PaceHeart::pace_V(double amp, double wid)
00325 {
00326     Output_V(amp,wid);
00327     return;
00328 }
00329 
00330 void PaceHeart::pace_V()
00331 {
00332     double amplitude = get_p_vPaceAmp();
00333     double width = get_p_vPaceWidth();
00334     pace_V(amplitude,width);
00335     return;
00336 }
00337 
00338 
00339 void PaceHeart::pace(int mode)
00340 {
00341     switch(mode){
00342     case 1:  //VOOR
00343            pace_V();
00344     case 0:  //VOO
00345            pace_V();
00346     }
00347     return;
00348 }
00349 
00350 void PaceHeart::pace()
00351 {
00352     int mode = get_p_pacingMode();
00353     pace(mode);
00354     return;
00355 }
00356 int PaceHeart::get_p_activityThresh()
00357 {
00358     return p_activityThresh;
00359 }
00360 int PaceHeart::get_p_reactionTime()
00361 {
00362     return p_reactionTime;
00363 }
00364 int PaceHeart::get_p_responseFactor()
00365 {
00366     return p_responseFactor;
00367 }
00368 int PaceHeart::get_p_recoveryTime()
00369 {
00370     return p_recoveryTime;
00371 }
00372 void PaceHeart::set_p_activityThresh(int x)
00373 {
00374     if (p_pacingMode == 1) {
00375         p_activityThresh=x; //no increment set at beginning
00376     }
00377     else {
00378         p_activityThresh=x;
00379     }
00380     return;
00381 }
00382 void PaceHeart::set_p_reactionTime(int x)
00383 {
00384     if (p_pacingMode == 1) {
00385         
00386         if (dir ==1){
00387             if (p_reactionTime >= 10000 && p_reactionTime <= 40000) {
00388                 p_reactionTime += 10000;
00389         }  
00390         else if (p_reactionTime >40000)
00391             {
00392                 return;
00393             }
00394         }
00395         else if (dir==0)
00396         {
00397             if (p_reactionTime >=20000 && p_reactionTime <=50000)
00398             {
00399                 p_reactionTime -= 10000;
00400             }
00401             else if (p_reactionTime < 20000)
00402             {
00403                 return;
00404             }
00405         }
00406     }
00407     else {
00408         p_reactionTime = x;
00409     }
00410     return;
00411 }
00412 void PaceHeart::set_p_responseFactor(int x)
00413 {
00414     if (p_pacingMode == 1) {
00415             
00416         if (dir ==1){
00417             if (p_responseFactor >= 1 && p_responseFactor <= 15) {
00418                 p_responseFactor += 1;
00419         }  
00420         else if (p_responseFactor >15)
00421             {
00422                 return;
00423             }
00424         }
00425         else if (dir==0)
00426         {
00427             if (p_responseFactor >=2 && p_responseFactor <=16)
00428             {
00429                 p_responseFactor -= 1;
00430             }
00431             else if (p_responseFactor < 2)
00432             {
00433                 return;
00434             }
00435         }
00436     }
00437     else {
00438         p_responseFactor=x;
00439     }
00440     return;
00441 }
00442 void PaceHeart::set_p_recoveryTime(int x)
00443 {
00444     if (p_pacingMode == 1) {
00445             
00446         if (dir ==1){
00447             if (p_recoveryTime >= 120000 && p_recoveryTime <= 900000) {
00448                 p_recoveryTime += 60000;
00449         }  
00450         else if (p_recoveryTime >900000)
00451             {
00452                 return;
00453             }
00454         }
00455         else if (dir==0)
00456         {
00457             if (p_recoveryTime >=180000 && p_recoveryTime <=960000)
00458             {
00459                 p_recoveryTime -= 60000;
00460             }
00461             else if (p_recoveryTime < 180000)
00462             {
00463                 return;
00464             }
00465         }
00466     }
00467     else {
00468         p_recoveryTime=x;
00469     }
00470     return;
00471 }
00472 void PaceHeart::set_dir(int x)
00473 {
00474     dir=x;
00475     return;
00476 }