HomeWaterLeaksDetection
|
#include <PulseCounter.h>
Public Member Functions | |
PulseCounter (int inputPin) | |
Constructor of the class. More... | |
void | update () |
Updates the class. More... | |
int | isActive () const |
Returns information if a pulse has been detected. More... | |
time_t | getLastPulseTime () const |
Return the time when the last pulse was detected. More... | |
const String | getHTMLData (const int id) const |
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... | |
Private Attributes | |
int | inputPin |
number of the input pin More... | |
time_t | lastPulseTime |
time when the last pulse was detected More... | |
int | previousInputValue |
previous state of the input pin More... | |
int | pulseDown |
flag if a pulse just occurred More... | |
std::map< int, String(*)(const PulseCounter &pulseCounter)> | htmlData |
A map of different values (keys) and their associated functions which returns the appropriate values. More... | |
Friends | |
String | HTML_lastPulseTime (const PulseCounter &pulseCounter) |
Associated function for returing the last pulse time. More... | |
String | HTML_currentTime (const PulseCounter &pulseCounter) |
Associated function for returing the current time. More... | |
String | HTML_currentDate (const PulseCounter &pulseCounter) |
Associated function for returing the current date. More... | |
Additional Inherited Members | |
![]() | |
static const String | UNDEFINED_DATA = String("UNDEFINED") |
string "UNDEFINED" More... | |
This class represents the main input of the system. It keeps counting the pulses occuring on the input pin. A pulse is understood as the level of voltage going from high to low.
Definition at line 25 of file PulseCounter.h.
PulseCounter::PulseCounter | ( | int | inputPin | ) |
Constructor of the class.
inputPin | number of the input pin the flow sensor is connected to |
Definition at line 9 of file PulseCounter.cpp.
References HTML_currentDate, HTML_currentTime, HTML_lastPulseTime, htmlData, inputPin, lastPulseTime, previousInputValue, and pulseDown.
|
virtual |
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.
time_t PulseCounter::getLastPulseTime | ( | ) | const |
Return the time when the last pulse was detected.
Definition at line 44 of file PulseCounter.cpp.
References lastPulseTime.
Referenced by LowLeakDetection::getPercentLeakDetectionReset(), HighLeakDetection::getPercentLeakDetectionReset(), LowLeakDetection::testResetLeak(), HighLeakDetection::testResetLeak(), and LowLeakDetection::update().
int PulseCounter::isActive | ( | ) | const |
Returns information if a pulse has been detected.
Definition at line 40 of file PulseCounter.cpp.
References pulseDown.
Referenced by Consumption::update(), LowLeakDetection::update(), and HighLeakDetection::update().
void PulseCounter::update | ( | ) |
Updates the class.
It reads the current state of the input pin and if it has gone from high to low, the flag will be set. This method is supposed to be called as frequently as possible so every pulse occurred will be detected.
Definition at line 25 of file PulseCounter.cpp.
References inputPin, lastPulseTime, previousInputValue, and pulseDown.
Referenced by LeaksController::update().
|
friend |
Associated function for returing the current date.
pulseCounter | - the instance of the PulseCounter class |
Referenced by PulseCounter().
|
friend |
Associated function for returing the current time.
pulseCounter | - the instance of the PulseCounter class |
Referenced by PulseCounter().
|
friend |
Associated function for returing the last pulse time.
pulseCounter | - the instance of the PulseCounter class |
Referenced by PulseCounter().
|
private |
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition at line 65 of file PulseCounter.h.
Referenced by PulseCounter().
|
private |
number of the input pin
Definition at line 32 of file PulseCounter.h.
Referenced by PulseCounter(), and update().
|
private |
time when the last pulse was detected
Definition at line 33 of file PulseCounter.h.
Referenced by getLastPulseTime(), PulseCounter(), and update().
|
private |
previous state of the input pin
Definition at line 34 of file PulseCounter.h.
Referenced by PulseCounter(), and update().
|
private |
flag if a pulse just occurred
Definition at line 35 of file PulseCounter.h.
Referenced by isActive(), PulseCounter(), and update().