Commit 19b83884 authored by fmg005's avatar fmg005

Fixed bugs in algorithm 2 source files

parent 9a80b2ef
......@@ -54,31 +54,13 @@ void Controller::update(std::unique_ptr<PhysiologyEngine>& engine) {
}; // End Controller update()
void Controller::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const char* file_path) {
void Controller::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const std::shared_ptr<Config>& cf) {
try
{
// Read configration file
cfg.readFile(file_path);
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
}
// Extract the rate and assign it to m_rate_Hz
controller_rate_Hz = cfg.lookup("controller.rate");
controller_rate_Hz = cf->lookup("controller.rate");
Setting& root = cfg.getRoot();
Setting& root = cf->getRoot();
Setting& enabled = root["controller"]["patientData"]["enabled"];
......@@ -105,8 +87,8 @@ void Controller::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const cha
time_step = engine->GetTimeStep(TimeUnit::s);
//MAX_RATE_Hz = 1/time_step;
WAIT_10_MIN = cfg.lookup("controller.algorithm.wait_10");
WAIT_5_MIN = cfg.lookup("controller.algorithm.wait_5");
WAIT_10_MIN = cf->lookup("controller.algorithm.wait_10");
WAIT_5_MIN = cf->lookup("controller.algorithm.wait_5");
WAIT_10_MIN = (60 * WAIT_10_MIN)/time_step; // 10 min
WAIT_5_MIN = (60 * WAIT_5_MIN)/time_step; // 5 min
......
......@@ -2,7 +2,7 @@
// Constructor
MedicalDevice::MedicalDevice() :
MedicalDevice::MedicalDevice() :
m_rate_Hz(50.0), MAX_RATE_Hz(50.0) // Initialize member variables
{
......@@ -18,7 +18,8 @@ void MedicalDevice::update(std::unique_ptr<PhysiologyEngine>& engine) {
// Extract the rate from the configuration file
// str: path to configuration file
// Pure virtual function to be implemented in derived classes
void MedicalDevice::LoadConfig(std::unique_ptr<PhysiologyEngine>&, const char* str){
void
MedicalDevice::LoadConfig(std::unique_ptr<PhysiologyEngine>&, const std::shared_ptr<Config>& cf){
};
......
......@@ -66,26 +66,10 @@ void Monitor::update(std::unique_ptr<PhysiologyEngine>& engine) {
}
void Monitor::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const char* file_path) {
void Monitor::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const std::shared_ptr<Config>& cf) {
try
{
// Read configration file
m_cfg.readFile(file_path);
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
}
// Grab the monitor rates from config file
m_rate_Hz = m_cfg.lookup("monitor.input_rate");
output_rate_Hz = m_cfg.lookup("monitor.output_rate");
m_rate_Hz = cf->lookup("monitor.input_rate");
output_rate_Hz = cf->lookup("monitor.output_rate");
// Get engine time step/period
time_step = engine->GetTimeStep(TimeUnit::s);
......
......@@ -61,26 +61,13 @@ void Pump::update(std::unique_ptr<PhysiologyEngine>& engine) {
}
void Pump::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const char* file_path) {
void Pump::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, const
std::shared_ptr<Config>& cf) {
try
{
// Read configration file
m_cfg.readFile(file_path);
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
}
// Grab pump settings from config file
pump_rate_Hz = m_cfg.lookup("pump.rate");
pump_delay = m_cfg.lookup("pump.delay");
pump_rate_Hz = cf->lookup("pump.rate");
pump_delay = cf->lookup("pump.delay");
// Probably make these global
......
This diff is collapsed.
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