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 #include "Fw/Log/LogTextPortAc.hpp"
22 #if !FW_DIRECT_PORT_CALLS
24 #endif
25 #if !FW_DIRECT_PORT_CALLS
27 #endif
28 #include "Fw/Time/TimePortAc.hpp"
29 #include "Fw/Tlm/TlmPortAc.hpp"
30 #include "Fw/Tlm/TlmString.hpp"
31 #include "Os/Mutex.hpp"
34 #include "Svc/Ping/PingPortAc.hpp"
37 
38 namespace Svc {
39 
46  {
47 
48  // ----------------------------------------------------------------------
49  // Friend classes
50  // ----------------------------------------------------------------------
51 
53  friend class FileDownlinkTesterBase;
55  friend class FileDownlinkTester;
56 
57  protected:
58 
59  // ----------------------------------------------------------------------
60  // Constants
61  // ----------------------------------------------------------------------
62 
64  enum {
66  };
67 
69  enum {
74  };
75 
77  enum {
84  };
85 
87  enum {
91  };
92 
94  enum {
96  OPCODE_CANCEL = 0x1,
98  };
99 
101  enum {
113  };
114 
116  enum {
120  };
121 
122  public:
123 
124  // ----------------------------------------------------------------------
125  // Component initialization
126  // ----------------------------------------------------------------------
127 
129  void init(
130  FwSizeType queueDepth,
131  FwEnumStoreType instance = 0
132  );
133 
134 #if !FW_DIRECT_PORT_CALLS
135 
136  public:
137 
138  // ----------------------------------------------------------------------
139  // Getters for special input ports
140  // ----------------------------------------------------------------------
141 
146  FwIndexType portNum
147  );
148 
149 #endif
150 
151 #if !FW_DIRECT_PORT_CALLS
152 
153  public:
154 
155  // ----------------------------------------------------------------------
156  // Getters for typed input ports
157  // ----------------------------------------------------------------------
158 
163  FwIndexType portNum
164  );
165 
170  FwIndexType portNum
171  );
172 
177  FwIndexType portNum
178  );
179 
184  FwIndexType portNum
185  );
186 
187 #endif
188 
189 #if !FW_DIRECT_PORT_CALLS
190 
191  public:
192 
193  // ----------------------------------------------------------------------
194  // Connect input ports to special output ports
195  // ----------------------------------------------------------------------
196 
199  FwIndexType portNum,
200  Fw::InputCmdRegPort* port
201  );
202 
205  FwIndexType portNum,
207  );
208 
211  FwIndexType portNum,
212  Fw::InputLogPort* port
213  );
214 
215 #if FW_ENABLE_TEXT_LOGGING == 1
216 
218  void set_textEventOut_OutputPort(
219  FwIndexType portNum,
220  Fw::InputLogTextPort* port
221  );
222 
223 #endif
224 
227  FwIndexType portNum,
228  Fw::InputTimePort* port
229  );
230 
233  FwIndexType portNum,
234  Fw::InputTlmPort* port
235  );
236 
237 #endif
238 
239 #if !FW_DIRECT_PORT_CALLS
240 
241  public:
242 
243  // ----------------------------------------------------------------------
244  // Connect typed input ports to typed output ports
245  // ----------------------------------------------------------------------
246 
249  FwIndexType portNum,
251  );
252 
255  FwIndexType portNum,
257  );
258 
261  FwIndexType portNum,
262  Svc::InputPingPort* port
263  );
264 
265 #endif
266 
267 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
268 
269  public:
270 
271  // ----------------------------------------------------------------------
272  // Connect serial input ports to special output ports
273  // ----------------------------------------------------------------------
274 
277  FwIndexType portNum,
278  Fw::InputSerializePort* port
279  );
280 
283  FwIndexType portNum,
284  Fw::InputSerializePort* port
285  );
286 
289  FwIndexType portNum,
290  Fw::InputSerializePort* port
291  );
292 
293 #if FW_ENABLE_TEXT_LOGGING == 1
294 
296  void set_textEventOut_OutputPort(
297  FwIndexType portNum,
298  Fw::InputSerializePort* port
299  );
300 
301 #endif
302 
305  FwIndexType portNum,
306  Fw::InputSerializePort* port
307  );
308 
311  FwIndexType portNum,
312  Fw::InputSerializePort* port
313  );
314 
315 #endif
316 
317 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
318 
319  public:
320 
321  // ----------------------------------------------------------------------
322  // Connect serial input ports to typed output ports
323  // ----------------------------------------------------------------------
324 
327  FwIndexType portNum,
328  Fw::InputSerializePort* port
329  );
330 
333  FwIndexType portNum,
334  Fw::InputSerializePort* port
335  );
336 
339  FwIndexType portNum,
340  Fw::InputSerializePort* port
341  );
342 
343 #endif
344 
345  public:
346 
347  // ----------------------------------------------------------------------
348  // Command registration
349  // ----------------------------------------------------------------------
350 
354  void regCommands();
355 
356  protected:
357 
358  // ----------------------------------------------------------------------
359  // Component construction and destruction
360  // ----------------------------------------------------------------------
361 
364  const char* compName = ""
365  );
366 
368  virtual ~FileDownlinkComponentBase();
369 
370  protected:
371 
372  // ----------------------------------------------------------------------
373  // Getters for numbers of special input ports
374  // ----------------------------------------------------------------------
375 
380  return NUM_CMDIN_INPUT_PORTS;
381  }
382 
383  protected:
384 
385  // ----------------------------------------------------------------------
386  // Getters for numbers of typed input ports
387  // ----------------------------------------------------------------------
388 
392  static constexpr FwIndexType getNum_Run_InputPorts() {
393  return NUM_RUN_INPUT_PORTS;
394  }
395 
401  }
402 
408  }
409 
414  return NUM_PINGIN_INPUT_PORTS;
415  }
416 
417  protected:
418 
419  // ----------------------------------------------------------------------
420  // Getters for numbers of special output ports
421  // ----------------------------------------------------------------------
422 
428  }
429 
435  }
436 
442  }
443 
444 #if FW_ENABLE_TEXT_LOGGING == 1
445 
449  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
451  }
452 
453 #endif
454 
460  }
461 
467  }
468 
469  protected:
470 
471  // ----------------------------------------------------------------------
472  // Getters for numbers of typed output ports
473  // ----------------------------------------------------------------------
474 
480  }
481 
487  }
488 
494  }
495 
496  protected:
497 
498  // ----------------------------------------------------------------------
499  // Connection status queries for special output ports
500  // ----------------------------------------------------------------------
501 
506  FwIndexType portNum
507  ) const;
508 
513  FwIndexType portNum
514  ) const;
515 
520  FwIndexType portNum
521  ) const;
522 
523 #if FW_ENABLE_TEXT_LOGGING == 1
524 
528  bool isConnected_textEventOut_OutputPort(
529  FwIndexType portNum
530  ) const;
531 
532 #endif
533 
538  FwIndexType portNum
539  ) const;
540 
545  FwIndexType portNum
546  ) const;
547 
548  protected:
549 
550  // ----------------------------------------------------------------------
551  // Connection status queries for typed output ports
552  // ----------------------------------------------------------------------
553 
558  FwIndexType portNum
559  ) const;
560 
565  FwIndexType portNum
566  ) const;
567 
572  FwIndexType portNum
573  ) const;
574 
575 #if FW_DIRECT_PORT_CALLS
576  public:
577 #else
578  protected:
579 #endif
580 
581  // ----------------------------------------------------------------------
582  // Port handler base-class functions for special input ports
583  //
584  // Call these functions directly to bypass the corresponding ports
585  // ----------------------------------------------------------------------
586 
588  void cmdIn_handlerBase(
589  FwIndexType portNum,
590  FwOpcodeType opCode,
591  U32 cmdSeq,
592  Fw::CmdArgBuffer& args
593  );
594 
595  protected:
596 
597  // ----------------------------------------------------------------------
598  // Handlers to implement for typed input ports
599  // ----------------------------------------------------------------------
600 
602  virtual void Run_handler(
603  FwIndexType portNum,
604  U32 context
605  ) = 0;
606 
609  FwIndexType portNum,
610  const Fw::StringBase& sourceFileName,
611  const Fw::StringBase& destFileName,
612  U32 offset,
613  U32 length
614  ) = 0;
615 
617  virtual void bufferReturn_handler(
618  FwIndexType portNum,
619  Fw::Buffer& fwBuffer
620  ) = 0;
621 
623  virtual void pingIn_handler(
624  FwIndexType portNum,
625  U32 key
626  ) = 0;
627 
628 #if FW_DIRECT_PORT_CALLS
629  public:
630 #else
631  protected:
632 #endif
633 
634  // ----------------------------------------------------------------------
635  // Port handler base-class functions for typed input ports
636  //
637  // Call these functions directly to bypass the corresponding ports
638  // ----------------------------------------------------------------------
639 
641  void Run_handlerBase(
642  FwIndexType portNum,
643  U32 context
644  );
645 
648  FwIndexType portNum,
649  const Fw::StringBase& sourceFileName,
650  const Fw::StringBase& destFileName,
651  U32 offset,
652  U32 length
653  );
654 
657  FwIndexType portNum,
658  Fw::Buffer& fwBuffer
659  );
660 
662  void pingIn_handlerBase(
663  FwIndexType portNum,
664  U32 key
665  );
666 
667  protected:
668 
669  // ----------------------------------------------------------------------
670  // Pre-message hooks for typed async input ports
671  //
672  // Each of these functions is invoked just before processing a message
673  // on the corresponding port. By default, they do nothing. You can
674  // override them to provide specific pre-message behavior.
675  // ----------------------------------------------------------------------
676 
678  virtual void Run_preMsgHook(
679  FwIndexType portNum,
680  U32 context
681  );
682 
684  virtual void bufferReturn_preMsgHook(
685  FwIndexType portNum,
686  Fw::Buffer& fwBuffer
687  );
688 
690  virtual void pingIn_preMsgHook(
691  FwIndexType portNum,
692  U32 key
693  );
694 
695  protected:
696 
697  // ----------------------------------------------------------------------
698  // Invocation functions for typed output ports
699  // ----------------------------------------------------------------------
700 
702  void FileComplete_out(
703  FwIndexType portNum,
704  const Svc::SendFileResponse& resp
705  ) const;
706 
708  void bufferSendOut_out(
709  FwIndexType portNum,
710  Fw::Buffer& fwBuffer
711  ) const;
712 
714  void pingOut_out(
715  FwIndexType portNum,
716  U32 key
717  ) const;
718 
719  protected:
720 
721  // ----------------------------------------------------------------------
722  // Command response
723  // ----------------------------------------------------------------------
724 
726  void cmdResponse_out(
727  FwOpcodeType opCode,
728  U32 cmdSeq,
729  Fw::CmdResponse response
730  );
731 
732  protected:
733 
734  // ----------------------------------------------------------------------
735  // Command handlers to implement
736  // ----------------------------------------------------------------------
737 
741  virtual void SendFile_cmdHandler(
742  FwOpcodeType opCode,
743  U32 cmdSeq,
744  const Fw::CmdStringArg& sourceFileName,
745  const Fw::CmdStringArg& destFileName
746  ) = 0;
747 
751  virtual void Cancel_cmdHandler(
752  FwOpcodeType opCode,
753  U32 cmdSeq
754  ) = 0;
755 
759  virtual void SendPartial_cmdHandler(
760  FwOpcodeType opCode,
761  U32 cmdSeq,
762  const Fw::CmdStringArg& sourceFileName,
763  const Fw::CmdStringArg& destFileName,
764  U32 startOffset,
765  U32 length
766  ) = 0;
767 
768  protected:
769 
770  // ----------------------------------------------------------------------
771  // Command handler base-class functions
772  //
773  // Call these functions directly to bypass the command input port
774  // ----------------------------------------------------------------------
775 
780  FwOpcodeType opCode,
781  U32 cmdSeq,
782  Fw::CmdArgBuffer& args
783  );
784 
789  FwOpcodeType opCode,
790  U32 cmdSeq,
791  Fw::CmdArgBuffer& args
792  );
793 
798  FwOpcodeType opCode,
799  U32 cmdSeq,
800  Fw::CmdArgBuffer& args
801  );
802 
803  protected:
804 
805  // ----------------------------------------------------------------------
806  // Pre-message hooks for async commands
807  //
808  // Each of these functions is invoked just before processing the
809  // corresponding command. By default they do nothing. You can
810  // override them to provide specific pre-command behavior.
811  // ----------------------------------------------------------------------
812 
814  virtual void SendFile_preMsgHook(
815  FwOpcodeType opCode,
816  U32 cmdSeq
817  );
818 
820  virtual void Cancel_preMsgHook(
821  FwOpcodeType opCode,
822  U32 cmdSeq
823  );
824 
826  virtual void SendPartial_preMsgHook(
827  FwOpcodeType opCode,
828  U32 cmdSeq
829  );
830 
831  protected:
832 
833  // ----------------------------------------------------------------------
834  // Event logging functions
835  // ----------------------------------------------------------------------
836 
841  const Fw::StringBase& fileName
842  ) const;
843 
848  const Fw::StringBase& fileName,
849  I32 status
850  ) const;
851 
856  const Fw::StringBase& sourceFileName,
857  const Fw::StringBase& destFileName
858  ) const;
859 
864  const Fw::StringBase& sourceFileName,
865  const Fw::StringBase& destFileName
866  ) const;
867 
872  U32 startOffset,
873  U32 length,
874  U32 filesize,
875  const Fw::StringBase& sourceFileName,
876  const Fw::StringBase& destFileName
877  ) const;
878 
883  const Fw::StringBase& sourceFileName,
884  const Fw::StringBase& destFileName,
885  U32 startOffset,
886  U32 filesize
887  ) const;
888 
893  const Fw::StringBase& sourceFileName,
894  U32 byteOffset
895  ) const;
896 
901  U32 fileSize,
902  const Fw::StringBase& sourceFileName,
903  const Fw::StringBase& destFileName
904  ) const;
905 
910  const Fw::StringBase& sourceFileName
911  ) const;
912 
917 
922 
923  protected:
924 
925  // ----------------------------------------------------------------------
926  // Telemetry serialized write
927  // ----------------------------------------------------------------------
928 
933  void tlmWrite(
934  FwChanIdType id,
935  Fw::TlmBuffer& _tlmBuff,
936  Fw::Time _tlmTime = Fw::Time()
937  ) const;
938 
939  protected:
940 
941  // ----------------------------------------------------------------------
942  // Telemetry write functions
943  // ----------------------------------------------------------------------
944 
948  void tlmWrite_FilesSent(
949  U32 arg,
950  Fw::Time _tlmTime = Fw::Time()
951  ) const;
952 
957  U32 arg,
958  Fw::Time _tlmTime = Fw::Time()
959  ) const;
960 
964  void tlmWrite_Warnings(
965  U32 arg,
966  Fw::Time _tlmTime = Fw::Time()
967  ) const;
968 
969  protected:
970 
971  // ----------------------------------------------------------------------
972  // Time
973  // ----------------------------------------------------------------------
974 
978  Fw::Time getTime() const;
979 
980  protected:
981 
982  // ----------------------------------------------------------------------
983  // Mutex operations for guarded ports
984  //
985  // You can override these operations to provide more sophisticated
986  // synchronization
987  // ----------------------------------------------------------------------
988 
990  virtual void lock();
991 
993  virtual void unLock();
994 
995  private:
996 
997  // ----------------------------------------------------------------------
998  // Message dispatch functions
999  // ----------------------------------------------------------------------
1000 
1002  virtual MsgDispatchStatus doDispatch();
1003 
1004  private:
1005 
1006  // ----------------------------------------------------------------------
1007  // Calls for messages received on special input ports
1008  // ----------------------------------------------------------------------
1009 
1011  static void m_p_cmdIn_in(
1012  Fw::PassiveComponentBase* callComp,
1013  FwIndexType portNum,
1014  FwOpcodeType opCode,
1015  U32 cmdSeq,
1016  Fw::CmdArgBuffer& args
1017  );
1018 
1019  private:
1020 
1021  // ----------------------------------------------------------------------
1022  // Calls for messages received on typed input ports
1023  // ----------------------------------------------------------------------
1024 
1026  static void m_p_Run_in(
1027  Fw::PassiveComponentBase* callComp,
1028  FwIndexType portNum,
1029  U32 context
1030  );
1031 
1033  static Svc::SendFileResponse m_p_SendFile_in(
1034  Fw::PassiveComponentBase* callComp,
1035  FwIndexType portNum,
1036  const Fw::StringBase& sourceFileName,
1037  const Fw::StringBase& destFileName,
1038  U32 offset,
1039  U32 length
1040  );
1041 
1043  static void m_p_bufferReturn_in(
1044  Fw::PassiveComponentBase* callComp,
1045  FwIndexType portNum,
1046  Fw::Buffer& fwBuffer
1047  );
1048 
1050  static void m_p_pingIn_in(
1051  Fw::PassiveComponentBase* callComp,
1052  FwIndexType portNum,
1053  U32 key
1054  );
1055 
1056  private:
1057 
1058  // ----------------------------------------------------------------------
1059  // Invocation functions for special output ports
1060  // ----------------------------------------------------------------------
1061 
1063  void cmdRegOut_out(
1064  FwIndexType portNum,
1065  FwOpcodeType opCode
1066  ) const;
1067 
1069  void cmdResponseOut_out(
1070  FwIndexType portNum,
1071  FwOpcodeType opCode,
1072  U32 cmdSeq,
1073  const Fw::CmdResponse& response
1074  ) const;
1075 
1077  void eventOut_out(
1078  FwIndexType portNum,
1079  FwEventIdType id,
1080  Fw::Time& timeTag,
1081  const Fw::LogSeverity& severity,
1082  Fw::LogBuffer& args
1083  ) const;
1084 
1085 #if FW_ENABLE_TEXT_LOGGING
1086 
1088  void textEventOut_out(
1089  FwIndexType portNum,
1090  FwEventIdType id,
1091  Fw::Time& timeTag,
1092  const Fw::LogSeverity& severity,
1093  Fw::TextLogString& text
1094  ) const;
1095 
1096 #endif
1097 
1099  void timeCaller_out(
1100  FwIndexType portNum,
1101  Fw::Time& time
1102  ) const;
1103 
1105  void tlmOut_out(
1106  FwIndexType portNum,
1107  FwChanIdType id,
1108  Fw::Time& timeTag,
1109  Fw::TlmBuffer& val
1110  ) const;
1111 
1112 #if !FW_DIRECT_PORT_CALLS
1113 
1114  private:
1115 
1116  // ----------------------------------------------------------------------
1117  // Special input ports
1118  // ----------------------------------------------------------------------
1119 
1121  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
1122 
1123 #endif
1124 
1125 #if !FW_DIRECT_PORT_CALLS
1126 
1127  private:
1128 
1129  // ----------------------------------------------------------------------
1130  // Typed input ports
1131  // ----------------------------------------------------------------------
1132 
1134  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
1135 
1138 
1140  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1141 
1143  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1144 
1145 #endif
1146 
1147 #if !FW_DIRECT_PORT_CALLS
1148 
1149  private:
1150 
1151  // ----------------------------------------------------------------------
1152  // Special output ports
1153  // ----------------------------------------------------------------------
1154 
1156  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1157 
1159  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1160 
1162  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1163 
1164 #if FW_ENABLE_TEXT_LOGGING == 1
1165 
1167  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1168 
1169 #endif
1170 
1172  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1173 
1175  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1176 
1177 #endif
1178 
1179 #if !FW_DIRECT_PORT_CALLS
1180 
1181  private:
1182 
1183  // ----------------------------------------------------------------------
1184  // Typed output ports
1185  // ----------------------------------------------------------------------
1186 
1189 
1191  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1192 
1194  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1195 
1196 #endif
1197 
1198  private:
1199 
1200  // ----------------------------------------------------------------------
1201  // Mutexes
1202  // ----------------------------------------------------------------------
1203 
1205  Os::Mutex m_guardedPortMutex;
1206 
1207  };
1208 
1209 }
1210 
1211 #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
FwIdType FwEventIdType
The type of an event identifier.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
Enum representing event severity.
PlatformIndexType FwIndexType
Send file response struct.
RateGroupDivider component implementation.