software:firmware
MakAir Firmware
alarm_controller.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 // INCLUDES ===================================================================
11 
12 // Internals
13 #include "../includes/alarm.h"
14 #include "../includes/cycle.h"
15 
16 // CONSTANTS ==================================================================
17 
18 #define ALARMS_SIZE 21u
19 
20 #define RCM_SW_1 12u // Plateau pressure not reached
21 #define RCM_SW_2 11u // Patient is unplugged
22 #define RCM_SW_3 14u // Peep not reached
23 #define RCM_SW_11 21u // Battery Low
24 #define RCM_SW_12 13u // Battery vers Low
25 #define RCM_SW_14 22u // Plateau pressure not reached
26 #define RCM_SW_15 23u // Peep not reached
27 #define RCM_SW_16 31u // Mains disconnected
28 #define RCM_SW_18 17u // Pressure too high
29 #define RCM_SW_19 24u // Patient is unplugged
30 
31 #define RCM_SW_4 40u // Inspiratory minute Volume is too low
32 #define RCM_SW_5 41u // Inspiratory minute Volume is too high
33 #define RCM_SW_6 42u // Expiratory minute Volume is too low
34 #define RCM_SW_7 43u // Expiratory minute Volume is too high
35 #define RCM_SW_8 44u // Respiratory rate is too low
36 #define RCM_SW_9 45u // Respiratory rate is too high
37 #define RCM_SW_10 46u // Leak is too high
38 
39 #define RCM_SW_20 47u // Tidal Volume is too low
40 #define RCM_SW_21 48u // Tidal Volume is too high
41 #define RCM_SW_22 49u // peak pressure is too high
42 #define RCM_SW_23 107u // Expiratory flow too low
43 
45 struct Alarms {
46  uint8_t alarms[ALARMS_SIZE];
47 };
48 
49 // CLASS =====================================================================
50 
53  public:
56 
62  void snooze();
63 
67  void unsnooze();
68 
70  bool isSnoozed() const { return !m_unsnooze; }
71 
81  void detectedAlarm(uint8_t p_alarmCode,
82  uint32_t p_cycleNumber,
83  uint32_t p_expected,
84  uint32_t p_measured);
85 
90  void notDetectedAlarm(uint8_t p_alarmCode);
91 
97  void runAlarmEffects(uint32_t p_tick);
98 
100  void updateCoreData(uint32_t p_tick,
101  uint16_t p_pressure,
102  CyclePhases p_phase,
103  uint32_t p_cycle_number);
104 
106  uint8_t* triggeredAlarms() { return m_triggeredAlarms; }
107 
113  void updateEnabledAlarms(Alarms enabledAlarms);
114 
115  private:
118 
120  uint32_t m_snoozeTime;
121 
124 
127 
130 
132  uint16_t m_tick;
133 
135  uint16_t m_pressure;
136 
139 
141  uint32_t m_cycle_number;
142 
145 };
146 
147 // INITIALISATION =============================================================
148 
AlarmPriority
Priority levels of an alarm.
Definition: alarm.h:18
AlarmController alarmController
Instance of the alarm controller.
#define ALARMS_SIZE
Manage alarm features.
bool isSnoozed() const
Check if alarms are currently snoozed.
bool m_snoozedAlarms[ALARMS_SIZE]
Collections of snoozed alarms.
void updateCoreData(uint32_t p_tick, uint16_t p_pressure, CyclePhases p_phase, uint32_t p_cycle_number)
Update internal state of alarm controller with data from pressure controller.
AlarmController()
Default constructor.
uint32_t m_cycle_number
Current cycle number.
void detectedAlarm(uint8_t p_alarmCode, uint32_t p_cycleNumber, uint32_t p_expected, uint32_t p_measured)
Mark a specific alarm as detected.
uint32_t m_snoozeTime
Time when snoozed was triggered.
bool m_unsnooze
Is unsnoozed right now.
uint8_t * triggeredAlarms()
Get the alarms triggered during this cycle.
uint16_t m_tick
Current pressure.
void snooze()
Snooze alarm for 2 minutes.
Alarm m_alarms[ALARMS_SIZE]
Collections of available alarms.
CyclePhases m_phase
Current phase.
void updateEnabledAlarms(Alarms enabledAlarms)
Update the list of enabled alarms (alarms not provided here will have no effects)
void unsnooze()
Unsnooze alarms.
uint8_t m_triggeredAlarms[ALARMS_SIZE]
Alarms currently triggered.
void runAlarmEffects(uint32_t p_tick)
Run effects (buzzer, LCD message, LED) according to the currently triggered alarms.
AlarmPriority m_highestPriority
Highest priority of the currently triggered alarms.
void notDetectedAlarm(uint8_t p_alarmCode)
Reset detection of a specific alarm.
uint16_t m_pressure
Current pressure.
Describe an alarm and handle its dynamic state.
Definition: alarm.h:23
CyclePhases
Defines the 2 main phases of the respiratory cycle.
Definition: cycle.h:14
List of alarms (named by their code)
uint8_t alarms[ALARMS_SIZE]