Commit a37fa6fd authored by fmg005's avatar fmg005

modified files

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