1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Alarms.h

#ifndef _ALARMS_h
#define _ALARMS_h

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif
#include "HAL.h"
#include "SystemStatus.h"
#include "generic_definitions.h"

/**
 * Class that manage the ALARMS and WARNINGS
 */
class AlarmClass
{
private:
	HAL* _HAL;
	t_SystemStatus *_sys_c;

	void CheckStaticAlarms();
	void Sound();
    void AlarmActions();
    uint32_t GenerateFlag(int alarm_code);


    uint32_t ALARM_FLAG = 0x0;
    uint32_t ALARM_FLAG_SNOOZE = 0x0;
    uint32_t ALARM_FLAG_FILTERED = 0x0;
    uint64_t ALARM_FLAG_SNOOZE_millis = 0;

    int alarm_state=0;

    uint64_t buzzer_time;
    uint64_t blinker_led_time;
    uint64_t wdog_timer;
    bool AlarmSound=false;
    bool isInAlarm = false;
    bool led_on = false;
    bool wdog_enable=false;
    float P0Loop=0;
    float P0Patient=0;
    bool _disable_alarms = 0;
    CircularBuffer* CycleCyclePLoop;
    CircularBuffer* CycleCyclePPatient;

public:
	void Action_OverPressureSecurity();
	void Init(HAL* hal, t_SystemStatus* sys_c);
    void TriggerAlarm(t_ALARM Alarm);
    void ResetAlarm();
    void TransitionInhaleExhale_Event();
    void TransitionEndCycleEvent();
    void TransitionNewCycleEvent();
    void Tick();
    void ResetWatchDog();
    void EnableWatchDog(bool enable);
    void SetAlarmGUI(bool in_alarm);
    void SetAlarmTest(bool in_alarm);
    void DisableAllAlarms(bool disable);
};

#endif


//                  #     # ### 
//                  ##    #  #  
//                  # #   #  #  
//                  #  #  #  #  
//                  #   # #  #  
//                  #    ##  #  
//                  #     # ### 
//
// Nuclear Instruments 2020 - All rights reserved
// Any commercial use of this code is forbidden
// Contact info@nuclearinstruments.eu