Commit 01327d56 authored by fmg005's avatar fmg005

Added example code

parent ec58d407
......@@ -10,32 +10,61 @@
using namespace std;
int main() {
/*serial instance arguments*/
std::string port = "/dev/ttyUSB0"; // arbitrary port
std::string port = "/dev/ttyACM0";
uint32_t baudrate = 115200;
serial::Timeout timeout = serial::Timeout();
serial::bytesize_t bytesize = serial::eightbits;
serial::parity_t parity = serial::parity_none;
serial::stopbits_t stopbits = serial::stopbits_one;
serial::flowcontrol_t flowcontrol = serial::flowcontrol_hardware;
/*end serial instance arguments*/
CLA::LOGGER logger("mylog.log");
// or CLA::LOGGER logger; /* for timestamped logs */
serial::Serial myserial(port, baudrate, timeout, bytesize, parity, stopbits,
flowcontrol);
CLA::LOGGER logger;
serial::Serial myserial(port, baudrate, timeout, bytesize, parity, stopbits, flowcontrol);
HardwareSimulator simulator(&myserial, &logger);
/*
Do stuff with simulator object
*/
while(true) {
string s_input;
int input;
size_t* int_sz;
cout << "Select number to switch states"<<endl;
cout << "1.Remote Mode\n2.Local Mode\n3.Set IBP\n4.Get Mode\n5.Quit\n\n";
getline(cin, s_input);
input = stoi(s_input, int_sz);
if(input == 1) {
simulator.SetRemoteMode();
cout<<"\n";
}
else if(input == 2) {
simulator.SetLocalMode();
cout<<"\n";
}
else if(input == 3) {
double sys;
double diast;
string sys_string;
string diast_string;
size_t* sz;
cout <<"Enter the systolic pressure: ";
getline(cin, sys_string);
sys = stod(sys_string, sz);
cout <<"Enter the diastolic pressure: ";
getline(cin, diast_string);
diast = stod(diast_string, sz);
simulator.SetIBP(1, sys, diast);
cout<<"\n";
}
else if(input == 4) {
cout<<"Device is currently in "<<simulator.GetCurrentMode()<<" mode\n\n";
}
else if(input == 5) {
break;
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment