F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Fw::Time Class Reference

#include <Fw/Time/Time.hpp>

Inheritance diagram for Fw::Time:
Fw::Serializable

Public Types

enum  { SERIALIZED_SIZE = sizeof(FwTimeBaseStoreType) + sizeof(FwTimeContextStoreType) + sizeof(U32) + sizeof(U32) }
 
- Public Types inherited from Fw::Serializable
using SizeType = FwSizeType
 

Public Member Functions

 Time ()
 
 Time (const Time &other)
 
 Time (U32 seconds, U32 useconds)
 
 Time (TimeBase timeBase, U32 seconds, U32 useconds)
 
 Time (TimeBase timeBase, FwTimeContextStoreType context, U32 seconds, U32 useconds)
 
 Time (F64 seconds)
 Constructor with floating-point (F64) seconds. More...
 
virtual ~Time ()
 
void set (U32 seconds, U32 useconds)
 
void set (TimeBase timeBase, U32 seconds, U32 useconds)
 
void set (TimeBase timeBase, FwTimeContextStoreType context, U32 seconds, U32 useconds)
 
void set (F64 seconds)
 Sets value of time stored. More...
 
void setTimeBase (TimeBase timeBase)
 
void setTimeContext (FwTimeContextStoreType context)
 
U32 getSeconds () const
 
U32 getUSeconds () const
 
TimeBase getTimeBase () const
 
FwTimeContextStoreType getContext () const
 
SerializeStatus serializeTo (SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
 Serialize the contents of this object to a buffer. More...
 
SerializeStatus deserializeFrom (SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
 Deserialize the contents of this object from a buffer. More...
 
bool operator== (const Time &other) const
 
bool operator!= (const Time &other) const
 
bool operator> (const Time &other) const
 
bool operator< (const Time &other) const
 
bool operator>= (const Time &other) const
 
bool operator<= (const Time &other) const
 
Timeoperator= (const Time &other)
 
Timeoperator= (F64 seconds)
 Assign this Time from floating-point (F64) seconds. More...
 
Timeoperator+= (F64 seconds)
 Add floating-point (F64) value to this Time. More...
 
 operator F64 () const
 Convert object to floating point (F64) representation. More...
 
TimeValue asTimeValue () const
 get the underlying TimeValue More...
 
void add (U32 seconds, U32 mseconds)
 
void add (F64 seconds)
 Add floating-point (F64) seconds to existing time. More...
 
- Public Member Functions inherited from Fw::Serializable
 DEPRECATED (SerializeStatus serialize(SerialBufferBase &buffer) const, "Use serializeTo(SerialBufferBase& buffer) instead")
 
 DEPRECATED (SerializeStatus deserialize(SerialBufferBase &buffer), "Use deserializeFrom(SerialBufferBase& buffer) instead")
 

Static Public Member Functions

static Time zero (TimeBase timeBase=TimeBase::TB_NONE)
 The type of a comparison result. More...
 
static TimeComparison compare (const Time &time1, const Time &time2)
 
static Time add (const Time &a, const Time &b)
 
static Time sub (const Time &minuend, const Time &subtrahend)
 
static U32 parseSeconds (F64 seconds)
 Extract seconds from a floating-point (F64) More...
 
static U32 parseUSeconds (F64 seconds)
 Extract microseconds from a floating-point (F64) More...
 

Friends

class TimeTester
 

Additional Inherited Members

- Protected Member Functions inherited from Fw::Serializable
 Serializable ()
 Default constructor. More...
 
virtual ~Serializable ()
 Virtual destructor. More...
 

Detailed Description

Definition at line 12 of file Time.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SERIALIZED_SIZE 

Definition at line 16 of file Time.hpp.

Constructor & Destructor Documentation

◆ Time() [1/6]

Fw::Time::Time ( )

Definition at line 7 of file Time.cpp.

◆ Time() [2/6]

Fw::Time::Time ( const Time other)

Definition at line 16 of file Time.cpp.

◆ Time() [3/6]

Fw::Time::Time ( U32  seconds,
U32  useconds 
)

Definition at line 21 of file Time.cpp.

◆ Time() [4/6]

Fw::Time::Time ( TimeBase  timeBase,
U32  seconds,
U32  useconds 
)

Definition at line 25 of file Time.cpp.

◆ Time() [5/6]

Fw::Time::Time ( TimeBase  timeBase,
FwTimeContextStoreType  context,
U32  seconds,
U32  useconds 
)

Definition at line 37 of file Time.cpp.

◆ Time() [6/6]

Fw::Time::Time ( F64  seconds)
explicit

Constructor with floating-point (F64) seconds.

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug)

Definition at line 47 of file Time.cpp.

◆ ~Time()

Fw::Time::~Time ( )
virtual

Definition at line 14 of file Time.cpp.

Member Function Documentation

◆ add() [1/3]

Time Fw::Time::add ( const Time a,
const Time b 
)
static

Add two times

Returns
The result
Parameters
aTime a
bTime b

Definition at line 164 of file Time.cpp.

◆ add() [2/3]

void Fw::Time::add ( U32  seconds,
U32  mseconds 
)

Definition at line 230 of file Time.cpp.

◆ add() [3/3]

void Fw::Time::add ( F64  seconds)

Add floating-point (F64) seconds to existing time.

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug)

Definition at line 241 of file Time.cpp.

◆ asTimeValue()

TimeValue Fw::Time::asTimeValue ( ) const

get the underlying TimeValue

Returns
the TimeValue representation of this Time as a copy

Definition at line 106 of file Time.cpp.

