PhysiologyEngine.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "cdm/CommonDefs.h"
6#include "cdm/utils/Logger.h"
7
9class SEPatient;
12
13class SECondition;
14class SEAction;
15
19class SEDrugSystem;
21class SEEnergySystem;
23class SEHepaticSystem;
24class SENervousSystem;
25class SERenalSystem;
27class SETissueSystem;
28class SEEnvironment;
30class SEBagValveMask;
31class SEECMO;
33class SEInhaler;
37class SEActionManager;
39class SEEventManager;
40
41class SEEngineTracker;
43
44enum class eEngineInitializationState
45{
46 Uninitialized = 0,
47 FailedState = 1,
48 FailedPatientSetup = 2,
49 FailedStabilization = 3,
50 Initialized = 4
51};
52extern CDM_DECL const std::string& eEngineInitializationState_Name(eEngineInitializationState s);
53
59{
61 : CommonDataModelException( "Physiology Engine Error" ) {}
62
63 PhysiologyEngineException(const std::string& _Message)
64 : CommonDataModelException(_Message) {}
65};
66
67class CDM_DECL PhysiologyEngine : public Loggable
68{
69public:
70 PhysiologyEngine(Logger* logger = nullptr) : Loggable(logger) {}
71 virtual ~PhysiologyEngine() = default;
72
73 //--------------------------------------------------------------------------------------------------
76 //--------------------------------------------------------------------------------------------------
77 virtual std::string GetTypeName() const = 0;
78
79 //--------------------------------------------------------------------------------------------------
86 //--------------------------------------------------------------------------------------------------
87 virtual bool SerializeFromFile(const std::string& file) = 0;
88
89 //--------------------------------------------------------------------------------------------------
94 //--------------------------------------------------------------------------------------------------
95 virtual bool SerializeToFile(const std::string& filename) const = 0;
96
97 //--------------------------------------------------------------------------------------------------
104 //--------------------------------------------------------------------------------------------------
105 virtual bool SerializeFromString(const std::string& state, eSerializationFormat m) = 0;
106
107 //--------------------------------------------------------------------------------------------------
112 //--------------------------------------------------------------------------------------------------
113 virtual bool SerializeToString(std::string& state, eSerializationFormat m) const = 0;
114
115 //--------------------------------------------------------------------------------------------------
123 //--------------------------------------------------------------------------------------------------
124 virtual bool InitializeEngine(const std::string& patient_configuration, eSerializationFormat m) = 0;
125
126 //--------------------------------------------------------------------------------------------------
133 //--------------------------------------------------------------------------------------------------
134 virtual bool InitializeEngine(const SEPatientConfiguration& patient_configuration) = 0;
135
136 //--------------------------------------------------------------------------------------------------
141 //--------------------------------------------------------------------------------------------------
142 virtual eEngineInitializationState GetInitializationState() const = 0;
143
144 //--------------------------------------------------------------------------------------------------
149 //--------------------------------------------------------------------------------------------------
150 virtual void Clear() = 0;
151
152 //--------------------------------------------------------------------------------------------------
157 //--------------------------------------------------------------------------------------------------
158 virtual const SEConditionManager& GetConditionManager() const = 0;
159
160 //--------------------------------------------------------------------------------------------------
167 //--------------------------------------------------------------------------------------------------
168 virtual bool SetConfigurationOverride(const SEEngineConfiguration* config) = 0;
169
170 //--------------------------------------------------------------------------------------------------
173 //--------------------------------------------------------------------------------------------------
174 virtual const SEEngineConfiguration* GetConfiguration() const = 0;
175
176 //--------------------------------------------------------------------------------------------------
181 //--------------------------------------------------------------------------------------------------
182 virtual SEEngineTracker* GetEngineTracker() const = 0;
183
184 //--------------------------------------------------------------------------------------------------
188 //--------------------------------------------------------------------------------------------------
189 virtual double GetTimeStep(const TimeUnit& unit) const = 0;
190
191 //--------------------------------------------------------------------------------------------------
194 //--------------------------------------------------------------------------------------------------
195 virtual double GetSimulationTime(const TimeUnit& unit) const = 0;
196
197 //--------------------------------------------------------------------------------------------------
200 //--------------------------------------------------------------------------------------------------
201 virtual double GetStabilizationTime(const TimeUnit& unit) const = 0;
202
203 //--------------------------------------------------------------------------------------------------
207 //--------------------------------------------------------------------------------------------------
208 virtual void SetSimulationTime(const SEScalarTime& time) = 0;
209
210 //--------------------------------------------------------------------------------------------------
217 //--------------------------------------------------------------------------------------------------
218 virtual bool AdvanceModelTime() = 0;
219
220 //--------------------------------------------------------------------------------------------------
228 //--------------------------------------------------------------------------------------------------
229 virtual bool AdvanceModelTime(double time, const TimeUnit& unit) = 0;
230
231 //--------------------------------------------------------------------------------------------------
234 //--------------------------------------------------------------------------------------------------
235 virtual void SetAdvanceHandler(SEAdvanceHandler* handler) = 0;
236
237 //--------------------------------------------------------------------------------------------------
243 //--------------------------------------------------------------------------------------------------
244 virtual bool ProcessAction(const SEAction& action) = 0;
245
246 //--------------------------------------------------------------------------------------------------
251 //--------------------------------------------------------------------------------------------------
252 virtual const SEActionManager& GetActionManager() const = 0;
253
254 //--------------------------------------------------------------------------------------------------
258 //--------------------------------------------------------------------------------------------------
259 virtual const SESubstanceManager& GetSubstanceManager() const = 0;
260
261 //--------------------------------------------------------------------------------------------------
265 //--------------------------------------------------------------------------------------------------
266 virtual const SEEventManager& GetEventManager() const = 0;
267
268 //--------------------------------------------------------------------------------------------------
272 //--------------------------------------------------------------------------------------------------
273 virtual const SEPatient& GetPatient() const = 0;
274
275 //--------------------------------------------------------------------------------------------------
279 //--------------------------------------------------------------------------------------------------
280 virtual const SEPatient& GetInitialPatient() const = 0;
281
282 //--------------------------------------------------------------------------------------------------
288 //--------------------------------------------------------------------------------------------------
289 virtual bool GetPatientAssessment(SEPatientAssessment& assessment) const = 0;
290
291 //--------------------------------------------------------------------------------------------------
295 //--------------------------------------------------------------------------------------------------
296 virtual const SEEnvironment* GetEnvironment() const = 0;
297
298 //--------------------------------------------------------------------------------------------------
302 //--------------------------------------------------------------------------------------------------
304
305 //--------------------------------------------------------------------------------------------------
309 //--------------------------------------------------------------------------------------------------
311
312 //--------------------------------------------------------------------------------------------------
316 //--------------------------------------------------------------------------------------------------
317 virtual const SEDrugSystem* GetDrugSystem() const = 0;
318
319 //--------------------------------------------------------------------------------------------------
323 //--------------------------------------------------------------------------------------------------
324 virtual const SEEndocrineSystem* GetEndocrineSystem() const = 0;
325
326 //--------------------------------------------------------------------------------------------------
330 //--------------------------------------------------------------------------------------------------
331 virtual const SEEnergySystem* GetEnergySystem() const = 0;
332
333 //--------------------------------------------------------------------------------------------------
337 //--------------------------------------------------------------------------------------------------
339
340 //--------------------------------------------------------------------------------------------------
344 //--------------------------------------------------------------------------------------------------
345 virtual const SEHepaticSystem* GetHepaticSystem() const = 0;
346
347 //--------------------------------------------------------------------------------------------------
351 //--------------------------------------------------------------------------------------------------
352 virtual const SENervousSystem* GetNervousSystem() const = 0;
353
354 //--------------------------------------------------------------------------------------------------
358 //--------------------------------------------------------------------------------------------------
359 virtual const SERenalSystem* GetRenalSystem() const = 0;
360
361 //--------------------------------------------------------------------------------------------------
365 //--------------------------------------------------------------------------------------------------
366 virtual const SERespiratorySystem* GetRespiratorySystem() const = 0;
367
368 //--------------------------------------------------------------------------------------------------
372 //--------------------------------------------------------------------------------------------------
373 virtual const SETissueSystem* GetTissueSystem() const = 0;
374
375 //--------------------------------------------------------------------------------------------------
379 //--------------------------------------------------------------------------------------------------
380 virtual const SEAnesthesiaMachine* GetAnesthesiaMachine() const = 0;
381
382 //--------------------------------------------------------------------------------------------------
386 //--------------------------------------------------------------------------------------------------
387 virtual const SEBagValveMask* GetBagValveMask() const = 0;
388
389 //--------------------------------------------------------------------------------------------------
393 //--------------------------------------------------------------------------------------------------
394 virtual const SEECMO* GetECMO() const = 0;
395
396 //--------------------------------------------------------------------------------------------------
400 //--------------------------------------------------------------------------------------------------
401 virtual const SEElectroCardioGram* GetElectroCardioGram() const = 0;
402
403 //--------------------------------------------------------------------------------------------------
407 //--------------------------------------------------------------------------------------------------
408 virtual const SEInhaler* GetInhaler() const = 0;
409
410 //--------------------------------------------------------------------------------------------------
414 //--------------------------------------------------------------------------------------------------
416
417 //--------------------------------------------------------------------------------------------------
422 //--------------------------------------------------------------------------------------------------
423 virtual const SECompartmentManager& GetCompartments() const = 0;
424
425 //--------------------------------------------------------------------------------------------------
432 //--------------------------------------------------------------------------------------------------
433 virtual SEBlackBoxManager& GetBlackBoxes() const = 0;
434};
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PhysiologyEngine.h:68
virtual bool SetConfigurationOverride(const SEEngineConfiguration *config)=0
Engines can have a configuration for allowing a user to set certain internal parameters Engines with ...
virtual const SEEnvironment * GetEnvironment() const =0
Returns the environment object used by the engine.
virtual const SECompartmentManager & GetCompartments() const =0
Retrieves the engine compartments, providing such data as: flows, pressure, volume as well as substan...
virtual const SEECMO * GetECMO() const =0
Returns the current state of the ECMO machine.
virtual void SetSimulationTime(const SEScalarTime &time)=0
Set the current time of the simulation. Engine Simulation time will be advanced from this time point.
virtual double GetStabilizationTime(const TimeUnit &unit) const =0
returns the stabilization time of the simulation (if stabilized)
virtual bool SerializeFromFile(const std::string &file)=0
Reset engine and set it to the state in the provided file. The file may contain json or binary....
PhysiologyEngine(Logger *logger=nullptr)
Definition: PhysiologyEngine.h:70
virtual double GetTimeStep(const TimeUnit &unit) const =0
returns the engine time step that is used when advancing time.
virtual ~PhysiologyEngine()=default
virtual const SEEventManager & GetEventManager() const =0
Retrieves the associated event manager.
virtual const SEDrugSystem * GetDrugSystem() const =0
Returns the current state of the drug system.
virtual const SEEndocrineSystem * GetEndocrineSystem() const =0
Returns the current state of the Endocrine System.
virtual bool SerializeToString(std::string &state, eSerializationFormat m) const =0
Save the current state of the engine. The state can be saved as JSON or bytes in the given string....
virtual double GetSimulationTime(const TimeUnit &unit) const =0
returns the current time of the simulation.
virtual const SEPatient & GetPatient() const =0
Returns the patient object used by the engine.
virtual const SEMechanicalVentilator * GetMechanicalVentilator() const =0
Returns the current state of the Mechanical ventilator.
virtual const SEPatient & GetInitialPatient() const =0
Returns the initial simulation patient object used by the engine.
virtual bool InitializeEngine(const SEPatientConfiguration &patient_configuration)=0
This will create an engine that you can send instructions (patient,actions,conditions) to dynamically...
virtual std::string GetTypeName() const =0
Returns the engine type, such as "Human Adult Whole Body".
virtual const SEInhaler * GetInhaler() const =0
Returns the current state of the Inhaler.
virtual void SetAdvanceHandler(SEAdvanceHandler *handler)=0
Add a callback object that will be called after each timestep.
virtual bool AdvanceModelTime(double time, const TimeUnit &unit)=0
executes time loop of the engine beginning at the current time and running for the duration specified...
virtual const SERespiratorySystem * GetRespiratorySystem() const =0
Returns the current state of the Respiratory System.
virtual const SEEngineConfiguration * GetConfiguration() const =0
returns the engine configuration.
virtual const SERenalSystem * GetRenalSystem() const =0
Returns the current state of the Renal System.
virtual const SETissueSystem * GetTissueSystem() const =0
Returns the current state of the tissue system.
virtual const SEHepaticSystem * GetHepaticSystem() const =0
Returns the current state of the Hepatic System.
virtual bool ProcessAction(const SEAction &action)=0
Execute the provided action. true will be returned if the engine supports the action false will be re...
virtual const SEAnesthesiaMachine * GetAnesthesiaMachine() const =0
Returns the current state of the Anesthesia machine.
virtual const SEEnergySystem * GetEnergySystem() const =0
Returns the current state of the Energy System.
virtual SEEngineTracker * GetEngineTracker() const =0
Retrieve the SEEngineTracker associated with tracking data from this engine to a file The SEEngineTra...
virtual const SEElectroCardioGram * GetElectroCardioGram() const =0
Returns the current state of the Electrocardiogram machine.
virtual bool AdvanceModelTime()=0
executes one pass through the time loop of the engine at the fixed timestep
virtual const SEGastrointestinalSystem * GetGastrointestinalSystem() const =0
Returns the current state of the Gastrointestinal System.
virtual void Clear()=0
Closes out any files and resets state.
virtual const SEBagValveMask * GetBagValveMask() const =0
Returns the current state of the Bag Valve Mask.
virtual const SEBloodChemistrySystem * GetBloodChemistrySystem() const =0
Returns the current state of the Blood Chemistry System.
virtual bool GetPatientAssessment(SEPatientAssessment &assessment) const =0
Determines the assessment type and fills the data object with current data.
virtual const SENervousSystem * GetNervousSystem() const =0
Returns the current state of the Nervous System.
virtual eEngineInitializationState GetInitializationState() const =0
Get a bit more detail as to how initialization went.
virtual const SEConditionManager & GetConditionManager() const =0
Get the Condition Manager. Allows a user to check the state of active conditions.
virtual bool SerializeFromString(const std::string &state, eSerializationFormat m)=0
Reset engine and set it to the state in the provided string. The string can contain JSON or binary....
virtual SEBlackBoxManager & GetBlackBoxes() const =0
Retrieves the engine black box manager Black boxes allow users to inject or retrieve flows,...
virtual const SEActionManager & GetActionManager() const =0
Get the Action Manager. Allows a user to check the state of active actions.
virtual bool InitializeEngine(const std::string &patient_configuration, eSerializationFormat m)=0
Initialize an engine based on the engines initialization structure.
virtual bool SerializeToFile(const std::string &filename) const =0
Save the current state of the engine to provided filename. Using a .json extension will save a json/a...
virtual const SESubstanceManager & GetSubstanceManager() const =0
Retrieves the associated substance manager.
virtual const SECardiovascularSystem * GetCardiovascularSystem() const =0
Returns the current state of the Cardiovascular System.
Definition: SEAction.h:14
Definition: SEActionManager.h:12
Definition: SEAdvanceHandler.h:8
Definition: SEAnesthesiaMachine.h:24
Definition: SEBagValveMask.h:14
Definition: SEBlackBoxManager.h:11
Definition: SEBloodChemistrySystem.h:10
Definition: SECardiovascularSystem.h:24
Definition: SECompartmentManager.h:25
Definition: SECondition.h:8
Definition: SEConditionManager.h:26
Definition: SEDrugSystem.h:9
Definition: SEECMO.h:10
Definition: SEElectroCardioGram.h:9
Definition: SEEndocrineSystem.h:8
Definition: SEEnergySystem.h:8
Definition: SEEngineConfiguration.h:8
Definition: SEEngineTracker.h:66
Definition: SEEnvironment.h:13
Definition: SEEventManager.h:117
Definition: SEGastrointestinalSystem.h:9
Definition: SEHepaticSystem.h:8
Definition: SEInhaler.h:12
Definition: SEMechanicalVentilator.h:10
Definition: SENervousSystem.h:9
Data formed at a level of a clinicians report. This is high level data, such as a mean or generalized...
Definition: SEPatientAssessment.h:22
Definition: SEPatientConfiguration.h:11
Definition: SEPatient.h:13
Definition: SERenalSystem.h:8
Definition: SERespiratorySystem.h:25
Definition: SEScalarTime.h:28
Definition: SESubstanceManager.h:9
Definition: SETissueSystem.h:8
Definition: SEScalarTime.h:8
Definition: CommonDefs.h:127
Base exception class that all CDM classes throw when an error occurs.
Definition: PhysiologyEngine.h:59
PhysiologyEngineException()
Definition: PhysiologyEngine.h:60
PhysiologyEngineException(const std::string &_Message)
Definition: PhysiologyEngine.h:63

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.