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 // Equipment
63 AnesthesiaMachineOxygenBottleOneExhausted = 1000,
64 AnesthesiaMachineOxygenBottleTwoExhausted = 1001,
65 AnesthesiaMachineReliefValveActive = 1002,
66 MechanicalVentilatorReliefValveActive = 1003,
67 SupplementalOxygenBottleExhausted = 1004,
68 NonRebreatherMaskOxygenBagEmpty = 1005
69};
70extern CDM_DECL const std::string& eEvent_Name(eEvent m);
71
72class CDM_DECL SEEventHandler
73{
74public:
76 virtual ~SEEventHandler() {};
77
78 virtual void HandleEvent(eEvent e, bool active, const SEScalarTime* simTime = nullptr) = 0;
79};
80
81class CDM_DECL SEActiveEvent
82{
83public:
84 SEActiveEvent(eEvent e, const SEScalarTime& duration);
85 SEActiveEvent(eEvent e, double duration, const TimeUnit& unit);
86
87 static bool SerializeToString(std::vector<const SEActiveEvent*>& active, std::string& output, eSerializationFormat m, Logger* logger);
88 static bool SerializeFromString(const std::string& src, std::vector<const SEActiveEvent*>& active, eSerializationFormat m, Logger* logger);
89
90 eEvent GetEvent() const { return m_Event; }
91 const SEScalarTime& GetDuration() const { return m_Duration; }
92
93protected:
94 eEvent m_Event;
96};
97
98class CDM_DECL SEEventChange
99{
100public:
101 SEEventChange(eEvent e, bool active, const SEScalarTime* simTime = nullptr);
102
103 static bool SerializeToString(std::vector<const SEEventChange*>& changes, std::string& output, eSerializationFormat m, Logger* logger);
104 static bool SerializeFromString(const std::string& src, std::vector<const SEEventChange*>& changes, eSerializationFormat m, Logger* logger);
105
106 eEvent GetEvent() const { return m_Event; }
107 bool GetActive() const { return m_Active; }
108 const SEScalarTime& GetSimTime() const { return m_SimTime; }
109
110protected:
112 eEvent m_Event;
114};
115
116class CDM_DECL SEEventManager : public Loggable
117{
118public:
119 SEEventManager(Logger* logger);
120 virtual ~SEEventManager();
121
122 void Clear();
123 // Essentially a load, this will set the state to active and set its duration
124 virtual void OverrideActiveState(eEvent state, const SEScalarTime& duration);
125
126 virtual const std::map<eEvent, bool>& GetEventStates() const { return m_EventState; }
127 virtual void SetEvent(eEvent e, bool active, const SEScalarTime& time);
128 virtual bool IsEventActive(eEvent e) const;
129 virtual double GetEventDuration(eEvent e, const TimeUnit& unit) const;
130 virtual void UpdateEvents(const SEScalarTime& timeStep);
131 virtual bool GetActiveEvents(std::vector<const SEActiveEvent*>& active) const;
139 virtual void ForwardEvents(SEEventHandler* handler) const;
140 virtual SEEventHandler* GetEventHandler() { return m_EventHandler; }
141
142protected:
143
144 std::stringstream m_ss;
146 std::map<eEvent, bool> m_EventState;
147 std::map<eEvent, double> m_EventDuration_s;
148};
Definition: Logger.h:23
Definition: Logger.h:71
Definition: SEEventManager.h:82
SEScalarTime m_Duration
Definition: SEEventManager.h:95
const SEScalarTime & GetDuration() const
Definition: SEEventManager.h:91
eEvent m_Event
Definition: SEEventManager.h:94
eEvent GetEvent() const
Definition: SEEventManager.h:90
Definition: SEEventManager.h:99
eEvent m_Event
Definition: SEEventManager.h:112
SEScalarTime m_SimTime
Definition: SEEventManager.h:113
bool m_Active
Definition: SEEventManager.h:111
bool GetActive() const
Definition: SEEventManager.h:107
const SEScalarTime & GetSimTime() const
Definition: SEEventManager.h:108
eEvent GetEvent() const
Definition: SEEventManager.h:106
Definition: SEEventManager.h:73
virtual void HandleEvent(eEvent e, bool active, const SEScalarTime *simTime=nullptr)=0
virtual ~SEEventHandler()
Definition: SEEventManager.h:76
SEEventHandler()
Definition: SEEventManager.h:75
Definition: SEEventManager.h:117
std::map< eEvent, double > m_EventDuration_s
Definition: SEEventManager.h:147
std::stringstream m_ss
Definition: SEEventManager.h:144
SEEventHandler * m_EventHandler
Definition: SEEventManager.h:145
virtual const std::map< eEvent, bool > & GetEventStates() const
Definition: SEEventManager.h:126
virtual SEEventHandler * GetEventHandler()
Definition: SEEventManager.h:140
std::map< eEvent, bool > m_EventState
Definition: SEEventManager.h:146
Definition: SEScalarTime.h:28
Definition: SEScalarTime.h:8

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.