F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TimeConverter.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TimeConverter.hpp
3 // \author devin
4 // \brief hpp file for TimeConverter component implementation class
5 // ======================================================================
6 
7 #ifndef Svc_TimeConverter_HPP
8 #define Svc_TimeConverter_HPP
9 
10 #include <limits>
11 
16 
17 namespace Svc {
18 
20  public:
22  static constexpr I64 US_PER_SECOND = 1000000;
23 
25  static constexpr I64 MAX_TIME_US =
26  static_cast<I64>(std::numeric_limits<U32>::max()) * US_PER_SECOND + (US_PER_SECOND - 1);
27 
28  // ----------------------------------------------------------------------
29  // Component construction and destruction
30  // ----------------------------------------------------------------------
31 
33  explicit TimeConverter(const char* const compName
34  );
35 
38 
39  private:
41  enum class StoreStatus {
42  OK,
43  INVALID,
44  TABLE_FULL
45  };
46 
47  // ----------------------------------------------------------------------
48  // Handler implementations for user-defined typed input ports
49  // ----------------------------------------------------------------------
50 
52  void offsetUpdate_handler(FwIndexType portNum,
53  const Svc::TimeOffset& offset
54  ) override;
55 
57  Svc::ConvertTimeStatus convertTime_handler(FwIndexType portNum,
58  const Fw::Time& in_time,
59  Fw::Time& out_time
60  ) override;
62 
63  // ----------------------------------------------------------------------
64  // Handler implementations for commands
65  // ----------------------------------------------------------------------
66 
68  void SET_OFFSET_cmdHandler(FwOpcodeType opCode,
69  U32 cmdSeq,
70  const TimeBase& from,
71  const TimeBase& to,
72  I64 offset_us
73  ) override;
74 
76  void CLEAR_OFFSETS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;
77 
79  void GET_OFFSET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const TimeBase& from, const TimeBase& to) override;
80 
82  void DUMP_OFFSETS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;
83 
84  // ----------------------------------------------------------------------
85  // Helper functions
86  // ----------------------------------------------------------------------
87 
90  Fw::Success lookupOffset(const TimeBase& from, const TimeBase& to, I64& offset_us) const;
91 
94  StoreStatus storeOffset(const TimeBase& from, const TimeBase& to, I64 offset_us);
95 
98  Fw::Success checkTimeBases(const TimeBase& from, const TimeBase& to);
99 
102 };
103 
104 } // namespace Svc
105 
106 #endif
FwIdType FwOpcodeType
The type of a command opcode.
TimeConverter(const char *const compName)
Construct TimeConverter object.
Auto-generated base for TimeConverter component.
~TimeConverter()
Destroy TimeConverter object.
Result of a time base conversion.
static constexpr I64 US_PER_SECOND
Microseconds in one second.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
Define enumeration for Time base types.
Success/Failure.
static constexpr I64 MAX_TIME_US
Largest time representable by an Fw::Time, in microseconds.