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 #if FW_ENABLE_TEXT_LOGGING == 1
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #endif
25 #include "Fw/Time/TimePortAc.hpp"
27 #include "Svc/Ping/PingPortAc.hpp"
31 
32 namespace Svc {
33 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
49  friend class FileDispatcherTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
60  };
61 
63  enum {
66  };
67 
69  enum {
75  };
76 
78  enum {
81  };
82 
84  enum {
86  };
87 
89  enum {
92  };
93 
94  public:
95 
96  // ----------------------------------------------------------------------
97  // Component initialization
98  // ----------------------------------------------------------------------
99 
101  void init(
102  FwSizeType queueDepth,
103  FwEnumStoreType instance = 0
104  );
105 
106  public:
107 
108  // ----------------------------------------------------------------------
109  // Getters for special input ports
110  // ----------------------------------------------------------------------
111 
116  FwIndexType portNum
117  );
118 
119  public:
120 
121  // ----------------------------------------------------------------------
122  // Getters for typed input ports
123  // ----------------------------------------------------------------------
124 
129  FwIndexType portNum
130  );
131 
136  FwIndexType portNum
137  );
138 
139  public:
140 
141  // ----------------------------------------------------------------------
142  // Connect input ports to special output ports
143  // ----------------------------------------------------------------------
144 
147  FwIndexType portNum,
148  Fw::InputCmdRegPort* port
149  );
150 
153  FwIndexType portNum,
155  );
156 
159  FwIndexType portNum,
160  Fw::InputLogPort* port
161  );
162 
163 #if FW_ENABLE_TEXT_LOGGING == 1
164 
166  void set_logTextOut_OutputPort(
167  FwIndexType portNum,
168  Fw::InputLogTextPort* port
169  );
170 
171 #endif
172 
175  FwIndexType portNum,
176  Fw::InputTimePort* port
177  );
178 
179  public:
180 
181  // ----------------------------------------------------------------------
182  // Connect typed input ports to typed output ports
183  // ----------------------------------------------------------------------
184 
187  FwIndexType portNum,
189  );
190 
193  FwIndexType portNum,
194  Svc::InputPingPort* port
195  );
196 
197 #if FW_PORT_SERIALIZATION
198 
199  public:
200 
201  // ----------------------------------------------------------------------
202  // Connect serial input ports to special output ports
203  // ----------------------------------------------------------------------
204 
207  FwIndexType portNum,
208  Fw::InputSerializePort* port
209  );
210 
213  FwIndexType portNum,
214  Fw::InputSerializePort* port
215  );
216 
219  FwIndexType portNum,
220  Fw::InputSerializePort* port
221  );
222 
223 #if FW_ENABLE_TEXT_LOGGING == 1
224 
226  void set_logTextOut_OutputPort(
227  FwIndexType portNum,
228  Fw::InputSerializePort* port
229  );
230 
231 #endif
232 
235  FwIndexType portNum,
236  Fw::InputSerializePort* port
237  );
238 
239 #endif
240 
241 #if FW_PORT_SERIALIZATION
242 
243  public:
244 
245  // ----------------------------------------------------------------------
246  // Connect serial input ports to typed output ports
247  // ----------------------------------------------------------------------
248 
251  FwIndexType portNum,
252  Fw::InputSerializePort* port
253  );
254 
257  FwIndexType portNum,
258  Fw::InputSerializePort* port
259  );
260 
261 #endif
262 
263  public:
264 
265  // ----------------------------------------------------------------------
266  // Command registration
267  // ----------------------------------------------------------------------
268 
272  void regCommands();
273 
274  protected:
275 
276  // ----------------------------------------------------------------------
277  // Component construction and destruction
278  // ----------------------------------------------------------------------
279 
282  const char* compName = ""
283  );
284 
287 
288  protected:
289 
290  // ----------------------------------------------------------------------
291  // Getters for numbers of special input ports
292  // ----------------------------------------------------------------------
293 
298  return NUM_CMDIN_INPUT_PORTS;
299  }
300 
301  protected:
302 
303  // ----------------------------------------------------------------------
304  // Getters for numbers of typed input ports
305  // ----------------------------------------------------------------------
306 
312  }
313 
318  return NUM_PINGIN_INPUT_PORTS;
319  }
320 
321  protected:
322 
323  // ----------------------------------------------------------------------
324  // Getters for numbers of special output ports
325  // ----------------------------------------------------------------------
326 
332  }
333 
339  }
340 
346  }
347 
348 #if FW_ENABLE_TEXT_LOGGING == 1
349 
353  static constexpr FwIndexType getNum_logTextOut_OutputPorts() {
355  }
356 
357 #endif
358 
364  }
365 
366  protected:
367 
368  // ----------------------------------------------------------------------
369  // Getters for numbers of typed output ports
370  // ----------------------------------------------------------------------
371 
377  }
378 
384  }
385 
386  protected:
387 
388  // ----------------------------------------------------------------------
389  // Connection status queries for special output ports
390  // ----------------------------------------------------------------------
391 
396  FwIndexType portNum
397  );
398 
403  FwIndexType portNum
404  );
405 
410  FwIndexType portNum
411  );
412 
413 #if FW_ENABLE_TEXT_LOGGING == 1
414 
418  bool isConnected_logTextOut_OutputPort(
419  FwIndexType portNum
420  );
421 
422 #endif
423 
428  FwIndexType portNum
429  );
430 
431  protected:
432 
433  // ----------------------------------------------------------------------
434  // Connection status queries for typed output ports
435  // ----------------------------------------------------------------------
436 
441  FwIndexType portNum
442  );
443 
448  FwIndexType portNum
449  );
450 
451  protected:
452 
453  // ----------------------------------------------------------------------
454  // Handlers to implement for typed input ports
455  // ----------------------------------------------------------------------
456 
458  virtual void fileAnnounceRecv_handler(
459  FwIndexType portNum,
460  Fw::StringBase& file_name
461  ) = 0;
462 
464  virtual void pingIn_handler(
465  FwIndexType portNum,
466  U32 key
467  ) = 0;
468 
469  protected:
470 
471  // ----------------------------------------------------------------------
472  // Port handler base-class functions for typed input ports
473  //
474  // Call these functions directly to bypass the corresponding ports
475  // ----------------------------------------------------------------------
476 
479  FwIndexType portNum,
480  Fw::StringBase& file_name
481  );
482 
484  void pingIn_handlerBase(
485  FwIndexType portNum,
486  U32 key
487  );
488 
489  protected:
490 
491  // ----------------------------------------------------------------------
492  // Pre-message hooks for typed async input ports
493  //
494  // Each of these functions is invoked just before processing a message
495  // on the corresponding port. By default, they do nothing. You can
496  // override them to provide specific pre-message behavior.
497  // ----------------------------------------------------------------------
498 
500  virtual void fileAnnounceRecv_preMsgHook(
501  FwIndexType portNum,
502  Fw::StringBase& file_name
503  );
504 
506  virtual void pingIn_preMsgHook(
507  FwIndexType portNum,
508  U32 key
509  );
510 
511  protected:
512 
513  // ----------------------------------------------------------------------
514  // Invocation functions for typed output ports
515  // ----------------------------------------------------------------------
516 
518  void fileDispatch_out(
519  FwIndexType portNum,
520  Fw::StringBase& file_name
521  );
522 
524  void pingOut_out(
525  FwIndexType portNum,
526  U32 key
527  );
528 
529  protected:
530 
531  // ----------------------------------------------------------------------
532  // Command response
533  // ----------------------------------------------------------------------
534 
536  void cmdResponse_out(
537  FwOpcodeType opCode,
538  U32 cmdSeq,
539  Fw::CmdResponse response
540  );
541 
542  protected:
543 
544  // ----------------------------------------------------------------------
545  // Command handlers to implement
546  // ----------------------------------------------------------------------
547 
549  virtual void ENABLE_DISPATCH_cmdHandler(
550  FwOpcodeType opCode,
551  U32 cmdSeq,
553  Fw::Enabled enable
554  ) = 0;
555 
556  protected:
557 
558  // ----------------------------------------------------------------------
559  // Command handler base-class functions
560  //
561  // Call these functions directly to bypass the command input port
562  // ----------------------------------------------------------------------
563 
566  FwOpcodeType opCode,
567  U32 cmdSeq,
568  Fw::CmdArgBuffer& args
569  );
570 
571  protected:
572 
573  // ----------------------------------------------------------------------
574  // Pre-message hooks for async commands
575  //
576  // Each of these functions is invoked just before processing the
577  // corresponding command. By default they do nothing. You can
578  // override them to provide specific pre-command behavior.
579  // ----------------------------------------------------------------------
580 
582  virtual void ENABLE_DISPATCH_preMsgHook(
583  FwOpcodeType opCode,
584  U32 cmdSeq
585  );
586 
587  protected:
588 
589  // ----------------------------------------------------------------------
590  // Event logging functions
591  // ----------------------------------------------------------------------
592 
596  Fw::Enabled enabled
597  ) const;
598 
601  const Fw::StringBase& file_name,
603  ) const;
604 
605  protected:
606 
607  // ----------------------------------------------------------------------
608  // Time
609  // ----------------------------------------------------------------------
610 
614  Fw::Time getTime() const;
615 
616  private:
617 
618  // ----------------------------------------------------------------------
619  // Message dispatch functions
620  // ----------------------------------------------------------------------
621 
623  virtual MsgDispatchStatus doDispatch();
624 
625  private:
626 
627  // ----------------------------------------------------------------------
628  // Calls for messages received on special input ports
629  // ----------------------------------------------------------------------
630 
632  static void m_p_cmdIn_in(
633  Fw::PassiveComponentBase* callComp,
634  FwIndexType portNum,
635  FwOpcodeType opCode,
636  U32 cmdSeq,
637  Fw::CmdArgBuffer& args
638  );
639 
640  private:
641 
642  // ----------------------------------------------------------------------
643  // Calls for messages received on typed input ports
644  // ----------------------------------------------------------------------
645 
647  static void m_p_fileAnnounceRecv_in(
648  Fw::PassiveComponentBase* callComp,
649  FwIndexType portNum,
650  Fw::StringBase& file_name
651  );
652 
654  static void m_p_pingIn_in(
655  Fw::PassiveComponentBase* callComp,
656  FwIndexType portNum,
657  U32 key
658  );
659 
660  private:
661 
662  // ----------------------------------------------------------------------
663  // Special input ports
664  // ----------------------------------------------------------------------
665 
667  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
668 
669  private:
670 
671  // ----------------------------------------------------------------------
672  // Typed input ports
673  // ----------------------------------------------------------------------
674 
676  Svc::InputFileAnnouncePort m_fileAnnounceRecv_InputPort[NUM_FILEANNOUNCERECV_INPUT_PORTS];
677 
679  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
680 
681  private:
682 
683  // ----------------------------------------------------------------------
684  // Special output ports
685  // ----------------------------------------------------------------------
686 
688  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
689 
691  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
692 
694  Fw::OutputLogPort m_logOut_OutputPort[NUM_LOGOUT_OUTPUT_PORTS];
695 
696 #if FW_ENABLE_TEXT_LOGGING == 1
697 
699  Fw::OutputLogTextPort m_logTextOut_OutputPort[NUM_LOGTEXTOUT_OUTPUT_PORTS];
700 
701 #endif
702 
704  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
705 
706  private:
707 
708  // ----------------------------------------------------------------------
709  // Typed output ports
710  // ----------------------------------------------------------------------
711 
714 
716  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
717 
718  };
719 
720 }
721 
722 #endif
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
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()
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)
virtual void fileAnnounceRecv_handler(FwIndexType portNum, Fw::StringBase &file_name)=0
Handler for input port fileAnnounceRecv.
void log_ACTIVITY_HI_FileDispatchState(Svc::FileDispatcherCfg::FileDispatchPort file_type, Fw::Enabled enabled) const
Log event FileDispatchState.
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
bool isConnected_fileDispatch_OutputPort(FwIndexType 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.
static constexpr FwIndexType getNum_fileDispatch_OutputPorts()
void fileDispatch_out(FwIndexType portNum, Fw::StringBase &file_name)
Invoke output port fileDispatch.
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
bool isConnected_logOut_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_logOut_OutputPorts()
static constexpr FwIndexType getNum_pingIn_InputPorts()
virtual void ENABLE_DISPATCH_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::FileDispatcherCfg::FileDispatchPort file_type, Fw::Enabled enable)=0
Handler for command ENABLE_DISPATCH.
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.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
virtual void fileAnnounceRecv_preMsgHook(FwIndexType portNum, Fw::StringBase &file_name)
Pre-message hook for async input port fileAnnounceRecv.
Enabled and disabled states.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
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)
virtual ~FileDispatcherComponentBase()
Destroy FileDispatcherComponentBase object.
PlatformIndexType FwIndexType
Auto-generated base for FileDispatcher component.
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
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].
static constexpr FwIndexType getNum_pingOut_OutputPorts()
void log_ACTIVITY_HI_FileDispatched(const Fw::StringBase &file_name, Svc::FileDispatcherCfg::FileDispatchPort file_type) const
Log event FileDispatched.
static constexpr FwIndexType getNum_fileAnnounceRecv_InputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)