a

Dependencies:   mbed

Fork of HelloWorld by Vincent Cheung

interface.cpp

Committer:
kevinmadethis
Date:
2016-10-29
Revision:
4:fb75731983cd
Parent:
3:641eefd1110b

File content as of revision 4:fb75731983cd:

#include "PaceHeart.h"
#include <string>
#include <iostream>

using namespace std;

void interface(){

int initialize_settings = 1;
while(initialize_settings ==1){


    PaceHeart* Pace = new PaceHeart(); //change contents based on constructor
int VA;


cout << "Enter 1 for atrium, 2 for ventricle: " << endl;
cin >> VA;


if (VA == 2){
    system ("CLS");
    int waveform = 0;
    cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
    cin >> waveform;


    if (waveform == 0){
        continue;
    }
    else if (waveform == 1){

        //Make sure reference to PaceHeart is correct
        double amplitude = Pace->get_p_vPaceAmp();
        cout << "Current amplitude is: " << amplitude << " mV." << endl;


        cout << "Set the amplitude for the ventricle in mV (or enter -1 to escape): " << endl;
        cin >> amplitude;
        if (Pace->amp_inRange(amplitude)== true) {
            cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
            Pace->set_p_vPaceAmp(amplitude);
        }
        else if (amplitude == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return

        }
    }
    else if (waveform == 2){


        //Make sure reference to PaceHeart is correct
        int duration = Pace->get_p_VRP();
        cout << "Current duration is: " << duration << "msec. " << endl;


        cout << "Set the duration for the ventricle in msec (or enter -1 to escape): " << endl;
        cin >> duration;
        if (Pace->dur_inRange(duration)==true) {
            cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
            Pace->set_p_VRP(duration);
        }
        else if (duration == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return
        }




    }
    else if (waveform == 3){
        //Make sure reference to PaceHeart is correct
        double width = Pace->get_p_vPaceWidth();
        cout << "Current width is: " << width << "msec. " << endl;


        cout << "Set the width for the ventricle in msec (or enter -1 to escape): " << endl;
        cin >> width;
        if (Pace->width_inRange(width)==true) {
            cout << "Valid input. Width is now set to " << width<< "msec" << endl;
        Pace->set_p_vPaceWidth(width);
        }
        else if (width == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return
        }


    }


}
else if (VA == 1){
    system ("CLS");
    int waveform = 0;
    cout << "Enter 1 to change amplitude, 2 for duration, 3 for width, 0 to cancel: " << endl;
    cin >> waveform;


    if (waveform == 0){
        continue;
    }
    else if (waveform == 1){

        //Make sure reference to PaceHeart is correct
        int amplitude = Pace->get_p_aPaceAmp();
        cout << "Current amplitude is: " << amplitude << " mV." << endl;


        cout << "Set the amplitude for the atrium in mV (or enter -1 to escape): " << endl;
        cin >> amplitude;
        if (Pace->amp_inRange(amplitude)== true) {
            cout << "Valid input. Amplitude is now set to " << amplitude << "mV" << endl;
            Pace->set_p_aPaceAmp(amplitude);
        }
        else if (amplitude == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return


        }
    }
    else if (waveform == 2){


        //Make sure reference to PaceHeart is correct
        int duration = Pace->get_p_ARP();
        cout << "Current duration is: " << duration << "msec. " << endl;


        cout << "Set the duration for the atrium in msec (or enter -1 to escape): " << endl;
        cin >> duration;
        if (Pace->dur_inRange(duration)==true) {
            cout << "Valid input. Duration is now set to " << duration << "msec" << endl;
            Pace->set_p_ARP(duration);
        }
        else if (duration == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return
        }




    }
    else if (waveform == 3){
        //Make sure reference to PaceHeart is correct
        double width = Pace->get_p_aPaceWidth();
        cout << "Current width is: " << width << "msec. " << endl;


        cout << "Set the width for the atrium in msec (or enter -1 to escape): " << endl;
        cin >> width;
        if (Pace->width_inRange(width)==true) {
            cout << "Valid input. Width is now set to " << width<< "msec" << endl;
            Pace->set_p_aPaceWidth(width);
        }
        else if (width == -1) continue;
        else {
            cout << "Invalid input. Returning to main menu" << endl;
            system("PAUSE"); //use these to prompt user to return
        }


    }
    //Checks if user wants to re-input settings
    cout << "Do you want to change any values? (1 to re-input all settings, 0 to start PaceMaker)" << endl;
    cin >> initialize_settings;


    }
    }
}