CIS541 / Mbed 2 deprecated CIS541PM

Dependencies:   mbed mbed-rtos TextLCD

Committer:
shibulal
Date:
Mon Nov 30 20:29:58 2015 +0000
Revision:
4:242a71a6efed
Parent:
3:ac2e5aceb324
Child:
5:a74776e6504f
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shibulal 0:2d6b43fc4625 1 #include "mbed.h"
shibulal 1:e3a5388e46ab 2 #include "rtos.h"
shibulal 3:ac2e5aceb324 3 #include "TextLCD.h"
shibulal 2:b178e27d9f22 4 InterruptIn A(p8);
shibulal 2:b178e27d9f22 5 InterruptIn V(p9);
shibulal 3:ac2e5aceb324 6 int pacemakerrate;
shibulal 3:ac2e5aceb324 7 DigitalOut Apace(p10);
shibulal 3:ac2e5aceb324 8 DigitalOut Vpace(p11);
shibulal 3:ac2e5aceb324 9 DigitalOut ApaceLED(LED1);
shibulal 3:ac2e5aceb324 10 DigitalOut VpaceLED(LED2);
shibulal 3:ac2e5aceb324 11 DigitalOut AsigLED(LED3);
shibulal 3:ac2e5aceb324 12 DigitalOut VsigLED(LED4);
shibulal 3:ac2e5aceb324 13 TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2);
shibulal 1:e3a5388e46ab 14 Serial pc(USBTX, USBRX);
shibulal 3:ac2e5aceb324 15 Queue<char, 16> AVsigpmv;
shibulal 3:ac2e5aceb324 16 Queue<char, 16> AVsensepmv;
shibulal 3:ac2e5aceb324 17 Queue<char, 16> AVpacepmv;
shibulal 3:ac2e5aceb324 18 Queue<char, 16> AVsigpms;
shibulal 3:ac2e5aceb324 19 Queue<char, 16> AVsensepms;
shibulal 3:ac2e5aceb324 20 Queue<char, 16> AVpacepms;
shibulal 3:ac2e5aceb324 21 Queue<char, 16> AVsigpma;
shibulal 3:ac2e5aceb324 22 Queue<char, 16> AVsensepma;
shibulal 3:ac2e5aceb324 23 Queue<char, 16> AVpacepma;
shibulal 3:ac2e5aceb324 24 Queue<char, 16> AVsigpmm;
shibulal 3:ac2e5aceb324 25 Queue<char, 16> AVsensepmm;
shibulal 3:ac2e5aceb324 26 Queue<char, 16> AVpacepmm;
shibulal 3:ac2e5aceb324 27 Queue<char, 16> AVsigpmd;
shibulal 3:ac2e5aceb324 28 Queue<char, 16> AVsensepmd;
shibulal 3:ac2e5aceb324 29 Queue<char, 16> AVpacepmd;
shibulal 1:e3a5388e46ab 30 void PacemakerKeyboardInput(void const *args);
shibulal 1:e3a5388e46ab 31 void PacemakerModes(void const *args);
shibulal 3:ac2e5aceb324 32
shibulal 2:b178e27d9f22 33 void PacemakerSend(void const *args);
shibulal 3:ac2e5aceb324 34 void PaceMakerAtrialInterval(void const *args);
shibulal 3:ac2e5aceb324 35 void PaceMakerVentricalInterval(void const *args);
shibulal 3:ac2e5aceb324 36 int pacemakerMode;
shibulal 1:e3a5388e46ab 37 int modeSwitchTimeInterval = 5000;
shibulal 1:e3a5388e46ab 38 int flag=0;
shibulal 3:ac2e5aceb324 39 int PVAB;
shibulal 1:e3a5388e46ab 40 const int sleepModeURI = 1000;
shibulal 1:e3a5388e46ab 41 const int sleepModeLRI = 2000;
shibulal 1:e3a5388e46ab 42 const int normalModeURI = 600;
shibulal 1:e3a5388e46ab 43 const int normalModeLRI = 1500;
shibulal 1:e3a5388e46ab 44 const int sportsModeURI = 343;
shibulal 1:e3a5388e46ab 45 const int sportsModeLRI = 600;
shibulal 1:e3a5388e46ab 46 const int manualModeURI = 343;
shibulal 1:e3a5388e46ab 47 const int manualModeLRI = 2000;
shibulal 4:242a71a6efed 48 int low[4] = {30,40,100,30};
shibulal 4:242a71a6efed 49 int high[4] = {60,100,175,175};
shibulal 3:ac2e5aceb324 50 int pulses = 0;
shibulal 3:ac2e5aceb324 51 int pacemakerInterval = 10;
shibulal 4:242a71a6efed 52 int newpacemakerInterval;
shibulal 3:ac2e5aceb324 53 int heartInterval = 10;
shibulal 4:242a71a6efed 54 int paceMakerRate = 0;
shibulal 3:ac2e5aceb324 55 int heartRate = 0;
shibulal 1:e3a5388e46ab 56 int LRI = normalModeLRI;
shibulal 1:e3a5388e46ab 57 int URI = normalModeURI;
shibulal 1:e3a5388e46ab 58 Timer k;
shibulal 3:ac2e5aceb324 59 Timer r;
shibulal 2:b178e27d9f22 60 Timer p;
shibulal 3:ac2e5aceb324 61 Timer t_loc;
shibulal 3:ac2e5aceb324 62 Timer t;
shibulal 2:b178e27d9f22 63 const int PVARP = 150;
shibulal 2:b178e27d9f22 64 const int VRP = PVARP;
shibulal 2:b178e27d9f22 65 const int AVI = 65;
shibulal 1:e3a5388e46ab 66 char mode;
shibulal 1:e3a5388e46ab 67 char manualPace;
shibulal 2:b178e27d9f22 68 char AorV;
shibulal 2:b178e27d9f22 69 char AorVsense;
shibulal 1:e3a5388e46ab 70 Thread Pmki(PacemakerKeyboardInput,(void *) 0);
shibulal 2:b178e27d9f22 71 Thread Pmm(PacemakerModes,(void *) 0);
shibulal 3:ac2e5aceb324 72 Thread Pms (PacemakerSend, (void *) 0);
shibulal 3:ac2e5aceb324 73 Thread PmA (PaceMakerAtrialInterval, (void *) 0);
shibulal 3:ac2e5aceb324 74 Thread PmV (PaceMakerVentricalInterval, (void *) 0);
shibulal 1:e3a5388e46ab 75 void PacemakerKeyboardInput(void const *args){
shibulal 1:e3a5388e46ab 76 k.start();
shibulal 1:e3a5388e46ab 77 char input;
shibulal 1:e3a5388e46ab 78 while(true){
shibulal 1:e3a5388e46ab 79 input=pc.getc();
shibulal 1:e3a5388e46ab 80 if (k.read()>=modeSwitchTimeInterval && flag==0){
shibulal 1:e3a5388e46ab 81 if (input=='F'){
shibulal 1:e3a5388e46ab 82 mode='F';
shibulal 1:e3a5388e46ab 83 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 84 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 85 }
shibulal 1:e3a5388e46ab 86 else if (input=='S'){
shibulal 1:e3a5388e46ab 87 mode='S';
shibulal 1:e3a5388e46ab 88 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 89 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 90 }
shibulal 1:e3a5388e46ab 91 else if (input=='N'){
shibulal 1:e3a5388e46ab 92 mode='N';
shibulal 1:e3a5388e46ab 93 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 94 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 95 }
shibulal 1:e3a5388e46ab 96 else if (input=='O'){
shibulal 1:e3a5388e46ab 97 mode='O';
shibulal 4:242a71a6efed 98 input=pc.getc();
shibulal 4:242a71a6efed 99 newpacemakerInterval=10*(int)input;
shibulal 4:242a71a6efed 100 input=pc.getc();
shibulal 4:242a71a6efed 101 newpacemakerInterval=newpacemakerInterval+(int)input;
shibulal 1:e3a5388e46ab 102 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 103 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 104 }
shibulal 1:e3a5388e46ab 105 else if (input=='M'){
shibulal 1:e3a5388e46ab 106 mode='M';
shibulal 1:e3a5388e46ab 107 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 108 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 109 }
shibulal 1:e3a5388e46ab 110 else if (input=='A'){
shibulal 1:e3a5388e46ab 111 if (mode=='M')
shibulal 1:e3a5388e46ab 112 manualPace='A';
shibulal 1:e3a5388e46ab 113 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 114 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 115 }
shibulal 1:e3a5388e46ab 116 }
shibulal 1:e3a5388e46ab 117 else if (input=='V'){
shibulal 1:e3a5388e46ab 118 if (mode=='M'){
shibulal 2:b178e27d9f22 119
shibulal 1:e3a5388e46ab 120 manualPace='V';
shibulal 1:e3a5388e46ab 121 Pmm.signal_set(0x1);
shibulal 1:e3a5388e46ab 122 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 123 }
shibulal 1:e3a5388e46ab 124 }
shibulal 1:e3a5388e46ab 125 }
shibulal 1:e3a5388e46ab 126 }
shibulal 2:b178e27d9f22 127
shibulal 1:e3a5388e46ab 128
shibulal 1:e3a5388e46ab 129
shibulal 1:e3a5388e46ab 130 void PacemakerModes(void const *args){
shibulal 1:e3a5388e46ab 131 while(1){
shibulal 1:e3a5388e46ab 132 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 133 if (mode=='F'){
shibulal 1:e3a5388e46ab 134 LRI=sportsModeLRI;
shibulal 1:e3a5388e46ab 135 URI=sportsModeURI;
shibulal 2:b178e27d9f22 136 Pmki.signal_set(0x1);
shibulal 1:e3a5388e46ab 137 }
shibulal 1:e3a5388e46ab 138 else if (mode=='S'){
shibulal 1:e3a5388e46ab 139 LRI=sleepModeLRI;
shibulal 1:e3a5388e46ab 140 URI=sleepModeURI;
shibulal 2:b178e27d9f22 141 Pmki.signal_set(0x1);
shibulal 1:e3a5388e46ab 142 }
shibulal 1:e3a5388e46ab 143 else if (mode=='N'){
shibulal 1:e3a5388e46ab 144 LRI=normalModeLRI;
shibulal 1:e3a5388e46ab 145 URI=normalModeURI;
shibulal 2:b178e27d9f22 146 Pmki.signal_set(0x1);
shibulal 1:e3a5388e46ab 147 }
shibulal 1:e3a5388e46ab 148 else if (mode=='O'){
shibulal 4:242a71a6efed 149 pacemakerInterval=newpacemakerInterval;
shibulal 2:b178e27d9f22 150 Pmki.signal_set(0x1);
shibulal 1:e3a5388e46ab 151 }
shibulal 1:e3a5388e46ab 152 else if (mode=='M'){
shibulal 1:e3a5388e46ab 153 LRI=manualModeLRI;
shibulal 1:e3a5388e46ab 154 URI=manualModeURI;
shibulal 2:b178e27d9f22 155 Pmki.signal_set(0x1);
shibulal 1:e3a5388e46ab 156 while(1){
shibulal 1:e3a5388e46ab 157 Thread::signal_wait(0x1);
shibulal 1:e3a5388e46ab 158 if (mode=='M'){
shibulal 1:e3a5388e46ab 159 if (manualPace=='A'){
shibulal 3:ac2e5aceb324 160 char* element;
shibulal 3:ac2e5aceb324 161 *element='A';
shibulal 3:ac2e5aceb324 162 AVpacepms.put(element);
shibulal 3:ac2e5aceb324 163 AVpacepma.put(element);
shibulal 3:ac2e5aceb324 164 AVpacepmv.put(element);
shibulal 3:ac2e5aceb324 165 AVpacepmm.put(element);
shibulal 3:ac2e5aceb324 166 AVpacepmd.put(element);
shibulal 1:e3a5388e46ab 167 }
shibulal 1:e3a5388e46ab 168 else if (manualPace=='V'){
shibulal 3:ac2e5aceb324 169 char* element;
shibulal 3:ac2e5aceb324 170 *element='V';
shibulal 3:ac2e5aceb324 171 AVpacepms.put(element);
shibulal 3:ac2e5aceb324 172 AVpacepma.put(element);
shibulal 3:ac2e5aceb324 173 AVpacepmv.put(element);
shibulal 3:ac2e5aceb324 174 AVpacepmm.put(element);
shibulal 3:ac2e5aceb324 175 AVpacepmd.put(element);
shibulal 1:e3a5388e46ab 176 }
shibulal 1:e3a5388e46ab 177 }
shibulal 1:e3a5388e46ab 178 else {
shibulal 2:b178e27d9f22 179 Pmm.signal_set(0x1);
shibulal 2:b178e27d9f22 180 Pmki.signal_set(0x1);
shibulal 2:b178e27d9f22 181 break;
shibulal 2:b178e27d9f22 182 }
shibulal 2:b178e27d9f22 183 Pmki.signal_set(0x1);
shibulal 2:b178e27d9f22 184 }
shibulal 2:b178e27d9f22 185 }
shibulal 2:b178e27d9f22 186 }
shibulal 2:b178e27d9f22 187 }
shibulal 3:ac2e5aceb324 188
shibulal 3:ac2e5aceb324 189 void PaceMakerAtrialInterval(void const *args){
shibulal 3:ac2e5aceb324 190 char *AorVsig;
shibulal 3:ac2e5aceb324 191 char *AorVpace;
shibulal 3:ac2e5aceb324 192 char *AorVsense;
shibulal 3:ac2e5aceb324 193 osEvent evt;
shibulal 3:ac2e5aceb324 194 while (1){
shibulal 3:ac2e5aceb324 195 evt = AVsigpma.get(1);
shibulal 3:ac2e5aceb324 196 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 197 AorVsig = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 198 }
shibulal 3:ac2e5aceb324 199 if (*AorVsig=='A'){
shibulal 3:ac2e5aceb324 200 AorVsig=0;
shibulal 3:ac2e5aceb324 201 char* element;
shibulal 3:ac2e5aceb324 202 *element='A';
shibulal 3:ac2e5aceb324 203 AVsensepms.put(element);
shibulal 3:ac2e5aceb324 204 AVsensepma.put(element);
shibulal 3:ac2e5aceb324 205 AVsensepmv.put(element);
shibulal 3:ac2e5aceb324 206 AVsensepmm.put(element);
shibulal 3:ac2e5aceb324 207 AVsensepmd.put(element);
shibulal 3:ac2e5aceb324 208 break;
shibulal 3:ac2e5aceb324 209 }
shibulal 3:ac2e5aceb324 210 evt = AVpacepma.get(1);
shibulal 3:ac2e5aceb324 211 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 212 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 213 }
shibulal 3:ac2e5aceb324 214 if (*AorVpace=='A'){
shibulal 3:ac2e5aceb324 215 AorVpace=0;
shibulal 3:ac2e5aceb324 216 break;
shibulal 3:ac2e5aceb324 217 }
shibulal 3:ac2e5aceb324 218 }
shibulal 3:ac2e5aceb324 219 t.reset();
shibulal 2:b178e27d9f22 220 while(1){
shibulal 3:ac2e5aceb324 221 osEvent evt = AVsensepma.get(1);
shibulal 3:ac2e5aceb324 222 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 223 AorVsense = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 224 }
shibulal 3:ac2e5aceb324 225 if (*AorVsense=='V'){
shibulal 3:ac2e5aceb324 226 AorVsense=0;
shibulal 3:ac2e5aceb324 227 break;
shibulal 3:ac2e5aceb324 228 }
shibulal 3:ac2e5aceb324 229 evt = AVsensepma.get(1);
shibulal 3:ac2e5aceb324 230 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 231 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 232 }
shibulal 3:ac2e5aceb324 233 if (*AorVpace=='V'){
shibulal 3:ac2e5aceb324 234 *AorVpace='V';
shibulal 3:ac2e5aceb324 235 break;
shibulal 3:ac2e5aceb324 236 }
shibulal 3:ac2e5aceb324 237 }
shibulal 3:ac2e5aceb324 238 k.reset();
shibulal 3:ac2e5aceb324 239 while(!(k>=PVARP));
shibulal 3:ac2e5aceb324 240 while(!(t>=URI));
shibulal 3:ac2e5aceb324 241 }
shibulal 3:ac2e5aceb324 242 void updatePacemaker(){
shibulal 3:ac2e5aceb324 243 int temp = 60/pacemakerInterval;
shibulal 4:242a71a6efed 244 paceMakerRate = paceMakerRate + temp;
shibulal 3:ac2e5aceb324 245 }
shibulal 3:ac2e5aceb324 246 void PaceMakerDisplay(void const *args){
shibulal 3:ac2e5aceb324 247 osEvent evt;
shibulal 3:ac2e5aceb324 248 char* AorVsense;
shibulal 3:ac2e5aceb324 249 char* AorVpace;
shibulal 3:ac2e5aceb324 250 while(1){
shibulal 3:ac2e5aceb324 251
shibulal 3:ac2e5aceb324 252 while(1){
shibulal 3:ac2e5aceb324 253 evt = AVsensepmd.get(1);
shibulal 3:ac2e5aceb324 254 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 255 AorVsense = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 256 }
shibulal 3:ac2e5aceb324 257 if (*AorVsense=='V'){
shibulal 3:ac2e5aceb324 258 break;
shibulal 3:ac2e5aceb324 259 }
shibulal 3:ac2e5aceb324 260 evt = AVpacepmd.get(1);
shibulal 3:ac2e5aceb324 261 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 262 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 263 }
shibulal 3:ac2e5aceb324 264 if (*AorVpace=='V'){
shibulal 3:ac2e5aceb324 265 break;
shibulal 3:ac2e5aceb324 266 }
shibulal 3:ac2e5aceb324 267 }
shibulal 3:ac2e5aceb324 268 if (r<=pacemakerInterval*1000){
shibulal 3:ac2e5aceb324 269 updatePacemaker();
shibulal 3:ac2e5aceb324 270 }
shibulal 3:ac2e5aceb324 271 else {
shibulal 4:242a71a6efed 272 if (paceMakerRate < low[mode]){
shibulal 3:ac2e5aceb324 273 r.reset();
shibulal 3:ac2e5aceb324 274 paceMakerRate=0;
shibulal 3:ac2e5aceb324 275 }
shibulal 4:242a71a6efed 276 else if (paceMakerRate >= low[mode] && paceMakerRate <= high[mode]){
shibulal 3:ac2e5aceb324 277 //high alarm
shibulal 3:ac2e5aceb324 278 r.reset();
shibulal 3:ac2e5aceb324 279 paceMakerRate=0;
shibulal 3:ac2e5aceb324 280 }
shibulal 4:242a71a6efed 281 else if (paceMakerRate > high[mode]){
shibulal 3:ac2e5aceb324 282 //low alarm
shibulal 3:ac2e5aceb324 283 r.reset();
shibulal 3:ac2e5aceb324 284 paceMakerRate=0;
shibulal 3:ac2e5aceb324 285 }
shibulal 3:ac2e5aceb324 286 }
shibulal 3:ac2e5aceb324 287
shibulal 3:ac2e5aceb324 288
shibulal 3:ac2e5aceb324 289 }
shibulal 3:ac2e5aceb324 290 }
shibulal 3:ac2e5aceb324 291 void PaceMakerVentricalInterval(void const *args){
shibulal 3:ac2e5aceb324 292 char *AorVsig;
shibulal 3:ac2e5aceb324 293 char *AorVsense;
shibulal 3:ac2e5aceb324 294 char *AorVpace;
shibulal 3:ac2e5aceb324 295 osEvent evt;
shibulal 3:ac2e5aceb324 296 while(1){
shibulal 3:ac2e5aceb324 297 while(1){
shibulal 3:ac2e5aceb324 298 evt = AVsigpmv.get(1);
shibulal 3:ac2e5aceb324 299 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 300 AorVsig = (char*)evt.value.p;
shibulal 2:b178e27d9f22 301 }
shibulal 3:ac2e5aceb324 302 if (*AorVsig=='V'){
shibulal 3:ac2e5aceb324 303 AorVsig=0;
shibulal 3:ac2e5aceb324 304 char* element;
shibulal 3:ac2e5aceb324 305 *element='V';
shibulal 3:ac2e5aceb324 306 AVsensepms.put(element);
shibulal 3:ac2e5aceb324 307 AVsensepma.put(element);
shibulal 3:ac2e5aceb324 308 AVsensepmv.put(element);
shibulal 3:ac2e5aceb324 309 AVsensepmm.put(element);
shibulal 3:ac2e5aceb324 310 AVsensepmd.put(element);
shibulal 3:ac2e5aceb324 311 break;
shibulal 3:ac2e5aceb324 312 }
shibulal 3:ac2e5aceb324 313 evt = AVsensepmv.get(1);
shibulal 3:ac2e5aceb324 314 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 315 AorVsense = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 316 }
shibulal 3:ac2e5aceb324 317 if (*AorVsense=='A'){
shibulal 3:ac2e5aceb324 318 AorVsense=0;
shibulal 3:ac2e5aceb324 319 p.reset();
shibulal 3:ac2e5aceb324 320 while(!(p>=PVAB));
shibulal 3:ac2e5aceb324 321 while(1){
shibulal 3:ac2e5aceb324 322 osEvent evt = AVsigpmv.get(1);
shibulal 3:ac2e5aceb324 323 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 324 AorVsig = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 325 }
shibulal 3:ac2e5aceb324 326 if (*AorVsig=='V'){
shibulal 3:ac2e5aceb324 327 AorVsig=0;
shibulal 3:ac2e5aceb324 328 break;
shibulal 3:ac2e5aceb324 329 }
shibulal 3:ac2e5aceb324 330 evt = AVpacepmv.get(1);
shibulal 3:ac2e5aceb324 331 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 332 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 333 }
shibulal 3:ac2e5aceb324 334 if (*AorVpace=='V'){
shibulal 3:ac2e5aceb324 335 char* element;
shibulal 3:ac2e5aceb324 336 *element='V';
shibulal 3:ac2e5aceb324 337 AVsensepmv.put(element);
shibulal 3:ac2e5aceb324 338 break;
shibulal 3:ac2e5aceb324 339 }
shibulal 3:ac2e5aceb324 340 p.reset();
shibulal 3:ac2e5aceb324 341 while(!(p>=VRP));
shibulal 2:b178e27d9f22 342 }
shibulal 3:ac2e5aceb324 343 break;
shibulal 3:ac2e5aceb324 344 }
shibulal 3:ac2e5aceb324 345 evt = AVpacepmv.get(1);
shibulal 3:ac2e5aceb324 346 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 347 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 348 }
shibulal 3:ac2e5aceb324 349 if (*AorVpace=='A'){
shibulal 3:ac2e5aceb324 350 AorVpace=0;
shibulal 3:ac2e5aceb324 351 p.reset();
shibulal 3:ac2e5aceb324 352 while(!(p>=PVAB));
shibulal 3:ac2e5aceb324 353 while(1){
shibulal 3:ac2e5aceb324 354 osEvent evt = AVsigpmv.get(1);
shibulal 3:ac2e5aceb324 355 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 356 AorVsig = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 357 }
shibulal 3:ac2e5aceb324 358 if (*AorVsig=='V'){
shibulal 3:ac2e5aceb324 359 AorVsig=0;
shibulal 3:ac2e5aceb324 360 break;
shibulal 3:ac2e5aceb324 361 }
shibulal 3:ac2e5aceb324 362 evt = AVpacepmv.get(1);
shibulal 3:ac2e5aceb324 363 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 364 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 365 }
shibulal 3:ac2e5aceb324 366 if (*AorVpace=='V'){
shibulal 3:ac2e5aceb324 367 char* element;
shibulal 3:ac2e5aceb324 368 *element='V';
shibulal 3:ac2e5aceb324 369 AVsensepms.put(element);
shibulal 3:ac2e5aceb324 370 AVsensepma.put(element);
shibulal 3:ac2e5aceb324 371 AVsensepmv.put(element);
shibulal 3:ac2e5aceb324 372 AVsensepmm.put(element);
shibulal 3:ac2e5aceb324 373 AVsensepmd.put(element);
shibulal 3:ac2e5aceb324 374 break;
shibulal 3:ac2e5aceb324 375 }
shibulal 3:ac2e5aceb324 376 p.reset();
shibulal 3:ac2e5aceb324 377 while(!(p.read()>=VRP));
shibulal 3:ac2e5aceb324 378 }
shibulal 3:ac2e5aceb324 379 break;
shibulal 2:b178e27d9f22 380 }
shibulal 3:ac2e5aceb324 381 }
shibulal 3:ac2e5aceb324 382 }
shibulal 3:ac2e5aceb324 383
shibulal 3:ac2e5aceb324 384 }
shibulal 3:ac2e5aceb324 385 void PacemakerSend(void const *args){
shibulal 3:ac2e5aceb324 386 char *AorV;
shibulal 3:ac2e5aceb324 387 while(1){
shibulal 3:ac2e5aceb324 388 while(1){
shibulal 3:ac2e5aceb324 389 osEvent evt = AVsensepms.get(1);
shibulal 3:ac2e5aceb324 390 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 391 AorV = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 392 }
shibulal 3:ac2e5aceb324 393 if (*AorV=='A'){
shibulal 3:ac2e5aceb324 394 AorV=0;
shibulal 3:ac2e5aceb324 395 break;
shibulal 3:ac2e5aceb324 396 }
shibulal 3:ac2e5aceb324 397 else if (t.read()>=AVI){
shibulal 3:ac2e5aceb324 398 char* element;
shibulal 3:ac2e5aceb324 399 *element='V';
shibulal 3:ac2e5aceb324 400 AVpacepms.put(element);
shibulal 3:ac2e5aceb324 401 AVpacepmv.put(element);
shibulal 3:ac2e5aceb324 402 AVpacepma.put(element);
shibulal 3:ac2e5aceb324 403 Vpace=1;
shibulal 3:ac2e5aceb324 404 wait(.1);
shibulal 3:ac2e5aceb324 405 Vpace=0;
shibulal 3:ac2e5aceb324 406 break;
shibulal 3:ac2e5aceb324 407 }
shibulal 3:ac2e5aceb324 408 else if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 409 while(pacemakerMode!=0);
shibulal 3:ac2e5aceb324 410 break;
shibulal 3:ac2e5aceb324 411 }
shibulal 3:ac2e5aceb324 412 }
shibulal 3:ac2e5aceb324 413 while(1){
shibulal 3:ac2e5aceb324 414 osEvent evt = AVsensepms.get(1);
shibulal 3:ac2e5aceb324 415 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 416 AorV = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 417 }
shibulal 3:ac2e5aceb324 418 if (*AorV=='A'){
shibulal 3:ac2e5aceb324 419 AorV=0;
shibulal 3:ac2e5aceb324 420 if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 421 while(pacemakerMode!=0);
shibulal 2:b178e27d9f22 422 break;
shibulal 2:b178e27d9f22 423 }
shibulal 3:ac2e5aceb324 424 else{
shibulal 3:ac2e5aceb324 425 t.reset();
shibulal 1:e3a5388e46ab 426 break;
shibulal 1:e3a5388e46ab 427 }
shibulal 2:b178e27d9f22 428 }
shibulal 3:ac2e5aceb324 429 else if (*AorV=='V'){
shibulal 3:ac2e5aceb324 430 AorV=0;
shibulal 3:ac2e5aceb324 431 t.reset();
shibulal 3:ac2e5aceb324 432 while(1){
shibulal 3:ac2e5aceb324 433 osEvent evt = AVsensepms.get(1);
shibulal 3:ac2e5aceb324 434 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 435 AorV = (char*)evt.value.p;
shibulal 2:b178e27d9f22 436 }
shibulal 3:ac2e5aceb324 437 if (*AorV=='A'){
shibulal 3:ac2e5aceb324 438 AorV=0;
shibulal 3:ac2e5aceb324 439 if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 440 while(pacemakerMode!=0);
shibulal 3:ac2e5aceb324 441 break;
shibulal 3:ac2e5aceb324 442 }
shibulal 3:ac2e5aceb324 443 else{
shibulal 3:ac2e5aceb324 444 t.reset();
shibulal 3:ac2e5aceb324 445 break;
shibulal 3:ac2e5aceb324 446 }
shibulal 3:ac2e5aceb324 447 }
shibulal 3:ac2e5aceb324 448 else if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 449 while(pacemakerMode!=0);
shibulal 3:ac2e5aceb324 450 break;
shibulal 3:ac2e5aceb324 451 }
shibulal 3:ac2e5aceb324 452 else if (t>= LRI-AVI){
shibulal 3:ac2e5aceb324 453 char* element;
shibulal 3:ac2e5aceb324 454 *element='A';
shibulal 3:ac2e5aceb324 455 AVpacepms.put(element);
shibulal 3:ac2e5aceb324 456 AVpacepma.put(element);
shibulal 3:ac2e5aceb324 457 AVpacepmv.put(element);
shibulal 3:ac2e5aceb324 458 AVpacepmm.put(element);
shibulal 3:ac2e5aceb324 459 AVpacepmd.put(element);
shibulal 3:ac2e5aceb324 460 Apace=1;
shibulal 3:ac2e5aceb324 461 wait(.1);
shibulal 3:ac2e5aceb324 462 Apace=0;
shibulal 3:ac2e5aceb324 463 if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 464 while(pacemakerMode!=0);
shibulal 3:ac2e5aceb324 465 break;
shibulal 3:ac2e5aceb324 466 }
shibulal 3:ac2e5aceb324 467 else{
shibulal 3:ac2e5aceb324 468 t.reset();
shibulal 3:ac2e5aceb324 469 break;
shibulal 3:ac2e5aceb324 470 }
shibulal 3:ac2e5aceb324 471 }
shibulal 2:b178e27d9f22 472 }
shibulal 2:b178e27d9f22 473 }
shibulal 3:ac2e5aceb324 474 else if (t.read()>=LRI){
shibulal 3:ac2e5aceb324 475 char* element;
shibulal 3:ac2e5aceb324 476 *element='A';
shibulal 3:ac2e5aceb324 477 AVpacepms.put(element);
shibulal 3:ac2e5aceb324 478 AVpacepma.put(element);
shibulal 3:ac2e5aceb324 479 AVpacepmv.put(element);
shibulal 3:ac2e5aceb324 480 AVpacepmm.put(element);
shibulal 3:ac2e5aceb324 481 AVpacepmd.put(element);
shibulal 3:ac2e5aceb324 482 Apace=1;
shibulal 3:ac2e5aceb324 483 wait(.1);
shibulal 3:ac2e5aceb324 484 Apace=0;
shibulal 3:ac2e5aceb324 485 if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 486 while(pacemakerMode!=0);
shibulal 3:ac2e5aceb324 487 break;
shibulal 3:ac2e5aceb324 488 }
shibulal 3:ac2e5aceb324 489 else{
shibulal 3:ac2e5aceb324 490 t.reset();
shibulal 3:ac2e5aceb324 491 break;
shibulal 3:ac2e5aceb324 492 }
shibulal 2:b178e27d9f22 493 }
shibulal 3:ac2e5aceb324 494 else if (pacemakerMode==1){
shibulal 3:ac2e5aceb324 495 while(pacemakerMode!=0);
shibulal 2:b178e27d9f22 496 break;
shibulal 2:b178e27d9f22 497 }
shibulal 1:e3a5388e46ab 498
shibulal 2:b178e27d9f22 499
shibulal 3:ac2e5aceb324 500 }
shibulal 2:b178e27d9f22 501 }
shibulal 3:ac2e5aceb324 502 }
shibulal 3:ac2e5aceb324 503 void Asig();
shibulal 3:ac2e5aceb324 504 void Vsig();
shibulal 1:e3a5388e46ab 505 int main(){
shibulal 3:ac2e5aceb324 506 osEvent evt;
shibulal 3:ac2e5aceb324 507 A.mode(PullDown);
shibulal 3:ac2e5aceb324 508 char* AorVpace;
shibulal 3:ac2e5aceb324 509 char* AorVsig;
shibulal 2:b178e27d9f22 510 A.rise(Asig);
shibulal 2:b178e27d9f22 511 V.mode(PullDown);
shibulal 2:b178e27d9f22 512 V.rise(Vsig);
shibulal 1:e3a5388e46ab 513
shibulal 3:ac2e5aceb324 514 while(1){
shibulal 3:ac2e5aceb324 515 evt = AVpacepmm.get(1);
shibulal 3:ac2e5aceb324 516 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 517 AorVpace = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 518 }
shibulal 3:ac2e5aceb324 519 if (*AorVpace=='A'){
shibulal 3:ac2e5aceb324 520 AorVpace=0;
shibulal 3:ac2e5aceb324 521 ApaceLED=1;
shibulal 3:ac2e5aceb324 522 wait(.1);
shibulal 3:ac2e5aceb324 523 ApaceLED=(0);
shibulal 3:ac2e5aceb324 524 }
shibulal 3:ac2e5aceb324 525 else if (*AorVpace=='V'){
shibulal 3:ac2e5aceb324 526 AorVpace=0;
shibulal 3:ac2e5aceb324 527 VpaceLED=1;
shibulal 3:ac2e5aceb324 528 wait(.1);
shibulal 3:ac2e5aceb324 529 VpaceLED=0;
shibulal 3:ac2e5aceb324 530 }
shibulal 3:ac2e5aceb324 531 evt = AVsigpmm.get(1);
shibulal 3:ac2e5aceb324 532 if (evt.status == osEventMessage) {
shibulal 3:ac2e5aceb324 533 AorVsig = (char*)evt.value.p;
shibulal 3:ac2e5aceb324 534 }
shibulal 3:ac2e5aceb324 535 if (*AorVsig=='A'){
shibulal 3:ac2e5aceb324 536 AorVsig=0;
shibulal 3:ac2e5aceb324 537 AsigLED=1;
shibulal 3:ac2e5aceb324 538 wait(.1);
shibulal 3:ac2e5aceb324 539 ApaceLED=(0);
shibulal 3:ac2e5aceb324 540 }
shibulal 3:ac2e5aceb324 541 else if (*AorVsig=='V'){
shibulal 3:ac2e5aceb324 542 AorVsig=0;
shibulal 3:ac2e5aceb324 543 VsigLED=1;
shibulal 3:ac2e5aceb324 544 wait(.1);
shibulal 3:ac2e5aceb324 545 VpaceLED=0;
shibulal 3:ac2e5aceb324 546 }
shibulal 3:ac2e5aceb324 547 lcd.cls();
shibulal 4:242a71a6efed 548 lcd.printf("%d", paceMakerRate);
shibulal 3:ac2e5aceb324 549 Thread::wait(15);
shibulal 3:ac2e5aceb324 550 };
shibulal 0:2d6b43fc4625 551 }
shibulal 2:b178e27d9f22 552
shibulal 2:b178e27d9f22 553
shibulal 2:b178e27d9f22 554 void Asig() {
shibulal 3:ac2e5aceb324 555 char* element;
shibulal 3:ac2e5aceb324 556 *element='A';
shibulal 3:ac2e5aceb324 557 AVsigpms.put(element);
shibulal 3:ac2e5aceb324 558 AVsigpma.put(element);
shibulal 3:ac2e5aceb324 559 AVsigpmv.put(element);
shibulal 3:ac2e5aceb324 560 AVsigpmm.put(element);
shibulal 3:ac2e5aceb324 561 AVsigpmd.put(element);
shibulal 2:b178e27d9f22 562
shibulal 2:b178e27d9f22 563 }
shibulal 2:b178e27d9f22 564 void Vsig() {
shibulal 3:ac2e5aceb324 565 char* element;
shibulal 3:ac2e5aceb324 566 *element='V';
shibulal 3:ac2e5aceb324 567 AVsigpms.put(element);
shibulal 3:ac2e5aceb324 568 AVsigpma.put(element);
shibulal 3:ac2e5aceb324 569 AVsigpmv.put(element);
shibulal 3:ac2e5aceb324 570 AVsigpmm.put(element);
shibulal 3:ac2e5aceb324 571 AVsigpmd.put(element);
shibulal 2:b178e27d9f22 572
shibulal 2:b178e27d9f22 573 }