F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SeqDispatcherComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SeqDispatcherComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for SeqDispatcher component base class
5 // ======================================================================
6 
7 #ifndef Svc_SeqDispatcherComponentAc_HPP
8 #define Svc_SeqDispatcherComponentAc_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 #if FW_ENABLE_TEXT_LOGGING == 1
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #endif
25 #include "Fw/Time/TimePortAc.hpp"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Fw/Tlm/TlmString.hpp"
28 #include "Fw/Types/WaitEnumAc.hpp"
32 
33 namespace Svc {
34 
41  {
42 
43  // ----------------------------------------------------------------------
44  // Friend classes
45  // ----------------------------------------------------------------------
46 
50  friend class SeqDispatcherTester;
51 
52  protected:
53 
54  // ----------------------------------------------------------------------
55  // Constants
56  // ----------------------------------------------------------------------
57 
59  enum {
61  };
62 
64  enum {
68  };
69 
71  enum {
78  };
79 
81  enum {
83  };
84 
86  enum {
87  OPCODE_RUN = 0x0,
89  };
90 
92  enum {
99  };
100 
102  enum {
106  };
107 
108  public:
109 
110  // ----------------------------------------------------------------------
111  // Component initialization
112  // ----------------------------------------------------------------------
113 
115  void init(
116  FwSizeType queueDepth,
117  FwEnumStoreType instance = 0
118  );
119 
120  public:
121 
122  // ----------------------------------------------------------------------
123  // Getters for special input ports
124  // ----------------------------------------------------------------------
125 
130  FwIndexType portNum
131  );
132 
133  public:
134 
135  // ----------------------------------------------------------------------
136  // Getters for typed input ports
137  // ----------------------------------------------------------------------
138 
143  FwIndexType portNum
144  );
145 
150  FwIndexType portNum
151  );
152 
157  FwIndexType portNum
158  );
159 
160  public:
161 
162  // ----------------------------------------------------------------------
163  // Connect input ports to special output ports
164  // ----------------------------------------------------------------------
165 
168  FwIndexType portNum,
169  Fw::InputCmdRegPort* port
170  );
171 
174  FwIndexType portNum,
176  );
177 
180  FwIndexType portNum,
181  Fw::InputLogPort* port
182  );
183 
184 #if FW_ENABLE_TEXT_LOGGING == 1
185 
187  void set_logTextOut_OutputPort(
188  FwIndexType portNum,
189  Fw::InputLogTextPort* port
190  );
191 
192 #endif
193 
196  FwIndexType portNum,
197  Fw::InputTimePort* port
198  );
199 
202  FwIndexType portNum,
203  Fw::InputTlmPort* port
204  );
205 
206  public:
207 
208  // ----------------------------------------------------------------------
209  // Connect typed input ports to typed output ports
210  // ----------------------------------------------------------------------
211 
214  FwIndexType portNum,
216  );
217 
218 #if FW_PORT_SERIALIZATION
219 
220  public:
221 
222  // ----------------------------------------------------------------------
223  // Connect serial input ports to special output ports
224  // ----------------------------------------------------------------------
225 
228  FwIndexType portNum,
229  Fw::InputSerializePort* port
230  );
231 
234  FwIndexType portNum,
235  Fw::InputSerializePort* port
236  );
237 
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  );
243 
244 #if FW_ENABLE_TEXT_LOGGING == 1
245 
247  void set_logTextOut_OutputPort(
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  );
251 
252 #endif
253 
256  FwIndexType portNum,
257  Fw::InputSerializePort* port
258  );
259 
262  FwIndexType portNum,
263  Fw::InputSerializePort* port
264  );
265 
266 #endif
267 
268 #if FW_PORT_SERIALIZATION
269 
270  public:
271 
272  // ----------------------------------------------------------------------
273  // Connect serial input ports to typed output ports
274  // ----------------------------------------------------------------------
275 
278  FwIndexType portNum,
279  Fw::InputSerializePort* port
280  );
281 
282 #endif
283 
284  public:
285 
286  // ----------------------------------------------------------------------
287  // Command registration
288  // ----------------------------------------------------------------------
289 
293  void regCommands();
294 
295  protected:
296 
297  // ----------------------------------------------------------------------
298  // Component construction and destruction
299  // ----------------------------------------------------------------------
300 
303  const char* compName = ""
304  );
305 
307  virtual ~SeqDispatcherComponentBase();
308 
309  protected:
310 
311  // ----------------------------------------------------------------------
312  // Getters for numbers of special input ports
313  // ----------------------------------------------------------------------
314 
319  return NUM_CMDIN_INPUT_PORTS;
320  }
321 
322  protected:
323 
324  // ----------------------------------------------------------------------
325  // Getters for numbers of typed input ports
326  // ----------------------------------------------------------------------
327 
333  }
334 
340  }
341 
347  }
348 
349  protected:
350 
351  // ----------------------------------------------------------------------
352  // Getters for numbers of special output ports
353  // ----------------------------------------------------------------------
354 
360  }
361 
367  }
368 
374  }
375 
376 #if FW_ENABLE_TEXT_LOGGING == 1
377 
381  static constexpr FwIndexType getNum_logTextOut_OutputPorts() {
383  }
384 
385 #endif
386 
392  }
393 
399  }
400 
401  protected:
402 
403  // ----------------------------------------------------------------------
404  // Getters for numbers of typed output ports
405  // ----------------------------------------------------------------------
406 
412  }
413 
414  protected:
415 
416  // ----------------------------------------------------------------------
417  // Connection status queries for special output ports
418  // ----------------------------------------------------------------------
419 
424  FwIndexType portNum
425  );
426 
431  FwIndexType portNum
432  );
433 
438  FwIndexType portNum
439  );
440 
441 #if FW_ENABLE_TEXT_LOGGING == 1
442 
446  bool isConnected_logTextOut_OutputPort(
447  FwIndexType portNum
448  );
449 
450 #endif
451 
456  FwIndexType portNum
457  );
458 
463  FwIndexType portNum
464  );
465 
466  protected:
467 
468  // ----------------------------------------------------------------------
469  // Connection status queries for typed output ports
470  // ----------------------------------------------------------------------
471 
476  FwIndexType portNum
477  );
478 
479  protected:
480 
481  // ----------------------------------------------------------------------
482  // Handlers to implement for typed input ports
483  // ----------------------------------------------------------------------
484 
486  virtual void seqDoneIn_handler(
487  FwIndexType portNum,
488  FwOpcodeType opCode,
489  U32 cmdSeq,
490  const Fw::CmdResponse& response
491  ) = 0;
492 
494  virtual void seqRunIn_handler(
495  FwIndexType portNum,
496  const Fw::StringBase& filename
497  ) = 0;
498 
500  virtual void seqStartIn_handler(
501  FwIndexType portNum,
502  const Fw::StringBase& filename
503  ) = 0;
504 
505  protected:
506 
507  // ----------------------------------------------------------------------
508  // Port handler base-class functions for typed input ports
509  //
510  // Call these functions directly to bypass the corresponding ports
511  // ----------------------------------------------------------------------
512 
515  FwIndexType portNum,
516  FwOpcodeType opCode,
517  U32 cmdSeq,
518  const Fw::CmdResponse& response
519  );
520 
523  FwIndexType portNum,
524  const Fw::StringBase& filename
525  );
526 
529  FwIndexType portNum,
530  const Fw::StringBase& filename
531  );
532 
533  protected:
534 
535  // ----------------------------------------------------------------------
536  // Pre-message hooks for typed async input ports
537  //
538  // Each of these functions is invoked just before processing a message
539  // on the corresponding port. By default, they do nothing. You can
540  // override them to provide specific pre-message behavior.
541  // ----------------------------------------------------------------------
542 
544  virtual void seqDoneIn_preMsgHook(
545  FwIndexType portNum,
546  FwOpcodeType opCode,
547  U32 cmdSeq,
548  const Fw::CmdResponse& response
549  );
550 
552  virtual void seqRunIn_preMsgHook(
553  FwIndexType portNum,
554  const Fw::StringBase& filename
555  );
556 
558  virtual void seqStartIn_preMsgHook(
559  FwIndexType portNum,
560  const Fw::StringBase& filename
561  );
562 
563  protected:
564 
565  // ----------------------------------------------------------------------
566  // Invocation functions for typed output ports
567  // ----------------------------------------------------------------------
568 
570  void seqRunOut_out(
571  FwIndexType portNum,
572  const Fw::StringBase& filename
573  );
574 
575  protected:
576 
577  // ----------------------------------------------------------------------
578  // Command response
579  // ----------------------------------------------------------------------
580 
582  void cmdResponse_out(
583  FwOpcodeType opCode,
584  U32 cmdSeq,
585  Fw::CmdResponse response
586  );
587 
588  protected:
589 
590  // ----------------------------------------------------------------------
591  // Command handlers to implement
592  // ----------------------------------------------------------------------
593 
597  virtual void RUN_cmdHandler(
598  FwOpcodeType opCode,
599  U32 cmdSeq,
600  const Fw::CmdStringArg& fileName,
601  Fw::Wait block
602  ) = 0;
603 
607  virtual void LOG_STATUS_cmdHandler(
608  FwOpcodeType opCode,
609  U32 cmdSeq
610  ) = 0;
611 
612  protected:
613 
614  // ----------------------------------------------------------------------
615  // Command handler base-class functions
616  //
617  // Call these functions directly to bypass the command input port
618  // ----------------------------------------------------------------------
619 
623  void RUN_cmdHandlerBase(
624  FwOpcodeType opCode,
625  U32 cmdSeq,
626  Fw::CmdArgBuffer& args
627  );
628 
633  FwOpcodeType opCode,
634  U32 cmdSeq,
635  Fw::CmdArgBuffer& args
636  );
637 
638  protected:
639 
640  // ----------------------------------------------------------------------
641  // Pre-message hooks for async commands
642  //
643  // Each of these functions is invoked just before processing the
644  // corresponding command. By default they do nothing. You can
645  // override them to provide specific pre-command behavior.
646  // ----------------------------------------------------------------------
647 
649  virtual void RUN_preMsgHook(
650  FwOpcodeType opCode,
651  U32 cmdSeq
652  );
653 
655  virtual void LOG_STATUS_preMsgHook(
656  FwOpcodeType opCode,
657  U32 cmdSeq
658  );
659 
660  protected:
661 
662  // ----------------------------------------------------------------------
663  // Event logging functions
664  // ----------------------------------------------------------------------
665 
667  void log_WARNING_HI_InvalidSequencer(U16 idx) const;
668 
671 
673  void log_WARNING_LO_UnknownSequenceFinished(U16 idx) const;
674 
677  U16 idx,
678  const Fw::StringBase& newSequence,
679  const Fw::StringBase& sequenceInInternalState
680  ) const;
681 
684  U16 idx,
685  const Fw::StringBase& newSequence
686  ) const;
687 
690  U16 idx,
692  const Fw::StringBase& filename
693  ) const;
694 
695  protected:
696 
697  // ----------------------------------------------------------------------
698  // Telemetry write functions
699  // ----------------------------------------------------------------------
700 
705  U32 arg,
706  Fw::Time _tlmTime = Fw::Time()
707  ) const;
708 
714  void tlmWrite_errorCount(
715  U32 arg,
716  Fw::Time _tlmTime = Fw::Time()
717  ) const;
718 
723  U32 arg,
724  Fw::Time _tlmTime = Fw::Time()
725  ) const;
726 
727  protected:
728 
729  // ----------------------------------------------------------------------
730  // Time
731  // ----------------------------------------------------------------------
732 
736  Fw::Time getTime() const;
737 
738  private:
739 
740  // ----------------------------------------------------------------------
741  // Message dispatch functions
742  // ----------------------------------------------------------------------
743 
745  virtual MsgDispatchStatus doDispatch();
746 
747  private:
748 
749  // ----------------------------------------------------------------------
750  // Calls for messages received on special input ports
751  // ----------------------------------------------------------------------
752 
754  static void m_p_cmdIn_in(
755  Fw::PassiveComponentBase* callComp,
756  FwIndexType portNum,
757  FwOpcodeType opCode,
758  U32 cmdSeq,
759  Fw::CmdArgBuffer& args
760  );
761 
762  private:
763 
764  // ----------------------------------------------------------------------
765  // Calls for messages received on typed input ports
766  // ----------------------------------------------------------------------
767 
769  static void m_p_seqDoneIn_in(
770  Fw::PassiveComponentBase* callComp,
771  FwIndexType portNum,
772  FwOpcodeType opCode,
773  U32 cmdSeq,
774  const Fw::CmdResponse& response
775  );
776 
778  static void m_p_seqRunIn_in(
779  Fw::PassiveComponentBase* callComp,
780  FwIndexType portNum,
781  const Fw::StringBase& filename
782  );
783 
785  static void m_p_seqStartIn_in(
786  Fw::PassiveComponentBase* callComp,
787  FwIndexType portNum,
788  const Fw::StringBase& filename
789  );
790 
791  private:
792 
793  // ----------------------------------------------------------------------
794  // Special input ports
795  // ----------------------------------------------------------------------
796 
798  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
799 
800  private:
801 
802  // ----------------------------------------------------------------------
803  // Typed input ports
804  // ----------------------------------------------------------------------
805 
808 
810  Svc::InputCmdSeqInPort m_seqRunIn_InputPort[NUM_SEQRUNIN_INPUT_PORTS];
811 
813  Svc::InputCmdSeqInPort m_seqStartIn_InputPort[NUM_SEQSTARTIN_INPUT_PORTS];
814 
815  private:
816 
817  // ----------------------------------------------------------------------
818  // Special output ports
819  // ----------------------------------------------------------------------
820 
822  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
823 
825  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
826 
828  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
829 
830 #if FW_ENABLE_TEXT_LOGGING == 1
831 
833  Fw::OutputLogTextPort m_logTextOut_OutputPort[NUM_LOGTEXTOUT_OUTPUT_PORTS];
834 
835 #endif
836 
838  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
839 
841  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
842 
843  private:
844 
845  // ----------------------------------------------------------------------
846  // Typed output ports
847  // ----------------------------------------------------------------------
848 
850  Svc::OutputCmdSeqInPort m_seqRunOut_OutputPort[NUM_SEQRUNOUT_OUTPUT_PORTS];
851 
852  };
853 
854 }
855 
856 #endif
Fw::InputCmdResponsePort * get_seqDoneIn_InputPort(FwIndexType portNum)
virtual void seqDoneIn_preMsgHook(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Pre-message hook for async input port seqDoneIn.
void tlmWrite_sequencersAvailable(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
virtual void LOG_STATUS_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command LOG_STATUS.
void tlmWrite_errorCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void seqRunIn_handlerBase(FwIndexType portNum, const Fw::StringBase &filename)
Handler base-class function for input port seqRunIn.
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
Svc::InputCmdSeqInPort * get_seqRunIn_InputPort(FwIndexType portNum)
I32 FwEnumStoreType
Wait or don&#39;t wait for something.
Definition: WaitEnumAc.hpp:17
virtual void RUN_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command RUN.
friend class SeqDispatcherTester
Friend class tester implementation to support white-box testing.
static constexpr FwIndexType getNum_seqDoneIn_InputPorts()
Svc::InputCmdSeqInPort * get_seqStartIn_InputPort(FwIndexType portNum)
friend class SeqDispatcherTesterBase
Friend class tester to support autocoded test harness.
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
Enum representing a command response.
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
void regCommands()
Register commands with the Command Dispatcher.
virtual void seqRunIn_preMsgHook(FwIndexType portNum, const Fw::StringBase &filename)
Pre-message hook for async input port seqRunIn.
void seqDoneIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Handler base-class function for input port seqDoneIn.
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
static constexpr FwIndexType getNum_logOut_OutputPorts()
void RUN_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void init()
Object initializer.
Definition: ObjBase.cpp:24
virtual void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase &filename)=0
Handler for input port seqRunIn.
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
virtual void seqStartIn_handler(FwIndexType portNum, const Fw::StringBase &filename)=0
Handler for input port seqStartIn.
virtual void LOG_STATUS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
void log_WARNING_LO_UnknownSequenceFinished(U16 idx) const
Log event UnknownSequenceFinished.
virtual ~SeqDispatcherComponentBase()
Destroy SeqDispatcherComponentBase object.
static constexpr FwIndexType getNum_seqRunOut_OutputPorts()
void log_ACTIVITY_LO_LogSequencerStatus(U16 idx, Svc::SeqDispatcher_CmdSequencerState state, const Fw::StringBase &filename) const
Log event LogSequencerStatus.
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
void set_seqRunOut_OutputPort(FwIndexType portNum, Svc::InputCmdSeqInPort *port)
Connect port to seqRunOut[portNum].
SeqDispatcherComponentBase(const char *compName="")
Construct SeqDispatcherComponentBase object.
virtual void RUN_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &fileName, Fw::Wait block)=0
static constexpr FwIndexType getNum_cmdIn_InputPorts()
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
void log_WARNING_LO_UnexpectedSequenceStarted(U16 idx, const Fw::StringBase &newSequence) const
Log event UnexpectedSequenceStarted.
bool isConnected_logOut_OutputPort(FwIndexType portNum)
void log_WARNING_HI_NoAvailableSequencers() const
Log event NoAvailableSequencers.
void seqStartIn_handlerBase(FwIndexType portNum, const Fw::StringBase &filename)
Handler base-class function for input port seqStartIn.
void seqRunOut_out(FwIndexType portNum, const Fw::StringBase &filename)
Invoke output port seqRunOut.
bool isConnected_seqRunOut_OutputPort(FwIndexType portNum)
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
PlatformIndexType FwIndexType
Auto-generated base for SeqDispatcher component.
bool isConnected_tlmOut_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
virtual void seqDoneIn_handler(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)=0
Handler for input port seqDoneIn.
void LOG_STATUS_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
RateGroupDivider component implementation.
void log_WARNING_HI_InvalidSequencer(U16 idx) const
Log event InvalidSequencer.
Dispatches a sequence to the first available sequencer.
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
static constexpr FwIndexType getNum_seqRunIn_InputPorts()
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual void seqStartIn_preMsgHook(FwIndexType portNum, const Fw::StringBase &filename)
Pre-message hook for async input port seqStartIn.
void log_WARNING_HI_ConflictingSequenceStarted(U16 idx, const Fw::StringBase &newSequence, const Fw::StringBase &sequenceInInternalState) const
Log event ConflictingSequenceStarted.
Logs via Events the state of each connected command sequencer.
static constexpr FwIndexType getNum_seqStartIn_InputPorts()
void tlmWrite_dispatchedCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].