Commit 8a5bf2b6 authored by djk032's avatar djk032

added control object to publish control messages

parent 7e51fc4b
......@@ -10,6 +10,7 @@
#include "SimulationEngine.h"
#include "Timer.h"
#include "Pump.h"
#include "Control.h"
//types Pulse types will be using
#include "scenario/SEDataRequestManager.h"
#include "patient/actions/SEHemorrhage.h"
......@@ -33,6 +34,8 @@ int main() {
const char* filepath = f_path.c_str();
const string patient_name = "Hassan";
std::vector<std::string> patients{"Hassan", "Gus"};
try {
cf->readFile(filepath);
}
......@@ -44,7 +47,10 @@ int main() {
std::cerr <<"-"<< pex.getError() << std::endl;
}
/*start simulation*/
Simulation(patient_name, cf);
//Simulation(patient_name, cf);
for (auto patient: patients) {
Simulation(patient, cf);
}
}
void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
......@@ -75,6 +81,7 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
std::shared_ptr<CLA::LOGGER> logger = std::make_shared<CLA::LOGGER>(patient_name,patient_name);
//logger->setLevel("INFO");/*DEFAULT: DEBUG */
Global_LoadConfig(logger, pe, cfg, sim_env);
CLA::Control control(logger, "/control", "std_msgs/String");
std::map<std::string, CLA::Pump*> my_pumps; /* pumps */
/* Params: drug name, pump topic to subscribe to, type of data published on that topic*/
......@@ -84,13 +91,13 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
my_pumps["saline"] = &saline_pump;
/* simulated monitor */
SimMonitor sim_monitor(logger, sim_env, my_pumps);
sim_monitor.LoadConfig(pe);
//SimMonitor sim_monitor(logger, sim_env, my_pumps);
//sim_monitor.LoadConfig(pe);
/* prosim hardware */
//Prosim prosim(logger, sim_env, my_pumps);
//prosim.LoadConfig(pe);
//prosim.SetRemoteMode(); /* switch remote mode */
Prosim prosim(logger, sim_env, my_pumps);
prosim.LoadConfig(pe);
prosim.SetRemoteMode(); /* switch remote mode */
// stop when the set time is reached
while (sim_env.time_index <= sim_env.simulation_timesteps ) {
......@@ -120,10 +127,13 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
sim_env.simulation_time/sim_env.pulse_advance_time;
logger->info("Realtime simulation started");
logger->info("Devices started");
/* start executing algorithm */
control.publish_control_message("start");
}
/* We both track data and advance engine inside the update method */
if (START_DEVICES) {
sim_monitor.update(pe);
//sim_monitor.update(pe);
prosim.update(pe);
}
/* This stops running once realtime starts */
if (!START_DEVICES) {
......@@ -132,6 +142,8 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg)
}
sim_env.time_index++;
}// End while looop
/* stop executing algorith */
control.publish_control_message("stop");
}// End Simulation function
void Global_LoadConfig(std::shared_ptr<CLA::LOGGER>& logger, std::unique_ptr<PhysiologyEngine>&
......
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