| 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 | #include <Fw/Types/Assert.hpp> | ||
| 10 | |||
| 11 | namespace Svc { | ||
| 12 | namespace Ccsds { | ||
| 13 | namespace Cfdp { | ||
| 14 | |||
| 15 | // ---------------------------------------------------------------------- | ||
| 16 | // Class construction and destruction | ||
| 17 | // ---------------------------------------------------------------------- | ||
| 18 | |||
| 19 | ✗ | Timer ::Timer() : timerStatus(UNINITIALIZED), secondsRemaining(0) {} | |
| 20 | |||
| 21 | ✗ | Timer ::~Timer() {} | |
| 22 | |||
| 23 | // ---------------------------------------------------------------------- | ||
| 24 | // Class interfaces | ||
| 25 | // ---------------------------------------------------------------------- | ||
| 26 | |||
| 27 | ✗ | void Timer ::setTimer(U32 timerDuration) { | |
| 28 | ✗ | this->timerStatus = RUNNING; | |
| 29 | ✗ | this->secondsRemaining = timerDuration; | |
| 30 | ✗ | } | |
| 31 | |||
| 32 | ✗ | void Timer ::disableTimer(void) { | |
| 33 | ✗ | this->timerStatus = EXPIRED; | |
| 34 | ✗ | this->secondsRemaining = 0; | |
| 35 | ✗ | } | |
| 36 | |||
| 37 | ✗ | Timer::Status Timer ::getStatus(void) { | |
| 38 | ✗ | return this->timerStatus; | |
| 39 | } | ||
| 40 | |||
| 41 | ✗ | void Timer ::run(void) { | |
| 42 | ✗ | if (this->timerStatus == RUNNING) { | |
| 43 | ✗ | FW_ASSERT(this->secondsRemaining > 0); | |
| 44 | ✗ | this->secondsRemaining--; | |
| 45 | |||
| 46 | ✗ | if (this->secondsRemaining == 0) { | |
| 47 | ✗ | this->timerStatus = EXPIRED; | |
| 48 | } | ||
| 49 | } | ||
| 50 | ✗ | } | |
| 51 | |||
| 52 | } // namespace Cfdp | ||
| 53 | } // namespace Ccsds | ||
| 54 | } // namespace Svc | ||
| 55 |