This is the implementation of the PhysiologyEngine interface for the this engines. More...

#include <Engine.h>

Inherits PhysiologyEngine, and PulseController.

Public Member Functions

 PulseEngine (Logger *logger, const std::string &data_dir=".")
 
 PulseEngine (const std::string &, const std::string &data_dir=".")
 
virtual ~PulseEngine ()
 
virtual bool SerializeFromFile (const std::string &file, SerializationFormat m)
 
virtual bool SerializeFromFile (const std::string &file, SerializationFormat m, const SEScalarTime *simTime, const SEEngineConfiguration *config)
 Reset engine and set it to the state in the provided file. You may provided a Simulation Time to be used if desired. It will be reflected in the GetSimulationTime method. Return value indicates engine was able to load provided state file. Engine will be in a cleared state if this method fails. Note the provided configuration will overwrite any configuration options in the state with its contents (Use with caution!) More...
 
virtual bool SerializeToFile (const std::string &file, SerializationFormat m) const
 Save the current state of the engine to provided filename. Engine will be in a cleared state if this method fails. More...
 
virtual bool SerializeFromString (const std::string &state, SerializationFormat m)
 
virtual bool SerializeFromString (const std::string &state, SerializationFormat m, const SEScalarTime *simTime, const SEEngineConfiguration *config)
 Reset engine and set it to the state in the provided string. The state is saved as bytes in the given string. Note that the bytes are binary, not text; we only use the string class as a convenient container. You may provided a Simulation Time to be used if desired. It will be reflected in the GetSimulationTime method. Return value indicates engine was able to load provided state file. Engine will be in a cleared state if this method fails. Note the provided configuration will overwrite any configuration options in the state with its contents (Use with caution!) More...
 
virtual bool SerializeToString (std::string &state, SerializationFormat m) const
 Save the current state of the engine. The state is saved as bytes in the given string. Note that the bytes are binary, not text; we only use the string class as a convenient container. Engine will be in a cleared state if this method fails. More...
 
virtual const SEConditionManagerGetConditionManager () const
 Get the Condition Manager. Allows a user to check the state of active conditions. More...
 
virtual LoggerGetLogger () const
 Retrieve the Logger associated with this engine. More...
 
virtual SEEngineTrackerGetEngineTracker () const
 Retrieve the SEEngineTracker associated with tracking data from this engine to a file The SEEngineTracker is a class set up to pull data requested from the engine (via SEDataRequest's) and provide access to the data easily (ex. to easily write data to csv files) More...
 
virtual bool InitializeEngine (const std::string &patient_configuration, SerializationFormat m, const SEEngineConfiguration *config=nullptr)
 locates the json patient file and reads in the values. More...
 
virtual bool InitializeEngine (const SEPatientConfiguration &patient_configuration, const SEEngineConfiguration *config=nullptr)
 This will create an engine that you can send instructions (patient,actions,conditions) to dynamically. The return value will indicate success failure of the creation of the engine. Some combinations of patients and conditions may prevent the engine from stabilizing. More...
 
virtual const SEEngineConfigurationGetConfiguration () const
 returns the engine configuration. More...
 
virtual double GetTimeStep (const TimeUnit &unit) const
 returns the engine time step that is used when advancing time. More...
 
virtual double GetSimulationTime (const TimeUnit &unit) const
 returns the current time of the simulation. More...
 
virtual void AdvanceModelTime ()
 executes one pass through the time loop of the engine at the fixed timestep More...
 
virtual void AdvanceModelTime (double time, const TimeUnit &unit)
 executes time loop of the engine beginning at the current time and running for the duration specified in the call at the fixed timestep More...
 
virtual bool ProcessAction (const SEAction &action)
 Execute the provided action. true will be returned if the engine supports the action false will be returned if the engine does not support the action. More...
 
virtual const SEActionManagerGetActionManager () const
 Get the Action Manager. Allows a user to check the state of active actions. More...
 
virtual SESubstanceManagerGetSubstanceManager ()
 Retrieves the associated substance manager. More...
 
virtual const SESubstanceManagerGetSubstanceManager () const
 
virtual void SetAdvanceHandler (SEAdvanceHandler *handler)
 Add a callback object that will be called after each timestep. More...
 
virtual void SetEventHandler (SEEventHandler *handler)
 Add a callback object that will be called whenever a pateint or anesthesia machine event changes state. More...
 
virtual const SEPatientGetPatient () const
 Returns the patient object used by the engine. More...
 
virtual bool GetPatientAssessment (SEPatientAssessment &assessment) const
 Determines the assessment type and fills the data object with current data. More...
 
virtual const SEEnvironmentGetEnvironment () const
 Returns the environment object used by the engine. More...
 
virtual const SEBloodChemistrySystemGetBloodChemistrySystem () const
 Returns the current state of the Blood Chemistry System. More...
 
virtual const SECardiovascularSystemGetCardiovascularSystem () const
 Returns the current state of the Cardiovascular System. More...
 
virtual const SEDrugSystemGetDrugSystem () const
 Returns the current state of the drug system. More...
 
virtual const SEEndocrineSystemGetEndocrineSystem () const
 Returns the current state of the Endocrine System. More...
 
virtual const SEEnergySystemGetEnergySystem () const
 Returns the current state of the Energy System. More...
 
virtual const SEGastrointestinalSystemGetGastrointestinalSystem () const
 Returns the current state of the Gastrointestinal System. More...
 
virtual const SEHepaticSystemGetHepaticSystem () const
 Returns the current state of the Hepatic System. More...
 
virtual const SENervousSystemGetNervousSystem () const
 Returns the current state of the Nervous System. More...
 
virtual const SERenalSystemGetRenalSystem () const
 Returns the current state of the Renal System. More...
 
virtual const SERespiratorySystemGetRespiratorySystem () const
 Returns the current state of the Respiratory System. More...
 
virtual const SETissueSystemGetTissueSystem () const
 Returns the current state of the tissue system. More...
 
virtual const SEAnesthesiaMachineGetAnesthesiaMachine () const
 Returns the current state of the Anesthesia machine. More...
 
virtual const SEElectroCardioGramGetElectroCardioGram () const
 Returns the current state of the Electrocardiogram machine. More...
 
virtual const SEInhalerGetInhaler () const
 Returns the current state of the Inhaler. More...
 
virtual const SECompartmentManagerGetCompartments () const
 Retrieves the engine compartments, providing such data as: flows, pressure, volume as well as substance volumes and volume fractions. More...
 
virtual void AdvanceCallback (double time_s)
 
- Public Member Functions inherited from PhysiologyEngine
virtual ~PhysiologyEngine ()
 
- Public Member Functions inherited from PulseController
 PulseController (Logger *logger, const std::string &data_dir=".")
 
 PulseController (const std::string &logfileName, const std::string &data_dir=".")
 
virtual ~PulseController ()
 
EngineState GetState ()
 
DataTrackGetDataTrack ()
 
SaturationCalculatorGetSaturationCalculator ()
 
PulseSubstancesGetSubstances ()
 
SEPatientGetPatient ()
 
bool GetPatientAssessment (SEPatientAssessment &assessment) const
 
SEBloodChemistrySystemGetBloodChemistry ()
 
SECardiovascularSystemGetCardiovascular ()
 
SEDrugSystemGetDrugs ()
 
SEEndocrineSystemGetEndocrine ()
 
SEEnergySystemGetEnergy ()
 
SEGastrointestinalSystemGetGastrointestinal ()
 
SEHepaticSystemGetHepatic ()
 
SENervousSystemGetNervous ()
 
SERenalSystemGetRenal ()
 
SERespiratorySystemGetRespiratory ()
 
SETissueSystemGetTissue ()
 
SEEnvironmentGetEnvironment ()
 
SEAnesthesiaMachineGetAnesthesiaMachine ()
 
SEElectroCardioGramGetECG ()
 
SEInhalerGetInhaler ()
 
SEActionManagerGetActions ()
 
SEConditionManagerGetConditions ()
 
PulseCircuitsGetCircuits ()
 
PulseCompartmentsGetCompartments ()
 
const PulseConfigurationGetConfiguration ()
 
const SEScalarTimeGetEngineTime ()
 
const SEScalarTimeGetSimulationTime ()
 
const SEScalarTimeGetTimeStep ()
 
eAirwayMode GetAirwayMode ()
 
void SetAirwayMode (eAirwayMode mode)
 
eSwitch GetIntubation ()
 
void SetIntubation (eSwitch s)
 
bool CreateCircuitsAndCompartments ()
 
- Public Member Functions inherited from Loggable
 Loggable ()
 
 Loggable (Logger *log)
 
virtual ~Loggable ()
 
virtual void Debug (std::string const &msg, std::string const &origin=empty) const
 
virtual void Debug (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Debug (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Info (std::string const &msg, std::string const &origin=empty) const
 
virtual void Info (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Info (const std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Info (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Warning (std::string const &msg, std::string const &origin=empty) const
 
virtual void Warning (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Warning (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Error (std::string const &msg, std::string const &origin=empty) const
 
virtual void Error (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Error (std::ostream &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::string const &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::stringstream &msg, std::string const &origin=empty) const
 
virtual void Fatal (std::ostream &msg, std::string const &origin=empty) const
 

Protected Member Functions

virtual bool IsReady () const
 
- Protected Member Functions inherited from PulseController
void SetupCardiovascular ()
 
void SetupRenal ()
 
void SetupTissue ()
 
void SetupGastrointestinal ()
 
void SetupRespiratory ()
 
void SetupAnesthesiaMachine ()
 
void SetupInhaler ()
 
void SetupMechanicalVentilator ()
 
void SetupExternalTemperature ()
 
void SetupInternalTemperature ()
 
bool Initialize (const PulseConfiguration *config)
 
bool SetupPatient ()
 
virtual void AtSteadyState (EngineState state)
 
void PreProcess ()
 
void Process ()
 
void PostProcess ()
 
void ForwardFatal (const std::string &msg, const std::string &origin)
 
- Protected Member Functions inherited from LoggerForward
virtual void ForwardDebug (std::string const &msg, std::string const &origin)
 
virtual void ForwardInfo (std::string const &msg, std::string const &origin)
 
virtual void ForwardWarning (std::string const &msg, std::string const &origin)
 
virtual void ForwardError (std::string const &msg, std::string const &origin)
 

Protected Attributes

SEEngineTrackerm_EngineTrack
 
std::stringstream m_ss
 
- Protected Attributes inherited from PulseController
EngineState m_State
 
DataTrackm_DataTrack
 
std::unique_ptr< SEScalarTimem_CurrentTime
 
std::unique_ptr< SEScalarTimem_SimulationTime
 
eAirwayMode m_AirwayMode
 
eSwitch m_Intubation
 
std::unique_ptr< PulseConfigurationm_Config
 
std::unique_ptr< SaturationCalculatorm_SaturationCalculator
 
std::unique_ptr< PulseSubstancesm_Substances
 
std::unique_ptr< SEActionManagerm_Actions
 
std::unique_ptr< SEConditionManagerm_Conditions
 
std::unique_ptr< PulseCircuitsm_Circuits
 
std::unique_ptr< PulseCompartmentsm_Compartments
 
std::unique_ptr< Environmentm_Environment
 
std::unique_ptr< BloodChemistrym_BloodChemistrySystem
 
std::unique_ptr< Cardiovascularm_CardiovascularSystem
 
std::unique_ptr< Endocrinem_EndocrineSystem
 
std::unique_ptr< Energym_EnergySystem
 
std::unique_ptr< Gastrointestinalm_GastrointestinalSystem
 
std::unique_ptr< Hepaticm_HepaticSystem
 
std::unique_ptr< Nervousm_NervousSystem
 
std::unique_ptr< Renalm_RenalSystem
 
std::unique_ptr< Respiratorym_RespiratorySystem
 
std::unique_ptr< Drugsm_DrugSystem
 
std::unique_ptr< Tissuem_TissueSystem
 
std::unique_ptr< ECGm_ECG
 
std::unique_ptr< AnesthesiaMachinem_AnesthesiaMachine
 
std::unique_ptr< Inhalerm_Inhaler
 
std::unique_ptr< SEPatientm_Patient
 
bool myLogger
 
SEEventHandlerm_EventHandler
 
SEAdvanceHandlerm_AdvanceHandler
 
std::string m_DataDir
 
- Protected Attributes inherited from Loggable
Loggerm_Logger
 

Friends

class PBPulseState
 

Additional Inherited Members

- Static Public Attributes inherited from Loggable
static const std::string empty
 

Detailed Description

This is the implementation of the PhysiologyEngine interface for the this engines.

It contains the necessary execution calls, patient customization calls, insult and intervention calls as well as assessment calls for obtaining the results. During engine execution a log files is generated containing information, warning and error data.

Constructor & Destructor Documentation

◆ PulseEngine() [1/2]

PulseEngine::PulseEngine ( Logger logger,
const std::string &  data_dir = "." 
)

◆ PulseEngine() [2/2]

PulseEngine::PulseEngine ( const std::string &  logFileName,
const std::string &  data_dir = "." 
)

◆ ~PulseEngine()

PulseEngine::~PulseEngine ( )
virtual

Member Function Documentation

◆ AdvanceCallback()

void PulseEngine::AdvanceCallback ( double  time_s)
virtual

Reimplemented from PulseController.

◆ AdvanceModelTime() [1/2]

void PulseEngine::AdvanceModelTime ( )
virtual

executes one pass through the time loop of the engine at the fixed timestep

Events, errors, and warning as are logged to file not errors are returned through the API at this time.

Implements PhysiologyEngine.

◆ AdvanceModelTime() [2/2]

void PulseEngine::AdvanceModelTime ( double  time,
const TimeUnit unit 
)
virtual

executes time loop of the engine beginning at the current time and running for the duration specified in the call at the fixed timestep

Events, errors, and warning as are logged to file not errors are returned through the API at this time.

Implements PhysiologyEngine.

◆ GetActionManager()

const SEActionManager & PulseEngine::GetActionManager ( ) const
virtual

Get the Action Manager. Allows a user to check the state of active actions.

Implements PhysiologyEngine.

◆ GetAnesthesiaMachine()

const SEAnesthesiaMachine * PulseEngine::GetAnesthesiaMachine ( ) const
virtual

Returns the current state of the Anesthesia machine.

Implements PhysiologyEngine.

◆ GetBloodChemistrySystem()

const SEBloodChemistrySystem * PulseEngine::GetBloodChemistrySystem ( ) const
virtual

Returns the current state of the Blood Chemistry System.

Implements PhysiologyEngine.

◆ GetCardiovascularSystem()

const SECardiovascularSystem * PulseEngine::GetCardiovascularSystem ( ) const
virtual

Returns the current state of the Cardiovascular System.

Implements PhysiologyEngine.

◆ GetCompartments()

const SECompartmentManager & PulseEngine::GetCompartments ( ) const
virtual

Retrieves the engine compartments, providing such data as: flows, pressure, volume as well as substance volumes and volume fractions.

Implements PhysiologyEngine.

◆ GetConditionManager()

const SEConditionManager & PulseEngine::GetConditionManager ( ) const
virtual

Get the Condition Manager. Allows a user to check the state of active conditions.

Implements PhysiologyEngine.

◆ GetConfiguration()

const SEEngineConfiguration * PulseEngine::GetConfiguration ( ) const
virtual

returns the engine configuration.

Implements PhysiologyEngine.

◆ GetDrugSystem()

const SEDrugSystem * PulseEngine::GetDrugSystem ( ) const
virtual

Returns the current state of the drug system.

Implements PhysiologyEngine.

◆ GetElectroCardioGram()

const SEElectroCardioGram * PulseEngine::GetElectroCardioGram ( ) const
virtual

Returns the current state of the Electrocardiogram machine.

Implements PhysiologyEngine.

◆ GetEndocrineSystem()

const SEEndocrineSystem * PulseEngine::GetEndocrineSystem ( ) const
virtual

Returns the current state of the Endocrine System.

Implements PhysiologyEngine.

◆ GetEnergySystem()

const SEEnergySystem * PulseEngine::GetEnergySystem ( ) const
virtual

Returns the current state of the Energy System.

Implements PhysiologyEngine.

◆ GetEngineTracker()

SEEngineTracker * PulseEngine::GetEngineTracker ( ) const
virtual

Retrieve the SEEngineTracker associated with tracking data from this engine to a file The SEEngineTracker is a class set up to pull data requested from the engine (via SEDataRequest's) and provide access to the data easily (ex. to easily write data to csv files)

Implements PhysiologyEngine.

◆ GetEnvironment()

const SEEnvironment * PulseEngine::GetEnvironment ( ) const
virtual

Returns the environment object used by the engine.

Implements PhysiologyEngine.

◆ GetGastrointestinalSystem()

const SEGastrointestinalSystem * PulseEngine::GetGastrointestinalSystem ( ) const
virtual

Returns the current state of the Gastrointestinal System.

Implements PhysiologyEngine.

◆ GetHepaticSystem()

const SEHepaticSystem * PulseEngine::GetHepaticSystem ( ) const
virtual

Returns the current state of the Hepatic System.

Implements PhysiologyEngine.

◆ GetInhaler()

const SEInhaler * PulseEngine::GetInhaler ( ) const
virtual

Returns the current state of the Inhaler.

Implements PhysiologyEngine.

◆ GetLogger()

Logger * PulseEngine::GetLogger ( ) const
virtual

Retrieve the Logger associated with this engine.

Implements PhysiologyEngine.

◆ GetNervousSystem()

const SENervousSystem * PulseEngine::GetNervousSystem ( ) const
virtual

Returns the current state of the Nervous System.

Implements PhysiologyEngine.

◆ GetPatient()

const SEPatient & PulseEngine::GetPatient ( ) const
virtual

Returns the patient object used by the engine.

Implements PhysiologyEngine.

◆ GetPatientAssessment()

bool PulseEngine::GetPatientAssessment ( SEPatientAssessment assessment) const
virtual

Determines the assessment type and fills the data object with current data.

Assessments can be queried at any point in the calculation and as many times are desired.

Implements PhysiologyEngine.

◆ GetRenalSystem()

const SERenalSystem * PulseEngine::GetRenalSystem ( ) const
virtual

Returns the current state of the Renal System.

Implements PhysiologyEngine.

◆ GetRespiratorySystem()

const SERespiratorySystem * PulseEngine::GetRespiratorySystem ( ) const
virtual

Returns the current state of the Respiratory System.

Implements PhysiologyEngine.

◆ GetSimulationTime()

double PulseEngine::GetSimulationTime ( const TimeUnit unit) const
virtual

returns the current time of the simulation.

Implements PhysiologyEngine.

◆ GetSubstanceManager() [1/2]

SESubstanceManager & PulseEngine::GetSubstanceManager ( )
virtual

Retrieves the associated substance manager.

Implements PhysiologyEngine.

◆ GetSubstanceManager() [2/2]

const SESubstanceManager & PulseEngine::GetSubstanceManager ( ) const
virtual

Implements PhysiologyEngine.

◆ GetTimeStep()

double PulseEngine::GetTimeStep ( const TimeUnit unit) const
virtual

returns the engine time step that is used when advancing time.

Implements PhysiologyEngine.

◆ GetTissueSystem()

const SETissueSystem * PulseEngine::GetTissueSystem ( ) const
virtual

Returns the current state of the tissue system.

Implements PhysiologyEngine.

◆ InitializeEngine() [1/2]

bool PulseEngine::InitializeEngine ( const std::string &  patient_configuration,
SerializationFormat  m,
const SEEngineConfiguration config = nullptr 
)
virtual

locates the json patient file and reads in the values.

This will create an engine that you can send instructions (patient,actions,conditions) to dynamically. The return value will indicate success failure of the creation of the engine. Some combinations of patients and conditions may prevent the engine from stabilizing

Implements PhysiologyEngine.

◆ InitializeEngine() [2/2]

bool PulseEngine::InitializeEngine ( const SEPatientConfiguration patient_configuration,
const SEEngineConfiguration config = nullptr 
)
virtual

This will create an engine that you can send instructions (patient,actions,conditions) to dynamically. The return value will indicate success failure of the creation of the engine. Some combinations of patients and conditions may prevent the engine from stabilizing.

Implements PhysiologyEngine.

◆ IsReady()

bool PulseEngine::IsReady ( ) const
protectedvirtual

◆ ProcessAction()

bool PulseEngine::ProcessAction ( const SEAction action)
virtual

Execute the provided action. true will be returned if the engine supports the action false will be returned if the engine does not support the action.

Implements PhysiologyEngine.

◆ SerializeFromFile() [1/2]

bool PulseEngine::SerializeFromFile ( const std::string &  file,
SerializationFormat  m 
)
virtual

◆ SerializeFromFile() [2/2]

bool PulseEngine::SerializeFromFile ( const std::string &  filename,
SerializationFormat  m,
const SEScalarTime simTime,
const SEEngineConfiguration config 
)
virtual

Reset engine and set it to the state in the provided file. You may provided a Simulation Time to be used if desired. It will be reflected in the GetSimulationTime method. Return value indicates engine was able to load provided state file. Engine will be in a cleared state if this method fails. Note the provided configuration will overwrite any configuration options in the state with its contents (Use with caution!)

Implements PhysiologyEngine.

◆ SerializeFromString() [1/2]

bool PulseEngine::SerializeFromString ( const std::string &  state,
SerializationFormat  m 
)
virtual

◆ SerializeFromString() [2/2]

bool PulseEngine::SerializeFromString ( const std::string &  state,
SerializationFormat  m,
const SEScalarTime simTime,
const SEEngineConfiguration config 
)
virtual

Reset engine and set it to the state in the provided string. The state is saved as bytes in the given string. Note that the bytes are binary, not text; we only use the string class as a convenient container. You may provided a Simulation Time to be used if desired. It will be reflected in the GetSimulationTime method. Return value indicates engine was able to load provided state file. Engine will be in a cleared state if this method fails. Note the provided configuration will overwrite any configuration options in the state with its contents (Use with caution!)

Implements PhysiologyEngine.

◆ SerializeToFile()

bool PulseEngine::SerializeToFile ( const std::string &  filename,
SerializationFormat  m 
) const
virtual

Save the current state of the engine to provided filename. Engine will be in a cleared state if this method fails.

Implements PhysiologyEngine.

◆ SerializeToString()

bool PulseEngine::SerializeToString ( std::string &  state,
SerializationFormat  m 
) const
virtual

Save the current state of the engine. The state is saved as bytes in the given string. Note that the bytes are binary, not text; we only use the string class as a convenient container. Engine will be in a cleared state if this method fails.

Implements PhysiologyEngine.

◆ SetAdvanceHandler()

void PulseEngine::SetAdvanceHandler ( SEAdvanceHandler handler)
virtual

Add a callback object that will be called after each timestep.

Implements PhysiologyEngine.

◆ SetEventHandler()

void PulseEngine::SetEventHandler ( SEEventHandler handler)
virtual

Add a callback object that will be called whenever a pateint or anesthesia machine event changes state.

Implements PhysiologyEngine.

Friends And Related Function Documentation

◆ PBPulseState

friend class PBPulseState
friend

Member Data Documentation

◆ m_EngineTrack

SEEngineTracker* PulseEngine::m_EngineTrack
protected

◆ m_ss

std::stringstream PulseEngine::m_ss
protected