| 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 | ✗ | Timer ::Timer() : timerStatus(UNINITIALIZED), secondsRemaining(0) {} | |
| 18 | |||
| 19 | ✗ | Timer ::~Timer() {} | |
| 20 | |||
| 21 | // ---------------------------------------------------------------------- | ||
| 22 | // Class interfaces | ||
| 23 | // ---------------------------------------------------------------------- | ||
| 24 | |||
| 25 | ✗ | void Timer ::setTimer(U32 timerDuration) { | |
| 26 | ✗ | this->timerStatus = RUNNING; | |
| 27 | ✗ | this->secondsRemaining = timerDuration; | |
| 28 | ✗ | } | |
| 29 | |||
| 30 | ✗ | void Timer ::disableTimer(void) { | |
| 31 | ✗ | this->timerStatus = EXPIRED; | |
| 32 | ✗ | this->secondsRemaining = 0; | |
| 33 | ✗ | } | |
| 34 | |||
| 35 | ✗ | Timer::Status Timer ::getStatus(void) { | |
| 36 | ✗ | return this->timerStatus; | |
| 37 | } | ||
| 38 | |||
| 39 | ✗ | void Timer ::run(void) { | |
| 40 | ✗ | 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 | ✗ | if (this->secondsRemaining > 0) { | |
| 44 | ✗ | this->secondsRemaining--; | |
| 45 | } | ||
| 46 | |||
| 47 | ✗ | if (this->secondsRemaining == 0) { | |
| 48 | ✗ | this->timerStatus = EXPIRED; | |
| 49 | } | ||
| 50 | } | ||
| 51 | ✗ | } | |
| 52 | |||
| 53 | } // namespace Cfdp | ||
| 54 | } // namespace Ccsds | ||
| 55 | } // namespace Svc | ||
| 56 |