Go to the documentation of this file.
15 #ifdef GENERATE_PULSES
44 #ifdef GENERATE_PULSES
45 PulseGenerator pulseGenerator(PG_DELAY_HIGH, PG_DELAY_LOW, PG_PIN);
82 std::vector<String>
split(String& data) {
83 std::vector<String> tokens;
85 for (
int i = 0; i < (int)data.length(); i++) {
87 tokens.push_back(buffer);
90 else buffer += data[i];
99 std::vector<String> tokens =
split(data);
103 if (tokens.size() != 4)
119 std::vector<String> tokens =
split(data);
123 if (tokens.size() != 4)
129 {strtoul(tokens[0].c_str(), NULL, 10), strtoul(tokens[1].c_str(), NULL, 10),
UNUSED,
LOW_BYPASS_PIN},
130 {strtoul(tokens[2].c_str(), NULL, 10), strtoul(tokens[3].c_str(), NULL, 10),
UNUSED,
LOW_BYPASS_PIN}
139 std::vector<String> tokens =
split(data);
143 if (tokens.size() != 4)
159 #ifdef EMAIL_NOTIFICATION
160 std::vector<String> tokens =
split(data);
164 if (tokens.size() != EmailSender::Type::COUNT + 1)
184 Serial.println(
"loading settings...");
192 Serial.println(
"ERROR - SD card initialization failed!");
217 settingsFile.close();
221 Serial.print(
"error opening ");
238 Serial.println(
"<[STARTING PROGRAM]>");
239 Serial.println(
"pins configuration...");
247 Serial.println(
"adding instances to logging...");
258 Serial.println(
"adding instances of all the controllers...");
282 Serial.println(
"web server initialization...");
312 dailyWaterConsumption,
313 monthlyWaterConsumption);
319 Serial.println(
"program is now running...");
323 #ifdef EMAIL_NOTIFICATION
326 "Home Water Leaks Detection",
327 "The device is now running\n\r"
337 #ifdef GENERATE_PULSES
338 pulseGenerator.update();
343 controller->update();
@ CHANGED_SETTINGS
when the user changes settings
@ Total
total water leak detection algorithm
LowLeakDetection * lowLeakDetection
void addLeakDetection(ALeakDetectable::Type type, ALeakDetectable *leak)
Adds another water leak detection algorithm to the collection.
@ BYPASS
when a bypass changes
HighLeakDetection * highLeakDetection
PulseCounter pulseCounter(SENSOR_PIN)
#define SS_SD_CARD
SD card pin (arduino documentation)
static Logger * getInstance()
Returns the instance of the class.
@ Low
low water leak detection algorithm
int setSettingsNotification(String data)
void applyDefaultSettings()
std::vector< String > split(String &data)
#define HIGH_BYPASS_PIN
high-water leak bypass button
int createTotalLeakDetection(String data)
void enableNotification(Type type, bool state)
Enables/disables the particular type of e-mail notification.
#define SETTINGS_FILE_NAME
the main settings file stored on the SD card
void setMonthlyConsumptionCounter(Consumption *monthlyConsumptionCounter)
Sets an instance of Consumption (monthly water consumption)
@ MONTH
monthly water consumption
#define SERIAL_BAUD_RATE
baud rate for the serial communication (terminal)
@ BOOTING
when the system boots up
int createLowLeakDetection(String data)
@ High
high water leak detection algorithm
void addItem(IDisplayable *item)
Adds another source of data for the LCD display (another class)
int createHighLeakDetection(String data)
void setReceiverEmailAddress(String email)
Changes the user's e-mail address.
#define LOW_BYPASS_PIN
low-water leak bypass button
std::vector< IControllable * > controllers
static DateTime * getInstance()
Returns the instance of the class.
@ LEAK_DETECTED
when a leak has been detected
TotalLeakDetection * totalLeakDetection
void addHTMLSource(HTMLDataSource *source)
Adds another source of data for the HTML content.
#define TOTAL_LEAK_NORMAL_DEFAULT_CONFIG
Passes the default total-water leak detection parameters to the constructor.
void setDailyConsumptionCounter(Consumption *dailyConsumptionCounter)
Sets an instance of Consumption (daily water consumption)
static FreeMemoryMeasurement * getInstance()
Returns the instance of the class.
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
void setPulseCounter(PulseCounter *pulseCounter)
Sets an instance of PulseCounter.
#define SS_ETHERNET
etherent pin (arduino documentation)
@ VALVE_STATE
when the state of the valve has changed
@ RESET
when the device resets
@ APPLIED_NEW_SETTING
when the new settings are applied
void addEntity(ILoggable *log)
Adds another class to the logging system.
static LCDController * getInstance()
Returns the instance of the class.
#define TOTAL_BYPASS_PIN
total-water leak bypass button
static WebServer * getInstance()
Returns the instance of the class.
#define HIGH_LEAK_NORMAL_DEFAULT_CONFIG
Passes the default high-water leak detection parameters to the constructor.
#define LOW_LEAK_NORMAL_DEFAULT_CONFIG
Passes the default low-water leak detection parameters to the constructor.
#define SENSOR_PIN
the flow sensor
static LeaksController * getInstance()
Returns the instance of the class.
@ DAILY_OVERVIEW
daily overview about the system
@ ALARM
when the state of the home alarm changes
@ DAY
daily water consumption
#define UNUSED
unused parameter
static EmailSender * getInstance()
Returns the instance of the class.
void setup(LeaksController *leaksController)
Sets the pointer to an instance of LeaksController.