SEAnesthesiaMachine.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/cdm/system/SESystem.h>
16 #include <biogears/exports.h>
17 #include <biogears/schema/cdm/AnesthesiaActions.hxx>
18 
19 namespace biogears {
20 
21 class SEEventHandler;
22 class SESubstanceManager;
23 class SEAnesthesiaMachineChamber;
24 class SEAnesthesiaMachineOxygenBottle;
25 class SEAnesthesiaMachineConfiguration;
26 class Serializer;
27 class TimeUnit;
28 class SEScalarVolumePerTime;
29 class VolumePerTimeUnit;
30 class SEScalarPressure;
31 class PressureUnit;
32 class SEScalarFrequency;
33 class FrequencyUnit;
34 class SEScalarFraction;
35 
36 class BIOGEARS_API SEAnesthesiaMachine : public SESystem {
37 protected:
39 
40 public:
42  ~SEAnesthesiaMachine() override;
43 
44  static size_t TypeHash() { return reinterpret_cast<size_t>(&TypeHash); }
45  static constexpr char const * const TypeTag() { return "SEAnesthesiaMachine"; }
46  const char* classname() const override { return TypeTag(); }
47  size_t hash_code() const override { return TypeHash(); }
48 
49  void Clear() override;
50 
51  bool Load(const CDM::AnesthesiaMachineData& in);
52  CDM::AnesthesiaMachineData* Unload() const override;
53 
54  Tree<const char*> GetPhysiologyRequestGraph() const override;
55 protected:
56  void Unload(CDM::AnesthesiaMachineData& data) const;
57 
63  virtual void StateChange() {};
64  void Merge(const SEAnesthesiaMachine& from);
65  void ProcessConfiguration(const SEAnesthesiaMachineConfiguration& config);
66 
67 public:
68  bool Load(const std::string& file);
69 
70  const SEScalar* GetScalar(const char* name) override;
71  const SEScalar* GetScalar(const std::string& name) override;
72 
73  const std::map<CDM::enumAnesthesiaMachineEvent::value, bool>& GetEventStates() const { return m_EventState; }
74  void SetEvent(CDM::enumAnesthesiaMachineEvent::value state, bool active, const SEScalarTime& time);
75  bool IsEventActive(CDM::enumAnesthesiaMachineEvent::value state) const;
76  double GetEventDuration(CDM::enumAnesthesiaMachineEvent::value type, const TimeUnit& unit) const;
77  void UpdateEvents(const SEScalarTime& timeStep);
85  void ForwardEvents(SEEventHandler* handler);
86 
87  virtual CDM::enumAnesthesiaMachineConnection::value GetConnection() const;
88  virtual void SetConnection(CDM::enumAnesthesiaMachineConnection::value c);
89  virtual bool HasConnection() const;
90  virtual void InvalidateConnection();
91 
92  bool HasInletFlow() const;
93  SEScalarVolumePerTime& GetInletFlow();
94  double GetInletFlow(const VolumePerTimeUnit& unit) const;
95 
96  bool HasInspiratoryExpiratoryRatio() const;
97  SEScalar& GetInspiratoryExpiratoryRatio();
98  double GetInspiratoryExpiratoryRatio() const;
99 
100  bool HasOxygenFraction() const;
101  SEScalarFraction& GetOxygenFraction();
102  double GetOxygenFraction() const;
103 
104  CDM::enumAnesthesiaMachineOxygenSource::value GetOxygenSource() const;
105  void SetOxygenSource(CDM::enumAnesthesiaMachineOxygenSource::value name);
106  bool HasOxygenSource() const;
107  void InvalidateOxygenSource();
108 
109  bool HasPositiveEndExpiredPressure() const;
110  SEScalarPressure& GetPositiveEndExpiredPressure();
111  double GetPositiveEndExpiredPressure(const PressureUnit& unit) const;
112 
113  CDM::enumAnesthesiaMachinePrimaryGas::value GetPrimaryGas() const;
114  void SetPrimaryGas(CDM::enumAnesthesiaMachinePrimaryGas::value name);
115  bool HasPrimaryGas() const;
116  void InvalidatePrimaryGas();
117 
118  bool HasRespiratoryRate() const;
119  SEScalarFrequency& GetRespiratoryRate();
120  double GetRespiratoryRate(const FrequencyUnit& unit) const;
121 
122  bool HasReliefValvePressure() const;
123  SEScalarPressure& GetReliefValvePressure();
124  double GetReliefValvePressure(const PressureUnit& unit) const;
125 
126  bool HasVentilatorPressure() const;
127  SEScalarPressure& GetVentilatorPressure();
128  double GetVentilatorPressure(const PressureUnit& unit) const;
129 
130  bool HasLeftChamber() const;
131  SEAnesthesiaMachineChamber& GetLeftChamber();
132  const SEAnesthesiaMachineChamber* GetLeftChamber() const;
133  void RemoveLeftChamber();
134 
135  bool HasRightChamber() const;
136  SEAnesthesiaMachineChamber& GetRightChamber();
137  const SEAnesthesiaMachineChamber* GetRightChamber() const;
138  void RemoveRightChamber();
139 
140  bool HasOxygenBottleOne() const;
141  SEAnesthesiaMachineOxygenBottle& GetOxygenBottleOne();
142  const SEAnesthesiaMachineOxygenBottle* GetOxygenBottleOne() const;
143  void RemoveOxygenBottleOne();
144 
145  bool HasOxygenBottleTwo() const;
146  SEAnesthesiaMachineOxygenBottle& GetOxygenBottleTwo();
147  const SEAnesthesiaMachineOxygenBottle* GetOxygenBottleTwo() const;
148  void RemoveOxygenBottleTwo();
149 
150 protected:
151  std::stringstream m_ss;
153  std::map<CDM::enumAnesthesiaMachineEvent::value, bool> m_EventState;
154  std::map<CDM::enumAnesthesiaMachineEvent::value, double> m_EventDuration_s;
155 
165 
167 
170 
173 
175 };
176 }
Definition: SEAnesthesiaMachineOxygenBottle.h:27
Definition: SEScalarFrequency.h:18
value
Underlying enum type.
Definition: Anesthesia.hxx:699
Definition: SEScalarFrequency.h:36
value
Underlying enum type.
Definition: Anesthesia.hxx:1160
Definition: SEScalar.h:33
size_t hash_code() const override
Definition: SEAnesthesiaMachine.h:47
SEScalarPressure * m_VentilatorPressure
Definition: SEAnesthesiaMachine.h:166
SEScalarFraction * m_OxygenFraction
Definition: SEAnesthesiaMachine.h:159
static constexpr char const *const TypeTag()
Definition: SEAnesthesiaMachine.h:45
friend SEAnesthesiaMachineConfiguration
Definition: SEAnesthesiaMachine.h:38
static size_t TypeHash()
Definition: SEAnesthesiaMachine.h:44
const std::map< CDM::enumAnesthesiaMachineEvent::value, bool > & GetEventStates() const
Definition: SEAnesthesiaMachine.h:73
Definition: SESystem.h:27
Definition: SEScalarVolumePerTime.h:18
SEScalarFrequency * m_RespiratoryRate
Definition: SEAnesthesiaMachine.h:163
CDM::enumAnesthesiaMachineOxygenSource::value m_OxygenSource
Definition: SEAnesthesiaMachine.h:160
std::map< CDM::enumAnesthesiaMachineEvent::value, bool > m_EventState
Definition: SEAnesthesiaMachine.h:153
SEAnesthesiaMachineChamber * m_LeftChamber
Definition: SEAnesthesiaMachine.h:168
SEScalarPressure * m_ReliefValvePressure
Definition: SEAnesthesiaMachine.h:164
const char * classname() const override
Definition: SEAnesthesiaMachine.h:46
SEEventHandler * m_EventHandler
Definition: SEAnesthesiaMachine.h:152
Definition: SEScalarFraction.h:18
Definition: SEScalarTime.h:37
Definition: SEAnesthesiaMachineConfiguration.h:20
Definition: SEScalarTime.h:18
CDM::enumAnesthesiaMachineConnection::value m_Connection
Definition: SEAnesthesiaMachine.h:156
SEScalarVolumePerTime * m_InletFlow
Definition: SEAnesthesiaMachine.h:157
value
Underlying enum type.
Definition: Anesthesia.hxx:1007
SEAnesthesiaMachineOxygenBottle * m_OxygenBottleTwo
Definition: SEAnesthesiaMachine.h:172
SEAnesthesiaMachineChamber * m_RightChamber
Definition: SEAnesthesiaMachine.h:169
Definition: SEScalarPressure.h:37
virtual void StateChange()
Definition: SEAnesthesiaMachine.h:63
Definition: SEAnesthesiaMachineChamber.h:27
CDM::enumAnesthesiaMachinePrimaryGas::value m_PrimaryGas
Definition: SEAnesthesiaMachine.h:162
Definition: SEScalarVolumePerTime.h:40
Definition: SEAnesthesiaMachine.h:36
SEScalarPressure * m_PositiveEndExpiredPressure
Definition: SEAnesthesiaMachine.h:161
std::stringstream m_ss
Definition: SEAnesthesiaMachine.h:151
Definition: SEScalarPressure.h:18
std::map< CDM::enumAnesthesiaMachineEvent::value, double > m_EventDuration_s
Definition: SEAnesthesiaMachine.h:154
SEAnesthesiaMachineOxygenBottle * m_OxygenBottleOne
Definition: SEAnesthesiaMachine.h:171
SEScalar * m_InspiratoryExpiratoryRatio
Definition: SEAnesthesiaMachine.h:158
Definition: SESubstanceManager.h:23
SESubstanceManager & m_Substances
Definition: SEAnesthesiaMachine.h:174
Definition: SEElectricalCircuit.h:18
Definition: SEEventHandler.h:23
Class corresponding to the AnesthesiaMachineData schema type.
Definition: Anesthesia.hxx:1539
value
Underlying enum type.
Definition: Anesthesia.hxx:853