HomeWaterLeaksDetection
LowLeakDetection Class Reference

#include <LowLeakDetection.h>

Public Member Functions

 LowLeakDetection (PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig)
 Constructor of the class. More...
 
 ~LowLeakDetection ()
 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 low-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...
 
- Public Member Functions inherited from ALeakDetectable
 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 Attributes

std::map< int, String(*)(const LowLeakDetection &highLeakDetection)> htmlData
 A map of different values (keys) and their associated functions which returns the appropriate values. More...
 
- Protected Attributes inherited from ALeakDetectable
PulseCounterpulseCounter
 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_tconfig
 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

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...
 

Private Attributes

int flipFlop
 state of the flip-flop (1/0) More...
 
time_t flipFlopSetTime
 time when the flip-flop has been set to 1 More...
 

Friends

String HTML_bypass (const LowLeakDetection &lowLeakDetection)
 Associated function for returing information about the state of the bypass. More...
 
String HTML_detected (const LowLeakDetection &lowLeakDetection)
 Associated function for returing information about a low-water leak being detected (1) More...
 
String HTML_detectedText (const LowLeakDetection &lowLeakDetection)
 Associated function for returing information about a low-water leak being detected (2) More...
 
String HTML_detectedTime (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the detection time of a low-water leak. More...
 
String HTML_activePercentage (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the [%] information about how close a leak is from being detected. More...
 
String HTML_activePercentageColor (const LowLeakDetection &lowLeakDetection)
 Associated function for returing a color according to [%] information about how close a leak is from being detected. More...
 
String HTML_resetPercentage (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the [%] information about how close the algorithm is from being reset. More...
 
String HTML_detectedLimitDays (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (days) in terms of the normal configuration. More...
 
String HTML_detectedLimitHours (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (hours) in terms of the normal configuration. More...
 
String HTML_detectedLimitMins (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (mins) in terms of the normal configuration. More...
 
String HTML_detectedLimitSecs (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (secs) in terms of the normal configuration. More...
 
String HTML_resetLimitDays (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (days) in the normal configuration. More...
 
String HTML_resetLimitHours (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (hours) in the normal configuration. More...
 
String HTML_resetLimitMins (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (mins) in the normal configuration. More...
 
String HTML_resetLimitSecs (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (secs) in the normal configuration. More...
 
String HTML_detectedLimitDaysAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (days) in terms of the alarm configuration. More...
 
String HTML_detectedLimitHoursAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (hours) in terms of the alarm configuration. More...
 
String HTML_detectedLimitMinsAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (mins) in terms of the alarm configuration. More...
 
String HTML_detectedLimitSecsAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the limit action time (secs) in terms of the alarm configuration. More...
 
String HTML_resetLimitDaysAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (days) in the alarm configuration. More...
 
String HTML_resetLimitHoursAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (hours) in the alarm configuration. More...
 
String HTML_resetLimitMinsAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (mins) in the alarm configuration. More...
 
String HTML_resetLimitSecsAlarm (const LowLeakDetection &lowLeakDetection)
 Associated function for returing the reset time (secs) in the alarm configuration. More...
 

Additional Inherited Members

- Public Types inherited from ALeakDetectable
enum  Type { Low, High, Total }
 The type of the water leak detection algorithm. More...
 
- Static Public Attributes inherited from HTMLDataSource
static const String UNDEFINED_DATA = String("UNDEFINED")
 string "UNDEFINED" More...
 
- Protected Member Functions inherited from ALeakDetectable
void applyNewConfig ()
 Applies the new config configuration. More...
 
String getType () const
 Returns the type of the water leak detection algorithm. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ LowLeakDetection()

LowLeakDetection::LowLeakDetection ( PulseCounter pulseCounter,
Type  type,
LeakDetectionConfig_t  normalConfig,
LeakDetectionConfig_t  alarmConfig 
)

Constructor of the class.

Parameters
pulseCounterinstance of PulseCounter (input)
typeof the algorithm (low-water)
normalConfigdefault normal settings
alarmConfigdefault alarm settings

Definition at line 29 of file LowLeakDetection.cpp.

34 #ifdef WEB_SERVER
35  // functions providing data to the webserver
36  htmlData[4] = &HTML_bypass;
37  htmlData[5] = &HTML_detected;
43 
48 
53 
58 
63 #endif
64  reset(); // reset the algorithm
65 }

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

Descrutor of the class.

Definition at line 51 of file LowLeakDetection.h.

51 {};

Member Function Documentation

◆ getFormatOfSettingsToSave()

String LowLeakDetection::getFormatOfSettingsToSave ( )
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

Returns
the current settings in a string format

Implements ALeakDetectable.

Definition at line 107 of file LowLeakDetection.cpp.

107  {
108  return String(newNormalConfig.limitResetTime) + ";" +
109  String(newNormalConfig.limitActionTime) + ";" +
110  String(newAlarmConfig.limitResetTime) + ";" +
111  String(newAlarmConfig.limitActionTime) + ";";
112 }

References LeakDetectionConfig_t::limitActionTime, LeakDetectionConfig_t::limitResetTime, ALeakDetectable::newAlarmConfig, and ALeakDetectable::newNormalConfig.

◆ 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

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.

Returns
information about how close the algorithm is from being reset

Definition at line 174 of file LowLeakDetection.cpp.

174  {
175  if (flipFlop == LOW)
176  return 0;
177 
178  time_t currentTime = millis();
179  time_t deltaTime = DELTA_TIME(currentTime, flipFlopSetTime);
180  float percentDetected = deltaTime / (float)config->limitActionTime;
181  percentDetected *= 100;
182  return min(100, percentDetected);
183 }

References ALeakDetectable::config, DELTA_TIME, flipFlop, flipFlopSetTime, and LeakDetectionConfig_t::limitActionTime.

Referenced by DailyOverview::update().

◆ getPercentLeakDetectionReset()

float LowLeakDetection::getPercentLeakDetectionReset ( ) const

Returns percentage information about how close a low-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.

Returns
information about how close a low-water leak is from being detected

Definition at line 161 of file LowLeakDetection.cpp.

161  {
162  if (active == HIGH)
163  return 0;
164 
165  time_t currentTime = millis();
166  time_t lastPulseTime = pulseCounter->getLastPulseTime();
167  time_t deltaTime = DELTA_TIME(currentTime, lastPulseTime);
168 
169  float percentReset = deltaTime / (float)config->limitResetTime;
170  percentReset *= 100;
171  return min(100, percentReset);
172 }

References ALeakDetectable::active, ALeakDetectable::config, DELTA_TIME, PulseCounter::getLastPulseTime(), LeakDetectionConfig_t::limitResetTime, and ALeakDetectable::pulseCounter.

Referenced by testActiveLeak().

◆ 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
rownumber of the row
Returns
content to be displayed on that row of the LCD

Implements IDisplayable.

◆ reset()

void LowLeakDetection::reset ( )
overridevirtual

Resets the algorithm.

Implements ALeakDetectable.

Definition at line 67 of file LowLeakDetection.cpp.

67  {
68  bypass = LOW;
69  active = LOW;
70  flipFlop = LOW;
71  flipFlopSetTime = 0;
72  detected = 0;
74  timeOfDetection = "";
75  ALeakDetectable::applyNewConfig(); // check if new settings should be applied
76 }

References ALeakDetectable::active, ALeakDetectable::applyNewConfig(), ALeakDetectable::bypass, ALeakDetectable::detected, flipFlop, flipFlopSetTime, ALeakDetectable::resetWhenDetected, and ALeakDetectable::timeOfDetection.

Referenced by LowLeakDetection().

◆ 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.

125  {
126  time_t currentTime = millis();
127  time_t deltaTime = DELTA_TIME(currentTime, flipFlopSetTime);
128  detected = (flipFlop == HIGH && deltaTime >= config->limitActionTime);
129 
130  if (detected) {
131  // store the reset % when a leak was detected
132  // if it has not been done yet
133  if (timeOfDetection == "") {
134  timeOfDetection = DateTime::getInstance()->getDateTimeStr(); // date time of detection
135  resetWhenDetected = (int)getPercentLeakDetectionReset(); // reset %
136 
137  // send e-mail to the user
138  #ifdef EMAIL_NOTIFICATION
139  sendEmailLeakDetected();
140  #endif
141  }
142  active = !bypass; // if the bypass is off, close the main valve
143  }
144  // indication LED
145  digitalWrite(LOW_ILOCK_LED_PIN, detected);
146 }

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

Tests if the low-water the algorithm should be reset based on inactivity of pulse on the input pin.

Implements ALeakDetectable.

Definition at line 114 of file LowLeakDetection.cpp.

114  {
115  time_t currentTime = millis();
116  time_t lastPulseTime = pulseCounter->getLastPulseTime();
117  time_t deltaTime = DELTA_TIME(currentTime, lastPulseTime);
118 
119  if (deltaTime >= config->limitResetTime && !detected) {
120  flipFlop = LOW;
122  }
123 }

References ALeakDetectable::applyNewConfig(), ALeakDetectable::config, DELTA_TIME, ALeakDetectable::detected, flipFlop, PulseCounter::getLastPulseTime(), LeakDetectionConfig_t::limitResetTime, and ALeakDetectable::pulseCounter.

Referenced by update().

◆ update()

void LowLeakDetection::update ( )
overridevirtual

Updates the algorithm.

Implements ALeakDetectable.

Definition at line 78 of file LowLeakDetection.cpp.

78  {
79  // read the bypass
80  bypass = digitalRead(config->bypassPin);
81 
82  // if the state of the bypass has changed
83  // send an e-mail to the user
84  #ifdef EMAIL_NOTIFICATION
85  if (oldBypassValue != bypass) {
87  String state = bypass ? "on" : "off";
90  getType() + " leak detection BYPASS",
91  "bypass is now " + state
92  );
93  }
94  #endif
95 
96  // if a pulse has been detected and the flipflop
97  // is down, set it up and store the time when it
98  // has been set up
99  if (pulseCounter->isActive() && flipFlop == LOW) {
100  flipFlop = HIGH;
102  }
103  testActiveLeak(); // test if a leak has occurred
104  testResetLeak(); // test if the algorithm should be reset
105 }

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().

Friends And Related Function Documentation

◆ HTML_activePercentage

String HTML_activePercentage ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the [%] information about how close a leak is from being detected.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
[%] information about how close a leak is from being detected

Referenced by LowLeakDetection().

◆ HTML_activePercentageColor

String HTML_activePercentageColor ( const LowLeakDetection lowLeakDetection)
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

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
color according to the state of the algorithm - detected [%]

Referenced by LowLeakDetection().

◆ HTML_bypass

String HTML_bypass ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing information about the state of the bypass.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
"OFF"/"ON" according to the current state of the bypass

Referenced by LowLeakDetection().

◆ HTML_detected

String HTML_detected ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing information about a low-water leak being detected (1)

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
"ON" if a low-water leak has occurred, "OFF" otherwise

Referenced by LowLeakDetection().

◆ HTML_detectedLimitDays

String HTML_detectedLimitDays ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (days) in terms of the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (days) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitDaysAlarm

String HTML_detectedLimitDaysAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (days) in terms of the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (days) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitHours

String HTML_detectedLimitHours ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (hours) in terms of the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
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
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (hours) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitMins

String HTML_detectedLimitMins ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (mins) in terms of the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (mins) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitMinsAlarm

String HTML_detectedLimitMinsAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (mins) in terms of the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (mins) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitSecs

String HTML_detectedLimitSecs ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (secs) in terms of the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (secs) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_detectedLimitSecsAlarm

String HTML_detectedLimitSecsAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the limit action time (secs) in terms of the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the limit action time (secs) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_detectedText

String HTML_detectedText ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing information about a low-water leak being detected (2)

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
"Detected" if a low-water leak has occurred, "Undetected" otherwise

Referenced by LowLeakDetection().

◆ HTML_detectedTime

String HTML_detectedTime ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the detection time of a low-water leak.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
the time of detection in a string format

Referenced by LowLeakDetection().

◆ HTML_resetLimitDays

String HTML_resetLimitDays ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (days) in the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (days) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitDaysAlarm

String HTML_resetLimitDaysAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (days) in the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (days) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitHours

String HTML_resetLimitHours ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (hours) in the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (hours) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitHoursAlarm

String HTML_resetLimitHoursAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (hours) in the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (hours) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitMins

String HTML_resetLimitMins ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (mins) in the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (mins) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitMinsAlarm

String HTML_resetLimitMinsAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (mins) in the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (mins) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitSecs

String HTML_resetLimitSecs ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (secs) in the normal configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (secs) in the normal configuration

Referenced by LowLeakDetection().

◆ HTML_resetLimitSecsAlarm

String HTML_resetLimitSecsAlarm ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the reset time (secs) in the alarm configuration.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
reset time (secs) in the alarm configuration

Referenced by LowLeakDetection().

◆ HTML_resetPercentage

String HTML_resetPercentage ( const LowLeakDetection lowLeakDetection)
friend

Associated function for returing the [%] information about how close the algorithm is from being reset.

Parameters
lowLeakDetection- the instance of the LowLeakDetection class
Returns
[%] information about how close the algorithm is from being reset

Referenced by LowLeakDetection().

Member Data Documentation

◆ flipFlop

int LowLeakDetection::flipFlop
private

state of the flip-flop (1/0)

Definition at line 24 of file LowLeakDetection.h.

Referenced by getPercentLeakDetected(), reset(), testActiveLeak(), testResetLeak(), and update().

◆ flipFlopSetTime

time_t LowLeakDetection::flipFlopSetTime
private

time when the flip-flop has been set to 1

Definition at line 25 of file LowLeakDetection.h.

Referenced by getPercentLeakDetected(), reset(), testActiveLeak(), and update().

◆ htmlData

std::map<int, String (*)(const LowLeakDetection& highLeakDetection)> LowLeakDetection::htmlData
protected

A map of different values (keys) and their associated functions which returns the appropriate values.

Definition at line 113 of file LowLeakDetection.h.

Referenced by LowLeakDetection().


The documentation for this class was generated from the following files:
ALeakDetectable::alarmConfig
LeakDetectionConfig_t alarmConfig
alarm configuration for when there's nobody in the house
Definition: ALeakDetectable.h:67
LowLeakDetection::flipFlop
int flipFlop
state of the flip-flop (1/0)
Definition: LowLeakDetection.h:24
LowLeakDetection::HTML_resetLimitDaysAlarm
friend String HTML_resetLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the alarm configuration.
ALeakDetectable::timeOfDetection
String timeOfDetection
time when the leak has been detected
Definition: ALeakDetectable.h:75
LOW_ILOCK_LED_PIN
#define LOW_ILOCK_LED_PIN
low-water leak LED (detected = on)
Definition: Pins.h:30
ALeakDetectable::type
Type type
the type of the water leak detection algorithm
Definition: ALeakDetectable.h:76
LowLeakDetection::HTML_detectedLimitDays
friend String HTML_detectedLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the normal configuration.
LowLeakDetection::htmlData
std::map< int, String(*)(const LowLeakDetection &highLeakDetection)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition: LowLeakDetection.h:113
EmailSender::BYPASS
@ BYPASS
when a bypass changes
Definition: EmailSender.h:53
LowLeakDetection::HTML_resetPercentage
friend String HTML_resetPercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close the algorithm is from being rese...
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
PulseCounter::getLastPulseTime
time_t getLastPulseTime() const
Return the time when the last pulse was detected.
Definition: PulseCounter.cpp:44
LowLeakDetection::reset
void reset() override
Resets the algorithm.
Definition: LowLeakDetection.cpp:67
LowLeakDetection::HTML_detectedLimitSecsAlarm
friend String HTML_detectedLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the alarm configuration.
LowLeakDetection::flipFlopSetTime
time_t flipFlopSetTime
time when the flip-flop has been set to 1
Definition: LowLeakDetection.h:25
LeakDetectionConfig_t::limitResetTime
time_t limitResetTime
limit reset time e.g. 5 mins, 24h, ....
Definition: LeakDetectionConfig.h:18
LowLeakDetection::HTML_resetLimitSecsAlarm
friend String HTML_resetLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the alarm configuration.
ALeakDetectable::resetWhenDetected
int resetWhenDetected
the reset value (%) when a leak was detected
Definition: ALeakDetectable.h:74
LowLeakDetection::HTML_resetLimitHours
friend String HTML_resetLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the normal configuration.
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
LowLeakDetection::HTML_detectedLimitSecs
friend String HTML_detectedLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the normal configuration.
LowLeakDetection::HTML_detectedLimitMinsAlarm
friend String HTML_detectedLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the alarm configuration.
LowLeakDetection::HTML_resetLimitDays
friend String HTML_resetLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the normal configuration.
LowLeakDetection::HTML_activePercentageColor
friend String HTML_activePercentageColor(const LowLeakDetection &lowLeakDetection)
Associated function for returing a color according to [%] information about how close a leak is from ...
LowLeakDetection::HTML_detected
friend String HTML_detected(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (1)
LowLeakDetection::HTML_resetLimitMins
friend String HTML_resetLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the normal configuration.
LeakDetectionConfig_t::bypassPin
int bypassPin
number of the bypass pin
Definition: LeakDetectionConfig.h:21
LowLeakDetection::getPercentLeakDetectionReset
float getPercentLeakDetectionReset() const
Returns percentage information about how close a low-water leak is from being detected.
Definition: LowLeakDetection.cpp:161
ALeakDetectable::applyNewConfig
void applyNewConfig()
Applies the new config configuration.
Definition: ALeakDetectable.cpp:34
DateTime::getInstance
static DateTime * getInstance()
Returns the instance of the class.
Definition: DateTime.cpp:26
LowLeakDetection::HTML_detectedLimitHoursAlarm
friend String HTML_detectedLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the alarm configuration.
LeakDetectionConfig_t::limitActionTime
time_t limitActionTime
limit action time (leak has been detected)
Definition: LeakDetectionConfig.h:19
ALeakDetectable::newNormalConfig
LeakDetectionConfig_t newNormalConfig
new parameters of the normal config when the user changes them
Definition: ALeakDetectable.h:78
time_t
unsigned long time_t
Referring to the data type unsigned long as time_t.
Definition: DateTime.h:20
LowLeakDetection::HTML_detectedLimitDaysAlarm
friend String HTML_detectedLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the alarm configuration.
LowLeakDetection::HTML_resetLimitHoursAlarm
friend String HTML_resetLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the alarm configuration.
LowLeakDetection::HTML_bypass
friend String HTML_bypass(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about the state of the bypass.
EmailSender::sendEmail
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
Definition: EmailSender.cpp:93
LowLeakDetection::testActiveLeak
void testActiveLeak() override
Tests if a low-water leak has occurred, and if so, it will set the appropriate variables and flags.
Definition: LowLeakDetection.cpp:125
LowLeakDetection::HTML_resetLimitMinsAlarm
friend String HTML_resetLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the alarm configuration.
DateTime::getDateTimeStr
String getDateTimeStr() const
Returns the current datatime in a string format.
Definition: DateTime.cpp:47
ALeakDetectable::active
int active
indication if a leak has been detected + bypass is off
Definition: ALeakDetectable.h:71
LowLeakDetection::HTML_detectedLimitHours
friend String HTML_detectedLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the normal configuration.
ALeakDetectable::newAlarmConfig
LeakDetectionConfig_t newAlarmConfig
new parameters of the alarm config when the user changes them
Definition: ALeakDetectable.h:79
LowLeakDetection::testResetLeak
void testResetLeak() override
Tests if the low-water the algorithm should be reset based on inactivity of pulse on the input pin.
Definition: LowLeakDetection.cpp:114
PulseCounter::isActive
int isActive() const
Returns information if a pulse has been detected.
Definition: PulseCounter.cpp:40
ALeakDetectable::oldBypassValue
int oldBypassValue
old bypass value (used for sending e-mails)
Definition: ALeakDetectable.h:70
LowLeakDetection::HTML_detectedTime
friend String HTML_detectedTime(const LowLeakDetection &lowLeakDetection)
Associated function for returing the detection time of a low-water leak.
DELTA_TIME
#define DELTA_TIME(time1, time2)
Calculates the time difference between two times given as parameters.
Definition: DateTime.h:35
ALeakDetectable::pulseCounter
PulseCounter * pulseCounter
instance of a pulse counter (input of the system)
Definition: ALeakDetectable.h:65
LowLeakDetection::HTML_detectedText
friend String HTML_detectedText(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (2)
LowLeakDetection::HTML_detectedLimitMins
friend String HTML_detectedLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the normal configuration.
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
LowLeakDetection::HTML_activePercentage
friend String HTML_activePercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close a leak is from being detected.
LowLeakDetection::HTML_resetLimitSecs
friend String HTML_resetLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the normal configuration.
EmailSender::getInstance
static EmailSender * getInstance()
Returns the instance of the class.
Definition: EmailSender.cpp:87