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 {
107  };
108 
110  enum {
114  };
115 
116  public:
117 
118  // ----------------------------------------------------------------------
119  // Component initialization
120  // ----------------------------------------------------------------------
121 
123  void init(
124  FwSizeType queueDepth,
125  FwEnumStoreType instance = 0
126  );
127 
128  public:
129 
130  // ----------------------------------------------------------------------
131  // Getters for special input ports
132  // ----------------------------------------------------------------------
133 
138  FwIndexType portNum
139  );
140 
141  public:
142 
143  // ----------------------------------------------------------------------
144  // Getters for typed input ports
145  // ----------------------------------------------------------------------
146 
151  FwIndexType portNum
152  );
153 
158  FwIndexType portNum
159  );
160 
165  FwIndexType portNum
166  );
167 
172  FwIndexType portNum
173  );
174 
175  public:
176 
177  // ----------------------------------------------------------------------
178  // Connect input ports to special output ports
179  // ----------------------------------------------------------------------
180 
183  FwIndexType portNum,
184  Fw::InputCmdRegPort* port
185  );
186 
189  FwIndexType portNum,
191  );
192 
195  FwIndexType portNum,
196  Fw::InputLogPort* port
197  );
198 
199 #if FW_ENABLE_TEXT_LOGGING == 1
200 
202  void set_textEventOut_OutputPort(
203  FwIndexType portNum,
204  Fw::InputLogTextPort* port
205  );
206 
207 #endif
208 
211  FwIndexType portNum,
212  Fw::InputTimePort* port
213  );
214 
217  FwIndexType portNum,
218  Fw::InputTlmPort* port
219  );
220 
221  public:
222 
223  // ----------------------------------------------------------------------
224  // Connect typed input ports to typed output ports
225  // ----------------------------------------------------------------------
226 
229  FwIndexType portNum,
231  );
232 
235  FwIndexType portNum,
237  );
238 
241  FwIndexType portNum,
242  Svc::InputPingPort* port
243  );
244 
245 #if FW_PORT_SERIALIZATION
246 
247  public:
248 
249  // ----------------------------------------------------------------------
250  // Connect serial input ports to special output ports
251  // ----------------------------------------------------------------------
252 
255  FwIndexType portNum,
256  Fw::InputSerializePort* port
257  );
258 
261  FwIndexType portNum,
262  Fw::InputSerializePort* port
263  );
264 
267  FwIndexType portNum,
268  Fw::InputSerializePort* port
269  );
270 
271 #if FW_ENABLE_TEXT_LOGGING == 1
272 
274  void set_textEventOut_OutputPort(
275  FwIndexType portNum,
276  Fw::InputSerializePort* port
277  );
278 
279 #endif
280 
283  FwIndexType portNum,
284  Fw::InputSerializePort* port
285  );
286 
289  FwIndexType portNum,
290  Fw::InputSerializePort* port
291  );
292 
293 #endif
294 
295 #if FW_PORT_SERIALIZATION
296 
297  public:
298 
299  // ----------------------------------------------------------------------
300  // Connect serial input ports to typed output ports
301  // ----------------------------------------------------------------------
302 
305  FwIndexType portNum,
306  Fw::InputSerializePort* port
307  );
308 
311  FwIndexType portNum,
312  Fw::InputSerializePort* port
313  );
314 
317  FwIndexType portNum,
318  Fw::InputSerializePort* port
319  );
320 
321 #endif
322 
323  public:
324 
325  // ----------------------------------------------------------------------
326  // Command registration
327  // ----------------------------------------------------------------------
328 
332  void regCommands();
333 
334  protected:
335 
336  // ----------------------------------------------------------------------
337  // Component construction and destruction
338  // ----------------------------------------------------------------------
339 
342  const char* compName = ""
343  );
344 
346  virtual ~FileDownlinkComponentBase();
347 
348  protected:
349 
350  // ----------------------------------------------------------------------
351  // Getters for numbers of special input ports
352  // ----------------------------------------------------------------------
353 
358  return NUM_CMDIN_INPUT_PORTS;
359  }
360 
361  protected:
362 
363  // ----------------------------------------------------------------------
364  // Getters for numbers of typed input ports
365  // ----------------------------------------------------------------------
366 
370  static constexpr FwIndexType getNum_Run_InputPorts() {
371  return NUM_RUN_INPUT_PORTS;
372  }
373 
379  }
380 
386  }
387 
392  return NUM_PINGIN_INPUT_PORTS;
393  }
394 
395  protected:
396 
397  // ----------------------------------------------------------------------
398  // Getters for numbers of special output ports
399  // ----------------------------------------------------------------------
400 
406  }
407 
413  }
414 
420  }
421 
422 #if FW_ENABLE_TEXT_LOGGING == 1
423 
427  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
429  }
430 
431 #endif
432 
438  }
439 
445  }
446 
447  protected:
448 
449  // ----------------------------------------------------------------------
450  // Getters for numbers of typed output ports
451  // ----------------------------------------------------------------------
452 
458  }
459 
465  }
466 
472  }
473 
474  protected:
475 
476  // ----------------------------------------------------------------------
477  // Connection status queries for special output ports
478  // ----------------------------------------------------------------------
479 
484  FwIndexType portNum
485  );
486 
491  FwIndexType portNum
492  );
493 
498  FwIndexType portNum
499  );
500 
501 #if FW_ENABLE_TEXT_LOGGING == 1
502 
506  bool isConnected_textEventOut_OutputPort(
507  FwIndexType portNum
508  );
509 
510 #endif
511 
516  FwIndexType portNum
517  );
518 
523  FwIndexType portNum
524  );
525 
526  protected:
527 
528  // ----------------------------------------------------------------------
529  // Connection status queries for typed output ports
530  // ----------------------------------------------------------------------
531 
536  FwIndexType portNum
537  );
538 
543  FwIndexType portNum
544  );
545 
550  FwIndexType portNum
551  );
552 
553  protected:
554 
555  // ----------------------------------------------------------------------
556  // Handlers to implement for typed input ports
557  // ----------------------------------------------------------------------
558 
560  virtual void Run_handler(
561  FwIndexType portNum,
562  U32 context
563  ) = 0;
564 
567  FwIndexType portNum,
568  const Fw::StringBase& sourceFileName,
569  const Fw::StringBase& destFileName,
570  U32 offset,
571  U32 length
572  ) = 0;
573 
575  virtual void bufferReturn_handler(
576  FwIndexType portNum,
577  Fw::Buffer& fwBuffer
578  ) = 0;
579 
581  virtual void pingIn_handler(
582  FwIndexType portNum,
583  U32 key
584  ) = 0;
585 
586  protected:
587 
588  // ----------------------------------------------------------------------
589  // Port handler base-class functions for typed input ports
590  //
591  // Call these functions directly to bypass the corresponding ports
592  // ----------------------------------------------------------------------
593 
595  void Run_handlerBase(
596  FwIndexType portNum,
597  U32 context
598  );
599 
602  FwIndexType portNum,
603  const Fw::StringBase& sourceFileName,
604  const Fw::StringBase& destFileName,
605  U32 offset,
606  U32 length
607  );
608 
611  FwIndexType portNum,
612  Fw::Buffer& fwBuffer
613  );
614 
616  void pingIn_handlerBase(
617  FwIndexType portNum,
618  U32 key
619  );
620 
621  protected:
622 
623  // ----------------------------------------------------------------------
624  // Pre-message hooks for typed async input ports
625  //
626  // Each of these functions is invoked just before processing a message
627  // on the corresponding port. By default, they do nothing. You can
628  // override them to provide specific pre-message behavior.
629  // ----------------------------------------------------------------------
630 
632  virtual void Run_preMsgHook(
633  FwIndexType portNum,
634  U32 context
635  );
636 
638  virtual void bufferReturn_preMsgHook(
639  FwIndexType portNum,
640  Fw::Buffer& fwBuffer
641  );
642 
644  virtual void pingIn_preMsgHook(
645  FwIndexType portNum,
646  U32 key
647  );
648 
649  protected:
650 
651  // ----------------------------------------------------------------------
652  // Invocation functions for typed output ports
653  // ----------------------------------------------------------------------
654 
656  void FileComplete_out(
657  FwIndexType portNum,
658  const Svc::SendFileResponse& resp
659  );
660 
662  void bufferSendOut_out(
663  FwIndexType portNum,
664  Fw::Buffer& fwBuffer
665  );
666 
668  void pingOut_out(
669  FwIndexType portNum,
670  U32 key
671  );
672 
673  protected:
674 
675  // ----------------------------------------------------------------------
676  // Command response
677  // ----------------------------------------------------------------------
678 
680  void cmdResponse_out(
681  FwOpcodeType opCode,
682  U32 cmdSeq,
683  Fw::CmdResponse response
684  );
685 
686  protected:
687 
688  // ----------------------------------------------------------------------
689  // Command handlers to implement
690  // ----------------------------------------------------------------------
691 
695  virtual void SendFile_cmdHandler(
696  FwOpcodeType opCode,
697  U32 cmdSeq,
698  const Fw::CmdStringArg& sourceFileName,
699  const Fw::CmdStringArg& destFileName
700  ) = 0;
701 
705  virtual void Cancel_cmdHandler(
706  FwOpcodeType opCode,
707  U32 cmdSeq
708  ) = 0;
709 
713  virtual void SendPartial_cmdHandler(
714  FwOpcodeType opCode,
715  U32 cmdSeq,
716  const Fw::CmdStringArg& sourceFileName,
717  const Fw::CmdStringArg& destFileName,
718  U32 startOffset,
719  U32 length
720  ) = 0;
721 
722  protected:
723 
724  // ----------------------------------------------------------------------
725  // Command handler base-class functions
726  //
727  // Call these functions directly to bypass the command input port
728  // ----------------------------------------------------------------------
729 
734  FwOpcodeType opCode,
735  U32 cmdSeq,
736  Fw::CmdArgBuffer& args
737  );
738 
743  FwOpcodeType opCode,
744  U32 cmdSeq,
745  Fw::CmdArgBuffer& args
746  );
747 
752  FwOpcodeType opCode,
753  U32 cmdSeq,
754  Fw::CmdArgBuffer& args
755  );
756 
757  protected:
758 
759  // ----------------------------------------------------------------------
760  // Pre-message hooks for async commands
761  //
762  // Each of these functions is invoked just before processing the
763  // corresponding command. By default they do nothing. You can
764  // override them to provide specific pre-command behavior.
765  // ----------------------------------------------------------------------
766 
768  virtual void SendFile_preMsgHook(
769  FwOpcodeType opCode,
770  U32 cmdSeq
771  );
772 
774  virtual void Cancel_preMsgHook(
775  FwOpcodeType opCode,
776  U32 cmdSeq
777  );
778 
780  virtual void SendPartial_preMsgHook(
781  FwOpcodeType opCode,
782  U32 cmdSeq
783  );
784 
785  protected:
786 
787  // ----------------------------------------------------------------------
788  // Event logging functions
789  // ----------------------------------------------------------------------
790 
795  const Fw::StringBase& fileName
796  ) const;
797 
802  const Fw::StringBase& fileName,
803  I32 status
804  ) const;
805 
810  const Fw::StringBase& sourceFileName,
811  const Fw::StringBase& destFileName
812  ) const;
813 
818  const Fw::StringBase& sourceFileName,
819  const Fw::StringBase& destFileName
820  ) const;
821 
826  U32 startOffset,
827  U32 length,
828  U32 filesize,
829  const Fw::StringBase& sourceFileName,
830  const Fw::StringBase& destFileName
831  ) const;
832 
837  const Fw::StringBase& sourceFileName,
838  const Fw::StringBase& destFileName,
839  U32 startOffset,
840  U32 filesize
841  ) const;
842 
847  const Fw::StringBase& sourceFileName,
848  U32 byteOffset
849  ) const;
850 
855  U32 fileSize,
856  const Fw::StringBase& sourceFileName,
857  const Fw::StringBase& destFileName
858  ) const;
859 
860  protected:
861 
862  // ----------------------------------------------------------------------
863  // Telemetry write functions
864  // ----------------------------------------------------------------------
865 
869  void tlmWrite_FilesSent(
870  U32 arg,
871  Fw::Time _tlmTime = Fw::Time()
872  ) const;
873 
878  U32 arg,
879  Fw::Time _tlmTime = Fw::Time()
880  ) const;
881 
885  void tlmWrite_Warnings(
886  U32 arg,
887  Fw::Time _tlmTime = Fw::Time()
888  ) const;
889 
890  protected:
891 
892  // ----------------------------------------------------------------------
893  // Time
894  // ----------------------------------------------------------------------
895 
899  Fw::Time getTime() const;
900 
901  protected:
902 
903  // ----------------------------------------------------------------------
904  // Mutex operations for guarded ports
905  //
906  // You can override these operations to provide more sophisticated
907  // synchronization
908  // ----------------------------------------------------------------------
909 
911  virtual void lock();
912 
914  virtual void unLock();
915 
916  private:
917 
918  // ----------------------------------------------------------------------
919  // Message dispatch functions
920  // ----------------------------------------------------------------------
921 
923  virtual MsgDispatchStatus doDispatch();
924 
925  private:
926 
927  // ----------------------------------------------------------------------
928  // Calls for messages received on special input ports
929  // ----------------------------------------------------------------------
930 
932  static void m_p_cmdIn_in(
933  Fw::PassiveComponentBase* callComp,
934  FwIndexType portNum,
935  FwOpcodeType opCode,
936  U32 cmdSeq,
937  Fw::CmdArgBuffer& args
938  );
939 
940  private:
941 
942  // ----------------------------------------------------------------------
943  // Calls for messages received on typed input ports
944  // ----------------------------------------------------------------------
945 
947  static void m_p_Run_in(
948  Fw::PassiveComponentBase* callComp,
949  FwIndexType portNum,
950  U32 context
951  );
952 
954  static Svc::SendFileResponse m_p_SendFile_in(
955  Fw::PassiveComponentBase* callComp,
956  FwIndexType portNum,
957  const Fw::StringBase& sourceFileName,
958  const Fw::StringBase& destFileName,
959  U32 offset,
960  U32 length
961  );
962 
964  static void m_p_bufferReturn_in(
965  Fw::PassiveComponentBase* callComp,
966  FwIndexType portNum,
967  Fw::Buffer& fwBuffer
968  );
969 
971  static void m_p_pingIn_in(
972  Fw::PassiveComponentBase* callComp,
973  FwIndexType portNum,
974  U32 key
975  );
976 
977  private:
978 
979  // ----------------------------------------------------------------------
980  // Special input ports
981  // ----------------------------------------------------------------------
982 
984  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
985 
986  private:
987 
988  // ----------------------------------------------------------------------
989  // Typed input ports
990  // ----------------------------------------------------------------------
991 
993  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
994 
997 
999  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1000 
1002  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1003 
1004  private:
1005 
1006  // ----------------------------------------------------------------------
1007  // Special output ports
1008  // ----------------------------------------------------------------------
1009 
1011  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1012 
1014  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1015 
1017  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1018 
1019 #if FW_ENABLE_TEXT_LOGGING == 1
1020 
1022  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1023 
1024 #endif
1025 
1027  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1028 
1030  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1031 
1032  private:
1033 
1034  // ----------------------------------------------------------------------
1035  // Typed output ports
1036  // ----------------------------------------------------------------------
1037 
1040 
1042  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1043 
1045  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1046 
1047  private:
1048 
1049  // ----------------------------------------------------------------------
1050  // Mutexes
1051  // ----------------------------------------------------------------------
1052 
1054  Os::Mutex m_guardedPortMutex;
1055 
1056  };
1057 
1058 }
1059 
1060 #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.