Commit db9815b9 authored by fmg005's avatar fmg005

Realtime capability added

parent 66017e52
......@@ -6,7 +6,7 @@ CLA::LOGGER::LOGGER() {
}
CLA::LOGGER::LOGGER(const string& filename): m_filename(move(filename)) {
m_logstream.open(prosim_logs_dir+m_filename);
m_logstream.open(prosim_logs_dir+m_filename, ios::out|ios::binary);
}
string CLA::LOGGER::current_time(bool display_tz){
......
......@@ -10,6 +10,7 @@
#include "HardwareSimulator.h"
#include "CLA_Logger.h"
#include "SimulationEngine.h"
#include "Realtime.h"
// Include the various types you will be using in your code
#include "scenario/SEDataRequestManager.h"
......@@ -81,7 +82,8 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
HardwareSimulator prosim(&myserial, &logger, &sim_env);
prosim.LoadConfig(filepath);
//sim_env.logger = std::make_shared<SimulationLogger>(prosim_results_dir"SimulationEngineLog_"+patient_name+".txt");
CLA::Realtime rt(pe, &logger);
rt.LoadConfig(filepath);
bool STOP = false; // Execute stop hemmorrhage only once; without this it be executed for each timestep
bool DEVICES_START = false;
......@@ -118,9 +120,12 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
}
// track patient data
pe->GetEngineTracker()->TrackData(pe->GetSimulationTime(TimeUnit::s));
pe->AdvanceModelTime();
//pe->GetEngineTracker()->TrackData(pe->GetSimulationTime(TimeUnit::s));
//pe->AdvanceModelTime();
rt.AdvanceModelTime(1.0);
sim_env.time_index++;
pe->GetEngineTracker()->TrackData((double)sim_env.time_index);
}// End while looop
}// End Simulation function
......@@ -139,7 +144,8 @@ void Global_LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const std::sha
env->simulation_injury_start = cf->lookup("simulation.time.injury_start");
env->simulation_injury_stop = cf->lookup("simulation.time.injury_stop");
env->time_index = 0; // initialize the time index
env->engine_timestep = engine->GetTimeStep(TimeUnit::s);
//env->engine_timestep = engine->GetTimeStep(TimeUnit::s);
env->engine_timestep = 1.0;
env->simulation_timesteps = env->simulation_time / env->engine_timestep;
env->simulation_injury_start_timestep = env->simulation_injury_start/env->engine_timestep;
env->simulation_injury_stop_timestep = env->simulation_injury_stop/env->engine_timestep;
......
......@@ -61,6 +61,7 @@ set( my_srcs
CLA_Logger.cpp
#example.cpp
SimulationEngine.cpp
Realtime.cpp
)
add_executable(prosim ${my_srcs})
......
......@@ -3,14 +3,16 @@
prosim = {
delay_5_sec = 5.0; # Prosim delay-->arbitrary value
};
}
realtime = {
time_steps = 12.0; # How many simulation seconds result into 1s of real time
}
simulation = {
time = {
run = 3600.0; # Time -> Seconds # How long should simulation run
injury_start = 5.0; # When should injury be introduced to patient
run = 120.0; # Time -> Seconds # How long should simulation run
injury_start = 5.0; # When should injury be introduced to patient
injury_stop = 700.0; # When should injury be stopped
}
};
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