Commit bcfe347e authored by fmg005's avatar fmg005

Added function to set invasive pressure

parent 857ed1f6
......@@ -11,7 +11,7 @@ bool HardwareSimulator::isOpen() {
}
/* HR range: 10-360 */
void HardwareSimulator::SetHeartRate(int rate) {
void HardwareSimulator::SetHeartRate(double rate) {
if (rate >= 10 && rate <= 360) {
SendCommand("NSRA=0"+std::to_string(rate));
......@@ -23,7 +23,7 @@ void HardwareSimulator::SetHeartRate(int rate) {
}
/* RR range: 10-150 */
void HardwareSimulator::SetRespRate(int rate) {
void HardwareSimulator::SetRespRate(double rate) {
if (rate >= 10 && rate <= 150) {
SendCommand("RESPRATE=0"+std::to_string(rate));
......@@ -35,7 +35,7 @@ void HardwareSimulator::SetRespRate(int rate) {
}
/* O2 range: 0-100 */
void HardwareSimulator::SetOxygenSat(int rate) {
void HardwareSimulator::SetOxygenSat(double rate) {
int i_rate = rate - 1;
std::string s_rate = std::to_string(i_rate);
......@@ -52,16 +52,49 @@ void HardwareSimulator::SetOxygenSat(int rate) {
}
}
// ToBeDefined
void HardwareSimulator::SetBloodPressure(int rate) {
/* IBP range: 0-300 */
void HardwareSimulator::SetIBP(int channel, double syst, double diast ) {
string s_syst = to_string(syst);
string s_diast = to_string(diast);
string s_channel = to_string(channel);
if (syst >= 0 && syst <= 300 && diast >= 0 && diast <= 300) {
if (syst < 10 && diast < 10) {
//SendCommand("IBPP="+s_channel+","+"00"+s_syst+","+"00"+s_diast);
m_logger->warning("IBP can't be this low: "+s_syst+"/"+s_diast);
}
else if (syst > 99 && diast > 99 && syst > diast) {
SendCommand("IBPP="+s_channel+","+s_syst+","+s_diast);
m_logger->info("IBP set to " +s_syst+ "/" +s_diast);
}
else if (syst > 99 && diast < 10) {
m_logger->warning("Invalid range between Systolic and Diastolic: "+s_syst+"/"+s_diast);
}
else if (syst > 99 && diast > 9 && diast < 100 && syst > diast) {
SendCommand("IBPP="+s_channel+","+s_syst+","+"0"+s_diast);
m_logger->info("IBP set to " +s_syst+ "/" +s_diast);
}
else if ( diast > syst) {
m_logger->warning("Systolic: "+s_syst+" can't be less than Diastolic: "+s_diast);
}
else if (syst > diast) {
SendCommand("IBPP="+s_channel+","+"0"+s_syst+","+"0"+s_diast);
m_logger->info("IBP set to " +s_syst+ "/" +s_diast);
}
}
else {
std::cout <<" Not within acceptable range 0-300\n";
m_logger->error("One of the set IBP values:"+s_syst+"/"+s_diast+" not within acceptable range 0-100");
}
}
void HardwareSimulator::SetRemoteMode() {
SendCommand("REMOTE");
m_logger->info("Device switched to REMOTE mode");
}
void HardwareSimulator::SetLocalMode() {
SendCommand("LOCAL");
m_logger->info("Device switched to LOCAL mode");
......
......@@ -15,7 +15,6 @@ class HardwareSimulator {
private:
serial::Serial* m_serial;
bool isRemoteMode();
void Clear();
size_t SendCommand(string);
string GetResponse();
......@@ -25,10 +24,10 @@ public:
HardwareSimulator(serial::Serial*, CLA::LOGGER*);
~HardwareSimulator();
bool isOpen();
void SetHeartRate(int);
void SetRespRate(int);
void SetOxygenSat(int);
void SetBloodPressure(int);
void SetHeartRate(double);
void SetRespRate(double);
void SetOxygenSat(double);
void SetIBP(int, double, double);
void SetRemoteMode();
void SetLocalMode();
string GetCurrentMode();
......
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