SEEngineTracker.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5
6class DataTrack;
7class SESystem;
8class SEPatient;
9class SEEnvironment;
11class SEActionManager;
14class SEDataRequest;
21#include "cdm/properties/SEScalar.h"
22
23enum class CompartmentUpdate {None,
24 InFlow, OutFlow,
25 HeatTransferRateIn, HeatTransferRateOut,
26 Volume,Pressure,
27 Heat, Temperature,
28 VolumeFraction,
29 Mass, Concentration,
30 pH, Molarity,
31 PartialPressure, Saturation};
32enum class TrackMode { CSV, Dynamic };
34{
35 friend class SEEngineTracker;
37
38protected:
40 {
41 UpdateProperty = CompartmentUpdate::None;
42 GasCmpt = nullptr;
43 GasSubstance = nullptr;
44 LiquidCmpt = nullptr;
45 LiquidSubstance = nullptr;
46 ThermalCmpt = nullptr;
47 }
48
49 void UpdateScalar();
50 void SetScalarRequest(const SEScalar& s, SEDataRequest& dr);
51
52 size_t idx;
53 std::string Heading;
54
55 // Compartment related variables
56 CompartmentUpdate UpdateProperty;
62 // Tissue cmpts don't have children and they don't have computed data that changes on call (like flow)
63};
64
65class CDM_DECL SEEngineTracker : public Loggable
66{
67public:
69 virtual ~SEEngineTracker();
70
71 void Clear();// Remove all requests and close the results file
72
73 DataTrack& GetDataTrack();
74 SEActionManager& GetActionManager() { return m_ActionMgr; }
76 SEDataRequestManager& GetDataRequestManager() { return *m_DataRequestMgr; }
77
78 // Add a system to look for data in
79 void AddSystem(SESystem& system);
80
81 void ResetFile();// Close file, so next Track Data will re hook up everything and make a new file
82
83 bool ConnectRequest(SEDataRequest& dr, SEDataRequestScalar& ds);
84
85 virtual bool SetupRequests();
86 // Set to false if you have already pulled the latest values
87 virtual void LogRequestedValues();
88 virtual void TrackData(double currentTime_s);
89 virtual void PullData(double currentTime_s);
90 virtual bool TrackRequest(SEDataRequest& dr);
91 virtual void ForceConnection() { m_ForceConnection = true; }
92
93 void SetTrackMode(TrackMode m) { m_Mode = m; }
94 TrackMode GetTrackMode() { return m_Mode; }
95
96
97 double GetValue(const SEDataRequest& dr) const;
98
99protected:
100 const SEDataRequestScalar* GetScalar(const SEDataRequest& dr) const;
101
102 TrackMode m_Mode= TrackMode::CSV;
106
107 std::stringstream m_ss;
108 std::ofstream m_ResultsStream;
110
115
116 SEEnvironment* m_Environment = nullptr;
117 std::vector<SESystem*> m_PhysiologySystems;
118 SESystem* m_AnesthesiaMachine = nullptr;
119 SESystem* m_ECG = nullptr;
120 SESystem* m_Inhaler = nullptr;
121 SESystem* m_MechanicalVentilator = nullptr;
122 std::map<const SEDataRequest*, SEDataRequestScalar*> m_Request2Scalar;
123};
Utility class to read a CSV file.
Definition: CSV.h:13
Definition: DataTrack.h:17
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PhysiologyEngine.h:68
Definition: SEActionManager.h:12
Definition: SECompartmentManager.h:25
Definition: SEDataRequest.h:18
Definition: SEDataRequestManager.h:10
Definition: SEEngineTracker.h:34
SEThermalCompartment * ThermalCmpt
Definition: SEEngineTracker.h:61
void SetScalarRequest(const SEScalar &s, SEDataRequest &dr)
Definition: SEEngineTracker.cpp:522
std::string Heading
Definition: SEEngineTracker.h:53
size_t idx
Definition: SEEngineTracker.h:52
SEGasSubstanceQuantity * GasSubstance
Definition: SEEngineTracker.h:58
void UpdateScalar()
Definition: SEEngineTracker.cpp:553
SEGasCompartment * GasCmpt
Definition: SEEngineTracker.h:57
SELiquidCompartment * LiquidCmpt
Definition: SEEngineTracker.h:59
SELiquidSubstanceQuantity * LiquidSubstance
Definition: SEEngineTracker.h:60
CompartmentUpdate UpdateProperty
Definition: SEEngineTracker.h:56
SEDataRequestScalar(Logger *logger)
Definition: SEEngineTracker.h:39
Definition: SEDynamicStabilizationPropertyConvergence.h:9
Definition: SEEngineTracker.h:66
SESubstanceManager & GetSubstanceManager()
Definition: SEEngineTracker.h:75
bool m_ForceConnection
Definition: SEEngineTracker.h:103
DataTrack * m_DataTrack
Definition: SEEngineTracker.h:105
std::ofstream m_ResultsStream
Definition: SEEngineTracker.h:108
SECompartmentManager & m_CmptMgr
Definition: SEEngineTracker.h:114
void SetTrackMode(TrackMode m)
Definition: SEEngineTracker.h:93
SESubstanceManager & m_SubMgr
Definition: SEEngineTracker.h:113
TrackMode GetTrackMode()
Definition: SEEngineTracker.h:94
std::map< const SEDataRequest *, SEDataRequestScalar * > m_Request2Scalar
Definition: SEEngineTracker.h:122
SEActionManager & m_ActionMgr
Definition: SEEngineTracker.h:112
std::stringstream m_ss
Definition: SEEngineTracker.h:107
SEActionManager & GetActionManager()
Definition: SEEngineTracker.h:74
SEDataRequestManager & GetDataRequestManager()
Definition: SEEngineTracker.h:76
SEPatient & m_Patient
Definition: SEEngineTracker.h:111
virtual void ForceConnection()
Definition: SEEngineTracker.h:91
double m_LastPullTime_s
Definition: SEEngineTracker.h:104
std::vector< SESystem * > m_PhysiologySystems
Definition: SEEngineTracker.h:117
SEDataRequestManager * m_DataRequestMgr
Definition: SEEngineTracker.h:109
Definition: SEEnvironment.h:13
Definition: SEGasCompartment.h:14
Definition: SEGasSubstanceQuantity.h:10
If you want to querry what a scalar is and don't know what scalar type you have...
Definition: SEScalar.h:282
Definition: SELiquidCompartment.h:11
Definition: SELiquidSubstanceQuantity.h:12
Definition: SEPatient.h:13
Definition: SEScalar.h:19
Definition: SESubstanceManager.h:9
Definition: SESystem.h:8
Definition: SEThermalCompartment.h:12

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.