HomeWaterLeaksDetection
ALeakDetectable.h
Go to the documentation of this file.
1 #ifndef A_LEAK_DETECTABLE_H
2 #define A_LEAK_DETECTABLE_H
3 
4 #include "ArduinoSTL.h"
5 #include "PulseCounter.h"
6 #include "LeakDetectionConfig.h"
7 #include "LimitsDefinition.h"
8 #include "DateTime.h"
9 #include "Pins.h"
10 
11 //====================web server========================
12 
13 // if the webserver is enabled,
14 // include these files as well
15 #ifdef WEB_SERVER
16 # include <map>
17 # include <HTMLDataSource.h>
18 #endif
19 
20 //====================debugging=========================
21 
22 // if debugging is enabled,
23 // include this file as well
24 #ifdef DEBUG
25 # include <ILoggable.h>
26 #endif
27 
28 //================email notifications===================
29 
30 // if email-notifications are
31 // enabled, include this file
32 // as well
33 #ifdef EMAIL_NOTIFICATION
34 # include <EmailSender.h>
35 #endif
36 
37 //==================LCD display=========================
38 
39 // if the LCD display is enabled,
40 // include this file as well
41 #ifdef LCD_DISPLAY
42 # include <IDisplayable.h>
43 #endif
44 
45 //==============ALeakDetectable class===================
46 
53 
54 //====================public data=======================
55 public:
57  enum Type {
58  Low,
59  High,
60  Total
61  };
62 
63 //===================protected data=====================
64 protected:
69  int bypass;
71  int active;
73  bool detected;
75  String timeOfDetection;
77 
82 
83 //==================private methods=====================
84 private:
88  virtual void testActiveLeak() = 0;
89 
93  virtual void testResetLeak() = 0;
94 
95 //=================protected methods====================
96 protected:
102  void applyNewConfig();
103 
106  String getType() const;
107 
108 //==================public methods======================
109 public:
119  Type type,
122 
124  virtual ~ALeakDetectable() {};
125 
128  int isActive() const { return active; }
129 
132  void changeStateOfHomeAlarm(bool state);
133 
137 
141 
148  virtual String getFormatOfSettingsToSave() = 0;
149 
157 
165 
170  virtual void update() = 0;
171 
176  virtual void reset() = 0;
177 
178 //===============email notifications====================
179 #ifdef EMAIL_NOTIFICATION
180  void sendEmailAboutSettings(EmailSender::Type emailType,
192  LeakDetectionConfig_t& oldSettings,
193  LeakDetectionConfig_t& newSettings,
194  bool alarm) const;
195 #endif
196 };
197 
198 #endif
ALeakDetectable::alarmConfig
LeakDetectionConfig_t alarmConfig
alarm configuration for when there's nobody in the house
Definition: ALeakDetectable.h:67
LeakDetectionConfig.h
ALeakDetectable::Total
@ Total
total water leak detection algorithm
Definition: ALeakDetectable.h:60
Pins.h
ALeakDetectable::timeOfDetection
String timeOfDetection
time when the leak has been detected
Definition: ALeakDetectable.h:75
ALeakDetectable::~ALeakDetectable
virtual ~ALeakDetectable()
Destructor of the class.
Definition: ALeakDetectable.h:124
ALeakDetectable::requestUpdateAlarmConfig
int requestUpdateAlarmConfig
flag if the new alarms config should be applied
Definition: ALeakDetectable.h:81
ALeakDetectable::changeStateOfHomeAlarm
void changeStateOfHomeAlarm(bool state)
Changes the state of the home alarm.
Definition: ALeakDetectable.cpp:93
ALeakDetectable::type
Type type
the type of the water leak detection algorithm
Definition: ALeakDetectable.h:76
IDisplayable.h
ALeakDetectable::getType
String getType() const
Returns the type of the water leak detection algorithm.
Definition: ALeakDetectable.cpp:84
ALeakDetectable::bypass
int bypass
bypass pin
Definition: ALeakDetectable.h:69
ALeakDetectable::Low
@ Low
low water leak detection algorithm
Definition: ALeakDetectable.h:58
DateTime.h
LeakDetectionConfig_t
Definition: LeakDetectionConfig.h:17
EmailSender::Type
Type
different types of e-mail that can be sent to the user
Definition: EmailSender.h:44
ILoggable.h
ALeakDetectable::resetWhenDetected
int resetWhenDetected
the reset value (%) when a leak was detected
Definition: ALeakDetectable.h:74
ALeakDetectable::config
LeakDetectionConfig_t * config
pointer to the current configuration
Definition: ALeakDetectable.h:68
ALeakDetectable::detected
bool detected
indication if a leak has been detected
Definition: ALeakDetectable.h:73
ALeakDetectable
Definition: ALeakDetectable.h:52
ALeakDetectable::updateAlarmConfig
void updateAlarmConfig(LeakDetectionConfig_t newAlarmConfig)
Updates the alarm settings.
Definition: ALeakDetectable.cpp:71
HTMLDataSource.h
EmailSender.h
ALeakDetectable::High
@ High
high water leak detection algorithm
Definition: ALeakDetectable.h:59
LimitsDefinition.h
ALeakDetectable::update
virtual void update()=0
This method is called for updating its state.
ALeakDetectable::getFormatOfSettingsToSave
virtual String getFormatOfSettingsToSave()=0
Returns a string containing the current settings of the detection algorithm.
ALeakDetectable::updateNormalConfig
void updateNormalConfig(LeakDetectionConfig_t newNormalConfig)
Updates the normal settings.
Definition: ALeakDetectable.cpp:58
ALeakDetectable::applyNewConfig
void applyNewConfig()
Applies the new config configuration.
Definition: ALeakDetectable.cpp:34
ALeakDetectable::stateOfHomeAlarm
int stateOfHomeAlarm
the current state of the home alarm
Definition: ALeakDetectable.h:72
ALeakDetectable::isActive
int isActive() const
Returns a flag whether of not a leak has been detected and the bypass is off.
Definition: ALeakDetectable.h:128
ALeakDetectable::newNormalConfig
LeakDetectionConfig_t newNormalConfig
new parameters of the normal config when the user changes them
Definition: ALeakDetectable.h:78
ALeakDetectable::getAlarmConfig
LeakDetectionConfig_t getAlarmConfig()
Returns the current alarm config.
Definition: ALeakDetectable.cpp:26
ALeakDetectable::Type
Type
The type of the water leak detection algorithm.
Definition: ALeakDetectable.h:57
ALeakDetectable::testActiveLeak
virtual void testActiveLeak()=0
Test is a water leak has been detected.
ALeakDetectable::active
int active
indication if a leak has been detected + bypass is off
Definition: ALeakDetectable.h:71
ALeakDetectable::newAlarmConfig
LeakDetectionConfig_t newAlarmConfig
new parameters of the alarm config when the user changes them
Definition: ALeakDetectable.h:79
PulseCounter
Definition: PulseCounter.h:29
PulseCounter.h
ALeakDetectable::oldBypassValue
int oldBypassValue
old bypass value (used for sending e-mails)
Definition: ALeakDetectable.h:70
ALeakDetectable::getNormalConfig
LeakDetectionConfig_t getNormalConfig()
Returns the current normal config.
Definition: ALeakDetectable.cpp:30
ALeakDetectable::pulseCounter
PulseCounter * pulseCounter
instance of a pulse counter (input of the system)
Definition: ALeakDetectable.h:65
ALeakDetectable::requestUpdateNormalConfig
int requestUpdateNormalConfig
flag if the new normal config should be applied
Definition: ALeakDetectable.h:80
ALeakDetectable::testResetLeak
virtual void testResetLeak()=0
Test is a water leak has been detected.
ALeakDetectable::reset
virtual void reset()=0
This method resets the algorithm.
ALeakDetectable::normalConfig
LeakDetectionConfig_t normalConfig
normal configuarion for when the house is occupied
Definition: ALeakDetectable.h:66
ALeakDetectable::ALeakDetectable
ALeakDetectable(PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig)
Constructor of the class.
Definition: ALeakDetectable.cpp:3