HomeWaterLeaksDetection
|
#include <LeaksController.h>
Public Member Functions | |
void | addLeakDetection (ALeakDetectable::Type type, ALeakDetectable *leak) |
Adds another water leak detection algorithm to the collection. More... | |
int | getNumberOfLeakDetections () const |
Return the number of water leak detection algorithm. More... | |
void | changeSettings (ALeakDetectable::Type type, unsigned long detected, unsigned long reset, bool alarm) |
Changes settings of a water leak detection algorithm. More... | |
void | setPulseCounter (PulseCounter *pulseCounter) |
Sets an instance of PulseCounter. More... | |
void | update () override |
Updates the class. More... | |
String | getFormatOfSettingsToSave () |
Returns all settings. 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... | |
void | setDailyConsumptionCounter (Consumption *dailyConsumptionCounter) |
Sets an instance of Consumption (daily water consumption) More... | |
void | setMonthlyConsumptionCounter (Consumption *monthlyConsumptionCounter) |
Sets an instance of Consumption (monthly water consumption) More... | |
Static Public Member Functions | |
static LeaksController * | getInstance () |
Returns the instance of the class. More... | |
Private Member Functions | |
LeaksController () | |
Constructor of the class. More... | |
LeaksController (LeaksController const &) | |
Copy constructor of the class. More... | |
LeaksController & | operator= (LeaksController const &) |
Assignment operator of the class. More... | |
Private Attributes | |
std::map< ALeakDetectable::Type, ALeakDetectable * > | leaks |
collection (map) of water leak detection algorithms More... | |
Button | manualResetButton = RESET_PIN |
instance of Button (the reset buttton) More... | |
int | valveState |
state of the main valve More... | |
int | stateOfHomeAlarm |
state of the home alarm More... | |
int | manualValveClose |
state of the "manual close" button More... | |
PulseCounter * | pulseCounter = NULL |
instance of PulseCounter (output from the sensor) More... | |
Consumption * | dailyConsumptionCounter = NULL |
daily water consumption More... | |
Consumption * | monthlyConsumptionCounter = NULL |
monthly water consumption More... | |
std::map< int, String(*)(const LeaksController &leaksController)> | htmlData |
A map of different values (keys) and their associated functions which returns the appropriate values. More... | |
Static Private Attributes | |
static LeaksController * | instance = NULL |
the instance of the class More... | |
Friends | |
String | HTML_valve (const LeaksController &leaksController) |
Associated function for returing the current state of the main valve. More... | |
String | HTML_alarm (const LeaksController &leaksController) |
Associated function for returing the current state of the home alarm. More... | |
String | HTML_manualClose (const LeaksController &leaksController) |
Associated function for returing the current state of the "manual close" button. More... | |
String | HTML_dailyConsumption (const LeaksController &leaksController) |
Associated function for returing the daily water consumption in liters. More... | |
String | HTML_monthlyConsumption (const LeaksController &leaksController) |
Associated function for returing the monthly water consumption in liters. More... | |
Additional Inherited Members | |
![]() | |
static const String | UNDEFINED_DATA = String("UNDEFINED") |
string "UNDEFINED" More... | |
This class sepresents a controller for the water leak detection part of the system. It takes care of reading the input values, such as the state of the home alarm, as well as upddating all the algorithms.
Definition at line 57 of file LeaksController.h.
|
private |
Constructor of the class.
Definition at line 13 of file LeaksController.cpp.
References HTML_alarm, HTML_dailyConsumption, HTML_manualClose, HTML_monthlyConsumption, HTML_valve, htmlData, stateOfHomeAlarm, and valveState.
Referenced by getInstance().
|
inlineprivate |
void LeaksController::addLeakDetection | ( | ALeakDetectable::Type | type, |
ALeakDetectable * | leak | ||
) |
Adds another water leak detection algorithm to the collection.
This method is used in main.cpp during initialization
type | of the water leak detection algorithm |
leak | pointer to an instance of ALeakDetectable (water leak detection algorithm) |
Definition at line 33 of file LeaksController.cpp.
References leaks.
Referenced by setup().
void LeaksController::changeSettings | ( | ALeakDetectable::Type | type, |
unsigned long | detected, | ||
unsigned long | reset, | ||
bool | alarm | ||
) |
Changes settings of a water leak detection algorithm.
type | of the water leak detection algorithm |
detected | limit (action) of a leak being detected |
reset | reset time value of the algorithm |
alarm | type of the settings (normal/alarm) |
Definition at line 51 of file LeaksController.cpp.
References ALeakDetectable::getAlarmConfig(), ALeakDetectable::getNormalConfig(), ALeakDetectable::High, leaks, LeakDetectionConfig_t::limitActionTime, LeakDetectionConfig_t::limitPulseAction, LeakDetectionConfig_t::limitResetTime, ALeakDetectable::Low, ALeakDetectable::Total, ALeakDetectable::updateAlarmConfig(), and ALeakDetectable::updateNormalConfig().
Referenced by WebServer::processHTTPRequestSettings().
String LeaksController::getFormatOfSettingsToSave | ( | ) |
Returns all settings.
This method is used when storing data on the SD card. It returns the settings of all water leak detection algorithms.
Definition at line 84 of file LeaksController.cpp.
References ALeakDetectable::High, leaks, ALeakDetectable::Low, and ALeakDetectable::Total.
Referenced by WebServer::saveSettings().
|
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.
|
static |
Returns the instance of the class.
If the instance has not been created, it will create it and then return it.
Definition at line 27 of file LeaksController.cpp.
References instance, and LeaksController().
Referenced by setup().
int LeaksController::getNumberOfLeakDetections | ( | ) | const |
Return the number of water leak detection algorithm.
This is used when parsin an HTTP request so we know how many values there are supposed to be (settings).
Definition at line 37 of file LeaksController.cpp.
References leaks.
Referenced by WebServer::processHTTPRequest().
|
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.
|
inlineprivate |
Assignment operator of the class.
Definition at line 88 of file LeaksController.h.
void LeaksController::setDailyConsumptionCounter | ( | Consumption * | dailyConsumptionCounter | ) |
Sets an instance of Consumption (daily water consumption)
dailyConsumptionCounter | pointer to an instance of Consumption |
Referenced by setup().
void LeaksController::setMonthlyConsumptionCounter | ( | Consumption * | monthlyConsumptionCounter | ) |
Sets an instance of Consumption (monthly water consumption)
monthlyConsumptionCounter | pointer to an instance of Consumption |
Referenced by setup().
void LeaksController::setPulseCounter | ( | PulseCounter * | pulseCounter | ) |
Sets an instance of PulseCounter.
This method is used in main.cpp during initialization
pulseCounter | pointer to an instance of PulseCounter |
Definition at line 90 of file LeaksController.cpp.
References pulseCounter.
Referenced by setup().
|
overridevirtual |
Updates the class.
It updates step by step all the variables and instance it holds. This process includes reading the state of the input pins, updating all water leak detection algorithms, and if necessary, closing the the main valve.
Implements IControllable.
Definition at line 94 of file LeaksController.cpp.
References EmailSender::ALARM, dailyConsumptionCounter, EmailSender::getInstance(), DateTime::getInstance(), HOME_ALARM_PIN, Button::isPressed(), leaks, manualResetButton, manualValveClose, monthlyConsumptionCounter, pulseCounter, EmailSender::RESET, EmailSender::sendEmail(), stateOfHomeAlarm, Consumption::update(), PulseCounter::update(), VALVE_LED_PIN, VALVE_MANUAL_CLOSE_PIN, VALVE_PIN, EmailSender::VALVE_STATE, and valveState.
Referenced by WebServer::update().
|
friend |
Associated function for returing the current state of the home alarm.
leaksController | - the instance of the LeaksController class |
Referenced by LeaksController().
|
friend |
Associated function for returing the daily water consumption in liters.
leaksController | - the instance of the LeaksController class |
Referenced by LeaksController().
|
friend |
Associated function for returing the current state of the "manual close" button.
leaksController | - the instance of the LeaksController class |
Referenced by LeaksController().
|
friend |
Associated function for returing the monthly water consumption in liters.
leaksController | - the instance of the LeaksController class |
Referenced by LeaksController().
|
friend |
Associated function for returing the current state of the main valve.
leaksController | - the instance of the LeaksController class |
Referenced by LeaksController().
|
private |
|
private |
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition at line 190 of file LeaksController.h.
Referenced by LeaksController().
|
staticprivate |
the instance of the class
Definition at line 70 of file LeaksController.h.
Referenced by getInstance().
|
private |
collection (map) of water leak detection algorithms
Definition at line 71 of file LeaksController.h.
Referenced by addLeakDetection(), changeSettings(), getFormatOfSettingsToSave(), getNumberOfLeakDetections(), and update().
instance of Button (the reset buttton)
Definition at line 72 of file LeaksController.h.
Referenced by update().
|
private |
state of the "manual close" button
Definition at line 76 of file LeaksController.h.
Referenced by update().
|
private |
|
private |
instance of PulseCounter (output from the sensor)
Definition at line 77 of file LeaksController.h.
Referenced by setPulseCounter(), and update().
|
private |
state of the home alarm
Definition at line 75 of file LeaksController.h.
Referenced by LeaksController(), and update().
|
private |
state of the main valve
Definition at line 74 of file LeaksController.h.
Referenced by LeaksController(), and update().