#include <LowLeakDetection.h>
|
void | testActiveLeak () override |
| Tests if a low-water leak has occurred, and if so, it will set the appropriate variables and flags. More...
|
|
void | testResetLeak () override |
| Tests if the low-water the algorithm should be reset based on inactivity of pulse on the input pin. More...
|
|
- Author
- silhavyj A17B0362P
This class implements the low-water leak detection algorithm and everything that is associated with it.
Definition at line 11 of file LowLeakDetection.h.
◆ LowLeakDetection()
Constructor of the class.
- Parameters
-
pulseCounter | instance of PulseCounter (input) |
type | of the algorithm (low-water) |
normalConfig | default normal settings |
alarmConfig | default alarm settings |
Definition at line 29 of file LowLeakDetection.cpp.
References HTML_activePercentage, HTML_activePercentageColor, HTML_bypass, HTML_detected, HTML_detectedLimitDays, HTML_detectedLimitDaysAlarm, HTML_detectedLimitHours, HTML_detectedLimitHoursAlarm, HTML_detectedLimitMins, HTML_detectedLimitMinsAlarm, HTML_detectedLimitSecs, HTML_detectedLimitSecsAlarm, HTML_detectedText, HTML_detectedTime, HTML_resetLimitDays, HTML_resetLimitDaysAlarm, HTML_resetLimitHours, HTML_resetLimitHoursAlarm, HTML_resetLimitMins, HTML_resetLimitMinsAlarm, HTML_resetLimitSecs, HTML_resetLimitSecsAlarm, HTML_resetPercentage, htmlData, and reset().
◆ ~LowLeakDetection()
LowLeakDetection::~LowLeakDetection |
( |
| ) |
|
|
inline |
◆ getFormatOfSettingsToSave()
String LowLeakDetection::getFormatOfSettingsToSave |
( |
| ) |
|
|
overridevirtual |
◆ getHTMLData()
const String LowLeakDetection::getHTMLData |
( |
const int |
id | ) |
const |
|
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.
- Parameters
-
id | - the id of the piece of data |
- Returns
- If the class holds this piece of information, it will return it. Otherwise, "UNDEFINED" will be returned.
Implements HTMLDataSource.
◆ getPercentLeakDetected()
float LowLeakDetection::getPercentLeakDetected |
( |
| ) |
const |
◆ getPercentLeakDetectionReset()
float LowLeakDetection::getPercentLeakDetectionReset |
( |
| ) |
const |
◆ getRow()
const String LowLeakDetection::getRow |
( |
int |
row | ) |
const |
|
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.
- Parameters
-
- Returns
- content to be displayed on that row of the LCD
Implements IDisplayable.
◆ reset()
void LowLeakDetection::reset |
( |
| ) |
|
|
overridevirtual |
◆ testActiveLeak()
void LowLeakDetection::testActiveLeak |
( |
| ) |
|
|
overrideprivatevirtual |
Tests if a low-water leak has occurred, and if so, it will set the appropriate variables and flags.
Implements ALeakDetectable.
Definition at line 125 of file LowLeakDetection.cpp.
126 time_t currentTime = millis();
138 #ifdef EMAIL_NOTIFICATION
139 sendEmailLeakDetected();
References ALeakDetectable::active, ALeakDetectable::bypass, ALeakDetectable::config, DELTA_TIME, ALeakDetectable::detected, flipFlop, flipFlopSetTime, DateTime::getDateTimeStr(), DateTime::getInstance(), getPercentLeakDetectionReset(), LeakDetectionConfig_t::limitActionTime, LOW_ILOCK_LED_PIN, ALeakDetectable::resetWhenDetected, and ALeakDetectable::timeOfDetection.
Referenced by update().
◆ testResetLeak()
void LowLeakDetection::testResetLeak |
( |
| ) |
|
|
overrideprivatevirtual |
◆ update()
void LowLeakDetection::update |
( |
| ) |
|
|
overridevirtual |
Updates the algorithm.
Implements ALeakDetectable.
Definition at line 78 of file LowLeakDetection.cpp.
84 #ifdef EMAIL_NOTIFICATION
87 String state =
bypass ?
"on" :
"off";
90 getType() +
" leak detection BYPASS",
91 "bypass is now " + state
References EmailSender::BYPASS, ALeakDetectable::bypass, LeakDetectionConfig_t::bypassPin, ALeakDetectable::config, flipFlop, flipFlopSetTime, EmailSender::getInstance(), PulseCounter::getLastPulseTime(), ALeakDetectable::getType(), PulseCounter::isActive(), ALeakDetectable::oldBypassValue, ALeakDetectable::pulseCounter, EmailSender::sendEmail(), testActiveLeak(), and testResetLeak().
◆ HTML_activePercentage
Associated function for returing the [%] information about how close a leak is from being detected.
- Parameters
-
- Returns
- [%] information about how close a leak is from being detected
Referenced by LowLeakDetection().
◆ HTML_activePercentageColor
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
- Parameters
-
- Returns
- color according to the state of the algorithm - detected [%]
Referenced by LowLeakDetection().
◆ HTML_bypass
Associated function for returing information about the state of the bypass.
- Parameters
-
- Returns
- "OFF"/"ON" according to the current state of the bypass
Referenced by LowLeakDetection().
◆ HTML_detected
Associated function for returing information about a low-water leak being detected (1)
- Parameters
-
- Returns
- "ON" if a low-water leak has occurred, "OFF" otherwise
Referenced by LowLeakDetection().
◆ HTML_detectedLimitDays
Associated function for returing the limit action time (days) in terms of the normal configuration.
- Parameters
-
- Returns
- the limit action time (days) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitDaysAlarm
Associated function for returing the limit action time (days) in terms of the alarm configuration.
- Parameters
-
- Returns
- the limit action time (days) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitHours
Associated function for returing the limit action time (hours) in terms of the normal configuration.
- Parameters
-
- Returns
- the limit action time (hours) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitHoursAlarm
String HTML_detectedLimitHoursAlarm |
( |
const LowLeakDetection & |
lowLeakDetection | ) |
|
|
friend |
Associated function for returing the limit action time (hours) in terms of the alarm configuration.
- Parameters
-
- Returns
- the limit action time (hours) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitMins
Associated function for returing the limit action time (mins) in terms of the normal configuration.
- Parameters
-
- Returns
- the limit action time (mins) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitMinsAlarm
Associated function for returing the limit action time (mins) in terms of the alarm configuration.
- Parameters
-
- Returns
- the limit action time (mins) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitSecs
Associated function for returing the limit action time (secs) in terms of the normal configuration.
- Parameters
-
- Returns
- the limit action time (secs) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_detectedLimitSecsAlarm
Associated function for returing the limit action time (secs) in terms of the alarm configuration.
- Parameters
-
- Returns
- the limit action time (secs) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_detectedText
Associated function for returing information about a low-water leak being detected (2)
- Parameters
-
- Returns
- "Detected" if a low-water leak has occurred, "Undetected" otherwise
Referenced by LowLeakDetection().
◆ HTML_detectedTime
Associated function for returing the detection time of a low-water leak.
- Parameters
-
- Returns
- the time of detection in a string format
Referenced by LowLeakDetection().
◆ HTML_resetLimitDays
Associated function for returing the reset time (days) in the normal configuration.
- Parameters
-
- Returns
- reset time (days) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitDaysAlarm
Associated function for returing the reset time (days) in the alarm configuration.
- Parameters
-
- Returns
- reset time (days) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitHours
Associated function for returing the reset time (hours) in the normal configuration.
- Parameters
-
- Returns
- reset time (hours) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitHoursAlarm
Associated function for returing the reset time (hours) in the alarm configuration.
- Parameters
-
- Returns
- reset time (hours) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitMins
Associated function for returing the reset time (mins) in the normal configuration.
- Parameters
-
- Returns
- reset time (mins) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitMinsAlarm
Associated function for returing the reset time (mins) in the alarm configuration.
- Parameters
-
- Returns
- reset time (mins) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitSecs
Associated function for returing the reset time (secs) in the normal configuration.
- Parameters
-
- Returns
- reset time (secs) in the normal configuration
Referenced by LowLeakDetection().
◆ HTML_resetLimitSecsAlarm
Associated function for returing the reset time (secs) in the alarm configuration.
- Parameters
-
- Returns
- reset time (secs) in the alarm configuration
Referenced by LowLeakDetection().
◆ HTML_resetPercentage
Associated function for returing the [%] information about how close the algorithm is from being reset.
- Parameters
-
- Returns
- [%] information about how close the algorithm is from being reset
Referenced by LowLeakDetection().
◆ flipFlop
int LowLeakDetection::flipFlop |
|
private |
◆ flipFlopSetTime
time_t LowLeakDetection::flipFlopSetTime |
|
private |
◆ htmlData
The documentation for this class was generated from the following files:
LeakDetectionConfig_t alarmConfig
alarm configuration for when there's nobody in the house
int flipFlop
state of the flip-flop (1/0)
friend String HTML_resetLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the alarm configuration.
String timeOfDetection
time when the leak has been detected
#define LOW_ILOCK_LED_PIN
low-water leak LED (detected = on)
Type type
the type of the water leak detection algorithm
friend String HTML_detectedLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the normal configuration.
std::map< int, String(*)(const LowLeakDetection &highLeakDetection)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
@ BYPASS
when a bypass changes
friend String HTML_resetPercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close the algorithm is from being rese...
String getType() const
Returns the type of the water leak detection algorithm.
time_t getLastPulseTime() const
Return the time when the last pulse was detected.
void reset() override
Resets the algorithm.
friend String HTML_detectedLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the alarm configuration.
time_t flipFlopSetTime
time when the flip-flop has been set to 1
time_t limitResetTime
limit reset time e.g. 5 mins, 24h, ....
friend String HTML_resetLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the alarm configuration.
int resetWhenDetected
the reset value (%) when a leak was detected
friend String HTML_resetLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the normal configuration.
LeakDetectionConfig_t * config
pointer to the current configuration
bool detected
indication if a leak has been detected
friend String HTML_detectedLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the normal configuration.
friend String HTML_detectedLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the alarm configuration.
friend String HTML_resetLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the normal configuration.
friend String HTML_activePercentageColor(const LowLeakDetection &lowLeakDetection)
Associated function for returing a color according to [%] information about how close a leak is from ...
friend String HTML_detected(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (1)
friend String HTML_resetLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the normal configuration.
int bypassPin
number of the bypass pin
float getPercentLeakDetectionReset() const
Returns percentage information about how close a low-water leak is from being detected.
void applyNewConfig()
Applies the new config configuration.
static DateTime * getInstance()
Returns the instance of the class.
friend String HTML_detectedLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the alarm configuration.
time_t limitActionTime
limit action time (leak has been detected)
LeakDetectionConfig_t newNormalConfig
new parameters of the normal config when the user changes them
unsigned long time_t
Referring to the data type unsigned long as time_t.
friend String HTML_detectedLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the alarm configuration.
friend String HTML_resetLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the alarm configuration.
friend String HTML_bypass(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about the state of the bypass.
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
void testActiveLeak() override
Tests if a low-water leak has occurred, and if so, it will set the appropriate variables and flags.
friend String HTML_resetLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the alarm configuration.
String getDateTimeStr() const
Returns the current datatime in a string format.
int active
indication if a leak has been detected + bypass is off
friend String HTML_detectedLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the normal configuration.
LeakDetectionConfig_t newAlarmConfig
new parameters of the alarm config when the user changes them
void testResetLeak() override
Tests if the low-water the algorithm should be reset based on inactivity of pulse on the input pin.
int isActive() const
Returns information if a pulse has been detected.
int oldBypassValue
old bypass value (used for sending e-mails)
friend String HTML_detectedTime(const LowLeakDetection &lowLeakDetection)
Associated function for returing the detection time of a low-water leak.
#define DELTA_TIME(time1, time2)
Calculates the time difference between two times given as parameters.
PulseCounter * pulseCounter
instance of a pulse counter (input of the system)
friend String HTML_detectedText(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (2)
friend String HTML_detectedLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the normal configuration.
LeakDetectionConfig_t normalConfig
normal configuarion for when the house is occupied
ALeakDetectable(PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig)
Constructor of the class.
friend String HTML_activePercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close a leak is from being detected.
friend String HTML_resetLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the normal configuration.
static EmailSender * getInstance()
Returns the instance of the class.