Vincent Cheung
/
HelloWorld
h
Fork of HelloWorld by
interface.cpp@5:afabac4fce1b, 2016-11-16 (annotated)
- Committer:
- oopakhooo
- Date:
- Wed Nov 16 21:44:03 2016 +0000
- Revision:
- 5:afabac4fce1b
- Parent:
- 3:641eefd1110b
serial params to interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oopakhooo | 3:641eefd1110b | 1 | #include "PaceHeart.h" |
oopakhooo | 3:641eefd1110b | 2 | #include <string> |
oopakhooo | 3:641eefd1110b | 3 | #include <iostream> |
oopakhooo | 3:641eefd1110b | 4 | |
oopakhooo | 3:641eefd1110b | 5 | using namespace std; |
oopakhooo | 3:641eefd1110b | 6 | |
oopakhooo | 3:641eefd1110b | 7 | void interface(){ |
oopakhooo | 3:641eefd1110b | 8 | |
oopakhooo | 3:641eefd1110b | 9 | int initialize_settings = 1; |
oopakhooo | 3:641eefd1110b | 10 | while(initialize_settings ==1){ |
oopakhooo | 3:641eefd1110b | 11 | |
oopakhooo | 3:641eefd1110b | 12 | |
oopakhooo | 3:641eefd1110b | 13 | PaceHeart* Pace = new PaceHeart(); //change contents based on constructor |
oopakhooo | 3:641eefd1110b | 14 | int VA; |
oopakhooo | 3:641eefd1110b | 15 | |
oopakhooo | 3:641eefd1110b | 16 | |
oopakhooo | 3:641eefd1110b | 17 | cout << "Enter 1 for atrium, 2 for ventricle: " << endl; |
oopakhooo | 3:641eefd1110b | 18 | cin >> VA; |
oopakhooo | 3:641eefd1110b | 19 | |
oopakhooo | 3:641eefd1110b | 20 | |
oopakhooo | 3:641eefd1110b | 21 | if (VA == 2){ |
oopakhooo | 3:641eefd1110b | 22 | system ("CLS"); |
oopakhooo | 3:641eefd1110b | 23 | int waveform = 0; |
oopakhooo | 3:641eefd1110b | 24 | cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl; |
oopakhooo | 3:641eefd1110b | 25 | cin >> waveform; |
oopakhooo | 3:641eefd1110b | 26 | |
oopakhooo | 3:641eefd1110b | 27 | |
oopakhooo | 3:641eefd1110b | 28 | if (waveform == 0){ |
oopakhooo | 3:641eefd1110b | 29 | continue; |
oopakhooo | 3:641eefd1110b | 30 | } |
oopakhooo | 3:641eefd1110b | 31 | else if (waveform == 1){ |
oopakhooo | 3:641eefd1110b | 32 | |
oopakhooo | 3:641eefd1110b | 33 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 34 | double amplitude = Pace->get_p_vPaceAmp(); |
oopakhooo | 3:641eefd1110b | 35 | cout << "Current amplitude is: " << amplitude << " mV." << endl; |
oopakhooo | 3:641eefd1110b | 36 | |
oopakhooo | 3:641eefd1110b | 37 | |
oopakhooo | 3:641eefd1110b | 38 | cout << "Set the amplitude for the ventricle in mV (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 39 | cin >> amplitude; |
oopakhooo | 3:641eefd1110b | 40 | if ((amplitude >= 500) && (amplitude <= 7000)) { |
oopakhooo | 3:641eefd1110b | 41 | cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl; |
oopakhooo | 3:641eefd1110b | 42 | Pace->set_p_vPaceAmp(amplitude); |
oopakhooo | 3:641eefd1110b | 43 | } |
oopakhooo | 3:641eefd1110b | 44 | else if (amplitude == -1) continue; |
oopakhooo | 3:641eefd1110b | 45 | else { |
oopakhooo | 3:641eefd1110b | 46 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 47 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 48 | |
oopakhooo | 3:641eefd1110b | 49 | } |
oopakhooo | 3:641eefd1110b | 50 | } |
oopakhooo | 3:641eefd1110b | 51 | else if (waveform == 2){ |
oopakhooo | 3:641eefd1110b | 52 | |
oopakhooo | 3:641eefd1110b | 53 | |
oopakhooo | 3:641eefd1110b | 54 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 55 | int duration = Pace->get_p_VRP(); |
oopakhooo | 3:641eefd1110b | 56 | cout << "Current duration is: " << duration << "msec. " << endl; |
oopakhooo | 3:641eefd1110b | 57 | |
oopakhooo | 3:641eefd1110b | 58 | |
oopakhooo | 3:641eefd1110b | 59 | cout << "Set the duration for the ventricle in msec (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 60 | cin >> duration; |
oopakhooo | 3:641eefd1110b | 61 | if ((duration >= 150) && (duration <= 500)) { |
oopakhooo | 3:641eefd1110b | 62 | cout << "Valid input. Duration is now set to " << duration << "msec" << endl; |
oopakhooo | 3:641eefd1110b | 63 | Pace->set_p_VRP(duration); |
oopakhooo | 3:641eefd1110b | 64 | } |
oopakhooo | 3:641eefd1110b | 65 | else if (duration == -1) continue; |
oopakhooo | 3:641eefd1110b | 66 | else { |
oopakhooo | 3:641eefd1110b | 67 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 68 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 69 | } |
oopakhooo | 3:641eefd1110b | 70 | |
oopakhooo | 3:641eefd1110b | 71 | |
oopakhooo | 3:641eefd1110b | 72 | |
oopakhooo | 3:641eefd1110b | 73 | |
oopakhooo | 3:641eefd1110b | 74 | } |
oopakhooo | 3:641eefd1110b | 75 | else if (waveform == 3){ |
oopakhooo | 3:641eefd1110b | 76 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 77 | double width = Pace->get_p_vPaceWidth(); |
oopakhooo | 3:641eefd1110b | 78 | cout << "Current width is: " << width << "msec. " << endl; |
oopakhooo | 3:641eefd1110b | 79 | |
oopakhooo | 3:641eefd1110b | 80 | |
oopakhooo | 3:641eefd1110b | 81 | cout << "Set the width for the ventricle in msec (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 82 | cin >> width; |
oopakhooo | 3:641eefd1110b | 83 | if ((width >= 0.1) && (width <= 1.9)) { |
oopakhooo | 3:641eefd1110b | 84 | cout << "Valid input. Width is now set to " << width<< "msec" << endl; |
oopakhooo | 3:641eefd1110b | 85 | Pace->set_p_vPaceWidth(width); |
oopakhooo | 3:641eefd1110b | 86 | } |
oopakhooo | 3:641eefd1110b | 87 | else if (width == -1) continue; |
oopakhooo | 3:641eefd1110b | 88 | else { |
oopakhooo | 3:641eefd1110b | 89 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 90 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 91 | } |
oopakhooo | 3:641eefd1110b | 92 | |
oopakhooo | 3:641eefd1110b | 93 | |
oopakhooo | 3:641eefd1110b | 94 | } |
oopakhooo | 3:641eefd1110b | 95 | |
oopakhooo | 3:641eefd1110b | 96 | |
oopakhooo | 3:641eefd1110b | 97 | } |
oopakhooo | 3:641eefd1110b | 98 | else if (VA == 1){ |
oopakhooo | 3:641eefd1110b | 99 | system ("CLS"); |
oopakhooo | 3:641eefd1110b | 100 | int waveform = 0; |
oopakhooo | 3:641eefd1110b | 101 | cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl; |
oopakhooo | 3:641eefd1110b | 102 | cin >> waveform; |
oopakhooo | 3:641eefd1110b | 103 | |
oopakhooo | 3:641eefd1110b | 104 | |
oopakhooo | 3:641eefd1110b | 105 | if (waveform == 0){ |
oopakhooo | 3:641eefd1110b | 106 | continue; |
oopakhooo | 3:641eefd1110b | 107 | } |
oopakhooo | 3:641eefd1110b | 108 | else if (waveform == 1){ |
oopakhooo | 3:641eefd1110b | 109 | |
oopakhooo | 3:641eefd1110b | 110 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 111 | int amplitude = Pace->get_p_aPaceAmp(); |
oopakhooo | 3:641eefd1110b | 112 | cout << "Current amplitude is: " << amplitude << " mV." << endl; |
oopakhooo | 3:641eefd1110b | 113 | |
oopakhooo | 3:641eefd1110b | 114 | |
oopakhooo | 3:641eefd1110b | 115 | cout << "Set the amplitude for the atrium in mV (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 116 | cin >> amplitude; |
oopakhooo | 3:641eefd1110b | 117 | if ((amplitude >= 500) && (amplitude <= 7000)) { |
oopakhooo | 3:641eefd1110b | 118 | cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl; |
oopakhooo | 3:641eefd1110b | 119 | Pace->set_p_aPaceAmp(amplitude); |
oopakhooo | 3:641eefd1110b | 120 | } |
oopakhooo | 3:641eefd1110b | 121 | else if (amplitude == -1) continue; |
oopakhooo | 3:641eefd1110b | 122 | else { |
oopakhooo | 3:641eefd1110b | 123 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 124 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 125 | |
oopakhooo | 3:641eefd1110b | 126 | |
oopakhooo | 3:641eefd1110b | 127 | } |
oopakhooo | 3:641eefd1110b | 128 | } |
oopakhooo | 3:641eefd1110b | 129 | else if (waveform == 2){ |
oopakhooo | 3:641eefd1110b | 130 | |
oopakhooo | 3:641eefd1110b | 131 | |
oopakhooo | 3:641eefd1110b | 132 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 133 | int duration = Pace->get_p_ARP(); |
oopakhooo | 3:641eefd1110b | 134 | cout << "Current duration is: " << duration << "msec. " << endl; |
oopakhooo | 3:641eefd1110b | 135 | |
oopakhooo | 3:641eefd1110b | 136 | |
oopakhooo | 3:641eefd1110b | 137 | cout << "Set the duration for the atrium in msec (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 138 | cin >> duration; |
oopakhooo | 3:641eefd1110b | 139 | if ((duration >= 150) && (duration <= 500)) { |
oopakhooo | 3:641eefd1110b | 140 | cout << "Valid input. Duration is now set to " << duration << "msec" << endl; |
oopakhooo | 3:641eefd1110b | 141 | Pace->set_p_ARP(duration); |
oopakhooo | 3:641eefd1110b | 142 | } |
oopakhooo | 3:641eefd1110b | 143 | else if (duration == -1) continue; |
oopakhooo | 3:641eefd1110b | 144 | else { |
oopakhooo | 3:641eefd1110b | 145 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 146 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 147 | } |
oopakhooo | 3:641eefd1110b | 148 | |
oopakhooo | 3:641eefd1110b | 149 | |
oopakhooo | 3:641eefd1110b | 150 | |
oopakhooo | 3:641eefd1110b | 151 | |
oopakhooo | 3:641eefd1110b | 152 | } |
oopakhooo | 3:641eefd1110b | 153 | else if (waveform == 3){ |
oopakhooo | 3:641eefd1110b | 154 | //Make sure reference to PaceHeart is correct |
oopakhooo | 3:641eefd1110b | 155 | double width = Pace->get_p_aPaceWidth(); |
oopakhooo | 3:641eefd1110b | 156 | cout << "Current width is: " << width << "msec. " << endl; |
oopakhooo | 3:641eefd1110b | 157 | |
oopakhooo | 3:641eefd1110b | 158 | |
oopakhooo | 3:641eefd1110b | 159 | cout << "Set the width for the atrium in msec (or enter -1 to escape): " << endl; |
oopakhooo | 3:641eefd1110b | 160 | cin >> width; |
oopakhooo | 3:641eefd1110b | 161 | if ((width >= 0.1) && (width <= 1.9)) { |
oopakhooo | 3:641eefd1110b | 162 | cout << "Valid input. Width is now set to " << width<< "msec" << endl; |
oopakhooo | 3:641eefd1110b | 163 | Pace->set_p_aPaceWidth(width); |
oopakhooo | 3:641eefd1110b | 164 | } |
oopakhooo | 3:641eefd1110b | 165 | else if (width == -1) continue; |
oopakhooo | 3:641eefd1110b | 166 | else { |
oopakhooo | 3:641eefd1110b | 167 | cout << "Invalid input. Returning to main menu" << endl; |
oopakhooo | 3:641eefd1110b | 168 | system("PAUSE"); //use these to prompt user to return |
oopakhooo | 3:641eefd1110b | 169 | } |
oopakhooo | 3:641eefd1110b | 170 | |
oopakhooo | 3:641eefd1110b | 171 | |
oopakhooo | 3:641eefd1110b | 172 | } |
oopakhooo | 3:641eefd1110b | 173 | //Checks if user wants to re-input settings |
oopakhooo | 3:641eefd1110b | 174 | cout << "Do you want to change any values? (1 to re-input all settings, 0 to start PaceMaker)" << endl; |
oopakhooo | 3:641eefd1110b | 175 | cin >> initialize_settings; |
oopakhooo | 3:641eefd1110b | 176 | |
oopakhooo | 3:641eefd1110b | 177 | |
oopakhooo | 3:641eefd1110b | 178 | } |
oopakhooo | 3:641eefd1110b | 179 | } |
oopakhooo | 3:641eefd1110b | 180 | } |