PhysiologyEngineTrack.h
1 /**************************************************************************************
2 Copyright 2015 Applied Research Associates, Inc.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the License
5 at:
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software distributed under
8 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9 CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 specific language governing permissions and limitations under the License.
11 **************************************************************************************/
12 
13 #pragma once
14 
15 #include <biogears/cdm/compartment/fluid/SEGasCompartment.h>
16 #include <biogears/cdm/compartment/fluid/SEGasCompartmentLink.h>
17 #include <biogears/cdm/compartment/fluid/SELiquidCompartmentLink.h>
18 #include <biogears/cdm/compartment/tissue/SETissueCompartment.h>
19 #include <biogears/cdm/properties/SEGenericScalar.h>
20 #include <biogears/cdm/properties/SEScalar.h>
21 #include <biogears/cdm/scenario/requests/SEDataRequestManager.h>
22 #include <biogears/cdm/utils/DataTrack.h>
23 
24 namespace biogears {
25 class SESystem;
26 class SEPatient;
27 class SEEnvironment;
28 class PhysiologyEngine;
29 class SESubstanceManager;
30 class SECompartmentManager;
31 
32 enum class CompartmentUpdate { None,
33  InFlow,
34  OutFlow,
37  Volume,
38  Pressure,
39  Heat,
42  Mass,
44  pH,
45  Molarity,
47  Saturation };
48 
50 public:
52  : SEGenericScalar(logger)
53  {
54  Heading.clear();
55 
57  GasCmpt = nullptr;
58  GasSubstance = nullptr;
59  LiquidCmpt = nullptr;
60  LiquidSubstance = nullptr;
61  ThermalCmpt = nullptr;
62  }
63 
64  void UpdateScalar();
65  void SetScalar(const SEScalar* s, SEDataRequest& dr); // SEScalar* in order to internnally throw error if the Track cannot find the requested property, it will pass in nullptr if it cannot find it
66 
67  std::string Heading;
68 
69  // Compartment related variables
76  // Tissue cmpts don't have children and they don't have computed data that changes on call (like flow)
77 };
78 
79 class BIOGEARS_API PhysiologyEngineTrack : public Loggable {
80 public:
83  SESubstanceManager& subMgr,
84  SECompartmentManager& cmptMgr,
85  const std::vector<SESystem*>& physiology,
86  const std::vector<SESystem*>& equipment
87  );
90  virtual ~PhysiologyEngineTrack();
91 
92  void Clear(); // Remove all requests and close the results file
93 
94  DataTrack& GetDataTrack();
95  SEDataRequestManager& GetDataRequestManager() { return m_DataRequestMgr; }
96 
97  void ResetFile(); // Close file, so next Track Data will re hook up everything and make a new file
98 
99  bool ConnectRequest(SEDataRequest& dr, SEDataRequestScalar& ds);
100 
101  virtual void SetupRequests(bool append = false);
102  virtual void TrackData(double currentTime_s, bool append = false);
103  virtual void PullData();
104  virtual bool TrackRequest(SEDataRequest& dr);
105  virtual void ForceConnection() { m_ForceConnection = true; }
106 
107 protected:
110 
111  std::stringstream m_ss;
112  std::ofstream m_ResultsStream;
114 
118 
120  std::vector<SESystem*> m_PhysiologySystems;
121  std::vector<SESystem*> m_EquipmentSystems;
122  std::map<const SEDataRequest*, SEDataRequestScalar*> m_Request2Scalar;
123 };
124 }
bool m_ForceConnection
Definition: PhysiologyEngineTrack.h:108
SEDataRequestManager m_DataRequestMgr
Definition: PhysiologyEngineTrack.h:113
Definition: PhysiologyEngineTrack.h:49
std::vector< SESystem * > m_PhysiologySystems
Definition: PhysiologyEngineTrack.h:120
Definition: SEScalar.h:33
SEPatient * m_Patient
Definition: PhysiologyEngineTrack.h:115
Definition: SEThermalCompartment.h:26
Definition: SECompartmentManager.h:32
Definition: SELiquidSubstanceQuantity.h:28
If you want to querry what a scalar is and don't know what scalar type you have...
Definition: SEGenericScalar.h:25
virtual void ForceConnection()
Definition: PhysiologyEngineTrack.h:105
Definition: SEPatient.h:48
SEGasSubstanceQuantity * GasSubstance
Definition: PhysiologyEngineTrack.h:72
Definition: Logger.h:27
Definition: Logger.h:75
Definition: SELiquidCompartment.h:27
std::stringstream m_ss
Definition: PhysiologyEngineTrack.h:111
Definition: PhysiologyEngine.h:68
CompartmentUpdate UpdateProperty
Definition: PhysiologyEngineTrack.h:70
Definition: PhysiologyEngineTrack.h:79
void UpdateScalar()
Definition: PhysiologyEngineTrack.cpp:556
void SetScalar(const SEScalar *s, SEDataRequest &dr)
Definition: PhysiologyEngineTrack.cpp:534
Definition: DataTrack.h:37
Definition: SEDataRequestManager.h:30
SELiquidSubstanceQuantity * LiquidSubstance
Definition: PhysiologyEngineTrack.h:74
Definition: SEGasSubstanceQuantity.h:20
SEDataRequestManager & GetDataRequestManager()
Definition: PhysiologyEngineTrack.h:95
SEGasCompartment * GasCmpt
Definition: PhysiologyEngineTrack.h:71
std::vector< SESystem * > m_EquipmentSystems
Definition: PhysiologyEngineTrack.h:121
std::string Heading
Definition: PhysiologyEngineTrack.h:67
SESubstanceManager * m_SubMgr
Definition: PhysiologyEngineTrack.h:116
SEEnvironment * m_Environment
Definition: PhysiologyEngineTrack.h:119
std::ofstream m_ResultsStream
Definition: PhysiologyEngineTrack.h:112
SEThermalCompartment * ThermalCmpt
Definition: PhysiologyEngineTrack.h:75
SEDataRequestScalar(Logger *logger)
Definition: PhysiologyEngineTrack.h:51
Definition: SEDataRequest.h:25
DataTrack m_DataTrack
Definition: PhysiologyEngineTrack.h:109
Definition: SESubstanceManager.h:23
std::map< const SEDataRequest *, SEDataRequestScalar * > m_Request2Scalar
Definition: PhysiologyEngineTrack.h:122
SELiquidCompartment * LiquidCmpt
Definition: PhysiologyEngineTrack.h:73
Definition: SEElectricalCircuit.h:18
SECompartmentManager * m_CmptMgr
Definition: PhysiologyEngineTrack.h:117
Definition: SEEnvironment.h:33
CompartmentUpdate
Definition: PhysiologyEngineTrack.h:32
Definition: SEGasCompartment.h:24