F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileDownlinkComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileDownlinkComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for FileDownlink component base class
5 // ======================================================================
6 
7 #ifndef Svc_FileDownlinkComponentAc_HPP
8 #define Svc_FileDownlinkComponentAc_HPP
9 
10 #include <atomic>
11 
13 #include "Fw/Cmd/CmdPortAc.hpp"
14 #include "Fw/Cmd/CmdRegPortAc.hpp"
16 #include "Fw/Cmd/CmdString.hpp"
18 #include "Fw/FPrimeBasicTypes.hpp"
19 #include "Fw/Log/LogPortAc.hpp"
20 #include "Fw/Log/LogString.hpp"
21 #if FW_ENABLE_TEXT_LOGGING == 1
22 #include "Fw/Log/LogTextPortAc.hpp"
23 #endif
26 #include "Fw/Time/TimePortAc.hpp"
27 #include "Fw/Tlm/TlmPortAc.hpp"
28 #include "Fw/Tlm/TlmString.hpp"
29 #include "Os/Mutex.hpp"
32 #include "Svc/Ping/PingPortAc.hpp"
35 
36 namespace Svc {
37 
44  {
45 
46  // ----------------------------------------------------------------------
47  // Friend classes
48  // ----------------------------------------------------------------------
49 
51  friend class FileDownlinkTesterBase;
53  friend class FileDownlinkTester;
54 
55  protected:
56 
57  // ----------------------------------------------------------------------
58  // Constants
59  // ----------------------------------------------------------------------
60 
62  enum {
64  };
65 
67  enum {
72  };
73 
75  enum {
82  };
83 
85  enum {
89  };
90 
92  enum {
94  OPCODE_CANCEL = 0x1,
96  };
97 
99  enum {
111  };
112 
114  enum {
118  };
119 
120  public:
121 
122  // ----------------------------------------------------------------------
123  // Component initialization
124  // ----------------------------------------------------------------------
125 
127  void init(
128  FwSizeType queueDepth,
129  FwEnumStoreType instance = 0
130  );
131 
132  public:
133 
134  // ----------------------------------------------------------------------
135  // Getters for special input ports
136  // ----------------------------------------------------------------------
137 
142  FwIndexType portNum
143  );
144 
145  public:
146 
147  // ----------------------------------------------------------------------
148  // Getters for typed input ports
149  // ----------------------------------------------------------------------
150 
155  FwIndexType portNum
156  );
157 
162  FwIndexType portNum
163  );
164 
169  FwIndexType portNum
170  );
171 
176  FwIndexType portNum
177  );
178 
179  public:
180 
181  // ----------------------------------------------------------------------
182  // Connect input ports to special output ports
183  // ----------------------------------------------------------------------
184 
187  FwIndexType portNum,
188  Fw::InputCmdRegPort* port
189  );
190 
193  FwIndexType portNum,
195  );
196 
199  FwIndexType portNum,
200  Fw::InputLogPort* port
201  );
202 
203 #if FW_ENABLE_TEXT_LOGGING == 1
204 
206  void set_textEventOut_OutputPort(
207  FwIndexType portNum,
208  Fw::InputLogTextPort* port
209  );
210 
211 #endif
212 
215  FwIndexType portNum,
216  Fw::InputTimePort* port
217  );
218 
221  FwIndexType portNum,
222  Fw::InputTlmPort* port
223  );
224 
225  public:
226 
227  // ----------------------------------------------------------------------
228  // Connect typed input ports to typed output ports
229  // ----------------------------------------------------------------------
230 
233  FwIndexType portNum,
235  );
236 
239  FwIndexType portNum,
241  );
242 
245  FwIndexType portNum,
246  Svc::InputPingPort* port
247  );
248 
249 #if FW_PORT_SERIALIZATION
250 
251  public:
252 
253  // ----------------------------------------------------------------------
254  // Connect serial input ports to special output ports
255  // ----------------------------------------------------------------------
256 
259  FwIndexType portNum,
260  Fw::InputSerializePort* port
261  );
262 
265  FwIndexType portNum,
266  Fw::InputSerializePort* port
267  );
268 
271  FwIndexType portNum,
272  Fw::InputSerializePort* port
273  );
274 
275 #if FW_ENABLE_TEXT_LOGGING == 1
276 
278  void set_textEventOut_OutputPort(
279  FwIndexType portNum,
280  Fw::InputSerializePort* port
281  );
282 
283 #endif
284 
287  FwIndexType portNum,
288  Fw::InputSerializePort* port
289  );
290 
293  FwIndexType portNum,
294  Fw::InputSerializePort* port
295  );
296 
297 #endif
298 
299 #if FW_PORT_SERIALIZATION
300 
301  public:
302 
303  // ----------------------------------------------------------------------
304  // Connect serial input ports to typed output ports
305  // ----------------------------------------------------------------------
306 
309  FwIndexType portNum,
310  Fw::InputSerializePort* port
311  );
312 
315  FwIndexType portNum,
316  Fw::InputSerializePort* port
317  );
318 
321  FwIndexType portNum,
322  Fw::InputSerializePort* port
323  );
324 
325 #endif
326 
327  public:
328 
329  // ----------------------------------------------------------------------
330  // Command registration
331  // ----------------------------------------------------------------------
332 
336  void regCommands();
337 
338  protected:
339 
340  // ----------------------------------------------------------------------
341  // Component construction and destruction
342  // ----------------------------------------------------------------------
343 
346  const char* compName = ""
347  );
348 
350  virtual ~FileDownlinkComponentBase();
351 
352  protected:
353 
354  // ----------------------------------------------------------------------
355  // Getters for numbers of special input ports
356  // ----------------------------------------------------------------------
357 
362  return NUM_CMDIN_INPUT_PORTS;
363  }
364 
365  protected:
366 
367  // ----------------------------------------------------------------------
368  // Getters for numbers of typed input ports
369  // ----------------------------------------------------------------------
370 
374  static constexpr FwIndexType getNum_Run_InputPorts() {
375  return NUM_RUN_INPUT_PORTS;
376  }
377 
383  }
384 
390  }
391 
396  return NUM_PINGIN_INPUT_PORTS;
397  }
398 
399  protected:
400 
401  // ----------------------------------------------------------------------
402  // Getters for numbers of special output ports
403  // ----------------------------------------------------------------------
404 
410  }
411 
417  }
418 
424  }
425 
426 #if FW_ENABLE_TEXT_LOGGING == 1
427 
431  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
433  }
434 
435 #endif
436 
442  }
443 
449  }
450 
451  protected:
452 
453  // ----------------------------------------------------------------------
454  // Getters for numbers of typed output ports
455  // ----------------------------------------------------------------------
456 
462  }
463 
469  }
470 
476  }
477 
478  protected:
479 
480  // ----------------------------------------------------------------------
481  // Connection status queries for special output ports
482  // ----------------------------------------------------------------------
483 
488  FwIndexType portNum
489  );
490 
495  FwIndexType portNum
496  );
497 
502  FwIndexType portNum
503  );
504 
505 #if FW_ENABLE_TEXT_LOGGING == 1
506 
510  bool isConnected_textEventOut_OutputPort(
511  FwIndexType portNum
512  );
513 
514 #endif
515 
520  FwIndexType portNum
521  );
522 
527  FwIndexType portNum
528  );
529 
530  protected:
531 
532  // ----------------------------------------------------------------------
533  // Connection status queries for typed output ports
534  // ----------------------------------------------------------------------
535 
540  FwIndexType portNum
541  );
542 
547  FwIndexType portNum
548  );
549 
554  FwIndexType portNum
555  );
556 
557  protected:
558 
559  // ----------------------------------------------------------------------
560  // Handlers to implement for typed input ports
561  // ----------------------------------------------------------------------
562 
564  virtual void Run_handler(
565  FwIndexType portNum,
566  U32 context
567  ) = 0;
568 
571  FwIndexType portNum,
572  const Fw::StringBase& sourceFileName,
573  const Fw::StringBase& destFileName,
574  U32 offset,
575  U32 length
576  ) = 0;
577 
579  virtual void bufferReturn_handler(
580  FwIndexType portNum,
581  Fw::Buffer& fwBuffer
582  ) = 0;
583 
585  virtual void pingIn_handler(
586  FwIndexType portNum,
587  U32 key
588  ) = 0;
589 
590  protected:
591 
592  // ----------------------------------------------------------------------
593  // Port handler base-class functions for typed input ports
594  //
595  // Call these functions directly to bypass the corresponding ports
596  // ----------------------------------------------------------------------
597 
599  void Run_handlerBase(
600  FwIndexType portNum,
601  U32 context
602  );
603 
606  FwIndexType portNum,
607  const Fw::StringBase& sourceFileName,
608  const Fw::StringBase& destFileName,
609  U32 offset,
610  U32 length
611  );
612 
615  FwIndexType portNum,
616  Fw::Buffer& fwBuffer
617  );
618 
620  void pingIn_handlerBase(
621  FwIndexType portNum,
622  U32 key
623  );
624 
625  protected:
626 
627  // ----------------------------------------------------------------------
628  // Pre-message hooks for typed async input ports
629  //
630  // Each of these functions is invoked just before processing a message
631  // on the corresponding port. By default, they do nothing. You can
632  // override them to provide specific pre-message behavior.
633  // ----------------------------------------------------------------------
634 
636  virtual void Run_preMsgHook(
637  FwIndexType portNum,
638  U32 context
639  );
640 
642  virtual void bufferReturn_preMsgHook(
643  FwIndexType portNum,
644  Fw::Buffer& fwBuffer
645  );
646 
648  virtual void pingIn_preMsgHook(
649  FwIndexType portNum,
650  U32 key
651  );
652 
653  protected:
654 
655  // ----------------------------------------------------------------------
656  // Invocation functions for typed output ports
657  // ----------------------------------------------------------------------
658 
660  void FileComplete_out(
661  FwIndexType portNum,
662  const Svc::SendFileResponse& resp
663  );
664 
666  void bufferSendOut_out(
667  FwIndexType portNum,
668  Fw::Buffer& fwBuffer
669  );
670 
672  void pingOut_out(
673  FwIndexType portNum,
674  U32 key
675  );
676 
677  protected:
678 
679  // ----------------------------------------------------------------------
680  // Command response
681  // ----------------------------------------------------------------------
682 
684  void cmdResponse_out(
685  FwOpcodeType opCode,
686  U32 cmdSeq,
687  Fw::CmdResponse response
688  );
689 
690  protected:
691 
692  // ----------------------------------------------------------------------
693  // Command handlers to implement
694  // ----------------------------------------------------------------------
695 
699  virtual void SendFile_cmdHandler(
700  FwOpcodeType opCode,
701  U32 cmdSeq,
702  const Fw::CmdStringArg& sourceFileName,
703  const Fw::CmdStringArg& destFileName
704  ) = 0;
705 
709  virtual void Cancel_cmdHandler(
710  FwOpcodeType opCode,
711  U32 cmdSeq
712  ) = 0;
713 
717  virtual void SendPartial_cmdHandler(
718  FwOpcodeType opCode,
719  U32 cmdSeq,
720  const Fw::CmdStringArg& sourceFileName,
721  const Fw::CmdStringArg& destFileName,
722  U32 startOffset,
723  U32 length
724  ) = 0;
725 
726  protected:
727 
728  // ----------------------------------------------------------------------
729  // Command handler base-class functions
730  //
731  // Call these functions directly to bypass the command input port
732  // ----------------------------------------------------------------------
733 
738  FwOpcodeType opCode,
739  U32 cmdSeq,
740  Fw::CmdArgBuffer& args
741  );
742 
747  FwOpcodeType opCode,
748  U32 cmdSeq,
749  Fw::CmdArgBuffer& args
750  );
751 
756  FwOpcodeType opCode,
757  U32 cmdSeq,
758  Fw::CmdArgBuffer& args
759  );
760 
761  protected:
762 
763  // ----------------------------------------------------------------------
764  // Pre-message hooks for async commands
765  //
766  // Each of these functions is invoked just before processing the
767  // corresponding command. By default they do nothing. You can
768  // override them to provide specific pre-command behavior.
769  // ----------------------------------------------------------------------
770 
772  virtual void SendFile_preMsgHook(
773  FwOpcodeType opCode,
774  U32 cmdSeq
775  );
776 
778  virtual void Cancel_preMsgHook(
779  FwOpcodeType opCode,
780  U32 cmdSeq
781  );
782 
784  virtual void SendPartial_preMsgHook(
785  FwOpcodeType opCode,
786  U32 cmdSeq
787  );
788 
789  protected:
790 
791  // ----------------------------------------------------------------------
792  // Event logging functions
793  // ----------------------------------------------------------------------
794 
799  const Fw::StringBase& fileName
800  ) const;
801 
806  const Fw::StringBase& fileName,
807  I32 status
808  ) const;
809 
814  const Fw::StringBase& sourceFileName,
815  const Fw::StringBase& destFileName
816  ) const;
817 
822  const Fw::StringBase& sourceFileName,
823  const Fw::StringBase& destFileName
824  ) const;
825 
830  U32 startOffset,
831  U32 length,
832  U32 filesize,
833  const Fw::StringBase& sourceFileName,
834  const Fw::StringBase& destFileName
835  ) const;
836 
841  const Fw::StringBase& sourceFileName,
842  const Fw::StringBase& destFileName,
843  U32 startOffset,
844  U32 filesize
845  ) const;
846 
851  const Fw::StringBase& sourceFileName,
852  U32 byteOffset
853  ) const;
854 
859  U32 fileSize,
860  const Fw::StringBase& sourceFileName,
861  const Fw::StringBase& destFileName
862  ) const;
863 
868  const Fw::StringBase& sourceFileName
869  ) const;
870 
875 
880 
881  protected:
882 
883  // ----------------------------------------------------------------------
884  // Telemetry write functions
885  // ----------------------------------------------------------------------
886 
890  void tlmWrite_FilesSent(
891  U32 arg,
892  Fw::Time _tlmTime = Fw::Time()
893  ) const;
894 
899  U32 arg,
900  Fw::Time _tlmTime = Fw::Time()
901  ) const;
902 
906  void tlmWrite_Warnings(
907  U32 arg,
908  Fw::Time _tlmTime = Fw::Time()
909  ) const;
910 
911  protected:
912 
913  // ----------------------------------------------------------------------
914  // Time
915  // ----------------------------------------------------------------------
916 
920  Fw::Time getTime() const;
921 
922  protected:
923 
924  // ----------------------------------------------------------------------
925  // Mutex operations for guarded ports
926  //
927  // You can override these operations to provide more sophisticated
928  // synchronization
929  // ----------------------------------------------------------------------
930 
932  virtual void lock();
933 
935  virtual void unLock();
936 
937  private:
938 
939  // ----------------------------------------------------------------------
940  // Message dispatch functions
941  // ----------------------------------------------------------------------
942 
944  virtual MsgDispatchStatus doDispatch();
945 
946  private:
947 
948  // ----------------------------------------------------------------------
949  // Calls for messages received on special input ports
950  // ----------------------------------------------------------------------
951 
953  static void m_p_cmdIn_in(
954  Fw::PassiveComponentBase* callComp,
955  FwIndexType portNum,
956  FwOpcodeType opCode,
957  U32 cmdSeq,
958  Fw::CmdArgBuffer& args
959  );
960 
961  private:
962 
963  // ----------------------------------------------------------------------
964  // Calls for messages received on typed input ports
965  // ----------------------------------------------------------------------
966 
968  static void m_p_Run_in(
969  Fw::PassiveComponentBase* callComp,
970  FwIndexType portNum,
971  U32 context
972  );
973 
975  static Svc::SendFileResponse m_p_SendFile_in(
976  Fw::PassiveComponentBase* callComp,
977  FwIndexType portNum,
978  const Fw::StringBase& sourceFileName,
979  const Fw::StringBase& destFileName,
980  U32 offset,
981  U32 length
982  );
983 
985  static void m_p_bufferReturn_in(
986  Fw::PassiveComponentBase* callComp,
987  FwIndexType portNum,
988  Fw::Buffer& fwBuffer
989  );
990 
992  static void m_p_pingIn_in(
993  Fw::PassiveComponentBase* callComp,
994  FwIndexType portNum,
995  U32 key
996  );
997 
998  private:
999 
1000  // ----------------------------------------------------------------------
1001  // Special input ports
1002  // ----------------------------------------------------------------------
1003 
1005  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
1006 
1007  private:
1008 
1009  // ----------------------------------------------------------------------
1010  // Typed input ports
1011  // ----------------------------------------------------------------------
1012 
1014  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
1015 
1018 
1020  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1021 
1023  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1024 
1025  private:
1026 
1027  // ----------------------------------------------------------------------
1028  // Special output ports
1029  // ----------------------------------------------------------------------
1030 
1032  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1033 
1035  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1036 
1038  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1039 
1040 #if FW_ENABLE_TEXT_LOGGING == 1
1041 
1043  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1044 
1045 #endif
1046 
1048  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1049 
1051  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1052 
1053  private:
1054 
1055  // ----------------------------------------------------------------------
1056  // Typed output ports
1057  // ----------------------------------------------------------------------
1058 
1061 
1063  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1064 
1066  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1067 
1068  private:
1069 
1070  // ----------------------------------------------------------------------
1071  // Mutexes
1072  // ----------------------------------------------------------------------
1073 
1075  Os::Mutex m_guardedPortMutex;
1076 
1077  };
1078 
1079 }
1080 
1081 #endif
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
Enum representing a command response.
void init()
Object initializer.
Definition: ObjBase.cpp:24
PlatformIndexType FwIndexType
Send file response struct.
RateGroupDivider component implementation.