HomeWaterLeaksDetection
|
#include <HighLeakDetection.h>
Public Member Functions | |
HighLeakDetection (PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig) | |
Constructor of the class. More... | |
~HighLeakDetection () | |
Descrutor of the class. More... | |
void | update () override |
Updates the algorithm. More... | |
void | reset () override |
Resets the algorithm. More... | |
String | getFormatOfSettingsToSave () override |
Returns the current settings of the algorithm. More... | |
float | getPercentLeakDetectionReset () const |
Returns percentage information about how close a high-water leak is from being detected. More... | |
float | getPercentLeakDetected () const |
Returns percentage information about how close the algorithm is from being reset. More... | |
const String | getRow (int row) const override |
Returns the content of the row given as a parameter. More... | |
const String | getHTMLData (const int id) const override |
Since this class is registered as a source of data for the HTML content, it needs return the appropriate value according to the id given as a parameter. More... | |
![]() | |
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... | |
void | updateNormalConfig (LeakDetectionConfig_t newNormalConfig) |
Updates the normal settings. More... | |
void | updateAlarmConfig (LeakDetectionConfig_t newAlarmConfig) |
Updates the alarm settings. More... | |
Protected Member Functions | |
void | testActiveLeak () override |
Tests if a high-water leak has occurred, and if so, it will set the appropriate variables and flags. More... | |
void | testResetLeak () override |
Tests if the high-water the algorithm should be reset based on inactivity of pulse on the input pin. More... | |
![]() | |
void | applyNewConfig () |
Applies the new config configuration. More... | |
String | getType () const |
Returns the type of the water leak detection algorithm. More... | |
Protected Attributes | |
int | pulseCount |
number of pulses detected so far More... | |
std::map< int, String(*)(const HighLeakDetection &highLeakDetection)> | htmlData |
A map of different values (keys) and their associated functions which returns the appropriate values. More... | |
![]() | |
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... | |
Friends | |
String | HTML_bypass (const HighLeakDetection &highLeakDetection) |
Associated function for returing information about the state of the bypass. More... | |
String | HTML_detected (const HighLeakDetection &highLeakDetection) |
Associated function for returing information about a high-water leak being detected (1) More... | |
String | HTML_detectedText (const HighLeakDetection &highLeakDetection) |
Associated function for returing information about a high-water leak being detected (2) More... | |
String | HTML_detectedTime (const HighLeakDetection &highLeakDetection) |
Associated function for returing the detection time of a high-water leak. More... | |
String | HTML_activePercentage (const HighLeakDetection &highLeakDetection) |
Associated function for returing the [%] information about how close a leak is from being detected. More... | |
String | HTML_activePercentageColor (const HighLeakDetection &highLeakDetection) |
Associated function for returing a color according to [%] information about how close a leak is from being detected. More... | |
String | HTML_resetPercentage (const HighLeakDetection &highLeakDetection) |
Associated function for returing the [%] information about how close the algorithm is from being reset. More... | |
String | HTML_detectionLimit (const HighLeakDetection &highLeakDetection) |
Associated function for returing the limit (detection) in terms of the normal configuration. More... | |
String | HTML_resetLimitDays (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (days) in the normal configuration. More... | |
String | HTML_resetLimitHours (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (hours) in the normal configuration. More... | |
String | HTML_resetLimitMins (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (mins) in the normal configuration. More... | |
String | HTML_resetLimitSecs (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (secs) in the normal configuration. More... | |
String | HTML_detectionLimitAlarm (const HighLeakDetection &highLeakDetection) |
Associated function for returing the limit (detection) in terms of the alarm configuration. More... | |
String | HTML_resetLimitDaysAlarm (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (days) in the alarm configuration. More... | |
String | HTML_resetLimitHoursAlarm (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (hours) in the alarm configuration. More... | |
String | HTML_resetLimitMinsAlarm (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (mins) in the alarm configuration. More... | |
String | HTML_resetLimitSecsAlarm (const HighLeakDetection &highLeakDetection) |
Associated function for returing the reset time (secs) in the alarm configuration. More... | |
Additional Inherited Members | |
![]() | |
enum | Type { Low, High, Total } |
The type of the water leak detection algorithm. More... | |
![]() | |
static const String | UNDEFINED_DATA = String("UNDEFINED") |
string "UNDEFINED" More... | |
This class implements the high-water leak detection algorithm and everything that is associated with it.
Definition at line 13 of file HighLeakDetection.h.
HighLeakDetection::HighLeakDetection | ( | PulseCounter * | pulseCounter, |
Type | type, | ||
LeakDetectionConfig_t | normalConfig, | ||
LeakDetectionConfig_t | alarmConfig | ||
) |
Constructor of the class.
pulseCounter | instance of PulseCounter (input) |
type | of the algorithm (high-water) |
normalConfig | default normal settings |
alarmConfig | default alarm settings |
Definition at line 23 of file HighLeakDetection.cpp.
References HTML_activePercentage, HTML_activePercentageColor, HTML_bypass, HTML_detected, HTML_detectedText, HTML_detectedTime, HTML_detectionLimit, HTML_detectionLimitAlarm, HTML_resetLimitDays, HTML_resetLimitDaysAlarm, HTML_resetLimitHours, HTML_resetLimitHoursAlarm, HTML_resetLimitMins, HTML_resetLimitMinsAlarm, HTML_resetLimitSecs, HTML_resetLimitSecsAlarm, HTML_resetPercentage, htmlData, and reset().
|
inline |
|
overridevirtual |
Returns the current settings of the algorithm.
This method is called when storing data on the SD card so they can be loaded when the system reboots
Implements ALeakDetectable.
Definition at line 63 of file HighLeakDetection.cpp.
References LeakDetectionConfig_t::limitPulseAction, LeakDetectionConfig_t::limitResetTime, ALeakDetectable::newAlarmConfig, and ALeakDetectable::newNormalConfig.
|
overridevirtual |
Since this class is registered as a source of data for the HTML content, it needs return the appropriate value according to the id given as a parameter.
id | - the id of the piece of data |
Implements HTMLDataSource.
Reimplemented in TotalLeakDetection.
float HighLeakDetection::getPercentLeakDetected | ( | ) | const |
Returns percentage information about how close the algorithm is from being reset.
The particular value is worked out based on the current settings. This piece of information is then displayed to the user.
Definition at line 142 of file HighLeakDetection.cpp.
References ALeakDetectable::config, LeakDetectionConfig_t::limitPulseAction, and pulseCount.
Referenced by DailyOverview::update().
float HighLeakDetection::getPercentLeakDetectionReset | ( | ) | const |
Returns percentage information about how close a high-water leak is from being detected.
The particular value is worked out based on the current settings. This piece of information is then displayed to the user.
Definition at line 148 of file HighLeakDetection.cpp.
References ALeakDetectable::active, ALeakDetectable::config, DELTA_TIME, PulseCounter::getLastPulseTime(), LeakDetectionConfig_t::limitResetTime, and ALeakDetectable::pulseCounter.
Referenced by testActiveLeak().
|
overridevirtual |
Returns the content of the row given as a parameter.
This class represents one page on the LCD display. Each of the 4 rows has different content identified by the number of the row.
row | number of the row |
Implements IDisplayable.
Reimplemented in TotalLeakDetection.
|
overridevirtual |
Resets the algorithm.
Implements ALeakDetectable.
Reimplemented in TotalLeakDetection.
Definition at line 53 of file HighLeakDetection.cpp.
References ALeakDetectable::active, ALeakDetectable::applyNewConfig(), ALeakDetectable::bypass, ALeakDetectable::detected, pulseCount, ALeakDetectable::resetWhenDetected, and ALeakDetectable::timeOfDetection.
Referenced by HighLeakDetection(), and TotalLeakDetection::reset().
|
overrideprotectedvirtual |
Tests if a high-water leak has occurred, and if so, it will set the appropriate variables and flags.
Implements ALeakDetectable.
Reimplemented in TotalLeakDetection.
Definition at line 81 of file HighLeakDetection.cpp.
References ALeakDetectable::active, ALeakDetectable::bypass, ALeakDetectable::config, ALeakDetectable::detected, DateTime::getDateTimeStr(), DateTime::getInstance(), getPercentLeakDetectionReset(), HIGH_ILOCK_LED_PIN, LeakDetectionConfig_t::limitPulseAction, pulseCount, ALeakDetectable::resetWhenDetected, and ALeakDetectable::timeOfDetection.
Referenced by update().
|
overrideprotectedvirtual |
Tests if the high-water the algorithm should be reset based on inactivity of pulse on the input pin.
Implements ALeakDetectable.
Reimplemented in TotalLeakDetection.
Definition at line 70 of file HighLeakDetection.cpp.
References ALeakDetectable::applyNewConfig(), ALeakDetectable::config, DELTA_TIME, ALeakDetectable::detected, PulseCounter::getLastPulseTime(), LeakDetectionConfig_t::limitResetTime, pulseCount, and ALeakDetectable::pulseCounter.
Referenced by update().
|
overridevirtual |
Updates the algorithm.
Implements ALeakDetectable.
Definition at line 115 of file HighLeakDetection.cpp.
References EmailSender::BYPASS, ALeakDetectable::bypass, LeakDetectionConfig_t::bypassPin, ALeakDetectable::config, ALeakDetectable::detected, EmailSender::getInstance(), ALeakDetectable::getType(), PulseCounter::isActive(), ALeakDetectable::oldBypassValue, pulseCount, ALeakDetectable::pulseCounter, EmailSender::sendEmail(), testActiveLeak(), and testResetLeak().
|
friend |
Associated function for returing the [%] information about how close a leak is from being detected.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing a color according to [%] information about how close a leak is from being detected.
For instance, 0 - 59% -> gray 60 - 79% -> yellow 80 - 89% -> orange
90 - 100% ->red
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing information about the state of the bypass.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing information about a high-water leak being detected (1)
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing information about a high-water leak being detected (2)
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the detection time of a high-water leak.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the limit (detection) in terms of the normal configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the limit (detection) in terms of the alarm configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (days) in the normal configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (days) in the alarm configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (hours) in the normal configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (hours) in the alarm configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (mins) in the normal configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (mins) in the alarm configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (secs) in the normal configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the reset time (secs) in the alarm configuration.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
friend |
Associated function for returing the [%] information about how close the algorithm is from being reset.
highLeakDetection | - the instance of the HighLeakDetection class |
Referenced by HighLeakDetection().
|
protected |
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition at line 114 of file HighLeakDetection.h.
Referenced by HighLeakDetection().
|
protected |
number of pulses detected so far
Definition at line 26 of file HighLeakDetection.h.
Referenced by getPercentLeakDetected(), reset(), testActiveLeak(), TotalLeakDetection::testActiveLeak(), TotalLeakDetection::testResetLeak(), testResetLeak(), and update().