Commit b647581d authored by fmg005's avatar fmg005

got rid of the update realtime variables function

parent 79902024
......@@ -74,7 +74,7 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
SEHemorrhage hemorrhageLeg;
double initialMAP = 70.0;
double currentMAP;
bool START_HEMORRHAGE = true;
double hemorrhage_rate = 250;
bool STOP_HEMORRHAGE = false;
bool START_DEVICES = false;
CLA::Environment sim_env;
......@@ -105,13 +105,14 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
while (sim_env.time_index <= sim_env.simulation_timesteps ) {
currentMAP = pe->GetCardiovascularSystem()->GetMeanArterialPressure(PressureUnit::mmHg);
// event_hemorrage_start
if(sim_env.time_index == sim_env.simulation_injury_start_timestep && \
START_HEMORRHAGE) {
if(sim_env.time_index == sim_env.simulation_injury_start_timestep) {
// Hemorrhage Starts - instantiate a hemorrhage action and have the engine process it
logger->info("Hemorrhage Started");
logger->info("Patient hemorrhaging at a rate of "+ \
to_string((int)hemorrhage_rate)+ " mL/min");
hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg);
//the rate of hemorrhage
hemorrhageLeg.GetRate().SetValue(250,VolumePerTimeUnit::mL_Per_min);
hemorrhageLeg.GetRate().SetValue(hemorrhage_rate,VolumePerTimeUnit::mL_Per_min);
pe->ProcessAction(hemorrhageLeg);
STOP_HEMORRHAGE = true;
}
......@@ -120,11 +121,12 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg);
hemorrhageLeg.GetRate().SetValue(0,VolumePerTimeUnit::mL_Per_min);
pe->ProcessAction(hemorrhageLeg);
START_HEMORRHAGE = false;
STOP_HEMORRHAGE = false;
START_DEVICES = true; /* Begin real time simulation */
/* switch to realtime */
update_env_variables_for_realtime(sim_env);
/* update environment variables and switch to realtime */
sim_env.simulation_time = sim_env.simulation_realtime;
sim_env.simulation_timesteps = sim_env.time_index + \
sim_env.simulation_time/sim_env.pulse_advance_time;
logger->info("Realtime simulation started");
logger->info("Devices started");
}
......@@ -199,10 +201,3 @@ engine, const std::shared_ptr<Config>& cf, CLA::Environment& env) {
env.simulation_injury_start_timestep = env.simulation_injury_start/env.engine_timestep;
env.simulation_injury_stop_timestep = env.simulation_injury_stop/env.engine_timestep;
}// End Global_LoadConfig
void update_env_variables_for_realtime(CLA::Environment& env) {
env.simulation_timesteps = 0;
env.time_index = 0;
env.simulation_time = env.simulation_realtime;
env.simulation_timesteps = env.simulation_time/env.pulse_advance_time;
}
......@@ -10,6 +10,5 @@ using namespace libconfig;
void Simulation(const std::string, const std::shared_ptr<Config>&);
void Global_LoadConfig( std::shared_ptr<CLA::LOGGER>&, std::unique_ptr<PhysiologyEngine>&,
const std::shared_ptr<Config>&, CLA::Environment&);
void update_env_variables_for_realtime(CLA::Environment&);
#endif
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