HomeWaterLeaksDetection
|
#include <ALeakDetectable.h>
Public Types | |
enum | Type { Low, High, Total } |
The type of the water leak detection algorithm. More... | |
Public Member Functions | |
ALeakDetectable (PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig) | |
Constructor of the class. More... | |
virtual | ~ALeakDetectable () |
Destructor of the class. More... | |
int | isActive () const |
Returns a flag whether of not a leak has been detected and the bypass is off. More... | |
void | changeStateOfHomeAlarm (bool state) |
Changes the state of the home alarm. More... | |
LeakDetectionConfig_t | getAlarmConfig () |
Returns the current alarm config. More... | |
LeakDetectionConfig_t | getNormalConfig () |
Returns the current normal config. More... | |
virtual String | getFormatOfSettingsToSave ()=0 |
Returns a string containing the current settings of the detection algorithm. More... | |
void | updateNormalConfig (LeakDetectionConfig_t newNormalConfig) |
Updates the normal settings. More... | |
void | updateAlarmConfig (LeakDetectionConfig_t newAlarmConfig) |
Updates the alarm settings. More... | |
virtual void | update ()=0 |
This method is called for updating its state. More... | |
virtual void | reset ()=0 |
This method resets the algorithm. More... | |
Protected Member Functions | |
void | applyNewConfig () |
Applies the new config configuration. More... | |
String | getType () const |
Returns the type of the water leak detection algorithm. More... | |
Protected Attributes | |
PulseCounter * | pulseCounter |
instance of a pulse counter (input of the system) More... | |
LeakDetectionConfig_t | normalConfig |
normal configuarion for when the house is occupied More... | |
LeakDetectionConfig_t | alarmConfig |
alarm configuration for when there's nobody in the house More... | |
LeakDetectionConfig_t * | config |
pointer to the current configuration More... | |
int | bypass |
bypass pin More... | |
int | oldBypassValue |
old bypass value (used for sending e-mails) More... | |
int | active |
indication if a leak has been detected + bypass is off More... | |
int | stateOfHomeAlarm |
the current state of the home alarm More... | |
bool | detected |
indication if a leak has been detected More... | |
int | resetWhenDetected |
the reset value (%) when a leak was detected More... | |
String | timeOfDetection |
time when the leak has been detected More... | |
Type | type |
the type of the water leak detection algorithm More... | |
LeakDetectionConfig_t | newNormalConfig |
new parameters of the normal config when the user changes them More... | |
LeakDetectionConfig_t | newAlarmConfig |
new parameters of the alarm config when the user changes them More... | |
int | requestUpdateNormalConfig |
flag if the new normal config should be applied More... | |
int | requestUpdateAlarmConfig |
flag if the new alarms config should be applied More... | |
Private Member Functions | |
virtual void | testActiveLeak ()=0 |
Test is a water leak has been detected. More... | |
virtual void | testResetLeak ()=0 |
Test is a water leak has been detected. More... | |
This class sepresents an abstraction of a water leak detection algorithm. It holds all the common variables, defines the common methods, etc.
Definition at line 52 of file ALeakDetectable.h.
The type of the water leak detection algorithm.
Enumerator | |
---|---|
Low | low water leak detection algorithm |
High | high water leak detection algorithm |
Total | total water leak detection algorithm |
Definition at line 57 of file ALeakDetectable.h.
ALeakDetectable::ALeakDetectable | ( | PulseCounter * | pulseCounter, |
Type | type, | ||
LeakDetectionConfig_t | normalConfig, | ||
LeakDetectionConfig_t | alarmConfig | ||
) |
Constructor of the class.
pulseCounter | - instance of PulseCounter which is used as the main input of all water leak detection algorithms |
type | - type of the water leak detection algorithm (high, low, total) |
normalConfig | - default normal configuration (defined in LimitsDefinition.h) |
alarmConfig | - default alarms configuration (defined in LimitsDefinition.h) |
Definition at line 3 of file ALeakDetectable.cpp.
References alarmConfig, config, newAlarmConfig, newNormalConfig, normalConfig, oldBypassValue, pulseCounter, requestUpdateAlarmConfig, requestUpdateNormalConfig, stateOfHomeAlarm, and type.
|
inlinevirtual |
|
protected |
Applies the new config configuration.
This method is called on each reset of the algorithm. If the appropriate flag is set, the new settings will be put in place.
Definition at line 34 of file ALeakDetectable.cpp.
References alarmConfig, EmailSender::APPLIED_NEW_SETTING, config, newAlarmConfig, newNormalConfig, normalConfig, requestUpdateAlarmConfig, requestUpdateNormalConfig, and stateOfHomeAlarm.
Referenced by LowLeakDetection::reset(), HighLeakDetection::reset(), TotalLeakDetection::testResetLeak(), LowLeakDetection::testResetLeak(), and HighLeakDetection::testResetLeak().
void ALeakDetectable::changeStateOfHomeAlarm | ( | bool | state | ) |
Changes the state of the home alarm.
state | new state of the home alarm |
Definition at line 93 of file ALeakDetectable.cpp.
References stateOfHomeAlarm.
LeakDetectionConfig_t ALeakDetectable::getAlarmConfig | ( | ) |
Returns the current alarm config.
Definition at line 26 of file ALeakDetectable.cpp.
References alarmConfig.
Referenced by LeaksController::changeSettings().
|
pure virtual |
Returns a string containing the current settings of the detection algorithm.
It contains both kinds of configurations. The settings will be stored on the SD card so it can be loaded on the next start of the system.
Implemented in HighLeakDetection, and LowLeakDetection.
LeakDetectionConfig_t ALeakDetectable::getNormalConfig | ( | ) |
Returns the current normal config.
Definition at line 30 of file ALeakDetectable.cpp.
References normalConfig.
Referenced by LeaksController::changeSettings().
|
protected |
Returns the type of the water leak detection algorithm.
Definition at line 84 of file ALeakDetectable.cpp.
References High, Low, Total, and type.
Referenced by LowLeakDetection::update(), and HighLeakDetection::update().
|
inline |
Returns a flag whether of not a leak has been detected and the bypass is off.
Definition at line 128 of file ALeakDetectable.h.
References active.
|
pure virtual |
This method resets the algorithm.
This is called either when the user manually presses the reset button or when the algorithm resets by itself.
Implemented in HighLeakDetection, LowLeakDetection, and TotalLeakDetection.
|
privatepure virtual |
Test is a water leak has been detected.
The implementation depends on the particular algorithm.
Implemented in TotalLeakDetection, HighLeakDetection, and LowLeakDetection.
|
privatepure virtual |
Test is a water leak has been detected.
The implementation depends on the particular algorithm.
Implemented in HighLeakDetection, LowLeakDetection, and TotalLeakDetection.
|
pure virtual |
This method is called for updating its state.
It updates the algorithm in order to find out if there's a leak taking place.
Implemented in HighLeakDetection, and LowLeakDetection.
void ALeakDetectable::updateAlarmConfig | ( | LeakDetectionConfig_t | newAlarmConfig | ) |
Updates the alarm settings.
The settings won't be applied right away. Instead, the flag will be set and the new settings will be put in place when the algorithm resets.
newAlarmConfig | the new alarm settings |
Definition at line 71 of file ALeakDetectable.cpp.
References alarmConfig, EmailSender::CHANGED_SETTINGS, newAlarmConfig, and requestUpdateAlarmConfig.
Referenced by LeaksController::changeSettings().
void ALeakDetectable::updateNormalConfig | ( | LeakDetectionConfig_t | newNormalConfig | ) |
Updates the normal settings.
The settings won't be applied right away. Instead, the flag will be set and the new setting will be put in place when the algorithm resets.
newNormalConfig | the new normal settings |
Definition at line 58 of file ALeakDetectable.cpp.
References EmailSender::CHANGED_SETTINGS, newNormalConfig, normalConfig, and requestUpdateNormalConfig.
Referenced by LeaksController::changeSettings().
|
protected |
indication if a leak has been detected + bypass is off
Definition at line 71 of file ALeakDetectable.h.
Referenced by TotalLeakDetection::getPercentLeakDetectionReset(), LowLeakDetection::getPercentLeakDetectionReset(), HighLeakDetection::getPercentLeakDetectionReset(), isActive(), LowLeakDetection::reset(), HighLeakDetection::reset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), and TotalLeakDetection::testActiveLeak().
|
protected |
alarm configuration for when there's nobody in the house
Definition at line 67 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), getAlarmConfig(), and updateAlarmConfig().
|
protected |
bypass pin
Definition at line 69 of file ALeakDetectable.h.
Referenced by LowLeakDetection::reset(), HighLeakDetection::reset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), TotalLeakDetection::testActiveLeak(), LowLeakDetection::update(), and HighLeakDetection::update().
|
protected |
pointer to the current configuration
Definition at line 68 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), LowLeakDetection::getPercentLeakDetected(), HighLeakDetection::getPercentLeakDetected(), TotalLeakDetection::getPercentLeakDetectionReset(), LowLeakDetection::getPercentLeakDetectionReset(), HighLeakDetection::getPercentLeakDetectionReset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), TotalLeakDetection::testActiveLeak(), TotalLeakDetection::testResetLeak(), LowLeakDetection::testResetLeak(), HighLeakDetection::testResetLeak(), LowLeakDetection::update(), and HighLeakDetection::update().
|
protected |
indication if a leak has been detected
Definition at line 73 of file ALeakDetectable.h.
Referenced by LowLeakDetection::reset(), HighLeakDetection::reset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), TotalLeakDetection::testActiveLeak(), TotalLeakDetection::testResetLeak(), LowLeakDetection::testResetLeak(), HighLeakDetection::testResetLeak(), and HighLeakDetection::update().
|
protected |
new parameters of the alarm config when the user changes them
Definition at line 79 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), LowLeakDetection::getFormatOfSettingsToSave(), HighLeakDetection::getFormatOfSettingsToSave(), and updateAlarmConfig().
|
protected |
new parameters of the normal config when the user changes them
Definition at line 78 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), LowLeakDetection::getFormatOfSettingsToSave(), HighLeakDetection::getFormatOfSettingsToSave(), and updateNormalConfig().
|
protected |
normal configuarion for when the house is occupied
Definition at line 66 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), getNormalConfig(), and updateNormalConfig().
|
protected |
old bypass value (used for sending e-mails)
Definition at line 70 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), LowLeakDetection::update(), and HighLeakDetection::update().
|
protected |
instance of a pulse counter (input of the system)
Definition at line 65 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), LowLeakDetection::getPercentLeakDetectionReset(), HighLeakDetection::getPercentLeakDetectionReset(), LowLeakDetection::testResetLeak(), HighLeakDetection::testResetLeak(), LowLeakDetection::update(), and HighLeakDetection::update().
|
protected |
flag if the new alarms config should be applied
Definition at line 81 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), and updateAlarmConfig().
|
protected |
flag if the new normal config should be applied
Definition at line 80 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), and updateNormalConfig().
|
protected |
the reset value (%) when a leak was detected
Definition at line 74 of file ALeakDetectable.h.
Referenced by LowLeakDetection::reset(), HighLeakDetection::reset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), and TotalLeakDetection::testActiveLeak().
|
protected |
the current state of the home alarm
Definition at line 72 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), applyNewConfig(), and changeStateOfHomeAlarm().
|
protected |
time when the leak has been detected
Definition at line 75 of file ALeakDetectable.h.
Referenced by LowLeakDetection::reset(), HighLeakDetection::reset(), LowLeakDetection::testActiveLeak(), HighLeakDetection::testActiveLeak(), and TotalLeakDetection::testActiveLeak().
|
protected |
the type of the water leak detection algorithm
Definition at line 76 of file ALeakDetectable.h.
Referenced by ALeakDetectable(), and getType().