◆ compare()

TimeComparison Fw::Time::compare ( const Time time1,
const Time time2 
)
static

Compare two times

Returns
The result
Parameters
time1Time 1
time2Time 2

Definition at line 139 of file Time.cpp.

◆ deserializeFrom()

SerializeStatus Fw::Time::deserializeFrom ( SerialBufferBase buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
)
overridevirtual

Deserialize the contents of this object from a buffer.

This method reads serialized data from the provided buffer and reconstructs the object's data from it. The buffer should contain data in the format produced by serializeTo().

Parameters
bufferReference to the SerialBufferBase from which data will be deserialized
modeEndianness mode for deserialization (default is Endianness::BIG)
Returns
SerializeStatus indicating the result of the operation

Implements Fw::Serializable.

Definition at line 114 of file Time.cpp.

◆ getContext()

FwTimeContextStoreType Fw::Time::getContext ( ) const

Definition at line 130 of file Time.cpp.

◆ getSeconds()

U32 Fw::Time::getSeconds ( ) const

Definition at line 118 of file Time.cpp.

◆ getTimeBase()

TimeBase Fw::Time::getTimeBase ( ) const

Definition at line 126 of file Time.cpp.

◆ getUSeconds()

U32 Fw::Time::getUSeconds ( ) const

Definition at line 122 of file Time.cpp.

◆ operator F64()

Fw::Time::operator F64 ( ) const

Convert object to floating point (F64) representation.

Returns
The floating point (F64) representation of this Time

Definition at line 100 of file Time.cpp.

◆ operator!=()

bool Fw::Time::operator!= ( const Time other) const

Definition at line 78 of file Time.cpp.

◆ operator+=()

Time & Fw::Time::operator+= ( F64  seconds)

Add floating-point (F64) value to this Time.

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug mode)

Definition at line 69 of file Time.cpp.

◆ operator<()

bool Fw::Time::operator< ( const Time other) const

Definition at line 86 of file Time.cpp.

◆ operator<=()

bool Fw::Time::operator<= ( const Time other) const

Definition at line 95 of file Time.cpp.

◆ operator=() [1/2]

Time & Fw::Time::operator= ( const Time other)

Definition at line 57 of file Time.cpp.

◆ operator=() [2/2]

Time & Fw::Time::operator= ( F64  seconds)

Assign this Time from floating-point (F64) seconds.

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug mode)

Definition at line 64 of file Time.cpp.

◆ operator==()

bool Fw::Time::operator== ( const Time other) const

Definition at line 74 of file Time.cpp.

◆ operator>()

bool Fw::Time::operator> ( const Time other) const

Definition at line 82 of file Time.cpp.

◆ operator>=()

bool Fw::Time::operator>= ( const Time other) const

Definition at line 90 of file Time.cpp.

◆ parseSeconds()

U32 Fw::Time::parseSeconds ( F64  seconds)
static

Extract seconds from a floating-point (F64)

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug mode)
Returns
Seconds count as U32

Definition at line 214 of file Time.cpp.

◆ parseUSeconds()

U32 Fw::Time::parseUSeconds ( F64  seconds)
static

Extract microseconds from a floating-point (F64)

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug)
Returns
Microseconds count as U32

Definition at line 220 of file Time.cpp.

◆ serializeTo()

SerializeStatus Fw::Time::serializeTo ( SerialBufferBase buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
) const
overridevirtual

Serialize the contents of this object to a buffer.

This method serializes the object's data into the provided buffer. The serialization process converts the object's data into a format that can be stored or transmitted, and then writes it to the buffer.

Parameters
bufferReference to the SerialBufferBase where data will be serialized
modeEndianness mode for serialization (default is Endianness::BIG)
Returns
SerializeStatus indicating the result of the operation

Implements Fw::Serializable.

Definition at line 110 of file Time.cpp.

◆ set() [1/4]

void Fw::Time::set ( U32  seconds,
U32  useconds 
)

Definition at line 29 of file Time.cpp.

◆ set() [2/4]

void Fw::Time::set ( TimeBase  timeBase,
U32  seconds,
U32  useconds 
)

Definition at line 33 of file Time.cpp.

◆ set() [3/4]

void Fw::Time::set ( TimeBase  timeBase,
FwTimeContextStoreType  context,
U32  seconds,
U32  useconds 
)

Definition at line 41 of file Time.cpp.

◆ set() [4/4]

void Fw::Time::set ( F64  seconds)

Sets value of time stored.

Warning
Negative value (seconds < 0) results in undefined behavior (assert fail in Debug)

Definition at line 51 of file Time.cpp.

◆ setTimeBase()

void Fw::Time::setTimeBase ( TimeBase  timeBase)

Definition at line 248 of file Time.cpp.

◆ setTimeContext()

void Fw::Time::setTimeContext ( FwTimeContextStoreType  context)

Definition at line 252 of file Time.cpp.

◆ sub()

Time Fw::Time::sub ( const Time minuend,
const Time subtrahend 
)
static

Subtract subtrahend from minuend

Returns
The result
Parameters
minuendValue being subtracted from
subtrahendValue being subtracted

Definition at line 187 of file Time.cpp.

◆ zero()

Time Fw::Time::zero ( TimeBase  timeBase = TimeBase::TB_NONE)
static

The type of a comparison result.

Returns
time zero

Definition at line 134 of file Time.cpp.

Friends And Related Function Documentation

◆ TimeTester

friend class TimeTester
friend

Definition at line 13 of file Time.hpp.


The documentation for this class was generated from the following files: