mirror of
https://github.com/nasa/fprime.git
synced 2025-12-13 11:04:15 -06:00
* Add Os::RawTime and preliminary rule-based tests * Implement Stubs and stub tests tests + misc improvements * Update delay functions to use Fw::TimeInterval instead of Fw::Time * Replace TimerVal with Os::RawTime FPP type, SERIALIZED_SIZE fixed to 2*sizeof(U32) * Fix spelling and legacy code * Fix test import * Remove TimerVal files and misc clean up * Add Fw/Time as dependency of Os module * Fix include guards * Fix default constructors and missing getHandle stub * Add Handle and Serialization size to FpConfig, refactor interface for less vtable calls, refactor IntervalTimer * Fixes for new OS CMake API * Add RawTime FPP Model * Rename getRawTime to now(), better error handling, added docs for all functions * Correct handle size, spelling, and more robust test IntervalTimer test * Peer review changes * Move `Os.RawTime` to `Os/Types.fpp` * Fix unused variable * Fix spelling and comments * spelling extravaganza * Update metadata check-spelling run (pull_request_target) for os-interval-timer Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com> on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev> * Reference based approach to minuend and subtrahend --------- Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com> Co-authored-by: Thomas Boyer-Chammard <thomas-bc@users.noreply.github.com> Co-authored-by: M Starch <LeStarch@googlemail.com>
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// ======================================================================
|
|
// \title Os/IntervalTimer.cpp
|
|
// \brief Implementation for Os::IntervalTimer
|
|
// ======================================================================
|
|
|
|
#include <Os/IntervalTimer.hpp>
|
|
#include <cstring>
|
|
|
|
namespace Os {
|
|
|
|
IntervalTimer::IntervalTimer() : m_startTime(), m_stopTime() {}
|
|
|
|
void IntervalTimer::start() {
|
|
this->m_startTime.now();
|
|
}
|
|
|
|
void IntervalTimer::stop() {
|
|
this->m_stopTime.now();
|
|
}
|
|
|
|
U32 IntervalTimer::getDiffUsec() const {
|
|
U32 result = 0;
|
|
Os::RawTime::Status status = this->m_stopTime.getDiffUsec(this->m_startTime, result);
|
|
if (status == Os::RawTime::Status::OP_OVERFLOW) {
|
|
// If the operation fails due to overflow, we return the max value
|
|
result = std::numeric_limits<U32>::max();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
Os::RawTime::Status IntervalTimer::getTimeInterval(Fw::TimeInterval& interval) const {
|
|
return this->m_stopTime.getTimeInterval(this->m_startTime, interval);
|
|
}
|
|
}
|