HomeWaterLeaksDetection
|
#include <PulseGenerator.h>
Public Member Functions | |
PulseGenerator (time_t delayHigh, time_t delayLow, int outputPin) | |
Creates an instance of the class. More... | |
void | update () |
Updates the state of the output pin. More... | |
void | reset () |
Resets the pulse generator. More... | |
Private Attributes | |
time_t | delayHigh |
delay of the pulse in HIGH state More... | |
time_t | delayLow |
delay of the pulse in LOW state More... | |
int | outputPin |
number of the pin where the pulses are generated More... | |
int | value |
current state of the output pin (HIGH/LOW) More... | |
int | pulseCount |
number of pulses that have been generated so far More... | |
time_t | timeLastValueChange |
time when the state of the pin changed for the last time More... | |
Automatic pulse generator used for unit testing.
This class provides the functionality of generating pulses on the output pin. The number of the pin is passed into the constructor along with the parameters of the generated pulses. This class is used only when it comes to unit testing.
Definition at line 19 of file PulseGenerator.h.
Creates an instance of the class.
delayHigh | delay of the pulse in HIGH state |
delayLow | delay of the pulse in LOW state |
outputPin | number of the pin where the pulses are generated |
Definition at line 3 of file PulseGenerator.cpp.
void PulseGenerator::reset | ( | ) |
Resets the pulse generator.
When running unit tests, the generator needs to be reset every time when moving on to the next test case (scenario).
Definition at line 14 of file PulseGenerator.cpp.
References outputPin, pulseCount, timeLastValueChange, and value.
Referenced by PulseGenerator().
void PulseGenerator::update | ( | ) |
Updates the state of the output pin.
It changes the state of the pin depending if it is time to change it from HIGH to LOW, or otherwise. Both parameters delayHigh and delayLow are defined via the constructor
Definition at line 26 of file PulseGenerator.cpp.
References delayHigh, delayLow, DELTA_TIME, outputPin, pulseCount, timeLastValueChange, and value.
|
private |
delay of the pulse in HIGH state
Definition at line 23 of file PulseGenerator.h.
Referenced by PulseGenerator(), and update().
|
private |
delay of the pulse in LOW state
Definition at line 24 of file PulseGenerator.h.
Referenced by PulseGenerator(), and update().
|
private |
number of the pin where the pulses are generated
Definition at line 25 of file PulseGenerator.h.
Referenced by PulseGenerator(), reset(), and update().
|
private |
number of pulses that have been generated so far
Definition at line 28 of file PulseGenerator.h.
|
private |
time when the state of the pin changed for the last time
Definition at line 30 of file PulseGenerator.h.
|
private |
current state of the output pin (HIGH/LOW)
Definition at line 27 of file PulseGenerator.h.