AnesthesiaMachine.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 #include <biogears/cdm/CommonDataModel.h>
15 #include <biogears/exports.h>
16 
17 #include <biogears/cdm/properties/SEScalarTime.h>
18 #include <biogears/cdm/system/equipment/Anesthesia/SEAnesthesiaMachine.h>
19 #include <biogears/engine/Controller/BioGearsSystem.h>
20 #include <biogears/schema/biogears/BioGears.hxx>
21 #include <biogears/schema/biogears/BioGearsEquipment.hxx>
22 
23 namespace biogears {
24 class BioGears;
25 class SEAnesthesiaMachineActionCollection;
26 class SEGasCompartment;
27 class SEGasSubstanceQuantity;
28 class SEFluidCircuitNode;
29 class SEFluidCircuitPath;
30 
35 class BIOGEARS_API AnesthesiaMachine : public SEAnesthesiaMachine, public BioGearsSystem {
36  friend BioGears;
37  friend class BioGearsEngineTest;
38 
39 protected:
40  static auto make_unique(BioGears& bg) -> std::unique_ptr<AnesthesiaMachine>;
43 
44 public:
45  virtual ~AnesthesiaMachine();
46 
47  static size_t TypeHash() { return reinterpret_cast<size_t>(&TypeHash); }
48  static constexpr char const * const TypeTag() { return "AnesthesiaMachine"; }
49  const char* classname() const override { return TypeTag(); }
50  size_t hash_code() const override { return TypeHash(); }
51 
52  void Clear() override;
53 
54  // Set members to a stable homeostatic state
55  void Initialize() override;
56 
57  // Load a state
58  virtual bool Load(const CDM::BioGearsAnesthesiaMachineData& in);
59  virtual CDM::BioGearsAnesthesiaMachineData* Unload() const override;
60 
61 protected:
62  virtual void Unload(CDM::BioGearsAnesthesiaMachineData& data) const;
63 
64  // Set pointers and other member varialbes common to both homeostatic initialization and loading a state
65  void SetUp() override;
66 
67 public:
68  void StateChange() override;
69 
70  void PreProcess() override;
71  void Process() override;
72  void PostProcess() override;
73 
74  void CalculateScrubber();
75 
76  // Extending some functionality to these base class methods
77  // We will update the BioGears Airway mode when these are called
78  void SetConnection(CDM::enumAnesthesiaMachineConnection::value c) override;
79  void InvalidateConnection() override;
80 
81 private:
82  void CalculateSourceStatus();
83  void CalculateEquipmentLeak();
84  void SetConnection();
85  void CalculateValveResistances();
86  void CalculateVentilator();
87  void CalculateGasSource();
88  void CalculateCyclePhase();
89  void CheckReliefValve();
90 
91  // Serializable member variables (Set in Initialize and in schema)
92  bool m_inhaling;
97 
98  // Stateless member variable (Set in SetUp())
99  double m_dt_s;
128 };
129 }
const char * classname() const override
Definition: AnesthesiaMachine.h:49
SEFluidCircuitPath * m_pSelectorToReliefValve
Definition: AnesthesiaMachine.h:122
SEGasSubstanceQuantity * m_scrubberN2
Definition: AnesthesiaMachine.h:115
friend BioGears
Definition: AnesthesiaMachine.h:36
Class corresponding to the BioGearsAnesthesiaMachineData schema type.
Definition: BioGearsEquipment.hxx:688
value
Underlying enum type.
Definition: Anesthesia.hxx:1160
Definition: SEScalar.h:33
SEFluidCircuitPath * m_pExpiratoryLimbToSelector
Definition: AnesthesiaMachine.h:126
double m_dSwitchOpenResistance_cmH2O_s_Per_L
Definition: AnesthesiaMachine.h:102
Generic anesthesia machine for positive pressure ventilation.
Definition: AnesthesiaMachine.h:35
double m_dSwitchClosedResistance_cmH2O_s_Per_L
Definition: AnesthesiaMachine.h:103
SEFluidCircuitPath * m_pInspiratoryLimbToYPiece
Definition: AnesthesiaMachine.h:121
SEGasSubstanceQuantity * m_ambientCO2
Definition: AnesthesiaMachine.h:106
Definition: SEFluidCircuitPath.h:25
bool m_inhaling
Definition: AnesthesiaMachine.h:92
SEFluidCircuitNode * m_nSelector
Definition: AnesthesiaMachine.h:117
static size_t TypeHash()
Definition: AnesthesiaMachine.h:47
size_t hash_code() const override
Definition: AnesthesiaMachine.h:50
SEGasSubstanceQuantity * m_ambientN2
Definition: AnesthesiaMachine.h:107
SEFluidCircuitPath * m_pYPieceToExpiratoryLimb
Definition: AnesthesiaMachine.h:119
SEScalarTime m_currentbreathingCycleTime
Definition: AnesthesiaMachine.h:95
Definition: SEFluidCircuitNode.h:21
SEScalar m_O2InletVolumeFraction
Definition: AnesthesiaMachine.h:94
SEScalarTime m_inspirationTime
Definition: AnesthesiaMachine.h:93
Definition: SEScalarTime.h:37
SEAnesthesiaMachineActionCollection * m_actions
Definition: AnesthesiaMachine.h:104
Definition: BioGearsEngineTest.h:24
SEGasSubstanceQuantity * m_gasSourceN2
Definition: AnesthesiaMachine.h:111
SEFluidCircuitNode * m_nVentilator
Definition: AnesthesiaMachine.h:116
SEGasCompartment * m_ambient
Definition: AnesthesiaMachine.h:105
Definition: SEGasSubstanceQuantity.h:20
SEGasCompartment * m_gasSource
Definition: AnesthesiaMachine.h:109
double m_dValveOpenResistance_cmH2O_s_Per_L
Definition: AnesthesiaMachine.h:100
SEFluidCircuitPath * m_pEnvironmentToVentilator
Definition: AnesthesiaMachine.h:125
SEScalarTime m_totalBreathingCycleTime
Definition: AnesthesiaMachine.h:96
SEFluidCircuitPath * m_pAnesthesiaConnectionToEnvironment
Definition: AnesthesiaMachine.h:118
Definition: SEAnesthesiaMachine.h:36
SEGasCompartment * m_scrubber
Definition: AnesthesiaMachine.h:113
SEGasSubstanceQuantity * m_ambientO2
Definition: AnesthesiaMachine.h:108
double m_dt_s
Definition: AnesthesiaMachine.h:99
SEGasSubstanceQuantity * m_gasSourceCO2
Definition: AnesthesiaMachine.h:110
SEFluidCircuitPath * m_pEnvironmentToReliefValve
Definition: AnesthesiaMachine.h:123
Manages and controls execution of all data/systems in BioGears.
Definition: BioGears.h:86
SEFluidCircuitPath * m_pSelectorToEnvironment
Definition: AnesthesiaMachine.h:124
double m_dValveClosedResistance_cmH2O_s_Per_L
Definition: AnesthesiaMachine.h:101
Generic class for handling the BioGears stabilization methodology.
Definition: BioGearsSystem.h:23
Definition: SEElectricalCircuit.h:18
SEGasSubstanceQuantity * m_scubberCO2
Definition: AnesthesiaMachine.h:114
SEFluidCircuitPath * m_pSelectorToScrubber
Definition: AnesthesiaMachine.h:127
static constexpr char const *const TypeTag()
Definition: AnesthesiaMachine.h:48
SEGasSubstanceQuantity * m_gasSourceO2
Definition: AnesthesiaMachine.h:112
Definition: SEAnesthesiaMachineActionCollection.h:32
BioGears & m_data
Definition: AnesthesiaMachine.h:42
Definition: SEGasCompartment.h:24
SEFluidCircuitPath * m_pGasSourceToGasInlet
Definition: AnesthesiaMachine.h:120