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"
31 
32 namespace Svc {
33 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
49  friend class SeqDispatcherTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
60  };
61 
63  enum {
67  };
68 
70  enum {
77  };
78 
80  enum {
82  };
83 
85  enum {
86  OPCODE_RUN = 0x0,
88  };
89 
91  enum {
98  };
99 
101  enum {
105  };
106 
107  public:
108 
109  // ----------------------------------------------------------------------
110  // Component initialization
111  // ----------------------------------------------------------------------
112 
114  void init(
115  FwSizeType queueDepth,
116  FwEnumStoreType instance = 0
117  );
118 
119  public:
120 
121  // ----------------------------------------------------------------------
122  // Getters for special input ports
123  // ----------------------------------------------------------------------
124 
129  FwIndexType portNum
130  );
131 
132  public:
133 
134  // ----------------------------------------------------------------------
135  // Getters for typed input ports
136  // ----------------------------------------------------------------------
137 
142  FwIndexType portNum
143  );
144 
149  FwIndexType portNum
150  );
151 
156  FwIndexType portNum
157  );
158 
159  public:
160 
161  // ----------------------------------------------------------------------
162  // Connect input ports to special output ports
163  // ----------------------------------------------------------------------
164 
167  FwIndexType portNum,
168  Fw::InputCmdRegPort* port
169  );
170 
173  FwIndexType portNum,
175  );
176 
179  FwIndexType portNum,
180  Fw::InputLogPort* port
181  );
182 
183 #if FW_ENABLE_TEXT_LOGGING == 1
184 
186  void set_logTextOut_OutputPort(
187  FwIndexType portNum,
188  Fw::InputLogTextPort* port
189  );
190 
191 #endif
192 
195  FwIndexType portNum,
196  Fw::InputTimePort* port
197  );
198 
201  FwIndexType portNum,
202  Fw::InputTlmPort* port
203  );
204 
205  public:
206 
207  // ----------------------------------------------------------------------
208  // Connect typed input ports to typed output ports
209  // ----------------------------------------------------------------------
210 
213  FwIndexType portNum,
215  );
216 
217 #if FW_PORT_SERIALIZATION
218 
219  public:
220 
221  // ----------------------------------------------------------------------
222  // Connect serial input ports to special output ports
223  // ----------------------------------------------------------------------
224 
227  FwIndexType portNum,
228  Fw::InputSerializePort* port
229  );
230 
233  FwIndexType portNum,
234  Fw::InputSerializePort* port
235  );
236 
239  FwIndexType portNum,
240  Fw::InputSerializePort* port
241  );
242 
243 #if FW_ENABLE_TEXT_LOGGING == 1
244 
246  void set_logTextOut_OutputPort(
247  FwIndexType portNum,
248  Fw::InputSerializePort* port
249  );
250 
251 #endif
252 
255  FwIndexType portNum,
256  Fw::InputSerializePort* port
257  );
258 
261  FwIndexType portNum,
262  Fw::InputSerializePort* port
263  );
264 
265 #endif
266 
267 #if FW_PORT_SERIALIZATION
268 
269  public:
270 
271  // ----------------------------------------------------------------------
272  // Connect serial input ports to typed output ports
273  // ----------------------------------------------------------------------
274 
277  FwIndexType portNum,
278  Fw::InputSerializePort* port
279  );
280 
281 #endif
282 
283  public:
284 
285  // ----------------------------------------------------------------------
286  // Command registration
287  // ----------------------------------------------------------------------
288 
292  void regCommands();
293 
294  protected:
295 
296  // ----------------------------------------------------------------------
297  // Component construction and destruction
298  // ----------------------------------------------------------------------
299 
302  const char* compName = ""
303  );
304 
306  virtual ~SeqDispatcherComponentBase();
307 
308  protected:
309 
310  // ----------------------------------------------------------------------
311  // Getters for numbers of special input ports
312  // ----------------------------------------------------------------------
313 
318  return NUM_CMDIN_INPUT_PORTS;
319  }
320 
321  protected:
322 
323  // ----------------------------------------------------------------------
324  // Getters for numbers of typed input ports
325  // ----------------------------------------------------------------------
326 
332  }
333 
339  }
340 
346  }
347 
348  protected:
349 
350  // ----------------------------------------------------------------------
351  // Getters for numbers of special output ports
352  // ----------------------------------------------------------------------
353 
359  }
360 
366  }
367 
373  }
374 
375 #if FW_ENABLE_TEXT_LOGGING == 1
376 
380  static constexpr FwIndexType getNum_logTextOut_OutputPorts() {
382  }
383 
384 #endif
385 
391  }
392 
398  }
399 
400  protected:
401 
402  // ----------------------------------------------------------------------
403  // Getters for numbers of typed output ports
404  // ----------------------------------------------------------------------
405 
411  }
412 
413  protected:
414 
415  // ----------------------------------------------------------------------
416  // Connection status queries for special output ports
417  // ----------------------------------------------------------------------
418 
423  FwIndexType portNum
424  );
425 
430  FwIndexType portNum
431  );
432 
437  FwIndexType portNum
438  );
439 
440 #if FW_ENABLE_TEXT_LOGGING == 1
441 
445  bool isConnected_logTextOut_OutputPort(
446  FwIndexType portNum
447  );
448 
449 #endif
450 
455  FwIndexType portNum
456  );
457 
462  FwIndexType portNum
463  );
464 
465  protected:
466 
467  // ----------------------------------------------------------------------
468  // Connection status queries for typed output ports
469  // ----------------------------------------------------------------------
470 
475  FwIndexType portNum
476  );
477 
478  protected:
479 
480  // ----------------------------------------------------------------------
481  // Handlers to implement for typed input ports
482  // ----------------------------------------------------------------------
483 
485  virtual void seqDoneIn_handler(
486  FwIndexType portNum,
487  FwOpcodeType opCode,
488  U32 cmdSeq,
489  const Fw::CmdResponse& response
490  ) = 0;
491 
493  virtual void seqRunIn_handler(
494  FwIndexType portNum,
495  const Fw::StringBase& filename
496  ) = 0;
497 
499  virtual void seqStartIn_handler(
500  FwIndexType portNum,
501  const Fw::StringBase& filename
502  ) = 0;
503 
504  protected:
505 
506  // ----------------------------------------------------------------------
507  // Port handler base-class functions for typed input ports
508  //
509  // Call these functions directly to bypass the corresponding ports
510  // ----------------------------------------------------------------------
511 
514  FwIndexType portNum,
515  FwOpcodeType opCode,
516  U32 cmdSeq,
517  const Fw::CmdResponse& response
518  );
519 
522  FwIndexType portNum,
523  const Fw::StringBase& filename
524  );
525 
528  FwIndexType portNum,
529  const Fw::StringBase& filename
530  );
531 
532  protected:
533 
534  // ----------------------------------------------------------------------
535  // Pre-message hooks for typed async input ports
536  //
537  // Each of these functions is invoked just before processing a message
538  // on the corresponding port. By default, they do nothing. You can
539  // override them to provide specific pre-message behavior.
540  // ----------------------------------------------------------------------
541 
543  virtual void seqDoneIn_preMsgHook(
544  FwIndexType portNum,
545  FwOpcodeType opCode,
546  U32 cmdSeq,
547  const Fw::CmdResponse& response
548  );
549 
551  virtual void seqRunIn_preMsgHook(
552  FwIndexType portNum,
553  const Fw::StringBase& filename
554  );
555 
557  virtual void seqStartIn_preMsgHook(
558  FwIndexType portNum,
559  const Fw::StringBase& filename
560  );
561 
562  protected:
563 
564  // ----------------------------------------------------------------------
565  // Invocation functions for typed output ports
566  // ----------------------------------------------------------------------
567 
569  void seqRunOut_out(
570  FwIndexType portNum,
571  const Fw::StringBase& filename
572  );
573 
574  protected:
575 
576  // ----------------------------------------------------------------------
577  // Command response
578  // ----------------------------------------------------------------------
579 
581  void cmdResponse_out(
582  FwOpcodeType opCode,
583  U32 cmdSeq,
584  Fw::CmdResponse response
585  );
586 
587  protected:
588 
589  // ----------------------------------------------------------------------
590  // Command handlers to implement
591  // ----------------------------------------------------------------------
592 
596  virtual void RUN_cmdHandler(
597  FwOpcodeType opCode,
598  U32 cmdSeq,
599  const Fw::CmdStringArg& fileName,
600  Fw::Wait block
601  ) = 0;
602 
606  virtual void LOG_STATUS_cmdHandler(
607  FwOpcodeType opCode,
608  U32 cmdSeq
609  ) = 0;
610 
611  protected:
612 
613  // ----------------------------------------------------------------------
614  // Command handler base-class functions
615  //
616  // Call these functions directly to bypass the command input port
617  // ----------------------------------------------------------------------
618 
622  void RUN_cmdHandlerBase(
623  FwOpcodeType opCode,
624  U32 cmdSeq,
625  Fw::CmdArgBuffer& args
626  );
627 
632  FwOpcodeType opCode,
633  U32 cmdSeq,
634  Fw::CmdArgBuffer& args
635  );
636 
637  protected:
638 
639  // ----------------------------------------------------------------------
640  // Pre-message hooks for async commands
641  //
642  // Each of these functions is invoked just before processing the
643  // corresponding command. By default they do nothing. You can
644  // override them to provide specific pre-command behavior.
645  // ----------------------------------------------------------------------
646 
648  virtual void RUN_preMsgHook(
649  FwOpcodeType opCode,
650  U32 cmdSeq
651  );
652 
654  virtual void LOG_STATUS_preMsgHook(
655  FwOpcodeType opCode,
656  U32 cmdSeq
657  );
658 
659  protected:
660 
661  // ----------------------------------------------------------------------
662  // Event logging functions
663  // ----------------------------------------------------------------------
664 
666  void log_WARNING_HI_InvalidSequencer(U16 idx) const;
667 
670 
672  void log_WARNING_LO_UnknownSequenceFinished(U16 idx) const;
673 
676  U16 idx,
677  const Fw::StringBase& newSequence,
678  const Fw::StringBase& sequenceInInternalState
679  ) const;
680 
683  U16 idx,
684  const Fw::StringBase& newSequence
685  ) const;
686 
689  U16 idx,
691  const Fw::StringBase& filename
692  ) const;
693 
694  protected:
695 
696  // ----------------------------------------------------------------------
697  // Telemetry write functions
698  // ----------------------------------------------------------------------
699 
704  U32 arg,
705  Fw::Time _tlmTime = Fw::Time()
706  ) const;
707 
713  void tlmWrite_errorCount(
714  U32 arg,
715  Fw::Time _tlmTime = Fw::Time()
716  ) const;
717 
722  U32 arg,
723  Fw::Time _tlmTime = Fw::Time()
724  ) const;
725 
726  protected:
727 
728  // ----------------------------------------------------------------------
729  // Time
730  // ----------------------------------------------------------------------
731 
735  Fw::Time getTime() const;
736 
737  private:
738 
739  // ----------------------------------------------------------------------
740  // Message dispatch functions
741  // ----------------------------------------------------------------------
742 
744  virtual MsgDispatchStatus doDispatch();
745 
746  private:
747 
748  // ----------------------------------------------------------------------
749  // Calls for messages received on special input ports
750  // ----------------------------------------------------------------------
751 
753  static void m_p_cmdIn_in(
754  Fw::PassiveComponentBase* callComp,
755  FwIndexType portNum,
756  FwOpcodeType opCode,
757  U32 cmdSeq,
758  Fw::CmdArgBuffer& args
759  );
760 
761  private:
762 
763  // ----------------------------------------------------------------------
764  // Calls for messages received on typed input ports
765  // ----------------------------------------------------------------------
766 
768  static void m_p_seqDoneIn_in(
769  Fw::PassiveComponentBase* callComp,
770  FwIndexType portNum,
771  FwOpcodeType opCode,
772  U32 cmdSeq,
773  const Fw::CmdResponse& response
774  );
775 
777  static void m_p_seqRunIn_in(
778  Fw::PassiveComponentBase* callComp,
779  FwIndexType portNum,
780  const Fw::StringBase& filename
781  );
782 
784  static void m_p_seqStartIn_in(
785  Fw::PassiveComponentBase* callComp,
786  FwIndexType portNum,
787  const Fw::StringBase& filename
788  );
789 
790  private:
791 
792  // ----------------------------------------------------------------------
793  // Special input ports
794  // ----------------------------------------------------------------------
795 
797  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
798 
799  private:
800 
801  // ----------------------------------------------------------------------
802  // Typed input ports
803  // ----------------------------------------------------------------------
804 
807 
809  Svc::InputCmdSeqInPort m_seqRunIn_InputPort[NUM_SEQRUNIN_INPUT_PORTS];
810 
812  Svc::InputCmdSeqInPort m_seqStartIn_InputPort[NUM_SEQSTARTIN_INPUT_PORTS];
813 
814  private:
815 
816  // ----------------------------------------------------------------------
817  // Special output ports
818  // ----------------------------------------------------------------------
819 
821  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
822 
824  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
825 
827  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
828 
829 #if FW_ENABLE_TEXT_LOGGING == 1
830 
832  Fw::OutputLogTextPort m_logTextOut_OutputPort[NUM_LOGTEXTOUT_OUTPUT_PORTS];
833 
834 #endif
835 
837  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
838 
840  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
841 
842  private:
843 
844  // ----------------------------------------------------------------------
845  // Typed output ports
846  // ----------------------------------------------------------------------
847 
849  Svc::OutputCmdSeqInPort m_seqRunOut_OutputPort[NUM_SEQRUNOUT_OUTPUT_PORTS];
850 
851  };
852 
853 }
854 
855 #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
Logs via Events the state of each connected command sequencer.
void log_WARNING_LO_UnknownSequenceFinished(U16 idx) const
Log event UnknownSequenceFinished.
Dispatches a sequence to the first available sequencer.
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.
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.
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].