Commit a37fa6fd authored by fmg005's avatar fmg005

modified files

parent 91bc991c
builds/ builds/
logs/ logs/
results/ results/
serial/
include/configure_prosim_paths.h include/configure_prosim_paths.h
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "CLA_Logger.h" #include "CLA_Logger.h"
#include "SimulationEngine.h" #include "SimulationEngine.h"
// Include the various types you will be using in your code // Include the various types you will be using in your code
#include "scenario/SEDataRequestManager.h" #include "scenario/SEDataRequestManager.h"
#include "patient/actions/SEHemorrhage.h" #include "patient/actions/SEHemorrhage.h"
...@@ -51,7 +49,6 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c ...@@ -51,7 +49,6 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
// Create the engine and load the patient // Create the engine and load the patient
std::unique_ptr<PhysiologyEngine> pe = CreatePulseEngine(prosim_results_dir+"SimulationEngine_"+patient_name+".log"); std::unique_ptr<PhysiologyEngine> pe = CreatePulseEngine(prosim_results_dir+"SimulationEngine_"+patient_name+".log");
pe->GetLogger()->Info("CLA_Prosim Simulation"); pe->GetLogger()->Info("CLA_Prosim Simulation");
//if (!pe->LoadStateFile("./states/StandardMale@0s.pba"))
if (!pe->LoadStateFile(pulse_state_dir+patient_name+"@0s.pba")) if (!pe->LoadStateFile(pulse_state_dir+patient_name+"@0s.pba"))
{ {
pe->GetLogger()->Error("Could not load state, check the error"); pe->GetLogger()->Error("Could not load state, check the error");
...@@ -64,13 +61,13 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c ...@@ -64,13 +61,13 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
pe->GetEngineTracker()->GetDataRequestManager().SetResultsFilename(prosim_results_dir+"PulseSimEngine_"+patient_name+".txt"); pe->GetEngineTracker()->GetDataRequestManager().SetResultsFilename(prosim_results_dir+"PulseSimEngine_"+patient_name+".txt");
SEHemorrhage hemorrhageLeg; SEHemorrhage hemorrhageLeg;
double initialMAP = 75.0;
double currentMAP; double currentMAP;
double initialMAP = 70.0;
CLA::Environment sim_env; CLA::Environment sim_env;
Global_LoadConfig(pe, cfg, filepath, &sim_env); Global_LoadConfig(pe, cfg, filepath, &sim_env);
/*serial instance arguments*/ /*serial instance arguments*/
std::string port = "/dev/ttySB0"; // arbitrary port std::string port = "/dev/ttyACM0"; // arbitrary port
uint32_t baudrate = 115200; uint32_t baudrate = 115200;
serial::Timeout timeout = serial::Timeout(); serial::Timeout timeout = serial::Timeout();
serial::bytesize_t bytesize = serial::eightbits; serial::bytesize_t bytesize = serial::eightbits;
...@@ -82,17 +79,19 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c ...@@ -82,17 +79,19 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
flowcontrol); flowcontrol);
CLA::LOGGER logger; /* for timestamped logs */ CLA::LOGGER logger; /* for timestamped logs */
HardwareSimulator prosim(&myserial, &logger, &sim_env); HardwareSimulator prosim(&myserial, &logger, &sim_env);
prosim.LoadConfig(pe, filepath); prosim.LoadConfig(filepath);
//sim_env.logger = std::make_shared<SimulationLogger>(prosim_results_dir"SimulationEngineLog_"+patient_name+".txt"); //sim_env.logger = std::make_shared<SimulationLogger>(prosim_results_dir"SimulationEngineLog_"+patient_name+".txt");
bool STOP = false; // Execute stop hemmorrhage only once; without this it be executed for each timestep bool STOP = false; // Execute stop hemmorrhage only once; without this it be executed for each timestep
bool DEVICES_START = false; bool DEVICES_START = false;
prosim.SetRemoteMode();
// stop when the set time is reached // stop when the set time is reached
while (sim_env.time_index <= sim_env.simulation_timesteps) { while (sim_env.time_index <= sim_env.simulation_timesteps) {
// event_hemorrage_start // event_hemorrage_start
if(sim_env.time_index == sim_env.simulation_injury_start_timestep ){ if(sim_env.time_index == sim_env.simulation_injury_start_timestep) {
// Hemorrhage Starts - instantiate a hemorrhage action and have the engine process it // Hemorrhage Starts - instantiate a hemorrhage action and have the engine process it
cout<<"\nHemorrhage Started at: "<<pe->GetSimulationTime(TimeUnit::s)<<endl; cout<<"\nHemorrhage Started at: "<<pe->GetSimulationTime(TimeUnit::s)<<endl;
hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg); hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg);
...@@ -104,7 +103,7 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c ...@@ -104,7 +103,7 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
currentMAP = pe->GetCardiovascularSystem()->GetMeanArterialPressure(PressureUnit::mmHg); currentMAP = pe->GetCardiovascularSystem()->GetMeanArterialPressure(PressureUnit::mmHg);
if( currentMAP <= initialMAP && STOP){ if( currentMAP <= initialMAP && STOP) {
cout<<"\nHemorrhage Stoppd at: "<<pe->GetSimulationTime(TimeUnit::s)<<endl; cout<<"\nHemorrhage Stoppd at: "<<pe->GetSimulationTime(TimeUnit::s)<<endl;
hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg); hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg);
hemorrhageLeg.GetRate().SetValue(0,VolumePerTimeUnit::mL_Per_min); hemorrhageLeg.GetRate().SetValue(0,VolumePerTimeUnit::mL_Per_min);
...@@ -113,9 +112,11 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c ...@@ -113,9 +112,11 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
DEVICES_START = true; // instruct devices to start DEVICES_START = true; // instruct devices to start
cout << "START DEVICES" << endl; cout << "START DEVICES" << endl;
} }
if (DEVICES_START) {
if(DEVICES_START) {
prosim.update(pe); prosim.update(pe);
} }
// track patient data // track patient data
pe->GetEngineTracker()->TrackData(pe->GetSimulationTime(TimeUnit::s)); pe->GetEngineTracker()->TrackData(pe->GetSimulationTime(TimeUnit::s));
pe->AdvanceModelTime(); pe->AdvanceModelTime();
......
...@@ -42,7 +42,7 @@ namespace CLA { ...@@ -42,7 +42,7 @@ namespace CLA {
void info(const T& t) { void info(const T& t) {
ss << t; ss << t;
m_logstream<<current_time(true)<<","<<set_level(LOGGER::INFO)<<","+ss.str()+"\n"; m_logstream<<current_time(true)<<","<<set_level(LOGGER::INFO)<<","+ss.str()+"\n";
cout<<current_time(false)<<":"<<set_level(LOGGER::INFO)<<":"+ss.str()<<endl; cout<<current_time(false)<<" ("<<set_level(LOGGER::INFO)<<") "+ss.str()<<endl;
ss.str(""); ss.str("");
ss.clear(); ss.clear();
} }
...@@ -53,7 +53,7 @@ namespace CLA { ...@@ -53,7 +53,7 @@ namespace CLA {
ss << t; ss << t;
m_logstream<<current_time(true)<<","<<set_level(LOGGER::WARNING)<<","+ss.str()+"\n"; m_logstream<<current_time(true)<<","<<set_level(LOGGER::WARNING)<<","+ss.str()+"\n";
cout<<current_time(false)<<":"<<set_level(LOGGER::WARNING)<<":"+ss.str()<<endl; cout<<current_time(false)<<" ("<<set_level(LOGGER::WARNING)<<") "+ss.str()<<endl;
ss.str(""); ss.str("");
ss.clear(); ss.clear();
} }
......
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