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"
34 
35 namespace Svc {
36 
43  {
44 
45  // ----------------------------------------------------------------------
46  // Friend classes
47  // ----------------------------------------------------------------------
48 
50  friend class FileDownlinkTesterBase;
52  friend class FileDownlinkTester;
53 
54  protected:
55 
56  // ----------------------------------------------------------------------
57  // Constants
58  // ----------------------------------------------------------------------
59 
61  enum {
63  };
64 
66  enum {
71  };
72 
74  enum {
81  };
82 
84  enum {
88  };
89 
91  enum {
93  OPCODE_CANCEL = 0x1,
95  };
96 
98  enum {
108  };
109 
111  enum {
115  };
116 
117  public:
118 
119  // ----------------------------------------------------------------------
120  // Component initialization
121  // ----------------------------------------------------------------------
122 
124  void init(
125  FwSizeType queueDepth,
126  FwEnumStoreType instance = 0
127  );
128 
129  public:
130 
131  // ----------------------------------------------------------------------
132  // Getters for special input ports
133  // ----------------------------------------------------------------------
134 
139  FwIndexType portNum
140  );
141 
142  public:
143 
144  // ----------------------------------------------------------------------
145  // Getters for typed input ports
146  // ----------------------------------------------------------------------
147 
152  FwIndexType portNum
153  );
154 
159  FwIndexType portNum
160  );
161 
166  FwIndexType portNum
167  );
168 
173  FwIndexType portNum
174  );
175 
176  public:
177 
178  // ----------------------------------------------------------------------
179  // Connect input ports to special output ports
180  // ----------------------------------------------------------------------
181 
184  FwIndexType portNum,
185  Fw::InputCmdRegPort* port
186  );
187 
190  FwIndexType portNum,
192  );
193 
196  FwIndexType portNum,
197  Fw::InputLogPort* port
198  );
199 
200 #if FW_ENABLE_TEXT_LOGGING == 1
201 
203  void set_textEventOut_OutputPort(
204  FwIndexType portNum,
205  Fw::InputLogTextPort* port
206  );
207 
208 #endif
209 
212  FwIndexType portNum,
213  Fw::InputTimePort* port
214  );
215 
218  FwIndexType portNum,
219  Fw::InputTlmPort* port
220  );
221 
222  public:
223 
224  // ----------------------------------------------------------------------
225  // Connect typed input ports to typed output ports
226  // ----------------------------------------------------------------------
227 
230  FwIndexType portNum,
232  );
233 
236  FwIndexType portNum,
238  );
239 
242  FwIndexType portNum,
243  Svc::InputPingPort* port
244  );
245 
246 #if FW_PORT_SERIALIZATION
247 
248  public:
249 
250  // ----------------------------------------------------------------------
251  // Connect serial input ports to special output ports
252  // ----------------------------------------------------------------------
253 
256  FwIndexType portNum,
257  Fw::InputSerializePort* port
258  );
259 
262  FwIndexType portNum,
263  Fw::InputSerializePort* port
264  );
265 
268  FwIndexType portNum,
269  Fw::InputSerializePort* port
270  );
271 
272 #if FW_ENABLE_TEXT_LOGGING == 1
273 
275  void set_textEventOut_OutputPort(
276  FwIndexType portNum,
277  Fw::InputSerializePort* port
278  );
279 
280 #endif
281 
284  FwIndexType portNum,
285  Fw::InputSerializePort* port
286  );
287 
290  FwIndexType portNum,
291  Fw::InputSerializePort* port
292  );
293 
294 #endif
295 
296 #if FW_PORT_SERIALIZATION
297 
298  public:
299 
300  // ----------------------------------------------------------------------
301  // Connect serial input ports to typed output ports
302  // ----------------------------------------------------------------------
303 
306  FwIndexType portNum,
307  Fw::InputSerializePort* port
308  );
309 
312  FwIndexType portNum,
313  Fw::InputSerializePort* port
314  );
315 
318  FwIndexType portNum,
319  Fw::InputSerializePort* port
320  );
321 
322 #endif
323 
324  public:
325 
326  // ----------------------------------------------------------------------
327  // Command registration
328  // ----------------------------------------------------------------------
329 
333  void regCommands();
334 
335  protected:
336 
337  // ----------------------------------------------------------------------
338  // Component construction and destruction
339  // ----------------------------------------------------------------------
340 
343  const char* compName = ""
344  );
345 
347  virtual ~FileDownlinkComponentBase();
348 
349  protected:
350 
351  // ----------------------------------------------------------------------
352  // Getters for numbers of special input ports
353  // ----------------------------------------------------------------------
354 
359  return NUM_CMDIN_INPUT_PORTS;
360  }
361 
362  protected:
363 
364  // ----------------------------------------------------------------------
365  // Getters for numbers of typed input ports
366  // ----------------------------------------------------------------------
367 
371  static constexpr FwIndexType getNum_Run_InputPorts() {
372  return NUM_RUN_INPUT_PORTS;
373  }
374 
380  }
381 
387  }
388 
393  return NUM_PINGIN_INPUT_PORTS;
394  }
395 
396  protected:
397 
398  // ----------------------------------------------------------------------
399  // Getters for numbers of special output ports
400  // ----------------------------------------------------------------------
401 
407  }
408 
414  }
415 
421  }
422 
423 #if FW_ENABLE_TEXT_LOGGING == 1
424 
428  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
430  }
431 
432 #endif
433 
439  }
440 
446  }
447 
448  protected:
449 
450  // ----------------------------------------------------------------------
451  // Getters for numbers of typed output ports
452  // ----------------------------------------------------------------------
453 
459  }
460 
466  }
467 
473  }
474 
475  protected:
476 
477  // ----------------------------------------------------------------------
478  // Connection status queries for special output ports
479  // ----------------------------------------------------------------------
480 
485  FwIndexType portNum
486  );
487 
492  FwIndexType portNum
493  );
494 
499  FwIndexType portNum
500  );
501 
502 #if FW_ENABLE_TEXT_LOGGING == 1
503 
507  bool isConnected_textEventOut_OutputPort(
508  FwIndexType portNum
509  );
510 
511 #endif
512 
517  FwIndexType portNum
518  );
519 
524  FwIndexType portNum
525  );
526 
527  protected:
528 
529  // ----------------------------------------------------------------------
530  // Connection status queries for typed output ports
531  // ----------------------------------------------------------------------
532 
537  FwIndexType portNum
538  );
539 
544  FwIndexType portNum
545  );
546 
551  FwIndexType portNum
552  );
553 
554  protected:
555 
556  // ----------------------------------------------------------------------
557  // Handlers to implement for typed input ports
558  // ----------------------------------------------------------------------
559 
561  virtual void Run_handler(
562  FwIndexType portNum,
563  U32 context
564  ) = 0;
565 
568  FwIndexType portNum,
569  const Fw::StringBase& sourceFileName,
570  const Fw::StringBase& destFileName,
571  U32 offset,
572  U32 length
573  ) = 0;
574 
576  virtual void bufferReturn_handler(
577  FwIndexType portNum,
578  Fw::Buffer& fwBuffer
579  ) = 0;
580 
582  virtual void pingIn_handler(
583  FwIndexType portNum,
584  U32 key
585  ) = 0;
586 
587  protected:
588 
589  // ----------------------------------------------------------------------
590  // Port handler base-class functions for typed input ports
591  //
592  // Call these functions directly to bypass the corresponding ports
593  // ----------------------------------------------------------------------
594 
596  void Run_handlerBase(
597  FwIndexType portNum,
598  U32 context
599  );
600 
603  FwIndexType portNum,
604  const Fw::StringBase& sourceFileName,
605  const Fw::StringBase& destFileName,
606  U32 offset,
607  U32 length
608  );
609 
612  FwIndexType portNum,
613  Fw::Buffer& fwBuffer
614  );
615 
617  void pingIn_handlerBase(
618  FwIndexType portNum,
619  U32 key
620  );
621 
622  protected:
623 
624  // ----------------------------------------------------------------------
625  // Pre-message hooks for typed async input ports
626  //
627  // Each of these functions is invoked just before processing a message
628  // on the corresponding port. By default, they do nothing. You can
629  // override them to provide specific pre-message behavior.
630  // ----------------------------------------------------------------------
631 
633  virtual void Run_preMsgHook(
634  FwIndexType portNum,
635  U32 context
636  );
637 
639  virtual void bufferReturn_preMsgHook(
640  FwIndexType portNum,
641  Fw::Buffer& fwBuffer
642  );
643 
645  virtual void pingIn_preMsgHook(
646  FwIndexType portNum,
647  U32 key
648  );
649 
650  protected:
651 
652  // ----------------------------------------------------------------------
653  // Invocation functions for typed output ports
654  // ----------------------------------------------------------------------
655 
657  void FileComplete_out(
658  FwIndexType portNum,
659  const Svc::SendFileResponse& resp
660  );
661 
663  void bufferSendOut_out(
664  FwIndexType portNum,
665  Fw::Buffer& fwBuffer
666  );
667 
669  void pingOut_out(
670  FwIndexType portNum,
671  U32 key
672  );
673 
674  protected:
675 
676  // ----------------------------------------------------------------------
677  // Command response
678  // ----------------------------------------------------------------------
679 
681  void cmdResponse_out(
682  FwOpcodeType opCode,
683  U32 cmdSeq,
684  Fw::CmdResponse response
685  );
686 
687  protected:
688 
689  // ----------------------------------------------------------------------
690  // Command handlers to implement
691  // ----------------------------------------------------------------------
692 
696  virtual void SendFile_cmdHandler(
697  FwOpcodeType opCode,
698  U32 cmdSeq,
699  const Fw::CmdStringArg& sourceFileName,
700  const Fw::CmdStringArg& destFileName
701  ) = 0;
702 
706  virtual void Cancel_cmdHandler(
707  FwOpcodeType opCode,
708  U32 cmdSeq
709  ) = 0;
710 
714  virtual void SendPartial_cmdHandler(
715  FwOpcodeType opCode,
716  U32 cmdSeq,
717  const Fw::CmdStringArg& sourceFileName,
718  const Fw::CmdStringArg& destFileName,
719  U32 startOffset,
720  U32 length
721  ) = 0;
722 
723  protected:
724 
725  // ----------------------------------------------------------------------
726  // Command handler base-class functions
727  //
728  // Call these functions directly to bypass the command input port
729  // ----------------------------------------------------------------------
730 
735  FwOpcodeType opCode,
736  U32 cmdSeq,
737  Fw::CmdArgBuffer& args
738  );
739 
744  FwOpcodeType opCode,
745  U32 cmdSeq,
746  Fw::CmdArgBuffer& args
747  );
748 
753  FwOpcodeType opCode,
754  U32 cmdSeq,
755  Fw::CmdArgBuffer& args
756  );
757 
758  protected:
759 
760  // ----------------------------------------------------------------------
761  // Pre-message hooks for async commands
762  //
763  // Each of these functions is invoked just before processing the
764  // corresponding command. By default they do nothing. You can
765  // override them to provide specific pre-command behavior.
766  // ----------------------------------------------------------------------
767 
769  virtual void SendFile_preMsgHook(
770  FwOpcodeType opCode,
771  U32 cmdSeq
772  );
773 
775  virtual void Cancel_preMsgHook(
776  FwOpcodeType opCode,
777  U32 cmdSeq
778  );
779 
781  virtual void SendPartial_preMsgHook(
782  FwOpcodeType opCode,
783  U32 cmdSeq
784  );
785 
786  protected:
787 
788  // ----------------------------------------------------------------------
789  // Event logging functions
790  // ----------------------------------------------------------------------
791 
796  const Fw::StringBase& fileName
797  ) const;
798 
803  const Fw::StringBase& fileName,
804  I32 status
805  ) const;
806 
811  const Fw::StringBase& sourceFileName,
812  const Fw::StringBase& destFileName
813  ) const;
814 
819  const Fw::StringBase& sourceFileName,
820  const Fw::StringBase& destFileName
821  ) const;
822 
827  const Fw::StringBase& sourceFileName,
828  const Fw::StringBase& destFileName
829  ) const;
830 
835  U32 startOffset,
836  U32 length,
837  U32 filesize,
838  const Fw::StringBase& sourceFileName,
839  const Fw::StringBase& destFileName
840  ) const;
841 
846  const Fw::StringBase& sourceFileName,
847  const Fw::StringBase& destFileName,
848  U32 startOffset,
849  U32 filesize
850  ) const;
851 
856  const Fw::StringBase& sourceFileName,
857  U32 byteOffset
858  ) const;
859 
864  U32 fileSize,
865  const Fw::StringBase& sourceFileName,
866  const Fw::StringBase& destFileName
867  ) const;
868 
869  protected:
870 
871  // ----------------------------------------------------------------------
872  // Telemetry write functions
873  // ----------------------------------------------------------------------
874 
878  void tlmWrite_FilesSent(
879  U32 arg,
880  Fw::Time _tlmTime = Fw::Time()
881  ) const;
882 
887  U32 arg,
888  Fw::Time _tlmTime = Fw::Time()
889  ) const;
890 
894  void tlmWrite_Warnings(
895  U32 arg,
896  Fw::Time _tlmTime = Fw::Time()
897  ) const;
898 
899  protected:
900 
901  // ----------------------------------------------------------------------
902  // Time
903  // ----------------------------------------------------------------------
904 
908  Fw::Time getTime() const;
909 
910  protected:
911 
912  // ----------------------------------------------------------------------
913  // Mutex operations for guarded ports
914  //
915  // You can override these operations to provide more sophisticated
916  // synchronization
917  // ----------------------------------------------------------------------
918 
920  virtual void lock();
921 
923  virtual void unLock();
924 
925  private:
926 
927  // ----------------------------------------------------------------------
928  // Message dispatch functions
929  // ----------------------------------------------------------------------
930 
932  virtual MsgDispatchStatus doDispatch();
933 
934  private:
935 
936  // ----------------------------------------------------------------------
937  // Calls for messages received on special input ports
938  // ----------------------------------------------------------------------
939 
941  static void m_p_cmdIn_in(
942  Fw::PassiveComponentBase* callComp,
943  FwIndexType portNum,
944  FwOpcodeType opCode,
945  U32 cmdSeq,
946  Fw::CmdArgBuffer& args
947  );
948 
949  private:
950 
951  // ----------------------------------------------------------------------
952  // Calls for messages received on typed input ports
953  // ----------------------------------------------------------------------
954 
956  static void m_p_Run_in(
957  Fw::PassiveComponentBase* callComp,
958  FwIndexType portNum,
959  U32 context
960  );
961 
963  static Svc::SendFileResponse m_p_SendFile_in(
964  Fw::PassiveComponentBase* callComp,
965  FwIndexType portNum,
966  const Fw::StringBase& sourceFileName,
967  const Fw::StringBase& destFileName,
968  U32 offset,
969  U32 length
970  );
971 
973  static void m_p_bufferReturn_in(
974  Fw::PassiveComponentBase* callComp,
975  FwIndexType portNum,
976  Fw::Buffer& fwBuffer
977  );
978 
980  static void m_p_pingIn_in(
981  Fw::PassiveComponentBase* callComp,
982  FwIndexType portNum,
983  U32 key
984  );
985 
986  private:
987 
988  // ----------------------------------------------------------------------
989  // Special input ports
990  // ----------------------------------------------------------------------
991 
993  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
994 
995  private:
996 
997  // ----------------------------------------------------------------------
998  // Typed input ports
999  // ----------------------------------------------------------------------
1000 
1002  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
1003 
1006 
1008  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1009 
1011  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1012 
1013  private:
1014 
1015  // ----------------------------------------------------------------------
1016  // Special output ports
1017  // ----------------------------------------------------------------------
1018 
1020  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1021 
1023  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1024 
1026  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1027 
1028 #if FW_ENABLE_TEXT_LOGGING == 1
1029 
1031  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1032 
1033 #endif
1034 
1036  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1037 
1039  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1040 
1041  private:
1042 
1043  // ----------------------------------------------------------------------
1044  // Typed output ports
1045  // ----------------------------------------------------------------------
1046 
1049 
1051  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1052 
1054  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1055 
1056  private:
1057 
1058  // ----------------------------------------------------------------------
1059  // Mutexes
1060  // ----------------------------------------------------------------------
1061 
1063  Os::Mutex m_guardedPortMutex;
1064 
1065  };
1066 
1067 }
1068 
1069 #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.