software:firmware
MakAir Firmware
alarm.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 // INCLUDES =====================================================================
11 
12 // Externals
13 #include <stdint.h>
14 
15 // ENUMS =====================================================================
16 
19 
20 // CLASS =====================================================================
21 
23 class Alarm {
24  public:
33  Alarm(AlarmPriority p_priority, uint8_t p_code, uint8_t p_detectionThreshold);
34 
36  AlarmPriority getPriority() const;
37 
39  uint8_t getCode() const;
40 
42  bool isTriggered() const;
43 
45  uint32_t getCyclesSinceTrigger() const;
46 
53  void detected(uint32_t p_cycleNumber);
54 
56  void notDetected();
57 
59  void enable();
60 
62  void disable();
63 
65  bool isEnabled();
66 
67  private:
70 
72  uint8_t m_code;
73 
76 
79 
81  uint32_t m_cycleNumber;
82 
85 
87  bool m_enabled;
88 };
AlarmPriority
Priority levels of an alarm.
Definition: alarm.h:18
@ ALARM_NONE
Definition: alarm.h:18
@ ALARM_HIGH
Definition: alarm.h:18
@ ALARM_LOW
Definition: alarm.h:18
@ ALARM_MEDIUM
Definition: alarm.h:18
Describe an alarm and handle its dynamic state.
Definition: alarm.h:23
bool isTriggered() const
True if the number of detections is equal or above the detection threshold, false otherwise.
Definition: alarm.cpp:38
bool m_enabled
Whether or not this alarm is enabled.
Definition: alarm.h:87
uint8_t m_detectionThreshold
Alarm detection threshold.
Definition: alarm.h:75
void disable()
Disable this alarm.
Definition: alarm.cpp:59
AlarmPriority m_priority
Alarm priority.
Definition: alarm.h:69
uint32_t m_cyclesSinceTrigger
Number of cycles since the alarm was triggered.
Definition: alarm.h:84
void detected(uint32_t p_cycleNumber)
If the alarm is detected, it increments the number of detection until the detection threshold.
Definition: alarm.cpp:40
uint8_t m_detectionNumber
Number of detections.
Definition: alarm.h:78
Alarm(AlarmPriority p_priority, uint8_t p_code, uint8_t p_detectionThreshold)
Parameterized constructor.
Definition: alarm.cpp:20
void notDetected()
Reset to zero the number of detection.
Definition: alarm.cpp:51
AlarmPriority getPriority() const
Get the alarm priority.
Definition: alarm.cpp:31
void enable()
Enable this alarm.
Definition: alarm.cpp:57
uint8_t getCode() const
Get the alarm code.
Definition: alarm.cpp:33
uint8_t m_code
Alarm code.
Definition: alarm.h:72
uint32_t getCyclesSinceTrigger() const
Get the number of cycles since the alarm was triggered.
Definition: alarm.cpp:36
bool isEnabled()
True if this alarm is enabled.
Definition: alarm.cpp:61
uint32_t m_cycleNumber
Cycle number.
Definition: alarm.h:81