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 {
114  };
115 
117  enum {
121  };
122 
123  public:
124 
125  // ----------------------------------------------------------------------
126  // Component initialization
127  // ----------------------------------------------------------------------
128 
130  void init(
131  FwSizeType queueDepth,
132  FwEnumStoreType instance = 0
133  );
134 
135 #if !FW_DIRECT_PORT_CALLS
136 
137  public:
138 
139  // ----------------------------------------------------------------------
140  // Getters for special input ports
141  // ----------------------------------------------------------------------
142 
147  FwIndexType portNum
148  );
149 
150 #endif
151 
152 #if !FW_DIRECT_PORT_CALLS
153 
154  public:
155 
156  // ----------------------------------------------------------------------
157  // Getters for typed input ports
158  // ----------------------------------------------------------------------
159 
164  FwIndexType portNum
165  );
166 
171  FwIndexType portNum
172  );
173 
178  FwIndexType portNum
179  );
180 
185  FwIndexType portNum
186  );
187 
188 #endif
189 
190 #if !FW_DIRECT_PORT_CALLS
191 
192  public:
193 
194  // ----------------------------------------------------------------------
195  // Connect input ports to special output ports
196  // ----------------------------------------------------------------------
197 
200  FwIndexType portNum,
201  Fw::InputCmdRegPort* port
202  );
203 
206  FwIndexType portNum,
208  );
209 
212  FwIndexType portNum,
213  Fw::InputLogPort* port
214  );
215 
216 #if FW_ENABLE_TEXT_LOGGING == 1
217 
219  void set_textEventOut_OutputPort(
220  FwIndexType portNum,
221  Fw::InputLogTextPort* port
222  );
223 
224 #endif
225 
228  FwIndexType portNum,
229  Fw::InputTimePort* port
230  );
231 
234  FwIndexType portNum,
235  Fw::InputTlmPort* port
236  );
237 
238 #endif
239 
240 #if !FW_DIRECT_PORT_CALLS
241 
242  public:
243 
244  // ----------------------------------------------------------------------
245  // Connect typed input ports to typed output ports
246  // ----------------------------------------------------------------------
247 
250  FwIndexType portNum,
252  );
253 
256  FwIndexType portNum,
258  );
259 
262  FwIndexType portNum,
263  Svc::InputPingPort* port
264  );
265 
266 #endif
267 
268 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
269 
270  public:
271 
272  // ----------------------------------------------------------------------
273  // Connect serial input ports to special output ports
274  // ----------------------------------------------------------------------
275 
278  FwIndexType portNum,
279  Fw::InputSerializePort* port
280  );
281 
284  FwIndexType portNum,
285  Fw::InputSerializePort* port
286  );
287 
290  FwIndexType portNum,
291  Fw::InputSerializePort* port
292  );
293 
294 #if FW_ENABLE_TEXT_LOGGING == 1
295 
297  void set_textEventOut_OutputPort(
298  FwIndexType portNum,
299  Fw::InputSerializePort* port
300  );
301 
302 #endif
303 
306  FwIndexType portNum,
307  Fw::InputSerializePort* port
308  );
309 
312  FwIndexType portNum,
313  Fw::InputSerializePort* port
314  );
315 
316 #endif
317 
318 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
319 
320  public:
321 
322  // ----------------------------------------------------------------------
323  // Connect serial input ports to typed output ports
324  // ----------------------------------------------------------------------
325 
328  FwIndexType portNum,
329  Fw::InputSerializePort* port
330  );
331 
334  FwIndexType portNum,
335  Fw::InputSerializePort* port
336  );
337 
340  FwIndexType portNum,
341  Fw::InputSerializePort* port
342  );
343 
344 #endif
345 
346  public:
347 
348  // ----------------------------------------------------------------------
349  // Command registration
350  // ----------------------------------------------------------------------
351 
355  void regCommands();
356 
357  protected:
358 
359  // ----------------------------------------------------------------------
360  // Component construction and destruction
361  // ----------------------------------------------------------------------
362 
365  const char* compName = ""
366  );
367 
369  virtual ~FileDownlinkComponentBase();
370 
371  protected:
372 
373  // ----------------------------------------------------------------------
374  // Getters for numbers of special input ports
375  // ----------------------------------------------------------------------
376 
381  return NUM_CMDIN_INPUT_PORTS;
382  }
383 
384  protected:
385 
386  // ----------------------------------------------------------------------
387  // Getters for numbers of typed input ports
388  // ----------------------------------------------------------------------
389 
393  static constexpr FwIndexType getNum_Run_InputPorts() {
394  return NUM_RUN_INPUT_PORTS;
395  }
396 
402  }
403 
409  }
410 
415  return NUM_PINGIN_INPUT_PORTS;
416  }
417 
418  protected:
419 
420  // ----------------------------------------------------------------------
421  // Getters for numbers of special output ports
422  // ----------------------------------------------------------------------
423 
429  }
430 
436  }
437 
443  }
444 
445 #if FW_ENABLE_TEXT_LOGGING == 1
446 
450  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
452  }
453 
454 #endif
455 
461  }
462 
468  }
469 
470  protected:
471 
472  // ----------------------------------------------------------------------
473  // Getters for numbers of typed output ports
474  // ----------------------------------------------------------------------
475 
481  }
482 
488  }
489 
495  }
496 
497  protected:
498 
499  // ----------------------------------------------------------------------
500  // Connection status queries for special output ports
501  // ----------------------------------------------------------------------
502 
507  FwIndexType portNum
508  ) const;
509 
514  FwIndexType portNum
515  ) const;
516 
521  FwIndexType portNum
522  ) const;
523 
524 #if FW_ENABLE_TEXT_LOGGING == 1
525 
529  bool isConnected_textEventOut_OutputPort(
530  FwIndexType portNum
531  ) const;
532 
533 #endif
534 
539  FwIndexType portNum
540  ) const;
541 
546  FwIndexType portNum
547  ) const;
548 
549  protected:
550 
551  // ----------------------------------------------------------------------
552  // Connection status queries for typed output ports
553  // ----------------------------------------------------------------------
554 
559  FwIndexType portNum
560  ) const;
561 
566  FwIndexType portNum
567  ) const;
568 
573  FwIndexType portNum
574  ) const;
575 
576 #if FW_DIRECT_PORT_CALLS
577  public:
578 #else
579  protected:
580 #endif
581 
582  // ----------------------------------------------------------------------
583  // Port handler base-class functions for special input ports
584  //
585  // Call these functions directly to bypass the corresponding ports
586  // ----------------------------------------------------------------------
587 
589  void cmdIn_handlerBase(
590  FwIndexType portNum,
591  FwOpcodeType opCode,
592  U32 cmdSeq,
593  Fw::CmdArgBuffer& args
594  );
595 
596  protected:
597 
598  // ----------------------------------------------------------------------
599  // Handlers to implement for typed input ports
600  // ----------------------------------------------------------------------
601 
603  virtual void Run_handler(
604  FwIndexType portNum,
605  U32 context
606  ) = 0;
607 
610  FwIndexType portNum,
611  const Fw::StringBase& sourceFileName,
612  const Fw::StringBase& destFileName,
613  U32 offset,
614  U32 length
615  ) = 0;
616 
618  virtual void bufferReturn_handler(
619  FwIndexType portNum,
620  Fw::Buffer& fwBuffer
621  ) = 0;
622 
624  virtual void pingIn_handler(
625  FwIndexType portNum,
626  U32 key
627  ) = 0;
628 
629 #if FW_DIRECT_PORT_CALLS
630  public:
631 #else
632  protected:
633 #endif
634 
635  // ----------------------------------------------------------------------
636  // Port handler base-class functions for typed input ports
637  //
638  // Call these functions directly to bypass the corresponding ports
639  // ----------------------------------------------------------------------
640 
642  void Run_handlerBase(
643  FwIndexType portNum,
644  U32 context
645  );
646 
649  FwIndexType portNum,
650  const Fw::StringBase& sourceFileName,
651  const Fw::StringBase& destFileName,
652  U32 offset,
653  U32 length
654  );
655 
658  FwIndexType portNum,
659  Fw::Buffer& fwBuffer
660  );
661 
663  void pingIn_handlerBase(
664  FwIndexType portNum,
665  U32 key
666  );
667 
668  protected:
669 
670  // ----------------------------------------------------------------------
671  // Pre-message hooks for typed async input ports
672  //
673  // Each of these functions is invoked just before processing a message
674  // on the corresponding port. By default, they do nothing. You can
675  // override them to provide specific pre-message behavior.
676  // ----------------------------------------------------------------------
677 
679  virtual void Run_preMsgHook(
680  FwIndexType portNum,
681  U32 context
682  );
683 
685  virtual void bufferReturn_preMsgHook(
686  FwIndexType portNum,
687  Fw::Buffer& fwBuffer
688  );
689 
691  virtual void pingIn_preMsgHook(
692  FwIndexType portNum,
693  U32 key
694  );
695 
696  protected:
697 
698  // ----------------------------------------------------------------------
699  // Invocation functions for typed output ports
700  // ----------------------------------------------------------------------
701 
703  void FileComplete_out(
704  FwIndexType portNum,
705  const Svc::SendFileResponse& resp
706  ) const;
707 
709  void bufferSendOut_out(
710  FwIndexType portNum,
711  Fw::Buffer& fwBuffer
712  ) const;
713 
715  void pingOut_out(
716  FwIndexType portNum,
717  U32 key
718  ) const;
719 
720  protected:
721 
722  // ----------------------------------------------------------------------
723  // Command response
724  // ----------------------------------------------------------------------
725 
727  void cmdResponse_out(
728  FwOpcodeType opCode,
729  U32 cmdSeq,
730  Fw::CmdResponse response
731  );
732 
733  protected:
734 
735  // ----------------------------------------------------------------------
736  // Command handlers to implement
737  // ----------------------------------------------------------------------
738 
742  virtual void SendFile_cmdHandler(
743  FwOpcodeType opCode,
744  U32 cmdSeq,
745  const Fw::CmdStringArg& sourceFileName,
746  const Fw::CmdStringArg& destFileName
747  ) = 0;
748 
752  virtual void Cancel_cmdHandler(
753  FwOpcodeType opCode,
754  U32 cmdSeq
755  ) = 0;
756 
760  virtual void SendPartial_cmdHandler(
761  FwOpcodeType opCode,
762  U32 cmdSeq,
763  const Fw::CmdStringArg& sourceFileName,
764  const Fw::CmdStringArg& destFileName,
765  U32 startOffset,
766  U32 length
767  ) = 0;
768 
769  protected:
770 
771  // ----------------------------------------------------------------------
772  // Command handler base-class functions
773  //
774  // Call these functions directly to bypass the command input port
775  // ----------------------------------------------------------------------
776 
781  FwOpcodeType opCode,
782  U32 cmdSeq,
783  Fw::CmdArgBuffer& args
784  );
785 
790  FwOpcodeType opCode,
791  U32 cmdSeq,
792  Fw::CmdArgBuffer& args
793  );
794 
799  FwOpcodeType opCode,
800  U32 cmdSeq,
801  Fw::CmdArgBuffer& args
802  );
803 
804  protected:
805 
806  // ----------------------------------------------------------------------
807  // Pre-message hooks for async commands
808  //
809  // Each of these functions is invoked just before processing the
810  // corresponding command. By default they do nothing. You can
811  // override them to provide specific pre-command behavior.
812  // ----------------------------------------------------------------------
813 
815  virtual void SendFile_preMsgHook(
816  FwOpcodeType opCode,
817  U32 cmdSeq
818  );
819 
821  virtual void Cancel_preMsgHook(
822  FwOpcodeType opCode,
823  U32 cmdSeq
824  );
825 
827  virtual void SendPartial_preMsgHook(
828  FwOpcodeType opCode,
829  U32 cmdSeq
830  );
831 
832  protected:
833 
834  // ----------------------------------------------------------------------
835  // Event logging functions
836  // ----------------------------------------------------------------------
837 
842  const Fw::StringBase& fileName
843  ) const;
844 
849  const Fw::StringBase& fileName,
850  I32 status
851  ) const;
852 
857  const Fw::StringBase& sourceFileName,
858  const Fw::StringBase& destFileName
859  ) const;
860 
865  const Fw::StringBase& sourceFileName,
866  const Fw::StringBase& destFileName
867  ) const;
868 
873  U32 startOffset,
874  U32 length,
875  U32 filesize,
876  const Fw::StringBase& sourceFileName,
877  const Fw::StringBase& destFileName
878  ) const;
879 
884  const Fw::StringBase& sourceFileName,
885  const Fw::StringBase& destFileName,
886  U32 startOffset,
887  U32 filesize
888  ) const;
889 
894  const Fw::StringBase& sourceFileName,
895  U32 byteOffset
896  ) const;
897 
902  U32 fileSize,
903  const Fw::StringBase& sourceFileName,
904  const Fw::StringBase& destFileName
905  ) const;
906 
911  const Fw::StringBase& sourceFileName
912  ) const;
913 
918 
923 
928  const Fw::StringBase& fileName
929  ) const;
930 
931  protected:
932 
933  // ----------------------------------------------------------------------
934  // Telemetry serialized write
935  // ----------------------------------------------------------------------
936 
941  void tlmWrite(
942  FwChanIdType id,
943  Fw::TlmBuffer& _tlmBuff,
944  Fw::Time _tlmTime = Fw::Time()
945  ) const;
946 
947  protected:
948 
949  // ----------------------------------------------------------------------
950  // Telemetry write functions
951  // ----------------------------------------------------------------------
952 
956  void tlmWrite_FilesSent(
957  U32 arg,
958  Fw::Time _tlmTime = Fw::Time()
959  ) const;
960 
965  U32 arg,
966  Fw::Time _tlmTime = Fw::Time()
967  ) const;
968 
972  void tlmWrite_Warnings(
973  U32 arg,
974  Fw::Time _tlmTime = Fw::Time()
975  ) const;
976 
977  protected:
978 
979  // ----------------------------------------------------------------------
980  // Time
981  // ----------------------------------------------------------------------
982 
986  Fw::Time getTime() const;
987 
988  protected:
989 
990  // ----------------------------------------------------------------------
991  // Mutex operations for guarded ports
992  //
993  // You can override these operations to provide more sophisticated
994  // synchronization
995  // ----------------------------------------------------------------------
996 
998  virtual void lock();
999 
1001  virtual void unLock();
1002 
1003  private:
1004 
1005  // ----------------------------------------------------------------------
1006  // Message dispatch functions
1007  // ----------------------------------------------------------------------
1008 
1010  virtual MsgDispatchStatus doDispatch();
1011 
1012  private:
1013 
1014  // ----------------------------------------------------------------------
1015  // Calls for messages received on special input ports
1016  // ----------------------------------------------------------------------
1017 
1019  static void m_p_cmdIn_in(
1020  Fw::PassiveComponentBase* callComp,
1021  FwIndexType portNum,
1022  FwOpcodeType opCode,
1023  U32 cmdSeq,
1024  Fw::CmdArgBuffer& args
1025  );
1026 
1027  private:
1028 
1029  // ----------------------------------------------------------------------
1030  // Calls for messages received on typed input ports
1031  // ----------------------------------------------------------------------
1032 
1034  static void m_p_Run_in(
1035  Fw::PassiveComponentBase* callComp,
1036  FwIndexType portNum,
1037  U32 context
1038  );
1039 
1041  static Svc::SendFileResponse m_p_SendFile_in(
1042  Fw::PassiveComponentBase* callComp,
1043  FwIndexType portNum,
1044  const Fw::StringBase& sourceFileName,
1045  const Fw::StringBase& destFileName,
1046  U32 offset,
1047  U32 length
1048  );
1049 
1051  static void m_p_bufferReturn_in(
1052  Fw::PassiveComponentBase* callComp,
1053  FwIndexType portNum,
1054  Fw::Buffer& fwBuffer
1055  );
1056 
1058  static void m_p_pingIn_in(
1059  Fw::PassiveComponentBase* callComp,
1060  FwIndexType portNum,
1061  U32 key
1062  );
1063 
1064  private:
1065 
1066  // ----------------------------------------------------------------------
1067  // Invocation functions for special output ports
1068  // ----------------------------------------------------------------------
1069 
1071  void cmdRegOut_out(
1072  FwIndexType portNum,
1073  FwOpcodeType opCode
1074  ) const;
1075 
1077  void cmdResponseOut_out(
1078  FwIndexType portNum,
1079  FwOpcodeType opCode,
1080  U32 cmdSeq,
1081  const Fw::CmdResponse& response
1082  ) const;
1083 
1085  void eventOut_out(
1086  FwIndexType portNum,
1087  FwEventIdType id,
1088  Fw::Time& timeTag,
1089  const Fw::LogSeverity& severity,
1090  Fw::LogBuffer& args
1091  ) const;
1092 
1093 #if FW_ENABLE_TEXT_LOGGING
1094 
1096  void textEventOut_out(
1097  FwIndexType portNum,
1098  FwEventIdType id,
1099  Fw::Time& timeTag,
1100  const Fw::LogSeverity& severity,
1101  Fw::TextLogString& text
1102  ) const;
1103 
1104 #endif
1105 
1107  void timeCaller_out(
1108  FwIndexType portNum,
1109  Fw::Time& time
1110  ) const;
1111 
1113  void tlmOut_out(
1114  FwIndexType portNum,
1115  FwChanIdType id,
1116  Fw::Time& timeTag,
1117  Fw::TlmBuffer& val
1118  ) const;
1119 
1120 #if !FW_DIRECT_PORT_CALLS
1121 
1122  private:
1123 
1124  // ----------------------------------------------------------------------
1125  // Special input ports
1126  // ----------------------------------------------------------------------
1127 
1129  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
1130 
1131 #endif
1132 
1133 #if !FW_DIRECT_PORT_CALLS
1134 
1135  private:
1136 
1137  // ----------------------------------------------------------------------
1138  // Typed input ports
1139  // ----------------------------------------------------------------------
1140 
1142  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
1143 
1146 
1148  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1149 
1151  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1152 
1153 #endif
1154 
1155 #if !FW_DIRECT_PORT_CALLS
1156 
1157  private:
1158 
1159  // ----------------------------------------------------------------------
1160  // Special output ports
1161  // ----------------------------------------------------------------------
1162 
1164  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1165 
1167  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1168 
1170  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1171 
1172 #if FW_ENABLE_TEXT_LOGGING == 1
1173 
1175  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1176 
1177 #endif
1178 
1180  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1181 
1183  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1184 
1185 #endif
1186 
1187 #if !FW_DIRECT_PORT_CALLS
1188 
1189  private:
1190 
1191  // ----------------------------------------------------------------------
1192  // Typed output ports
1193  // ----------------------------------------------------------------------
1194 
1197 
1199  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1200 
1202  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1203 
1204 #endif
1205 
1206  private:
1207 
1208  // ----------------------------------------------------------------------
1209  // Mutexes
1210  // ----------------------------------------------------------------------
1211 
1213  Os::Mutex m_guardedPortMutex;
1214 
1215  };
1216 
1217 }
1218 
1219 #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.