weeb grammers / Mbed 2 deprecated Assignment2

Dependencies:   mbed

Fork of HelloWorld by Vincent Cheung

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers interface.cpp Source File

interface.cpp

00001 #include "PaceHeart.h"
00002 #include <string>
00003 #include <iostream>
00004 
00005 using namespace std;
00006 
00007 void interface(){
00008     
00009 int initialize_settings = 1;
00010 while(initialize_settings ==1){
00011 
00012 
00013     PaceHeart* Pace = new PaceHeart(); //change contents based on constructor
00014 int VA;
00015 
00016 
00017 cout << "Enter 1 for atrium, 2 for ventricle: " << endl;
00018 cin >> VA;
00019 
00020 
00021 if (VA == 2){
00022     system ("CLS");
00023     int waveform = 0;
00024     cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
00025     cin >> waveform;
00026 
00027 
00028     if (waveform == 0){
00029         continue;
00030     }
00031     else if (waveform == 1){
00032     
00033         //Make sure reference to PaceHeart is correct
00034         double amplitude = Pace->get_p_vPaceAmp();
00035         cout << "Current amplitude is: " << amplitude << " mV." << endl;
00036 
00037 
00038         cout << "Set the amplitude for the ventricle in mV (or enter -1 to escape): " << endl;
00039         cin >> amplitude;
00040         if ((amplitude >= 500) && (amplitude <= 7000)) {
00041             cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
00042             Pace->set_p_vPaceAmp(amplitude);
00043         }
00044         else if (amplitude == -1) continue;
00045         else {
00046             cout << "Invalid input. Returning to main menu" << endl;
00047             system("PAUSE"); //use these to prompt user to return
00048 
00049         }
00050     }
00051     else if (waveform == 2){
00052 
00053 
00054         //Make sure reference to PaceHeart is correct
00055         int duration = Pace->get_p_VRP();
00056         cout << "Current duration is: " << duration << "msec. " << endl;
00057 
00058 
00059         cout << "Set the duration for the ventricle in msec (or enter -1 to escape): " << endl;
00060         cin >> duration;
00061         if ((duration >= 150) && (duration <= 500)) {
00062             cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
00063             Pace->set_p_VRP(duration);
00064         }
00065         else if (duration == -1) continue;
00066         else {
00067             cout << "Invalid input. Returning to main menu" << endl;
00068             system("PAUSE"); //use these to prompt user to return
00069         }
00070 
00071 
00072 
00073 
00074     }
00075     else if (waveform == 3){
00076         //Make sure reference to PaceHeart is correct
00077         double width = Pace->get_p_vPaceWidth();
00078         cout << "Current width is: " << width << "msec. " << endl;
00079 
00080 
00081         cout << "Set the width for the ventricle in msec (or enter -1 to escape): " << endl;
00082         cin >> width;
00083         if ((width >= 0.1) && (width <= 1.9)) {
00084             cout << "Valid input. Width is now set to " << width<< "msec" << endl;
00085         Pace->set_p_vPaceWidth(width);
00086         }
00087         else if (width == -1) continue;
00088         else {
00089             cout << "Invalid input. Returning to main menu" << endl;
00090             system("PAUSE"); //use these to prompt user to return
00091         }
00092 
00093 
00094     }
00095 
00096 
00097 }
00098 else if (VA == 1){
00099     system ("CLS");
00100     int waveform = 0;
00101     cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
00102     cin >> waveform;
00103     
00104     
00105     if (waveform == 0){
00106         continue;
00107     }
00108     else if (waveform == 1){
00109         
00110         //Make sure reference to PaceHeart is correct
00111         int amplitude = Pace->get_p_aPaceAmp();
00112         cout << "Current amplitude is: " << amplitude << " mV." << endl;
00113     
00114     
00115         cout << "Set the amplitude for the atrium in mV (or enter -1 to escape): " << endl;
00116         cin >> amplitude;
00117         if ((amplitude >= 500) && (amplitude <= 7000)) {
00118             cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
00119             Pace->set_p_aPaceAmp(amplitude);
00120         }
00121         else if (amplitude == -1) continue;
00122         else {
00123             cout << "Invalid input. Returning to main menu" << endl;
00124             system("PAUSE"); //use these to prompt user to return
00125     
00126     
00127         }
00128     }
00129     else if (waveform == 2){
00130     
00131     
00132         //Make sure reference to PaceHeart is correct
00133         int duration = Pace->get_p_ARP();
00134         cout << "Current duration is: " << duration << "msec. " << endl;
00135     
00136     
00137         cout << "Set the duration for the atrium in msec (or enter -1 to escape): " << endl;
00138         cin >> duration;
00139         if ((duration >= 150) && (duration <= 500)) {
00140             cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
00141             Pace->set_p_ARP(duration);
00142         }
00143         else if (duration == -1) continue;
00144         else {
00145             cout << "Invalid input. Returning to main menu" << endl;
00146             system("PAUSE"); //use these to prompt user to return
00147         }
00148         
00149         
00150         
00151         
00152     }
00153     else if (waveform == 3){
00154         //Make sure reference to PaceHeart is correct
00155         double width = Pace->get_p_aPaceWidth();
00156         cout << "Current width is: " << width << "msec. " << endl;
00157             
00158             
00159         cout << "Set the width for the atrium in msec (or enter -1 to escape): " << endl;
00160         cin >> width;
00161         if ((width >= 0.1) && (width <= 1.9)) {
00162             cout << "Valid input. Width is now set to " << width<< "msec" << endl;
00163             Pace->set_p_aPaceWidth(width);
00164         }
00165         else if (width == -1) continue;
00166         else {
00167             cout << "Invalid input. Returning to main menu" << endl;
00168             system("PAUSE"); //use these to prompt user to return
00169         }
00170         
00171         
00172     }
00173     //Checks if user wants to re-input settings
00174     cout << "Do you want to change any values? (1 to re-input all settings, 0 to start PaceMaker)" << endl;
00175     cin >> initialize_settings;
00176     
00177     
00178     }
00179     }
00180 }