F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TimeConverterComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TimeConverterComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for TimeConverter component base class
5 // ======================================================================
6 
7 #ifndef Svc_TimeConverterComponentAc_HPP
8 #define Svc_TimeConverterComponentAc_HPP
9 
10 #include <atomic>
11 
12 #include "Fw/Cmd/CmdPortAc.hpp"
13 #include "Fw/Cmd/CmdRegPortAc.hpp"
15 #include "Fw/Cmd/CmdString.hpp"
17 #include "Fw/FPrimeBasicTypes.hpp"
18 #include "Fw/Log/LogPortAc.hpp"
19 #include "Fw/Log/LogString.hpp"
20 #include "Fw/Log/LogTextPortAc.hpp"
21 #if !FW_DIRECT_PORT_CALLS
23 #endif
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #include "Fw/Time/TimePortAc.hpp"
28 #include "Os/Mutex.hpp"
32 
33 namespace Svc {
34 
41  {
42 
43  // ----------------------------------------------------------------------
44  // Friend classes
45  // ----------------------------------------------------------------------
46 
50  friend class TimeConverterTester;
51 
52  protected:
53 
54  // ----------------------------------------------------------------------
55  // Constants
56  // ----------------------------------------------------------------------
57 
59  enum {
61  };
62 
64  enum {
67  };
68 
70  enum {
76  };
77 
79  enum {
84  };
85 
87  enum {
99  };
100 
102  enum {
109  };
110 
111  public:
112 
113  // ----------------------------------------------------------------------
114  // Component initialization
115  // ----------------------------------------------------------------------
116 
118  void init(
119  FwEnumStoreType instance = 0
120  );
121 
122 #if !FW_DIRECT_PORT_CALLS
123 
124  public:
125 
126  // ----------------------------------------------------------------------
127  // Getters for special input ports
128  // ----------------------------------------------------------------------
129 
134  FwIndexType portNum
135  );
136 
137 #endif
138 
139 #if !FW_DIRECT_PORT_CALLS
140 
141  public:
142 
143  // ----------------------------------------------------------------------
144  // Getters for typed input ports
145  // ----------------------------------------------------------------------
146 
151  FwIndexType portNum
152  );
153 
158  FwIndexType portNum
159  );
160 
161 #endif
162 
163 #if !FW_DIRECT_PORT_CALLS
164 
165  public:
166 
167  // ----------------------------------------------------------------------
168  // Connect input ports to special output ports
169  // ----------------------------------------------------------------------
170 
173  FwIndexType portNum,
174  Fw::InputCmdRegPort* port
175  );
176 
179  FwIndexType portNum,
181  );
182 
185  FwIndexType portNum,
186  Fw::InputLogPort* port
187  );
188 
189 #if FW_ENABLE_TEXT_LOGGING == 1
190 
192  void set_textEventOut_OutputPort(
193  FwIndexType portNum,
194  Fw::InputLogTextPort* port
195  );
196 
197 #endif
198 
201  FwIndexType portNum,
202  Fw::InputTimePort* port
203  );
204 
205 #endif
206 
207 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
208 
209  public:
210 
211  // ----------------------------------------------------------------------
212  // Connect serial input ports to special output ports
213  // ----------------------------------------------------------------------
214 
217  FwIndexType portNum,
218  Fw::InputSerializePort* port
219  );
220 
223  FwIndexType portNum,
224  Fw::InputSerializePort* port
225  );
226 
229  FwIndexType portNum,
230  Fw::InputSerializePort* port
231  );
232 
233 #if FW_ENABLE_TEXT_LOGGING == 1
234 
236  void set_textEventOut_OutputPort(
237  FwIndexType portNum,
238  Fw::InputSerializePort* port
239  );
240 
241 #endif
242 
245  FwIndexType portNum,
246  Fw::InputSerializePort* port
247  );
248 
249 #endif
250 
251  public:
252 
253  // ----------------------------------------------------------------------
254  // Command registration
255  // ----------------------------------------------------------------------
256 
260  void regCommands();
261 
262  protected:
263 
264  // ----------------------------------------------------------------------
265  // Component construction and destruction
266  // ----------------------------------------------------------------------
267 
270  const char* compName = ""
271  );
272 
274  virtual ~TimeConverterComponentBase();
275 
276  protected:
277 
278  // ----------------------------------------------------------------------
279  // Getters for numbers of special input ports
280  // ----------------------------------------------------------------------
281 
286  return NUM_CMDIN_INPUT_PORTS;
287  }
288 
289  protected:
290 
291  // ----------------------------------------------------------------------
292  // Getters for numbers of typed input ports
293  // ----------------------------------------------------------------------
294 
300  }
301 
307  }
308 
309  protected:
310 
311  // ----------------------------------------------------------------------
312  // Getters for numbers of special output ports
313  // ----------------------------------------------------------------------
314 
320  }
321 
327  }
328 
334  }
335 
336 #if FW_ENABLE_TEXT_LOGGING == 1
337 
341  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
343  }
344 
345 #endif
346 
352  }
353 
354  protected:
355 
356  // ----------------------------------------------------------------------
357  // Connection status queries for special output ports
358  // ----------------------------------------------------------------------
359 
364  FwIndexType portNum
365  ) const;
366 
371  FwIndexType portNum
372  ) const;
373 
378  FwIndexType portNum
379  ) const;
380 
381 #if FW_ENABLE_TEXT_LOGGING == 1
382 
386  bool isConnected_textEventOut_OutputPort(
387  FwIndexType portNum
388  ) const;
389 
390 #endif
391 
396  FwIndexType portNum
397  ) const;
398 
399 #if FW_DIRECT_PORT_CALLS
400  public:
401 #else
402  protected:
403 #endif
404 
405  // ----------------------------------------------------------------------
406  // Port handler base-class functions for special input ports
407  //
408  // Call these functions directly to bypass the corresponding ports
409  // ----------------------------------------------------------------------
410 
412  void cmdIn_handlerBase(
413  FwIndexType portNum,
414  FwOpcodeType opCode,
415  U32 cmdSeq,
416  Fw::CmdArgBuffer& args
417  );
418 
419  protected:
420 
421  // ----------------------------------------------------------------------
422  // Handlers to implement for typed input ports
423  // ----------------------------------------------------------------------
424 
427  FwIndexType portNum,
428  const Fw::Time& in_time,
429  Fw::Time& out_time
430  ) = 0;
431 
433  virtual void offsetUpdate_handler(
434  FwIndexType portNum,
435  const Svc::TimeOffset& offset
436  ) = 0;
437 
438 #if FW_DIRECT_PORT_CALLS
439  public:
440 #else
441  protected:
442 #endif
443 
444  // ----------------------------------------------------------------------
445  // Port handler base-class functions for typed input ports
446  //
447  // Call these functions directly to bypass the corresponding ports
448  // ----------------------------------------------------------------------
449 
452  FwIndexType portNum,
453  const Fw::Time& in_time,
454  Fw::Time& out_time
455  );
456 
459  FwIndexType portNum,
460  const Svc::TimeOffset& offset
461  );
462 
463  protected:
464 
465  // ----------------------------------------------------------------------
466  // Command response
467  // ----------------------------------------------------------------------
468 
470  void cmdResponse_out(
471  FwOpcodeType opCode,
472  U32 cmdSeq,
473  Fw::CmdResponse response
474  );
475 
476  protected:
477 
478  // ----------------------------------------------------------------------
479  // Command handlers to implement
480  // ----------------------------------------------------------------------
481 
485  virtual void SET_OFFSET_cmdHandler(
486  FwOpcodeType opCode,
487  U32 cmdSeq,
488  const TimeBase& from,
489  const TimeBase& to,
490  I64 offset_us
491  ) = 0;
492 
496  virtual void CLEAR_OFFSETS_cmdHandler(
497  FwOpcodeType opCode,
498  U32 cmdSeq
499  ) = 0;
500 
504  virtual void GET_OFFSET_cmdHandler(
505  FwOpcodeType opCode,
506  U32 cmdSeq,
507  const TimeBase& from,
508  const TimeBase& to
509  ) = 0;
510 
514  virtual void DUMP_OFFSETS_cmdHandler(
515  FwOpcodeType opCode,
516  U32 cmdSeq
517  ) = 0;
518 
519  protected:
520 
521  // ----------------------------------------------------------------------
522  // Command handler base-class functions
523  //
524  // Call these functions directly to bypass the command input port
525  // ----------------------------------------------------------------------
526 
531  FwOpcodeType opCode,
532  U32 cmdSeq,
533  Fw::CmdArgBuffer& args
534  );
535 
540  FwOpcodeType opCode,
541  U32 cmdSeq,
542  Fw::CmdArgBuffer& args
543  );
544 
549  FwOpcodeType opCode,
550  U32 cmdSeq,
551  Fw::CmdArgBuffer& args
552  );
553 
558  FwOpcodeType opCode,
559  U32 cmdSeq,
560  Fw::CmdArgBuffer& args
561  );
562 
563  protected:
564 
565  // ----------------------------------------------------------------------
566  // Event logging functions
567  // ----------------------------------------------------------------------
568 
573  const TimeBase& in_tb,
574  const TimeBase& out_tb
575  );
576 
581  const TimeBase& in_tb,
582  const TimeBase& out_tb,
583  I64 offset_us,
584  I64 in_time_us
585  );
586 
591  const TimeBase& from,
592  const TimeBase& to,
593  I64 offset_us
594  ) const;
595 
600  const TimeBase& from,
601  const TimeBase& to,
602  U32 capacity
603  );
604 
609  U32 entries
610  ) const;
611 
616  const TimeBase& from,
617  const TimeBase& to,
618  I64 offset_us
619  ) const;
620 
625  const TimeBase& from,
626  const TimeBase& to
627  ) const;
628 
633 
638  const TimeBase& tb
639  );
640 
645  const TimeBase& from,
646  const TimeBase& to,
647  I64 offset_us
648  );
649 
654  const TimeBase& tb
655  );
656 
657  protected:
658 
659  // ----------------------------------------------------------------------
660  // Event throttle reset functions
661  // ----------------------------------------------------------------------
662 
665 
668 
671 
674 
677 
680 
681  protected:
682 
683  // ----------------------------------------------------------------------
684  // Time
685  // ----------------------------------------------------------------------
686 
690  Fw::Time getTime() const;
691 
692  protected:
693 
694  // ----------------------------------------------------------------------
695  // Mutex operations for guarded ports
696  //
697  // You can override these operations to provide more sophisticated
698  // synchronization
699  // ----------------------------------------------------------------------
700 
702  virtual void lock();
703 
705  virtual void unLock();
706 
707  private:
708 
709  // ----------------------------------------------------------------------
710  // Calls for messages received on special input ports
711  // ----------------------------------------------------------------------
712 
714  static void m_p_cmdIn_in(
715  Fw::PassiveComponentBase* callComp,
716  FwIndexType portNum,
717  FwOpcodeType opCode,
718  U32 cmdSeq,
719  Fw::CmdArgBuffer& args
720  );
721 
722  private:
723 
724  // ----------------------------------------------------------------------
725  // Calls for messages received on typed input ports
726  // ----------------------------------------------------------------------
727 
729  static Svc::ConvertTimeStatus m_p_convertTime_in(
730  Fw::PassiveComponentBase* callComp,
731  FwIndexType portNum,
732  const Fw::Time& in_time,
733  Fw::Time& out_time
734  );
735 
737  static void m_p_offsetUpdate_in(
738  Fw::PassiveComponentBase* callComp,
739  FwIndexType portNum,
740  const Svc::TimeOffset& offset
741  );
742 
743  private:
744 
745  // ----------------------------------------------------------------------
746  // Invocation functions for special output ports
747  // ----------------------------------------------------------------------
748 
750  void cmdRegOut_out(
751  FwIndexType portNum,
752  FwOpcodeType opCode
753  ) const;
754 
756  void cmdResponseOut_out(
757  FwIndexType portNum,
758  FwOpcodeType opCode,
759  U32 cmdSeq,
760  const Fw::CmdResponse& response
761  ) const;
762 
764  void eventOut_out(
765  FwIndexType portNum,
766  FwEventIdType id,
767  Fw::Time& timeTag,
768  const Fw::LogSeverity& severity,
769  Fw::LogBuffer& args
770  ) const;
771 
772 #if FW_ENABLE_TEXT_LOGGING
773 
775  void textEventOut_out(
776  FwIndexType portNum,
777  FwEventIdType id,
778  Fw::Time& timeTag,
779  const Fw::LogSeverity& severity,
780  Fw::TextLogString& text
781  ) const;
782 
783 #endif
784 
786  void timeCaller_out(
787  FwIndexType portNum,
788  Fw::Time& time
789  ) const;
790 
791 #if !FW_DIRECT_PORT_CALLS
792 
793  private:
794 
795  // ----------------------------------------------------------------------
796  // Special input ports
797  // ----------------------------------------------------------------------
798 
800  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
801 
802 #endif
803 
804 #if !FW_DIRECT_PORT_CALLS
805 
806  private:
807 
808  // ----------------------------------------------------------------------
809  // Typed input ports
810  // ----------------------------------------------------------------------
811 
814 
817 
818 #endif
819 
820 #if !FW_DIRECT_PORT_CALLS
821 
822  private:
823 
824  // ----------------------------------------------------------------------
825  // Special output ports
826  // ----------------------------------------------------------------------
827 
829  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
830 
832  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
833 
835  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
836 
837 #if FW_ENABLE_TEXT_LOGGING == 1
838 
840  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
841 
842 #endif
843 
845  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
846 
847 #endif
848 
849  private:
850 
851  // ----------------------------------------------------------------------
852  // Counter values for event throttling
853  // ----------------------------------------------------------------------
854 
856  std::atomic<FwIndexType> m_NoConversionAvailableThrottle;
857 
859  std::atomic<FwIndexType> m_InvalidTimeThrottle;
860 
862  std::atomic<FwIndexType> m_OffsetTableFullThrottle;
863 
865  std::atomic<FwIndexType> m_IdenticalTimeBasesThrottle;
866 
868  std::atomic<FwIndexType> m_OffsetOutOfRangeThrottle;
869 
871  std::atomic<FwIndexType> m_UnusableTimeBaseThrottle;
872 
873  private:
874 
875  // ----------------------------------------------------------------------
876  // Mutexes
877  // ----------------------------------------------------------------------
878 
880  Os::Mutex m_guardedPortMutex;
881 
882  };
883 
884 }
885 
886 #endif
void log_WARNING_LO_InvalidTime_ThrottleClear()
Reset throttle value for InvalidTime.
void log_WARNING_LO_InvalidTime(const TimeBase &in_tb, const TimeBase &out_tb, I64 offset_us, I64 in_time_us)
No offset is stored for the requested pair of time bases.
void log_ACTIVITY_HI_OffsetReport(const TimeBase &from, const TimeBase &to, I64 offset_us) const
FwIdType FwOpcodeType
The type of a command opcode.
virtual Svc::ConvertTimeStatus convertTime_handler(FwIndexType portNum, const Fw::Time &in_time, Fw::Time &out_time)=0
Handler for input port convertTime.
void log_WARNING_LO_IdenticalTimeBases_ThrottleClear()
Reset throttle value for IdenticalTimeBases.
I32 FwEnumStoreType
static constexpr FwIndexType getNum_offsetUpdate_InputPorts()
A time base that denotes no clock was supplied as an end of a pair.
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
Auto-generated base for TimeConverter component.
virtual void offsetUpdate_handler(FwIndexType portNum, const Svc::TimeOffset &offset)=0
Handler for input port offsetUpdate.
friend class TimeConverterTesterBase
Friend class tester to support autocoded test harness.
TimeConverterComponentBase(const char *compName="")
Construct TimeConverterComponentBase object.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void log_WARNING_HI_OffsetTableFull(const TimeBase &from, const TimeBase &to, U32 capacity)
static constexpr FwIndexType getNum_eventOut_OutputPorts()
Svc::InputTimeOffsetSendPort * get_offsetUpdate_InputPort(FwIndexType portNum)
void CLEAR_OFFSETS_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
Enum representing a command response.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
void log_WARNING_HI_OffsetTableFull_ThrottleClear()
Reset throttle value for OffsetTableFull.
An offset was stored for a pair of time bases by command.
Svc::ConvertTimeStatus convertTime_handlerBase(FwIndexType portNum, const Fw::Time &in_time, Fw::Time &out_time)
Handler base-class function for input port convertTime.
An offset was supplied for a single time base rather than a pair.
virtual void CLEAR_OFFSETS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
virtual void unLock()
Unlock the guarded mutex.
void init()
Object initializer.
Definition: ObjBase.cpp:24
friend class TimeConverterTester
Friend class tester implementation to support white-box testing.
virtual void DUMP_OFFSETS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
FwIdType FwEventIdType
The type of an event identifier.
void log_WARNING_LO_NoConversionAvailable(const TimeBase &in_tb, const TimeBase &out_tb)
Conversion result is not representable as an Fw::Time.
virtual void SET_OFFSET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const TimeBase &from, const TimeBase &to, I64 offset_us)=0
void log_WARNING_HI_UnusableTimeBase_ThrottleClear()
Reset throttle value for UnusableTimeBase.
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_convertTime_InputPorts()
void log_WARNING_HI_UnusableTimeBase(const TimeBase &tb)
An offset could not be stored because the offset table is full.
Report the offset stored for a pair of time bases as an event.
void log_WARNING_HI_OffsetOutOfRange(const TimeBase &from, const TimeBase &to, I64 offset_us)
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
void DUMP_OFFSETS_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Enum representing event severity.
void GET_OFFSET_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Result of a time base conversion.
No offset is stored for the requested pair of time bases.
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum) const
virtual void lock()
Lock the guarded mutex.
void regCommands()
Register commands with the Command Dispatcher.
void offsetUpdate_handlerBase(FwIndexType portNum, const Svc::TimeOffset &offset)
Handler base-class function for input port offsetUpdate.
void log_ACTIVITY_HI_OffsetsCleared(U32 entries) const
void log_ACTIVITY_HI_OffsetSet(const TimeBase &from, const TimeBase &to, I64 offset_us) const
void SET_OFFSET_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
virtual ~TimeConverterComponentBase()
Destroy TimeConverterComponentBase object.
static constexpr FwIndexType getNum_cmdIn_InputPorts()
void log_WARNING_LO_NoConversionAvailable_ThrottleClear()
Reset throttle value for NoConversionAvailable.
Svc::InputConvertTimePort * get_convertTime_InputPort(FwIndexType portNum)
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
An offset was rejected because no time can be shifted that far.
void log_WARNING_LO_IdenticalTimeBases(const TimeBase &tb)
void log_WARNING_HI_OffsetOutOfRange_ThrottleClear()
Reset throttle value for OffsetOutOfRange.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
virtual void GET_OFFSET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const TimeBase &from, const TimeBase &to)=0
Set the offset between a pair of time bases.
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
Define enumeration for Time base types.
void log_WARNING_LO_NoOffsetStored(const TimeBase &from, const TimeBase &to) const