F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileDispatcherComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileDispatcherComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for FileDispatcher component base class
5 // ======================================================================
6 
7 #ifndef Svc_FileDispatcherComponentAc_HPP
8 #define Svc_FileDispatcherComponentAc_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"
29 #include "Svc/Ping/PingPortAc.hpp"
34 
35 namespace Svc {
36 
43  {
44 
45  // ----------------------------------------------------------------------
46  // Friend classes
47  // ----------------------------------------------------------------------
48 
52  friend class FileDispatcherTester;
53 
54  protected:
55 
56  // ----------------------------------------------------------------------
57  // Constants
58  // ----------------------------------------------------------------------
59 
61  enum {
63  };
64 
66  enum {
69  };
70 
72  enum {
78  };
79 
81  enum {
84  };
85 
87  enum {
89  };
90 
92  enum {
96  };
97 
99  enum {
101  };
102 
103  public:
104 
105  // ----------------------------------------------------------------------
106  // Component initialization
107  // ----------------------------------------------------------------------
108 
110  void init(
111  FwSizeType queueDepth,
112  FwEnumStoreType instance = 0
113  );
114 
115 #if !FW_DIRECT_PORT_CALLS
116 
117  public:
118 
119  // ----------------------------------------------------------------------
120  // Getters for special input ports
121  // ----------------------------------------------------------------------
122 
127  FwIndexType portNum
128  );
129 
130 #endif
131 
132 #if !FW_DIRECT_PORT_CALLS
133 
134  public:
135 
136  // ----------------------------------------------------------------------
137  // Getters for typed input ports
138  // ----------------------------------------------------------------------
139 
144  FwIndexType portNum
145  );
146 
151  FwIndexType portNum
152  );
153 
154 #endif
155 
156 #if !FW_DIRECT_PORT_CALLS
157 
158  public:
159 
160  // ----------------------------------------------------------------------
161  // Connect input ports to special output ports
162  // ----------------------------------------------------------------------
163 
166  FwIndexType portNum,
167  Fw::InputCmdRegPort* port
168  );
169 
172  FwIndexType portNum,
174  );
175 
178  FwIndexType portNum,
179  Fw::InputLogPort* port
180  );
181 
182 #if FW_ENABLE_TEXT_LOGGING == 1
183 
185  void set_logTextOut_OutputPort(
186  FwIndexType portNum,
187  Fw::InputLogTextPort* port
188  );
189 
190 #endif
191 
194  FwIndexType portNum,
195  Fw::InputTimePort* port
196  );
197 
198 #endif
199 
200 #if !FW_DIRECT_PORT_CALLS
201 
202  public:
203 
204  // ----------------------------------------------------------------------
205  // Connect typed input ports to typed output ports
206  // ----------------------------------------------------------------------
207 
210  FwIndexType portNum,
212  );
213 
216  FwIndexType portNum,
217  Svc::InputPingPort* port
218  );
219 
220 #endif
221 
222 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
223 
224  public:
225 
226  // ----------------------------------------------------------------------
227  // Connect serial input ports to special output ports
228  // ----------------------------------------------------------------------
229 
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  );
235 
238  FwIndexType portNum,
239  Fw::InputSerializePort* port
240  );
241 
244  FwIndexType portNum,
245  Fw::InputSerializePort* port
246  );
247 
248 #if FW_ENABLE_TEXT_LOGGING == 1
249 
251  void set_logTextOut_OutputPort(
252  FwIndexType portNum,
253  Fw::InputSerializePort* port
254  );
255 
256 #endif
257 
260  FwIndexType portNum,
261  Fw::InputSerializePort* port
262  );
263 
264 #endif
265 
266 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
267 
268  public:
269 
270  // ----------------------------------------------------------------------
271  // Connect serial input ports to typed output ports
272  // ----------------------------------------------------------------------
273 
276  FwIndexType portNum,
277  Fw::InputSerializePort* port
278  );
279 
282  FwIndexType portNum,
283  Fw::InputSerializePort* port
284  );
285 
286 #endif
287 
288  public:
289 
290  // ----------------------------------------------------------------------
291  // Command registration
292  // ----------------------------------------------------------------------
293 
297  void regCommands();
298 
299  protected:
300 
301  // ----------------------------------------------------------------------
302  // Component construction and destruction
303  // ----------------------------------------------------------------------
304 
307  const char* compName = ""
308  );
309 
312 
313  protected:
314 
315  // ----------------------------------------------------------------------
316  // Getters for numbers of special input ports
317  // ----------------------------------------------------------------------
318 
323  return NUM_CMDIN_INPUT_PORTS;
324  }
325 
326  protected:
327 
328  // ----------------------------------------------------------------------
329  // Getters for numbers of typed input ports
330  // ----------------------------------------------------------------------
331 
337  }
338 
343  return NUM_PINGIN_INPUT_PORTS;
344  }
345 
346  protected:
347 
348  // ----------------------------------------------------------------------
349  // Getters for numbers of special output ports
350  // ----------------------------------------------------------------------
351 
357  }
358 
364  }
365 
371  }
372 
373 #if FW_ENABLE_TEXT_LOGGING == 1
374 
378  static constexpr FwIndexType getNum_logTextOut_OutputPorts() {
380  }
381 
382 #endif
383 
389  }
390 
391  protected:
392 
393  // ----------------------------------------------------------------------
394  // Getters for numbers of typed output ports
395  // ----------------------------------------------------------------------
396 
402  }
403 
409  }
410 
411  protected:
412 
413  // ----------------------------------------------------------------------
414  // Connection status queries for special output ports
415  // ----------------------------------------------------------------------
416 
421  FwIndexType portNum
422  ) const;
423 
428  FwIndexType portNum
429  ) const;
430 
435  FwIndexType portNum
436  ) const;
437 
438 #if FW_ENABLE_TEXT_LOGGING == 1
439 
443  bool isConnected_logTextOut_OutputPort(
444  FwIndexType portNum
445  ) const;
446 
447 #endif
448 
453  FwIndexType portNum
454  ) const;
455 
456  protected:
457 
458  // ----------------------------------------------------------------------
459  // Connection status queries for typed output ports
460  // ----------------------------------------------------------------------
461 
466  FwIndexType portNum
467  ) const;
468 
473  FwIndexType portNum
474  ) const;
475 
476 #if FW_DIRECT_PORT_CALLS
477  public:
478 #else
479  protected:
480 #endif
481 
482  // ----------------------------------------------------------------------
483  // Port handler base-class functions for special input ports
484  //
485  // Call these functions directly to bypass the corresponding ports
486  // ----------------------------------------------------------------------
487 
489  void cmdIn_handlerBase(
490  FwIndexType portNum,
491  FwOpcodeType opCode,
492  U32 cmdSeq,
493  Fw::CmdArgBuffer& args
494  );
495 
496  protected:
497 
498  // ----------------------------------------------------------------------
499  // Handlers to implement for typed input ports
500  // ----------------------------------------------------------------------
501 
503  virtual void fileAnnounceRecv_handler(
504  FwIndexType portNum,
505  Fw::StringBase& file_name
506  ) = 0;
507 
509  virtual void pingIn_handler(
510  FwIndexType portNum,
511  U32 key
512  ) = 0;
513 
514 #if FW_DIRECT_PORT_CALLS
515  public:
516 #else
517  protected:
518 #endif
519 
520  // ----------------------------------------------------------------------
521  // Port handler base-class functions for typed input ports
522  //
523  // Call these functions directly to bypass the corresponding ports
524  // ----------------------------------------------------------------------
525 
528  FwIndexType portNum,
529  Fw::StringBase& file_name
530  );
531 
533  void pingIn_handlerBase(
534  FwIndexType portNum,
535  U32 key
536  );
537 
538  protected:
539 
540  // ----------------------------------------------------------------------
541  // Pre-message hooks for typed async input ports
542  //
543  // Each of these functions is invoked just before processing a message
544  // on the corresponding port. By default, they do nothing. You can
545  // override them to provide specific pre-message behavior.
546  // ----------------------------------------------------------------------
547 
549  virtual void fileAnnounceRecv_preMsgHook(
550  FwIndexType portNum,
551  Fw::StringBase& file_name
552  );
553 
555  virtual void pingIn_preMsgHook(
556  FwIndexType portNum,
557  U32 key
558  );
559 
560  protected:
561 
562  // ----------------------------------------------------------------------
563  // Invocation functions for typed output ports
564  // ----------------------------------------------------------------------
565 
567  void fileDispatch_out(
568  FwIndexType portNum,
569  Fw::StringBase& file_name
570  ) const;
571 
573  void pingOut_out(
574  FwIndexType portNum,
575  U32 key
576  ) const;
577 
578  protected:
579 
580  // ----------------------------------------------------------------------
581  // Command response
582  // ----------------------------------------------------------------------
583 
585  void cmdResponse_out(
586  FwOpcodeType opCode,
587  U32 cmdSeq,
588  Fw::CmdResponse response
589  );
590 
591  protected:
592 
593  // ----------------------------------------------------------------------
594  // Command handlers to implement
595  // ----------------------------------------------------------------------
596 
598  virtual void ENABLE_DISPATCH_cmdHandler(
599  FwOpcodeType opCode,
600  U32 cmdSeq,
602  const Fw::Enabled& enable
603  ) = 0;
604 
605  protected:
606 
607  // ----------------------------------------------------------------------
608  // Command handler base-class functions
609  //
610  // Call these functions directly to bypass the command input port
611  // ----------------------------------------------------------------------
612 
615  FwOpcodeType opCode,
616  U32 cmdSeq,
617  Fw::CmdArgBuffer& args
618  );
619 
620  protected:
621 
622  // ----------------------------------------------------------------------
623  // Pre-message hooks for async commands
624  //
625  // Each of these functions is invoked just before processing the
626  // corresponding command. By default they do nothing. You can
627  // override them to provide specific pre-command behavior.
628  // ----------------------------------------------------------------------
629 
631  virtual void ENABLE_DISPATCH_preMsgHook(
632  FwOpcodeType opCode,
633  U32 cmdSeq
634  );
635 
636  protected:
637 
638  // ----------------------------------------------------------------------
639  // Event logging functions
640  // ----------------------------------------------------------------------
641 
645  const Fw::Enabled& enabled
646  ) const;
647 
650  const Fw::StringBase& file_name,
652  ) const;
653 
656  const Fw::StringBase& file_name,
658  );
659 
660  protected:
661 
662  // ----------------------------------------------------------------------
663  // Event throttle reset functions
664  // ----------------------------------------------------------------------
665 
668 
669  protected:
670 
671  // ----------------------------------------------------------------------
672  // Time
673  // ----------------------------------------------------------------------
674 
678  Fw::Time getTime() const;
679 
680  private:
681 
682  // ----------------------------------------------------------------------
683  // Message dispatch functions
684  // ----------------------------------------------------------------------
685 
687  virtual MsgDispatchStatus doDispatch();
688 
689  private:
690 
691  // ----------------------------------------------------------------------
692  // Calls for messages received on special input ports
693  // ----------------------------------------------------------------------
694 
696  static void m_p_cmdIn_in(
697  Fw::PassiveComponentBase* callComp,
698  FwIndexType portNum,
699  FwOpcodeType opCode,
700  U32 cmdSeq,
701  Fw::CmdArgBuffer& args
702  );
703 
704  private:
705 
706  // ----------------------------------------------------------------------
707  // Calls for messages received on typed input ports
708  // ----------------------------------------------------------------------
709 
711  static void m_p_fileAnnounceRecv_in(
712  Fw::PassiveComponentBase* callComp,
713  FwIndexType portNum,
714  Fw::StringBase& file_name
715  );
716 
718  static void m_p_pingIn_in(
719  Fw::PassiveComponentBase* callComp,
720  FwIndexType portNum,
721  U32 key
722  );
723 
724  private:
725 
726  // ----------------------------------------------------------------------
727  // Invocation functions for special output ports
728  // ----------------------------------------------------------------------
729 
731  void cmdRegOut_out(
732  FwIndexType portNum,
733  FwOpcodeType opCode
734  ) const;
735 
737  void cmdResponseOut_out(
738  FwIndexType portNum,
739  FwOpcodeType opCode,
740  U32 cmdSeq,
741  const Fw::CmdResponse& response
742  ) const;
743 
745  void logOut_out(
746  FwIndexType portNum,
747  FwEventIdType id,
748  Fw::Time& timeTag,
749  const Fw::LogSeverity& severity,
750  Fw::LogBuffer& args
751  ) const;
752 
753 #if FW_ENABLE_TEXT_LOGGING
754 
756  void logTextOut_out(
757  FwIndexType portNum,
758  FwEventIdType id,
759  Fw::Time& timeTag,
760  const Fw::LogSeverity& severity,
761  Fw::TextLogString& text
762  ) const;
763 
764 #endif
765 
767  void timeCaller_out(
768  FwIndexType portNum,
769  Fw::Time& time
770  ) const;
771 
772 #if !FW_DIRECT_PORT_CALLS
773 
774  private:
775 
776  // ----------------------------------------------------------------------
777  // Special input ports
778  // ----------------------------------------------------------------------
779 
781  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
782 
783 #endif
784 
785 #if !FW_DIRECT_PORT_CALLS
786 
787  private:
788 
789  // ----------------------------------------------------------------------
790  // Typed input ports
791  // ----------------------------------------------------------------------
792 
794  Svc::InputFileAnnouncePort m_fileAnnounceRecv_InputPort[NUM_FILEANNOUNCERECV_INPUT_PORTS];
795 
797  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
798 
799 #endif
800 
801 #if !FW_DIRECT_PORT_CALLS
802 
803  private:
804 
805  // ----------------------------------------------------------------------
806  // Special output ports
807  // ----------------------------------------------------------------------
808 
810  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
811 
813  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
814 
816  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
817 
818 #if FW_ENABLE_TEXT_LOGGING == 1
819 
821  Fw::OutputLogTextPort m_logTextOut_OutputPort[NUM_LOGTEXTOUT_OUTPUT_PORTS];
822 
823 #endif
824 
826  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
827 
828 #endif
829 
830 #if !FW_DIRECT_PORT_CALLS
831 
832  private:
833 
834  // ----------------------------------------------------------------------
835  // Typed output ports
836  // ----------------------------------------------------------------------
837 
840 
842  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
843 
844 #endif
845 
846  private:
847 
848  // ----------------------------------------------------------------------
849  // Counter values for event throttling
850  // ----------------------------------------------------------------------
851 
853  std::atomic<FwIndexType> m_FileDispatchPortNotConnectedThrottle;
854 
855  };
856 
857 }
858 
859 #endif
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
FwIdType FwOpcodeType
The type of a command opcode.
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
bool isConnected_fileDispatch_OutputPort(FwIndexType portNum) const
PlatformSizeType FwSizeType
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
I32 FwEnumStoreType
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
friend class FileDispatcherTester
Friend class tester implementation to support white-box testing.
void fileAnnounceRecv_handlerBase(FwIndexType portNum, Fw::StringBase &file_name)
Handler base-class function for input port fileAnnounceRecv.
FileDispatcherComponentBase(const char *compName="")
Construct FileDispatcherComponentBase object.
Enum representing a command response.
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
virtual void fileAnnounceRecv_handler(FwIndexType portNum, Fw::StringBase &file_name)=0
Handler for input port fileAnnounceRecv.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
virtual void ENABLE_DISPATCH_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command ENABLE_DISPATCH.
void init()
Object initializer.
Definition: ObjBase.cpp:24
void regCommands()
Register commands with the Command Dispatcher.
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_fileDispatch_OutputPorts()
FwIdType FwEventIdType
The type of an event identifier.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
static constexpr FwIndexType getNum_logOut_OutputPorts()
void log_WARNING_LO_FileDispatchPortNotConnected(const Fw::StringBase &file_name, const Svc::FileDispatcherCfg::FileDispatchPort &file_type)
Log event FileDispatchPortNotConnected.
void log_ACTIVITY_HI_FileDispatchState(const Svc::FileDispatcherCfg::FileDispatchPort &file_type, const Fw::Enabled &enabled) const
Log event FileDispatchState.
static constexpr FwIndexType getNum_pingIn_InputPorts()
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_cmdIn_InputPorts()
friend class FileDispatcherTesterBase
Friend class tester to support autocoded test harness.
void ENABLE_DISPATCH_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Base-class handler function for command ENABLE_DISPATCH.
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
Enum representing event severity.
virtual void fileAnnounceRecv_preMsgHook(FwIndexType portNum, Fw::StringBase &file_name)
Pre-message hook for async input port fileAnnounceRecv.
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
Enabled and disabled states.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
void log_ACTIVITY_HI_FileDispatched(const Fw::StringBase &file_name, const Svc::FileDispatcherCfg::FileDispatchPort &file_type) const
Log event FileDispatched.
void set_fileDispatch_OutputPort(FwIndexType portNum, Svc::InputFileDispatchPort *port)
Connect port to fileDispatch[portNum].
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Svc::InputFileAnnouncePort * get_fileAnnounceRecv_InputPort(FwIndexType portNum)
void log_WARNING_LO_FileDispatchPortNotConnected_ThrottleClear()
Reset throttle value for FileDispatchPortNotConnected.
virtual ~FileDispatcherComponentBase()
Destroy FileDispatcherComponentBase object.
PlatformIndexType FwIndexType
Auto-generated base for FileDispatcher component.
RateGroupDivider component implementation.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
virtual void ENABLE_DISPATCH_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Svc::FileDispatcherCfg::FileDispatchPort &file_type, const Fw::Enabled &enable)=0
Handler for command ENABLE_DISPATCH.
static constexpr FwIndexType getNum_pingOut_OutputPorts()
void fileDispatch_out(FwIndexType portNum, Fw::StringBase &file_name) const
Invoke output port fileDispatch.
static constexpr FwIndexType getNum_fileAnnounceRecv_InputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)