26 this->
set(timeBase, 0, seconds, useconds);
38 this->
set(timeBase, context, seconds, useconds);
43 FW_ASSERT(useconds < 1000000, static_cast<FwAssertArgType>(useconds));
44 this->m_val.
set(timeBase, context, seconds, useconds);
52 U32 parsedSeconds = this->parseSeconds(seconds);
53 U32 parsedUseconds = this->parseUSeconds(seconds);
54 this->
set(parsedSeconds, parsedUseconds);
59 this->m_val = other.m_val;
100 Fw::Time::operator
F64()
const {
101 const U32 seconds = this->m_val.get_seconds();
102 const U32 useconds = this->m_val.get_useconds();
103 return static_cast<F64>(seconds) + (static_cast<F64>(useconds) / 1000000.0);
135 Time time(timeBase, 0, 0, 0);
153 }
else if (s1 > s2) {
155 }
else if (us1 < us2) {
157 }
else if (us1 > us2) {
172 if (uSeconds >= 1000000) {
188 const Time& subtrahend
191 static_cast<FwAssertArgType>(subtrahend.
getTimeBase()));
211 return Time(minuend.
getTimeBase(), context, seconds,
static_cast<U32
>(uSeconds));
216 FW_ASSERT(seconds >= static_cast<F64>(0.0));
217 return static_cast<U32
>(seconds);
222 FW_ASSERT(seconds >= static_cast<F64>(0.0));
223 U32 parsedSeconds =
static_cast<U32
>(seconds);
224 const F64 fractionalPart = seconds -
static_cast<F64>(parsedSeconds);
226 U32 parsedUSeconds =
static_cast<U32
>(fractionalPart *
static_cast<F64>(1000000.0) +
static_cast<F64>(0.5));
227 return parsedUSeconds;
231 U32 newSeconds = this->m_val.
get_seconds() + seconds;
232 U32 newUSeconds = this->m_val.
get_useconds() + useconds;
233 FW_ASSERT(newUSeconds < 1999999, static_cast<FwAssertArgType>(newUSeconds));
234 if (newUSeconds >= 1000000) {
236 newUSeconds -= 1000000;
238 this->
set(newSeconds, newUSeconds);
245 this->
add(parsedSeconds, parsedUseconds);
257 std::ostream& operator<<(std::ostream& os,
const Time& val) {
bool operator<=(const Time &other) const
U32 get_useconds() const
Get member useconds.
FwTimeContextStoreType get_timeContext() const
Get member timeContext.
Time & operator=(const Time &other)
TimeValue asTimeValue() const
get the underlying TimeValue
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
TimeBase getTimeBase() const
No time base has been established (Required)
TimeBase::T get_timeBase() const
Get member timeBase.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
static Time sub(const Time &minuend, const Time &subtrahend)
bool operator==(const Time &other) const
SerializeStatus
forward declaration for string
static Time zero(TimeBase timeBase=TimeBase::TB_NONE)
The type of a comparison result.
bool operator!=(const Time &other) const
void set_seconds(U32 seconds)
Set member seconds.
void setTimeContext(FwTimeContextStoreType context)
static U32 parseUSeconds(F64 seconds)
Extract microseconds from a floating-point (F64)
void set(U32 seconds, U32 useconds)
Time & operator+=(F64 seconds)
Add floating-point (F64) value to this Time.
bool operator>(const Time &other) const
bool operator>=(const Time &other) const
static U32 parseSeconds(F64 seconds)
Extract seconds from a floating-point (F64)
void set(TimeBase::T timeBase, FwTimeContextStoreType timeContext, U32 seconds, U32 useconds)
Set all members.
void setTimeBase(TimeBase timeBase)
void set_timeBase(TimeBase::T timeBase)
Set member timeBase.
void set_timeContext(FwTimeContextStoreType timeContext)
Set member timeContext.
static TimeComparison compare(const Time &time1, const Time &time2)
static Time add(const Time &a, const Time &b)
FwTimeContextStoreType getContext() const
double F64
64-bit floating point (double). Required for compiler-supplied double promotion.
U32 get_seconds() const
Get member seconds.
SerializeStatus serializeTo(SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
Serialize the contents of this object to a buffer.
Implementation of malloc based allocator.
bool operator<(const Time &other) const
Define enumeration for Time base types.
SerializeStatus deserializeFrom(SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
Deserialize the contents of this object from a buffer.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
void set_useconds(U32 useconds)
Set member useconds.