CIS441 Controller
Dependencies: TextLCD mbed-rtos mbed
Fork of PacemakerController by
Diff: PacemakerController.cpp
- Revision:
- 44:dfa38e4b3146
- Parent:
- 43:f28bc869321e
- Child:
- 45:ec9e76ccec6c
--- a/PacemakerController.cpp Wed Dec 02 06:41:57 2015 +0000 +++ b/PacemakerController.cpp Wed Dec 02 07:01:24 2015 +0000 @@ -15,7 +15,8 @@ int h_clock; int pm_clock; Timer avi_clk; -Timer t_count; +Timer sense_clk; +Timer pulse_clk; int LRI = 1000; int AVI = 300; @@ -134,37 +135,22 @@ void pm_sense(void const *args) { - while(1) { - /*if (agetSignal == 0) { - pc.printf("Aget:LO\n"); - } - - if (vgetSignal == 0) { - pc.printf("Vget:LO\n"); - } - if (agetSignal == 1) { - pc.printf("Aget:HI\n"); - } - - if (vgetSignal == 1) { - pc.printf("Vget:HI\n"); - }*/ - + while(1) { - if (t_count.read_ms() >= VRP && vgetSignal == 1) { + if (sense_clk.read_ms() >= VRP && vgetSignal == 1) { // Valid_V state - t_count.reset(); + sense_clk.reset(); vsense(); - } else if (t_count.read_ms() < VRP && vgetSignal == 1) { + } else if (sense_clk.read_ms() < VRP && vgetSignal == 1) { // Invalid_V state } - if (t_count.read_ms() < PVARP && agetSignal == 1) { + if (sense_clk.read_ms() < PVARP && agetSignal == 1) { // Invalid_A state - } else if (t_count.read_ms() >= PVARP && agetSignal == 1) { + } else if (sense_clk.read_ms() >= PVARP && agetSignal == 1) { // Valid_A state asense(); } @@ -175,61 +161,58 @@ { while(1) { - bool goInitalState = 1; - if (t_count.read_ms() >= LRI - AVI) { + bool goInitialState = 1; + if (pulse_clk.read_ms() >= LRI - AVI) { - goInitalState = 0; + goInitialState = 0; - // PM_A! sets the LED high - led_apace = 1; - avi_clk.reset(); + // PM_A! sets the LED high apace(); // At Atrial Event State while (avi_clk.read_ms() < AVI) { if (v_sense == 1) { - goInitalState = 1; + //sensed valid ventricular event + goInitialState = 1; + pulse_clk.reset(); break; } } - if (!goInitalState) { + if (!goInitialState) { // Ventricular Event - t_count.reset(); - + pulse_clk.reset(); + sense_clk.reset(); + // PM_V! sets the LED high - led_vpace = 1; - - t_count.reset(); pc.printf("in pmresponse 2"); vpace(); } - } else if (t_count.read_ms() < LRI - AVI) { + } else if (pulse_clk.read_ms() < LRI - AVI) { // if Asense, move on to atrial event if (a_sense == 1) { - goInitalState = 0; + goInitialState = 0; avi_clk.reset(); // At Atrial Event State while (avi_clk.read() < AVI) { if (v_sense == 1) { - goInitalState = 1; + pulse_clk.reset(); + goInitialState = 1; break; } } - - // Ventricular Event - t_count.reset(); - - // PM_V! sets the LED high - led_vpace = 1; - - t_count.reset(); - vpace(); + if (!goInitialState) { + // Ventricular Event + sense_clk.reset(); + pulse_clk.reset(); + + vpace(); + } } } } @@ -251,8 +234,8 @@ Thread t1(pm_sense, (void *)""); Thread t2(pm_response, (void *)""); Thread t3(PM_ALARM, (void *)""); - t_count.start(); - t_count.reset(); + sense_clk.start(); + pulse_clk.start(); while(1) { if (pc.readable()) {