| 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 |
1/1✓ Branch 5 taken 5 times.
|
5 | IntervalTimer::IntervalTimer() : m_startTime(), m_stopTime() {} |
| 12 | |||
| 13 | 5 | void IntervalTimer::start() { | |
| 14 | 5 | (void)this->m_startTime.now(); | |
| 15 | 5 | } | |
| 16 | |||
| 17 | 5 | void IntervalTimer::stop() { | |
| 18 | 5 | (void)this->m_stopTime.now(); | |
| 19 | 5 | } | |
| 20 | |||
| 21 | 8 | U32 IntervalTimer::getDiffUsec() const { | |
| 22 | 8 | U32 result = 0; | |
| 23 |
1/1✓ Branch 14 taken 8 times.
|
8 | Os::RawTime::Status status = this->m_stopTime.getDiffUsec(this->m_startTime, result); |
| 24 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | 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 | 8 | return result; | |
| 29 | } | ||
| 30 | |||
| 31 | 1 | Os::RawTime::Status IntervalTimer::getTimeInterval(Fw::TimeInterval& interval) const { | |
| 32 | 1 | return this->m_stopTime.getTimeInterval(this->m_startTime, interval); | |
| 33 | } | ||
| 34 | } // namespace Os | ||
| 35 |