something

Dependencies:   mbed

Fork of HelloWorld by Vincent Cheung

Revision:
3:641eefd1110b
Parent:
2:e2ae43e8acab
Child:
5:45d58f8a5912
--- a/PaceHeart.cpp	Mon Oct 24 01:11:37 2016 +0000
+++ b/PaceHeart.cpp	Wed Oct 26 21:17:17 2016 +0000
@@ -1,76 +1,186 @@
 #include "PaceHeart.h"
+#include "mbed.h"
+#include "Hardware.h"
+using namespace std;
+
+
 
-int p_pacingState = 0;
-int p_pacingMode = 0;
-int p_hysteresis = 0;
-int p_hysterwaiaInterval = 300;
-int lowrateInterval = 1000;
-double p_vPacwAmp = 3500.0;
-double p_vPaceWidth = 0.4;
-int p_VRP = 320;
+PaceHeart::PaceHeart(){
+    p_pacingState = 0;
+    p_pacingMode = 0;
+    int p_hysteresis = 0;
+    int p_hysteresisInterval = 300;
+    int lowrateInterval = 1000;
+    int uprateInterval = 500; //upper rate limit
+//Ventricle
+    double p_vPaceAmp = 3500.0;
+    double p_vPaceWidth = 0.4;
+    int p_VRP = 320;
+//Atrium (change defaults)
+    double p_aPaceAmp = 3500.0;
+    double p_aPaceWidth = 0.4;
+    int p_ARP = 320;
+}
 
-int get_p_pacingState()
+int PaceHeart::get_p_pacingState()
 {
     return p_pacingState;
 }
-int get_p_pacingMode()
+int PaceHeart::get_p_pacingMode()
 {
     return p_pacingMode;
 }
-int get_p_hysteresis()
+int PaceHeart::get_p_hysteresis()
 {
-    return hysteresis;
+    return p_hysteresis;
 }
-void set_p_hysteresis(int x)
+void PaceHeart::set_p_hysteresis(int x)
 {
     p_hysteresis = x;
     return;
 }
-int get_p_hysterwaiaInterval()
+int PaceHeart::get_p_hysteresisInterval()
 {
-    return p_hysterwaiaInterval;
+    return p_hysteresisInterval;
 }
-void set_p_hysterwaiaInterval(int x)
+void PaceHeart::set_p_hysteresisInterval(int x)
 {
-    p_hysterwaiaInterval = x;
+    p_hysteresisInterval = x;
     return;
 }
-int get_lowrateInterval()
+int PaceHeart::get_lowrateInterval()
 {
     return lowrateInterval;
 }
-void set_lowrateInterval(int x)
+void PaceHeart::set_lowrateInterval(int x)
 {
     lowrateInterval = x;
     return;
 }
-
-double get_p_vPacwAmp()
+int PaceHeart::get_uprateInterval()
 {
-    return p_vPacwAmp;
+    return uprateInterval;
 }
-void set_p_vPacwAmp(double x)
+void PaceHeart::set_uprateInterval(int x)
 {
-    p_vPacwAmp = x;
+    uprateInterval = x;
     return;
 }
-
-double get_p_vPaceWidth()
+//Ventricle
+double PaceHeart::get_p_vPaceAmp()
+{
+    return p_vPaceAmp;
+}
+void PaceHeart::set_p_vPaceAmp(double x)
+{
+    p_vPaceAmp = x;
+    return;
+}
+ 
+double PaceHeart::get_p_vPaceWidth()
 {
     return p_vPaceWidth;
 }
-void set_p_vPaceWidth(double x)
+void PaceHeart::set_p_vPaceWidth(double x)
 {
     p_vPaceWidth = x;
     return;
 }
-
-int get_p_VRP()
+ 
+int PaceHeart::get_p_VRP()
 {
     return p_VRP;
 }
-void set_p_VRP(int x)
+void PaceHeart::set_p_VRP(int x)
 {
     p_VRP = x;
     return;
-}
\ No newline at end of file
+}
+//Atrium
+double PaceHeart::get_p_aPaceAmp()
+{
+    return p_aPaceAmp;
+}
+void PaceHeart::set_p_aPaceAmp(double x)
+{
+    p_aPaceAmp = x;
+    return;
+}
+ 
+double PaceHeart::get_p_aPaceWidth()
+{
+    return p_aPaceWidth;
+}
+void PaceHeart::set_p_aPaceWidth(double x)
+{
+    p_aPaceWidth = x;
+    return;
+}
+ 
+int PaceHeart::get_p_ARP()
+{
+    return p_ARP;
+}
+void PaceHeart::set_p_ARP(int x)
+{
+    p_ARP = x;
+    return;
+}
+
+
+
+void PaceHeart::pace_A(double amp, double wid,int pin)
+{   
+    output_pin_A = !output_pin_A ;
+    wait(1);
+   
+    
+   
+    return;
+}
+
+void PaceHeart::pace_A()
+{
+    double amplitude = get_p_aPaceAmp();
+    double width = get_p_aPaceWidth();
+    // int output_pin = hardware.get_output_pin; //include the hardware module
+    pace_A(amplitude,width,output_pin_A);
+    return;
+}
+
+
+void PaceHeart::pace_V(double amp, double wid, int pin)
+{
+    output_pin_V = !output_pin_V ;
+    wait(2);
+   
+    return;
+}
+
+void PaceHeart::pace_V()
+{
+    double amplitude = get_p_vPaceAmp();
+    double width = get_p_vPaceWidth();
+    // int output_pin = hardware.get_output_pin; //include the hardware module
+    pace_V(amplitude,width,output_pin_V);
+    return;
+}
+
+
+void PaceHeart::pace(int mode)
+{
+    switch(mode){
+    case 1:  //AOO
+           pace_A();
+    case 2:  //VOO
+           pace_V();
+    }
+    return;
+}
+
+void PaceHeart::pace()
+{
+    int mode = get_p_pacingMode();
+    pace(mode);
+    return;
+}