Commit 87ae6213 authored by fmg005's avatar fmg005

added resp rate and oxygen saturation to send list

parent 2cf6433c
......@@ -21,10 +21,15 @@ void HardwareSimulator::update(std::unique_ptr<PhysiologyEngine>& engine) {
systolic_pressure = engine->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg);
diastolic_pressure = engine->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg);
heart_rate = engine->GetCardiovascularSystem()->GetHeartRate(FrequencyUnit::Per_min);
resp_rate = engine->GetRespiratorySystem()->GetRespirationRate(FrequencyUnit::Per_min);
oxygen_sat = engine->GetBloodChemistrySystem()->GetOxygenSaturation();
MAP = engine->GetCardiovascularSystem()->GetMeanArterialPressure(PressureUnit::mmHg);
/* send patient data to monitor */
SetIBP(1, systolic_pressure, diastolic_pressure);
SetHeartRate(heart_rate);
SetRespRate(resp_rate);
SetOxygenSat(oxygen_sat);
m_command_end = system_clock::now();
/*publish to dummy monitor topic for algorithm to capture */
......@@ -49,10 +54,10 @@ void HardwareSimulator::update(std::unique_ptr<PhysiologyEngine>& engine) {
m_total_duration_ms = duration_cast<milliseconds>(m_infusion_end - m_start).count();
/* log data */
m_logger->log_data(engine->GetSimulationTime(TimeUnit::s), \
m_action.get_bpdrug_rate(), m_action.get_saline_rate());
m_action.get_bpdrug_rate(), m_action.get_saline_rate());
/* log durations */
m_logger->log_duration(m_start,m_engine_duration_ms,m_command_duration_ms, \
m_infusion_duration_ms, m_total_duration_ms, m_next_update_time);
m_infusion_duration_ms, m_total_duration_ms, m_next_update_time);
/* checking if simulation will take longer than allotted 'time' */
if (m_total_duration_ms > m_next_update_time_duration_ms)
......@@ -107,11 +112,11 @@ void HardwareSimulator::SetRespRate(double rate) {
int resp_rate = static_cast<int>(rate);
if (rate >= 10 && rate < 100 ) {
SendCommand("RESPRATE=0"+std::to_string(resp_rate));
m_logger->info("Resp Rate: "+to_string(resp_rate)+" bprm");
m_logger->info("Resp Rate: "+to_string(resp_rate)+" bprm");
}
else if(rate > 99 && rate <=150) {
SendCommand("RESPRATE="+std::to_string(resp_rate));
m_logger->info("Resp Rate: "+to_string(resp_rate)+" bprm");
m_logger->info("Resp Rate: "+to_string(resp_rate)+" bprm");
}
else {
m_logger->warn("Respiratory rate value: "+to_string(resp_rate)+" not \
......@@ -121,7 +126,7 @@ void HardwareSimulator::SetRespRate(double rate) {
/* O2 range: 0-100 */
void HardwareSimulator::SetOxygenSat(double rate) {
int o2_rate = static_cast<int>(rate);
int o2_rate = static_cast<int>(rate*100);
/* prosim has a bug, monitor displays value which is 1 unit
higher than set value (for oxygen saturation)
*/
......@@ -130,15 +135,15 @@ void HardwareSimulator::SetOxygenSat(double rate) {
if (rate >= 0 && rate < 10) {
SendCommand("SAT=00"+s_rate);
m_logger->info("O2 Sat: "+ to_string(o2_rate));
m_logger->info("O2 Sat: "+ to_string(o2_rate));
}
else if(rate > 10 && rate < 100 ) {
SendCommand("SAT=0"+s_rate);
m_logger->info("O2 Sat: "+ to_string(o2_rate));
m_logger->info("O2 Sat: "+ to_string(o2_rate));
}
else if(rate == 100 ) {
SendCommand("SAT="+s_rate);
m_logger->info("O2 Sat: "+ to_string(o2_rate));
m_logger->info("O2 Sat: "+ to_string(o2_rate));
}
else {
m_logger->warn("Oxygen saturation value: "+to_string(o2_rate)+" not \
......
......@@ -23,6 +23,8 @@
#include "properties/SEScalarFrequency.h"
#include "engine/SEEngineTracker.h"
#include "system/physiology/SECardiovascularSystem.h"
#include "system/physiology/SEBloodChemistrySystem.h"
#include "system/physiology/SERespiratorySystem.h"
using namespace std;
using namespace libconfig;
......@@ -41,6 +43,8 @@ class HardwareSimulator {
double systolic_pressure;
double diastolic_pressure;
double heart_rate;
double resp_rate;
double oxygen_sat;
double MAP;
double advance_time;
double secs;
......
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