What’s New in the Pulse Physiology Engine 4.4.0
×
SEEventManager.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "cdm/properties/SEScalarTime.h"
6
7// Keep enums in sync with appropriate schema/cdm/Event.proto file !!
8enum class eEvent
9{
10 Antidiuresis = 0,
11 Bradycardia = 1,
12 Bradypnea = 2,
13 BrainOxygenDeficit = 3,
14 CardiacArrest = 4,
15 CardiogenicShock = 5,
16 CardiovascularCollapse = 6,
17 CriticalBrainOxygenDeficit = 7,
18 Diuresis = 8,
19 Fasciculation = 9,
20 Fatigue = 10,
21 FunctionalIncontinence = 11,
22 Hypercapnia = 12,
23 Hyperglycemia = 13,
24 Hypernatremia = 14,
25 Hyperthermia = 15,
26 Hypoglycemia = 16,
27 Hyponatremia = 17,
28 Hypothermia = 18,
29 Hypoxia = 19,
30 HypovolemicShock = 20,
31 IntracranialHypertension = 21,
32 IntracranialHypotension = 22,
33 IrreversibleState = 23,
34 Ketoacidosis = 24,
35 LacticAcidosis = 25,
36 MassiveHemothorax = 26,
37 MaximumPulmonaryVentilationRate = 27,
38 MediumHemothorax = 28,
39 MetabolicAcidosis = 29,
40 MetabolicAlkalosis = 30,
41 MildDehydration = 31,
42 MinimalHemothorax = 32,
43 ModerateDehydration = 33,
44 ModerateHyperoxemia = 34,
45 ModerateHypocapnia = 35,
46 MyocardiumOxygenDeficit = 36,
47 Natriuresis = 37,
48 NutritionDepleted = 38,
49 RenalHypoperfusion = 39,
50 RespiratoryAcidosis = 40,
51 RespiratoryAlkalosis = 41,
52 SevereDehydration = 42,
53 SevereHyperoxemia = 43,
54 SevereHypocapnia = 44,
55 Stabilizing = 45,
56 StartOfCardiacCycle = 46,
57 StartOfExhale = 47,
58 StartOfInhale = 48,
59 Tachycardia = 49,
60 Tachypnea = 50,
61
62 // Supplemental Oxygen
63 SupplementalOxygenBottleExhausted = 1000,
64 NonRebreatherMaskOxygenBagEmpty = 1001,
65
66 // Anesthesia Machine
67 AnesthesiaMachineOxygenBottleOneExhausted = 2000,
68 AnesthesiaMachineOxygenBottleTwoExhausted = 2001,
69 AnesthesiaMachineReliefValveActive = 2002,
70
71 // Mechanical Ventilator
72 MechanicalVentilatorReliefValveActive = 3000,
73 // Mechanical Ventilator Alarms
74 ApneaTimeAlarmTriggered = 3001,
75 AutoPositiveEndExpiratoryPressureAlarmTriggered = 3002,
76 CircuitLeakAlarmTriggered = 3003,
77 HighEndTidalCarbonDioxideAlarmTriggered = 3004,
78 HighMinuteVentilationAlarmTriggered = 3005,
79 HighOxygenSaturationAlarmTriggered = 3006,
80 HighPositiveEndExpiratoryPressureAlarmTriggered = 3007,
81 HighPressureAlarmTriggered = 3008,
82 HighRespiratoryRateAlarmTriggered = 3009,
83 HighTidalVolumeAlarmTriggered = 3010,
84 LowEndTidalCarbonDioxideAlarmTriggered = 3011,
85 LowMinuteVentilationAlarmTriggered = 3012,
86 LowOxygenSaturationAlarmTriggered = 3013,
87 LowPositiveEndExpiratoryPressureAlarmTriggered = 3014,
88 LowPressureAlarmTriggered = 3015,
89 LowTidalVolumeAlarmTriggered = 3016,
90 OxygenSupplyFailureAlarmTriggered = 3017
91};
92extern CDM_DECL const std::string& eEvent_Name(eEvent m);
93
94class CDM_DECL SEEventChange
95{
96 friend class SEEventManager;
97public:
98 SEEventChange(eEvent e, bool active)
99 {
100 m_Event = e;
101 m_Active = active;
102 m_Duration_s = 0;
103 }
104 SEEventChange(eEvent e, bool active, double duration_s)
105 {
106 m_Event = e;
107 m_Active = active;
108 m_Duration_s = duration_s;
109 }
110
111 eEvent GetEvent() const { return m_Event; }
112 bool GetActive() const { return m_Active; }
113 double GetDuration_s() const { return m_Duration_s; }
114
115protected:
117 eEvent m_Event;
119};
120
121class CDM_DECL SEEventHandler
122{
123public:
125 virtual ~SEEventHandler() {};
126
127 virtual void HandleEvent(eEvent type, bool active) = 0;
128};
129
130class CDM_DECL SEEventManager : public Loggable
131{
132 friend class PBEvents;//friend the serialization class
133public:
134 SEEventManager(Logger* logger); // If we want to track the sim time of events, pass in the engine &simtime
135 virtual ~SEEventManager();
136
137 void Clear();
138
139 virtual void SetEvent(eEvent e, bool active);
140 virtual bool IsEventActive(eEvent e) const;
141 virtual double GetEventDuration_s(eEvent e) const;
142 virtual double GetEventDuration(eEvent e, const TimeUnit& unit) const;
143 virtual void GetActiveEvents(std::vector<SEEventChange>& active) const; // Events where active==true
144 virtual void GetEventChanges(std::vector<SEEventChange>& changed) const; // Events where duration_s==0
145
146 virtual void ForwardEvents(SEEventHandler* handler) const { m_EventHandler = handler; }
147 virtual SEEventHandler* GetEventHandler() { return m_EventHandler; }
148
149 // Intended to be called by engine controllers at the end of a time step to increment event durations and call the event handler
150 virtual void UpdateEvents(const SEScalarTime& timeStep);
151
152protected:
153 SEEventChange& GetEvent(eEvent e);
154 const SEEventChange* GetEvent(eEvent e) const;
155
156 std::stringstream m_ss;
157 std::vector<SEEventChange> m_Events;
159};
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PBEvents.h:10
Definition: SEEventManager.h:95
eEvent m_Event
Definition: SEEventManager.h:117
bool m_Active
Definition: SEEventManager.h:116
bool GetActive() const
Definition: SEEventManager.h:112
double GetDuration_s() const
Definition: SEEventManager.h:113
SEEventChange(eEvent e, bool active)
Definition: SEEventManager.h:98
SEEventChange(eEvent e, bool active, double duration_s)
Definition: SEEventManager.h:104
double m_Duration_s
Definition: SEEventManager.h:118
eEvent GetEvent() const
Definition: SEEventManager.h:111
Definition: SEEventManager.h:122
virtual void HandleEvent(eEvent type, bool active)=0
virtual ~SEEventHandler()
Definition: SEEventManager.h:125
SEEventHandler()
Definition: SEEventManager.h:124
Definition: SEEventManager.h:131
std::stringstream m_ss
Definition: SEEventManager.h:156
SEEventHandler * m_EventHandler
Definition: SEEventManager.h:158
virtual void ForwardEvents(SEEventHandler *handler) const
Definition: SEEventManager.h:146
virtual SEEventHandler * GetEventHandler()
Definition: SEEventManager.h:147
std::vector< SEEventChange > m_Events
Definition: SEEventManager.h:157
Definition: SEScalarTime.h:28
Definition: SEScalarTime.h:8

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.