| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Timer.cpp | ||
| 3 | // \author Brian Campuzano | ||
| 4 | // \brief cpp file for the Timer class implementation | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #include <Svc/Ccsds/CfdpManager/Timer.hpp> | ||
| 8 | |||
| 9 | namespace Svc { | ||
| 10 | namespace Ccsds { | ||
| 11 | namespace Cfdp { | ||
| 12 | |||
| 13 | // ---------------------------------------------------------------------- | ||
| 14 | // Class construction and destruction | ||
| 15 | // ---------------------------------------------------------------------- | ||
| 16 | |||
| 17 | 32971 | Timer ::Timer() : timerStatus(UNINITIALIZED), secondsRemaining(0) {} | |
| 18 | |||
| 19 | 32971 | Timer ::~Timer() {} | |
| 20 | |||
| 21 | // ---------------------------------------------------------------------- | ||
| 22 | // Class interfaces | ||
| 23 | // ---------------------------------------------------------------------- | ||
| 24 | |||
| 25 | 313 | void Timer ::setTimer(U32 timerDuration) { | |
| 26 | 313 | this->timerStatus = RUNNING; | |
| 27 | 313 | this->secondsRemaining = timerDuration; | |
| 28 | 313 | } | |
| 29 | |||
| 30 | 31458 | void Timer ::disableTimer(void) { | |
| 31 | 31458 | this->timerStatus = EXPIRED; | |
| 32 | 31458 | this->secondsRemaining = 0; | |
| 33 | 31458 | } | |
| 34 | |||
| 35 | 410 | Timer::Status Timer ::getStatus(void) { | |
| 36 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
|
410 | return this->timerStatus; |
| 37 | } | ||
| 38 | |||
| 39 | 223 | void Timer ::run(void) { | |
| 40 |
3/4✗ Branch 1 not taken.
✓ Branch 2 taken 223 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 1 times.
|
223 | if (this->timerStatus == RUNNING) { |
| 41 | // A zero duration (e.g. a ground-set timer parameter of 0) is treated as | ||
| 42 | // immediately expired on the first tick rather than asserting. | ||
| 43 |
2/2✓ Branch 2 taken 220 times.
✓ Branch 3 taken 2 times.
|
222 | if (this->secondsRemaining > 0) { |
| 44 | 220 | this->secondsRemaining--; | |
| 45 | } | ||
| 46 | |||
| 47 |
2/2✓ Branch 2 taken 49 times.
✓ Branch 3 taken 173 times.
|
222 | if (this->secondsRemaining == 0) { |
| 48 | 49 | this->timerStatus = EXPIRED; | |
| 49 | } | ||
| 50 | } | ||
| 51 | 223 | } | |
| 52 | |||
| 53 | } // namespace Cfdp | ||
| 54 | } // namespace Ccsds | ||
| 55 | } // namespace Svc | ||
| 56 |