HomeWaterLeaksDetection
DailyOverview Class Reference

#include <DailyOverview.h>

Public Member Functions

 DailyOverview (HighLeakDetection *highLeakDetection, LowLeakDetection *lowLeakDetection, TotalLeakDetection *totalLeakDetection, Consumption *dailyConsumption, Consumption *monthlyConsumption)
 Constructor of the class. More...
 
void update () override
 Updates the class. More...
 
const String getRow (int row) const override
 Returns the content of the row given as a parameter. More...
 

Private Member Functions

void reset ()
 Resets all the variables at the end of the day. More...
 

Private Attributes

HighLeakDetectionhighLeakDetection
 instance of a high-water leak detection algorithm More...
 
LowLeakDetectionlowLeakDetection
 instance of a low-water leak detection algorithm More...
 
TotalLeakDetectiontotalLeakDetection
 instance of a total-water leak detection algorithm More...
 
ConsumptiondailyConsumption
 instance of Consumption (daily water consumption) More...
 
ConsumptionmonthlyConsumption
 instance of Consumption (monthly water consumption) More...
 
RTCDateTime initialDateTime
 instance of RTCDateTime (real-time module) More...
 
float maxHighLeakPercentage
 max [%] high-water leak detection within the monitoring period (extreme) More...
 
float maxLowLeakPercentage
 max [%] low-water leak detection within the monitoring period (extreme) More...
 
float maxTotalLeakPercentage
 max [%] total-water leak detection within the monitoring period (extreme) More...
 

Detailed Description

Author
silhavyj A17B0362P

This class collects information to be sent to the user as a daily overview. Such information includes daily water consumption, how close each type of water leak was from being detected [%], etc.

Definition at line 23 of file DailyOverview.h.

Constructor & Destructor Documentation

◆ DailyOverview()

DailyOverview::DailyOverview ( HighLeakDetection highLeakDetection,
LowLeakDetection lowLeakDetection,
TotalLeakDetection totalLeakDetection,
Consumption dailyConsumption,
Consumption monthlyConsumption 
)

Constructor of the class.

It takes already existing instances as parameters so it can gather information off them

Parameters
highLeakDetectioninstance of HighLeakDetection
lowLeakDetectioninstance of LowLeakDetection
totalLeakDetectioninstance of LowLeakDetection
dailyConsumptioninstance of Consumption (daily)
monthlyConsumptioninstance of Consumption (monthly)

Definition at line 3 of file DailyOverview.cpp.

7  {
8 
9  // store all the params given through the constructor
10  this->highLeakDetection = highLeakDetection; // high algorithm
11  this->lowLeakDetection = lowLeakDetection; // low algorithm
12  this->totalLeakDetection = totalLeakDetection; // total algorithm
13 
14  this->dailyConsumption = dailyConsumption;
15  this->monthlyConsumption = monthlyConsumption;
16 
17  // store the initial date time
19 
20  // set the hour and minute (e.g 10:30) when the daily
21  // overview should be sent to the user
24 
25  // reset the monitoring period
26  reset();
27 }

References DAILY_OVERVIEW_INIT_HOUR, DAILY_OVERVIEW_INIT_MIN, dailyConsumption, DateTime::getDateTime(), DateTime::getInstance(), highLeakDetection, initialDateTime, lowLeakDetection, monthlyConsumption, reset(), and totalLeakDetection.

Member Function Documentation

◆ getRow()

const String DailyOverview::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 DailyOverview::reset ( )
private

Resets all the variables at the end of the day.

Definition at line 29 of file DailyOverview.cpp.

29  {
33 }

References maxHighLeakPercentage, maxLowLeakPercentage, and maxTotalLeakPercentage.

Referenced by DailyOverview(), and update().

◆ update()

void DailyOverview::update ( )
overridevirtual

Updates the class.

It updates the class along with all the information it is collecting. Also, using the RTCDateTime, it resets all the variables at the end of the day.

Implements IControllable.

Definition at line 35 of file DailyOverview.cpp.

35  {
36  // get the current date time
37  RTCDateTime currentDateTime = DateTime::getInstance()->getDateTime();
38 
39  // TODO: add the minutes to the condition as well
40  // so it doesn't depend only on the hour
41  if (initialDateTime.day != currentDateTime.day) {
42  #ifdef EMAIL_NOTIFICATION
43  String data = "";
44  data += "Daily water consumption: " + String(PULSE_TO_LITER(dailyConsumption->getConsumptionCount())) + "l\r\n";
45  data += "Monthly water consumption: " + String(PULSE_TO_LITER(monthlyConsumption->getConsumptionCount())) + "l\r\n";
46  data += "max high leak detected: " + String(maxHighLeakPercentage) + "%\r\n";
47  data += "max low leak detected: " + String(maxLowLeakPercentage) + "%\r\n";
48  data += "max total leak detected: " + String(maxTotalLeakPercentage) + "%\r\n";
51  "Daily overview",
52  data);
53  #endif
54 
55  // start a new monitoring period
56  initialDateTime = currentDateTime;
57  reset();
58  }
59 
60  // update the maximum values (% detected) of all three
61  // water leak detection algorithms
65 }

References EmailSender::DAILY_OVERVIEW, dailyConsumption, Consumption::getConsumptionCount(), DateTime::getDateTime(), EmailSender::getInstance(), DateTime::getInstance(), LowLeakDetection::getPercentLeakDetected(), HighLeakDetection::getPercentLeakDetected(), highLeakDetection, initialDateTime, lowLeakDetection, maxHighLeakPercentage, maxLowLeakPercentage, maxTotalLeakPercentage, monthlyConsumption, PULSE_TO_LITER, reset(), EmailSender::sendEmail(), and totalLeakDetection.

Member Data Documentation

◆ dailyConsumption

Consumption* DailyOverview::dailyConsumption
private

instance of Consumption (daily water consumption)

Definition at line 34 of file DailyOverview.h.

Referenced by DailyOverview(), and update().

◆ highLeakDetection

HighLeakDetection* DailyOverview::highLeakDetection
private

instance of a high-water leak detection algorithm

Definition at line 30 of file DailyOverview.h.

Referenced by DailyOverview(), and update().

◆ initialDateTime

RTCDateTime DailyOverview::initialDateTime
private

instance of RTCDateTime (real-time module)

Definition at line 36 of file DailyOverview.h.

Referenced by DailyOverview(), and update().

◆ lowLeakDetection

LowLeakDetection* DailyOverview::lowLeakDetection
private

instance of a low-water leak detection algorithm

Definition at line 31 of file DailyOverview.h.

Referenced by DailyOverview(), and update().

◆ maxHighLeakPercentage

float DailyOverview::maxHighLeakPercentage
private

max [%] high-water leak detection within the monitoring period (extreme)

Definition at line 38 of file DailyOverview.h.

Referenced by reset(), and update().

◆ maxLowLeakPercentage

float DailyOverview::maxLowLeakPercentage
private

max [%] low-water leak detection within the monitoring period (extreme)

Definition at line 39 of file DailyOverview.h.

Referenced by reset(), and update().

◆ maxTotalLeakPercentage

float DailyOverview::maxTotalLeakPercentage
private

max [%] total-water leak detection within the monitoring period (extreme)

Definition at line 40 of file DailyOverview.h.

Referenced by reset(), and update().

◆ monthlyConsumption

Consumption* DailyOverview::monthlyConsumption
private

instance of Consumption (monthly water consumption)

Definition at line 35 of file DailyOverview.h.

Referenced by DailyOverview(), and update().

◆ totalLeakDetection

TotalLeakDetection* DailyOverview::totalLeakDetection
private

instance of a total-water leak detection algorithm

Definition at line 32 of file DailyOverview.h.

Referenced by DailyOverview(), and update().


The documentation for this class was generated from the following files:
DAILY_OVERVIEW_INIT_HOUR
#define DAILY_OVERVIEW_INIT_HOUR
hour when the daily overview email will be sent off
Definition: Setup.h:22
Consumption::getConsumptionCount
int getConsumptionCount() const
Returns the current number of pulses detected so far within the monitoring period.
Definition: Consumption.cpp:44
DailyOverview::maxLowLeakPercentage
float maxLowLeakPercentage
max [%] low-water leak detection within the monitoring period (extreme)
Definition: DailyOverview.h:39
DailyOverview::reset
void reset()
Resets all the variables at the end of the day.
Definition: DailyOverview.cpp:29
DailyOverview::totalLeakDetection
TotalLeakDetection * totalLeakDetection
instance of a total-water leak detection algorithm
Definition: DailyOverview.h:32
DailyOverview::dailyConsumption
Consumption * dailyConsumption
instance of Consumption (daily water consumption)
Definition: DailyOverview.h:34
DateTime::getInstance
static DateTime * getInstance()
Returns the instance of the class.
Definition: DateTime.cpp:26
DailyOverview::lowLeakDetection
LowLeakDetection * lowLeakDetection
instance of a low-water leak detection algorithm
Definition: DailyOverview.h:31
DailyOverview::monthlyConsumption
Consumption * monthlyConsumption
instance of Consumption (monthly water consumption)
Definition: DailyOverview.h:35
PULSE_TO_LITER
#define PULSE_TO_LITER(p)
Converts pulses to liters.
Definition: LimitsDefinition.h:17
LowLeakDetection::getPercentLeakDetected
float getPercentLeakDetected() const
Returns percentage information about how close the algorithm is from being reset.
Definition: LowLeakDetection.cpp:174
EmailSender::sendEmail
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
Definition: EmailSender.cpp:93
DateTime::getDateTime
RTCDateTime getDateTime() const
Returns the current datatime.
Definition: DateTime.cpp:51
DailyOverview::initialDateTime
RTCDateTime initialDateTime
instance of RTCDateTime (real-time module)
Definition: DailyOverview.h:36
DailyOverview::maxHighLeakPercentage
float maxHighLeakPercentage
max [%] high-water leak detection within the monitoring period (extreme)
Definition: DailyOverview.h:38
DailyOverview::maxTotalLeakPercentage
float maxTotalLeakPercentage
max [%] total-water leak detection within the monitoring period (extreme)
Definition: DailyOverview.h:40
DAILY_OVERVIEW_INIT_MIN
#define DAILY_OVERVIEW_INIT_MIN
minute when the daily overview email will be sent off
Definition: Setup.h:23
HighLeakDetection::getPercentLeakDetected
float getPercentLeakDetected() const
Returns percentage information about how close the algorithm is from being reset.
Definition: HighLeakDetection.cpp:142
EmailSender::DAILY_OVERVIEW
@ DAILY_OVERVIEW
daily overview about the system
Definition: EmailSender.h:46
DailyOverview::highLeakDetection
HighLeakDetection * highLeakDetection
instance of a high-water leak detection algorithm
Definition: DailyOverview.h:30
EmailSender::getInstance
static EmailSender * getInstance()
Returns the instance of the class.
Definition: EmailSender.cpp:87