F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
IntervalTimer.cpp
Go to the documentation of this file.
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 
14  this->m_startTime.now();
15  }
16 
18  this->m_stopTime.now();
19  }
20 
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 
32  return this->m_stopTime.getTimeInterval(this->m_startTime, interval);
33  }
34 }
Status now() override
Get the current time.
Definition: RawTime.cpp:36
IntervalTimer()
Constructor.
void stop()
Capture the stop time of the interval.
Os::RawTime::Status getTimeInterval(Fw::TimeInterval &interval) const
Get the time interval between the start and stop times.
void start()
Capture the start time of the interval.
Status getTimeInterval(const Os::RawTime &other, Fw::TimeInterval &interval) const override
Calculate the time interval between this and another raw time.
Definition: RawTime.cpp:41
U32 getDiffUsec() const
Get the difference between start and stop times in microseconds.
Status getDiffUsec(const RawTime &other, U32 &result) const
Calculate the difference in microseconds between two RawTime objects.
Definition: RawTime.cpp:56