| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Os/IntervalTimer.cpp | ||
| 3 | // \brief Implementation for Os::IntervalTimer | ||
| 4 | // ====================================================================== | ||
| 5 | |||
| 6 | #include <Os/IntervalTimer.hpp> | ||
| 7 | #include <cstring> | ||
| 8 | |||
| 9 | namespace Os { | ||
| 10 | |||
| 11 | ✗ | IntervalTimer::IntervalTimer() : m_startTime(), m_stopTime() {} | |
| 12 | |||
| 13 | ✗ | void IntervalTimer::start() { | |
| 14 | ✗ | (void)this->m_startTime.now(); | |
| 15 | ✗ | } | |
| 16 | |||
| 17 | ✗ | void IntervalTimer::stop() { | |
| 18 | ✗ | (void)this->m_stopTime.now(); | |
| 19 | ✗ | } | |
| 20 | |||
| 21 | ✗ | U32 IntervalTimer::getDiffUsec() const { | |
| 22 | ✗ | U32 result = 0; | |
| 23 | ✗ | Os::RawTime::Status status = this->m_stopTime.getDiffUsec(this->m_startTime, result); | |
| 24 | ✗ | if (status == Os::RawTime::Status::OP_OVERFLOW) { | |
| 25 | // If the operation fails due to overflow, we return the max value | ||
| 26 | ✗ | result = std::numeric_limits<U32>::max(); | |
| 27 | } | ||
| 28 | ✗ | return result; | |
| 29 | } | ||
| 30 | |||
| 31 | ✗ | Os::RawTime::Status IntervalTimer::getTimeInterval(Fw::TimeInterval& interval) const { | |
| 32 | ✗ | return this->m_stopTime.getTimeInterval(this->m_startTime, interval); | |
| 33 | } | ||
| 34 | } // namespace Os | ||
| 35 |