MechanicalVentilatorModel.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5
6#include "engine/common/system/Model.h"
7#include "engine/common/system/Systems.h"
8
15
16namespace pulse
17{
18 class PBEquipment;
19 class EngineTest;
24 class PULSE_DECL MechanicalVentilatorModel : public MechanicalVentilatorSystem, public Model
25 {
26 friend PBEquipment;//friend the serialization class
27 friend EngineTest;
28 public:
29 MechanicalVentilatorModel(Data& pc);
30 virtual ~MechanicalVentilatorModel();
31
32 void Clear() override;
33
34 // Set members to a stable homeostatic state
35 void Initialize() override;
36 // Set pointers and other member varialbes common to both homeostatic initialization and loading a state
37 void SetUp() override;
38
39 void StateChange() override;
40
41 void AtSteadyState() override {}
42 void PreProcess() override;
43 void Process(bool solve_and_transport = true) override;
44 void PostProcess(bool solve_and_transport = true) override;
45
46 protected:
47
48 void ComputeExposedModelParameters() override;
49
50 void UpdateAirwayMode();
51
52 void CheckInspirationTriggers();
53 void CalculateInspiration();
54 void CalculatePause();
55 void CalculateExpiration();
56 void SetVentilatorDriver();
57 void CycleMode(bool patientTriggered);
58 void SetLeak();
59 void SetHold();
60 void SetValves();
61 void CalculateRespiratoryParameters();
62 void CalculateInspiratoryRespiratoryParameters();
63 void CalculatePauseRespiratoryParameters();
64 void CalculateExpiratoryRespiratoryParameters();
65 void SetResistances();
66 void SetCompliance();
67 void SetVolumes();
68 void CheckReliefValve();
69
70 // Serializable member variables (Set in Initialize and in schema)
71 double m_CurrentPeriodTime_s;
72 double m_DriverPressure_cmH2O;
73 double m_PreviousDriverFlow_L_Per_s;
74 double m_PreviousDriverPressure_cmH2O;
75 double m_DriverFlow_L_Per_s;
76 double m_CurrentVentilatorVolume_L;
77 double m_CurrentRespiratoryVolume_L;
78 double m_InspirationTime_s;
79 double m_InspiratoryFlow_L_Per_s;
80 double m_PreviousYPieceToConnectionFlow_L_Per_s;
81 double m_PreviousConnectionPressure_cmH2O;
82 bool m_PauseOccurred;
83 eBreathState m_CurrentBreathState;
84 bool m_Initializing;
85
86 double m_PositiveEndExpiratoryPressure_cmH2O;
87 double m_PeakExpiratoryFlow_L_Per_s;
88 double m_PeakInspiratoryFlow_L_Per_s;
89 double m_EndTidalCarbonDioxideFraction;
90 double m_EndTidalCarbonDioxidePressure_cmH2O;
91 double m_EndTidalOxygenFraction;
92 double m_EndTidalOxygenPressure_cmH2O;
93
94 SERunningAverage* m_MeanAirwayPressure_cmH2O;
95
96 // Stateless member variable (Set in SetUp())
97 SEGasCompartment* m_Environment;
98 SEGasCompartment* m_Ventilator;
99 SEGasCompartment* m_Connection;
100 SELiquidCompartment* m_VentilatorAerosol;
101 SEFluidCircuitNode* m_VentilatorNode;
102 SEFluidCircuitNode* m_ExpiratoryLimbNode;
103 SEFluidCircuitNode* m_ExpiratoryValveNode;
104 SEFluidCircuitNode* m_InspiratoryLimbNode;
105 SEFluidCircuitNode* m_InspiratoryValveNode;
106 SEFluidCircuitNode* m_YPieceNode;
107 SEFluidCircuitNode* m_ConnectionNode;
108 SEFluidCircuitNode* m_AmbientNode;
109 SEFluidCircuitPath* m_EnvironmentToVentilator;
110 SEFluidCircuitPath* m_VentilatorToEnvironment;
111 SEFluidCircuitPath* m_YPieceToConnection;
112 SEFluidCircuitPath* m_VentilatorToExpiratoryValve;
113 SEFluidCircuitPath* m_VentilatorToInspiratoryValve;
114 SEFluidCircuitPath* m_ExpiratoryLimbToYPiece;
115 SEFluidCircuitPath* m_InspiratoryLimbToYPiece;
116 SEFluidCircuitPath* m_LeakConnectionToEnvironment;
117 SEFluidCircuitPath* m_ConnectionToReliefValve;
118 SEFluidCircuitPath* m_EnvironmentToReliefValve;
119 SEFluidCircuitPath* m_ConnectionToAirway;
120 double m_MachineClosedResistance_cmH2O_s_Per_L;
121 double m_MachineOpenResistance_cmH2O_s_Per_L;
122 // Piecewise linear function points
123 std::vector<std::pair<double, double>> m_leakPoints;
124 };
125END_NAMESPACE
Definition: SEEquipmentActionCollection.h:47
Definition: SEFluidCircuitNode.h:10
Definition: SEFluidCircuitPath.h:9
Definition: SEGasCompartment.h:14
Definition: SEGasSubstanceQuantity.h:10
Definition: SELiquidCompartment.h:11
Definition: SERunningAverage.h:8
Definition: Logger.h:14

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.