<
The Pulse Team is excited to announce the Pulse Physiology Engine 4.1.0 release. Upgrade now to get the best in dynamic simulation.
×
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 !!
8 enum 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  Dehydration = 8,
19  Diuresis = 9,
20  Fasciculation = 10,
21  Fatigue = 11,
22  FunctionalIncontinence = 12,
23  Hypercapnia = 13,
24  Hyperglycemia = 14,
25  Hyperthermia = 15,
26  Hypoglycemia = 16,
27  Hypothermia = 17,
28  Hypoxia = 18,
29  HypovolemicShock = 19,
30  IntracranialHypertension = 20,
31  IntracranialHypotension = 21,
32  IrreversibleState = 22,
33  Ketoacidosis = 23,
34  LacticAcidosis = 24,
35  MaximumPulmonaryVentilationRate = 25,
36  MetabolicAcidosis = 26,
37  MetabolicAlkalosis = 27,
38  ModerateHyperoxemia = 28,
39  ModerateHypocapnia = 29,
40  MyocardiumOxygenDeficit = 30,
41  Natriuresis = 31,
42  NutritionDepleted = 32,
43  RenalHypoperfusion = 33,
44  RespiratoryAcidosis = 34,
45  RespiratoryAlkalosis = 35,
46  SevereHyperoxemia = 36,
47  SevereHypocapnia = 37,
48  StartOfCardiacCycle = 38,
49  StartOfExhale = 39,
50  StartOfInhale = 40,
51  Tachycardia = 41,
52  Tachypnea = 42,
53 
54  // Equipment
55  AnesthesiaMachineOxygenBottleOneExhausted = 1000,
56  AnesthesiaMachineOxygenBottleTwoExhausted = 1001,
57  AnesthesiaMachineReliefValveActive = 1002,
58  MechanicalVentilatorReliefValveActive = 1003,
59  SupplementalOxygenBottleExhausted = 1004,
60  NonRebreatherMaskOxygenBagEmpty = 1005
61 };
62 extern const std::string& eEvent_Name(eEvent m);
63 
64 class CDM_DECL SEEventHandler
65 {
66 public:
68  virtual ~SEEventHandler() {};
69 
70  virtual void HandleEvent(eEvent e, bool active, const SEScalarTime* simTime = nullptr) = 0;
71 };
72 
73 class CDM_DECL SEActiveEvent
74 {
75 public:
76  SEActiveEvent(eEvent e, const SEScalarTime& duration);
77  SEActiveEvent(eEvent e, double duration, const TimeUnit& unit);
78 
79  static bool SerializeToString(std::vector<const SEActiveEvent*>& active, std::string& output, eSerializationFormat m, Logger* logger);
80  static bool SerializeFromString(const std::string& src, std::vector<const SEActiveEvent*>& active, eSerializationFormat m, Logger* logger);
81 
82  eEvent GetEvent() const { return m_Event; }
83  const SEScalarTime& GetDuration() const { return m_Duration; }
84 
85 protected:
86  eEvent m_Event;
88 };
89 
90 class CDM_DECL SEEventChange
91 {
92 public:
93  SEEventChange(eEvent e, bool active, const SEScalarTime* simTime = nullptr);
94 
95  static bool SerializeToString(std::vector<const SEEventChange*>& changes, std::string& output, eSerializationFormat m, Logger* logger);
96  static bool SerializeFromString(const std::string& src, std::vector<const SEEventChange*>& changes, eSerializationFormat m, Logger* logger);
97 
98  eEvent GetEvent() const { return m_Event; }
99  bool GetActive() const { return m_Active; }
100  const SEScalarTime& GetSimTime() const { return m_SimTime; }
101 
102 protected:
103  bool m_Active;
104  eEvent m_Event;
106 };
107 
108 class CDM_DECL SEEventManager : public Loggable
109 {
110 public:
111  SEEventManager(Logger* logger);
112  virtual ~SEEventManager();
113 
114  void Clear();
115  // Essentially a load, this will set the state to active and set its duration
116  virtual void OverrideActiveState(eEvent state, const SEScalarTime& duration);
117 
118  virtual const std::map<eEvent, bool>& GetEventStates() const { return m_EventState; }
119  virtual void SetEvent(eEvent e, bool active, const SEScalarTime& time);
120  virtual bool IsEventActive(eEvent e) const;
121  virtual double GetEventDuration(eEvent e, const TimeUnit& unit) const;
122  virtual void UpdateEvents(const SEScalarTime& timeStep);
123  virtual bool GetActiveEvents(std::vector<const SEActiveEvent*>& active) const;
131  virtual void ForwardEvents(SEEventHandler* handler) const;
132  virtual SEEventHandler* GetEventHandler() { return m_EventHandler; }
133 
134 protected:
135 
136  std::stringstream m_ss;
138  std::map<eEvent, bool> m_EventState;
139  std::map<eEvent, double> m_EventDuration_s;
140 };
virtual ~SEEventHandler()
Definition: SEEventManager.h:68
bool m_Active
Definition: SEEventManager.h:103
Definition: Logger.h:66
std::stringstream m_ss
Definition: SEEventManager.h:136
eEvent m_Event
Definition: SEEventManager.h:104
std::map< eEvent, double > m_EventDuration_s
Definition: SEEventManager.h:139
SEScalarTime m_SimTime
Definition: SEEventManager.h:105
const SEScalarTime & GetSimTime() const
Definition: SEEventManager.h:100
Definition: SEEventManager.h:64
eEvent m_Event
Definition: SEEventManager.h:86
Definition: SEScalarTime.h:7
SEEventHandler * m_EventHandler
Definition: SEEventManager.h:137
Definition: Logger.h:18
Definition: SEEventManager.h:90
virtual SEEventHandler * GetEventHandler()
Definition: SEEventManager.h:132
bool GetActive() const
Definition: SEEventManager.h:99
eEvent GetEvent() const
Definition: SEEventManager.h:98
Definition: SEEventManager.h:108
virtual const std::map< eEvent, bool > & GetEventStates() const
Definition: SEEventManager.h:118
SEScalarTime m_Duration
Definition: SEEventManager.h:87
Definition: SEScalarTime.h:27
Definition: SEEventManager.h:73
std::map< eEvent, bool > m_EventState
Definition: SEEventManager.h:138
eEvent GetEvent() const
Definition: SEEventManager.h:82
SEEventHandler()
Definition: SEEventManager.h:67
const SEScalarTime & GetDuration() const
Definition: SEEventManager.h:83

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.