software:firmware
MakAir Firmware
Alarm Class Reference

Describe an alarm and handle its dynamic state. More...

#include <alarm.h>

Public Member Functions

 Alarm (AlarmPriority p_priority, uint8_t p_code, uint8_t p_detectionThreshold)
 Parameterized constructor. More...
 
AlarmPriority getPriority () const
 Get the alarm priority. More...
 
uint8_t getCode () const
 Get the alarm code. More...
 
bool isTriggered () const
 True if the number of detections is equal or above the detection threshold, false otherwise. More...
 
uint32_t getCyclesSinceTrigger () const
 Get the number of cycles since the alarm was triggered. More...
 
void detected (uint32_t p_cycleNumber)
 If the alarm is detected, it increments the number of detection until the detection threshold. More...
 
void notDetected ()
 Reset to zero the number of detection. More...
 
void enable ()
 Enable this alarm. More...
 
void disable ()
 Disable this alarm. More...
 
bool isEnabled ()
 True if this alarm is enabled. More...
 

Private Attributes

AlarmPriority m_priority
 Alarm priority. More...
 
uint8_t m_code
 Alarm code. More...
 
uint8_t m_detectionThreshold
 Alarm detection threshold. More...
 
uint8_t m_detectionNumber
 Number of detections. More...
 
uint32_t m_cycleNumber
 Cycle number. More...
 
uint32_t m_cyclesSinceTrigger
 Number of cycles since the alarm was triggered. More...
 
bool m_enabled
 Whether or not this alarm is enabled. More...
 

Detailed Description

Describe an alarm and handle its dynamic state.

Definition at line 23 of file alarm.h.

Constructor & Destructor Documentation

◆ Alarm()

Alarm::Alarm ( AlarmPriority  p_priority,
uint8_t  p_code,
uint8_t  p_detectionThreshold 
)

Parameterized constructor.

Parameters
p_priorityAlarm priority
p_codeAlarm code
p_detectionThresholdNumber of detections in a row to trigger this alarm

Definition at line 20 of file alarm.cpp.

20  {
21  m_priority = p_priority;
22  m_code = p_code;
23  m_detectionThreshold = p_detectionThreshold;
25  UINT32_MAX; // We need this not to be 0 so that alarms can be triggered just after booting
26  m_detectionNumber = 0u;
28  m_enabled = true;
29 }
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
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
uint8_t m_detectionNumber
Number of detections.
Definition: alarm.h:78
uint8_t m_code
Alarm code.
Definition: alarm.h:72
uint32_t m_cycleNumber
Cycle number.
Definition: alarm.h:81

Member Function Documentation

◆ detected()

void Alarm::detected ( uint32_t  p_cycleNumber)

If the alarm is detected, it increments the number of detection until the detection threshold.

Parameters
p_cycleNumberThe cycle where the detection is done

Definition at line 40 of file alarm.cpp.

40  {
41  if (m_cycleNumber != p_cycleNumber) {
42  m_cycleNumber = p_cycleNumber;
47  }
48  }
49 }

◆ disable()

void Alarm::disable ( )

Disable this alarm.

Definition at line 59 of file alarm.cpp.

59 { m_enabled = false; }

◆ enable()

void Alarm::enable ( )

Enable this alarm.

Definition at line 57 of file alarm.cpp.

57 { m_enabled = true; }

◆ getCode()

uint8_t Alarm::getCode ( ) const

Get the alarm code.

Definition at line 33 of file alarm.cpp.

33 { return m_code; }

◆ getCyclesSinceTrigger()

uint32_t Alarm::getCyclesSinceTrigger ( ) const

Get the number of cycles since the alarm was triggered.

Definition at line 36 of file alarm.cpp.

36 { return m_cyclesSinceTrigger; }

◆ getPriority()

AlarmPriority Alarm::getPriority ( ) const

Get the alarm priority.

Definition at line 31 of file alarm.cpp.

31 { return m_priority; }

◆ isEnabled()

bool Alarm::isEnabled ( )

True if this alarm is enabled.

Definition at line 61 of file alarm.cpp.

61 { return m_enabled; }

◆ isTriggered()

bool Alarm::isTriggered ( ) const

True if the number of detections is equal or above the detection threshold, false otherwise.

Definition at line 38 of file alarm.cpp.

◆ notDetected()

void Alarm::notDetected ( )

Reset to zero the number of detection.

Definition at line 51 of file alarm.cpp.

51  {
52  m_cycleNumber = UINT32_MAX;
53  m_detectionNumber = 0u;
55 }

Member Data Documentation

◆ m_code

uint8_t Alarm::m_code
private

Alarm code.

Definition at line 72 of file alarm.h.

◆ m_cycleNumber

uint32_t Alarm::m_cycleNumber
private

Cycle number.

Definition at line 81 of file alarm.h.

◆ m_cyclesSinceTrigger

uint32_t Alarm::m_cyclesSinceTrigger
private

Number of cycles since the alarm was triggered.

Definition at line 84 of file alarm.h.

◆ m_detectionNumber

uint8_t Alarm::m_detectionNumber
private

Number of detections.

Definition at line 78 of file alarm.h.

◆ m_detectionThreshold

uint8_t Alarm::m_detectionThreshold
private

Alarm detection threshold.

Definition at line 75 of file alarm.h.

◆ m_enabled

bool Alarm::m_enabled
private

Whether or not this alarm is enabled.

Definition at line 87 of file alarm.h.

◆ m_priority

AlarmPriority Alarm::m_priority
private

Alarm priority.

Definition at line 69 of file alarm.h.


The documentation for this class was generated from the following files: