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
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #if !FW_DIRECT_PORT_CALLS
29 #endif
30 #include "Fw/Time/TimePortAc.hpp"
31 #include "Fw/Tlm/TlmPortAc.hpp"
32 #include "Fw/Tlm/TlmString.hpp"
33 #include "Os/Mutex.hpp"
36 #include "Svc/Ping/PingPortAc.hpp"
39 
40 namespace Svc {
41 
48  {
49 
50  // ----------------------------------------------------------------------
51  // Friend classes
52  // ----------------------------------------------------------------------
53 
55  friend class FileDownlinkTesterBase;
57  friend class FileDownlinkTester;
58 
59  protected:
60 
61  // ----------------------------------------------------------------------
62  // Constants
63  // ----------------------------------------------------------------------
64 
66  enum {
68  };
69 
71  enum {
76  };
77 
79  enum {
86  };
87 
89  enum {
93  };
94 
96  enum {
98  OPCODE_CANCEL = 0x1,
100  };
101 
103  enum {
115  };
116 
118  enum {
122  };
123 
124  public:
125 
126  // ----------------------------------------------------------------------
127  // Component initialization
128  // ----------------------------------------------------------------------
129 
131  void init(
132  FwSizeType queueDepth,
133  FwEnumStoreType instance = 0
134  );
135 
136 #if !FW_DIRECT_PORT_CALLS
137 
138  public:
139 
140  // ----------------------------------------------------------------------
141  // Getters for special input ports
142  // ----------------------------------------------------------------------
143 
148  FwIndexType portNum
149  );
150 
151 #endif
152 
153 #if !FW_DIRECT_PORT_CALLS
154 
155  public:
156 
157  // ----------------------------------------------------------------------
158  // Getters for typed input ports
159  // ----------------------------------------------------------------------
160 
165  FwIndexType portNum
166  );
167 
172  FwIndexType portNum
173  );
174 
179  FwIndexType portNum
180  );
181 
186  FwIndexType portNum
187  );
188 
189 #endif
190 
191 #if !FW_DIRECT_PORT_CALLS
192 
193  public:
194 
195  // ----------------------------------------------------------------------
196  // Connect input ports to special output ports
197  // ----------------------------------------------------------------------
198 
201  FwIndexType portNum,
202  Fw::InputCmdRegPort* port
203  );
204 
207  FwIndexType portNum,
209  );
210 
213  FwIndexType portNum,
214  Fw::InputLogPort* port
215  );
216 
217 #if FW_ENABLE_TEXT_LOGGING == 1
218 
220  void set_textEventOut_OutputPort(
221  FwIndexType portNum,
222  Fw::InputLogTextPort* port
223  );
224 
225 #endif
226 
229  FwIndexType portNum,
230  Fw::InputTimePort* port
231  );
232 
235  FwIndexType portNum,
236  Fw::InputTlmPort* port
237  );
238 
239 #endif
240 
241 #if !FW_DIRECT_PORT_CALLS
242 
243  public:
244 
245  // ----------------------------------------------------------------------
246  // Connect typed input ports to typed output ports
247  // ----------------------------------------------------------------------
248 
251  FwIndexType portNum,
253  );
254 
257  FwIndexType portNum,
259  );
260 
263  FwIndexType portNum,
264  Svc::InputPingPort* port
265  );
266 
267 #endif
268 
269 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
270 
271  public:
272 
273  // ----------------------------------------------------------------------
274  // Connect serial input ports to special output ports
275  // ----------------------------------------------------------------------
276 
279  FwIndexType portNum,
280  Fw::InputSerializePort* port
281  );
282 
285  FwIndexType portNum,
286  Fw::InputSerializePort* port
287  );
288 
291  FwIndexType portNum,
292  Fw::InputSerializePort* port
293  );
294 
295 #if FW_ENABLE_TEXT_LOGGING == 1
296 
298  void set_textEventOut_OutputPort(
299  FwIndexType portNum,
300  Fw::InputSerializePort* port
301  );
302 
303 #endif
304 
307  FwIndexType portNum,
308  Fw::InputSerializePort* port
309  );
310 
313  FwIndexType portNum,
314  Fw::InputSerializePort* port
315  );
316 
317 #endif
318 
319 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
320 
321  public:
322 
323  // ----------------------------------------------------------------------
324  // Connect serial input ports to typed output ports
325  // ----------------------------------------------------------------------
326 
329  FwIndexType portNum,
330  Fw::InputSerializePort* port
331  );
332 
335  FwIndexType portNum,
336  Fw::InputSerializePort* port
337  );
338 
341  FwIndexType portNum,
342  Fw::InputSerializePort* port
343  );
344 
345 #endif
346 
347  public:
348 
349  // ----------------------------------------------------------------------
350  // Command registration
351  // ----------------------------------------------------------------------
352 
356  void regCommands();
357 
358  protected:
359 
360  // ----------------------------------------------------------------------
361  // Component construction and destruction
362  // ----------------------------------------------------------------------
363 
366  const char* compName = ""
367  );
368 
370  virtual ~FileDownlinkComponentBase();
371 
372  protected:
373 
374  // ----------------------------------------------------------------------
375  // Getters for numbers of special input ports
376  // ----------------------------------------------------------------------
377 
382  return NUM_CMDIN_INPUT_PORTS;
383  }
384 
385  protected:
386 
387  // ----------------------------------------------------------------------
388  // Getters for numbers of typed input ports
389  // ----------------------------------------------------------------------
390 
394  static constexpr FwIndexType getNum_Run_InputPorts() {
395  return NUM_RUN_INPUT_PORTS;
396  }
397 
403  }
404 
410  }
411 
416  return NUM_PINGIN_INPUT_PORTS;
417  }
418 
419  protected:
420 
421  // ----------------------------------------------------------------------
422  // Getters for numbers of special output ports
423  // ----------------------------------------------------------------------
424 
430  }
431 
437  }
438 
444  }
445 
446 #if FW_ENABLE_TEXT_LOGGING == 1
447 
451  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
453  }
454 
455 #endif
456 
462  }
463 
469  }
470 
471  protected:
472 
473  // ----------------------------------------------------------------------
474  // Getters for numbers of typed output ports
475  // ----------------------------------------------------------------------
476 
482  }
483 
489  }
490 
496  }
497 
498  protected:
499 
500  // ----------------------------------------------------------------------
501  // Connection status queries for special output ports
502  // ----------------------------------------------------------------------
503 
508  FwIndexType portNum
509  ) const;
510 
515  FwIndexType portNum
516  ) const;
517 
522  FwIndexType portNum
523  ) const;
524 
525 #if FW_ENABLE_TEXT_LOGGING == 1
526 
530  bool isConnected_textEventOut_OutputPort(
531  FwIndexType portNum
532  ) const;
533 
534 #endif
535 
540  FwIndexType portNum
541  ) const;
542 
547  FwIndexType portNum
548  ) const;
549 
550  protected:
551 
552  // ----------------------------------------------------------------------
553  // Connection status queries for typed output ports
554  // ----------------------------------------------------------------------
555 
560  FwIndexType portNum
561  ) const;
562 
567  FwIndexType portNum
568  ) const;
569 
574  FwIndexType portNum
575  ) const;
576 
577 #if FW_DIRECT_PORT_CALLS
578  public:
579 #else
580  protected:
581 #endif
582 
583  // ----------------------------------------------------------------------
584  // Port handler base-class functions for special input ports
585  //
586  // Call these functions directly to bypass the corresponding ports
587  // ----------------------------------------------------------------------
588 
590  void cmdIn_handlerBase(
591  FwIndexType portNum,
592  FwOpcodeType opCode,
593  U32 cmdSeq,
594  Fw::CmdArgBuffer& args
595  );
596 
597  protected:
598 
599  // ----------------------------------------------------------------------
600  // Handlers to implement for typed input ports
601  // ----------------------------------------------------------------------
602 
604  virtual void Run_handler(
605  FwIndexType portNum,
606  U32 context
607  ) = 0;
608 
611  FwIndexType portNum,
612  const Fw::StringBase& sourceFileName,
613  const Fw::StringBase& destFileName,
614  U32 offset,
615  U32 length
616  ) = 0;
617 
619  virtual void bufferReturn_handler(
620  FwIndexType portNum,
621  Fw::Buffer& fwBuffer
622  ) = 0;
623 
625  virtual void pingIn_handler(
626  FwIndexType portNum,
627  U32 key
628  ) = 0;
629 
630 #if FW_DIRECT_PORT_CALLS
631  public:
632 #else
633  protected:
634 #endif
635 
636  // ----------------------------------------------------------------------
637  // Port handler base-class functions for typed input ports
638  //
639  // Call these functions directly to bypass the corresponding ports
640  // ----------------------------------------------------------------------
641 
643  void Run_handlerBase(
644  FwIndexType portNum,
645  U32 context
646  );
647 
650  FwIndexType portNum,
651  const Fw::StringBase& sourceFileName,
652  const Fw::StringBase& destFileName,
653  U32 offset,
654  U32 length
655  );
656 
659  FwIndexType portNum,
660  Fw::Buffer& fwBuffer
661  );
662 
664  void pingIn_handlerBase(
665  FwIndexType portNum,
666  U32 key
667  );
668 
669  protected:
670 
671  // ----------------------------------------------------------------------
672  // Pre-message hooks for typed async input ports
673  //
674  // Each of these functions is invoked just before processing a message
675  // on the corresponding port. By default, they do nothing. You can
676  // override them to provide specific pre-message behavior.
677  // ----------------------------------------------------------------------
678 
680  virtual void Run_preMsgHook(
681  FwIndexType portNum,
682  U32 context
683  );
684 
686  virtual void bufferReturn_preMsgHook(
687  FwIndexType portNum,
688  Fw::Buffer& fwBuffer
689  );
690 
692  virtual void pingIn_preMsgHook(
693  FwIndexType portNum,
694  U32 key
695  );
696 
697  protected:
698 
699  // ----------------------------------------------------------------------
700  // Invocation functions for typed output ports
701  // ----------------------------------------------------------------------
702 
704  void FileComplete_out(
705  FwIndexType portNum,
706  const Svc::SendFileResponse& resp
707  ) const;
708 
710  void bufferSendOut_out(
711  FwIndexType portNum,
712  Fw::Buffer& fwBuffer
713  ) const;
714 
716  void pingOut_out(
717  FwIndexType portNum,
718  U32 key
719  ) const;
720 
721  protected:
722 
723  // ----------------------------------------------------------------------
724  // Command response
725  // ----------------------------------------------------------------------
726 
728  void cmdResponse_out(
729  FwOpcodeType opCode,
730  U32 cmdSeq,
731  Fw::CmdResponse response
732  );
733 
734  protected:
735 
736  // ----------------------------------------------------------------------
737  // Command handlers to implement
738  // ----------------------------------------------------------------------
739 
743  virtual void SendFile_cmdHandler(
744  FwOpcodeType opCode,
745  U32 cmdSeq,
746  const Fw::CmdStringArg& sourceFileName,
747  const Fw::CmdStringArg& destFileName
748  ) = 0;
749 
753  virtual void Cancel_cmdHandler(
754  FwOpcodeType opCode,
755  U32 cmdSeq
756  ) = 0;
757 
761  virtual void SendPartial_cmdHandler(
762  FwOpcodeType opCode,
763  U32 cmdSeq,
764  const Fw::CmdStringArg& sourceFileName,
765  const Fw::CmdStringArg& destFileName,
766  U32 startOffset,
767  U32 length
768  ) = 0;
769 
770  protected:
771 
772  // ----------------------------------------------------------------------
773  // Command handler base-class functions
774  //
775  // Call these functions directly to bypass the command input port
776  // ----------------------------------------------------------------------
777 
782  FwOpcodeType opCode,
783  U32 cmdSeq,
784  Fw::CmdArgBuffer& args
785  );
786 
791  FwOpcodeType opCode,
792  U32 cmdSeq,
793  Fw::CmdArgBuffer& args
794  );
795 
800  FwOpcodeType opCode,
801  U32 cmdSeq,
802  Fw::CmdArgBuffer& args
803  );
804 
805  protected:
806 
807  // ----------------------------------------------------------------------
808  // Pre-message hooks for async commands
809  //
810  // Each of these functions is invoked just before processing the
811  // corresponding command. By default they do nothing. You can
812  // override them to provide specific pre-command behavior.
813  // ----------------------------------------------------------------------
814 
816  virtual void SendFile_preMsgHook(
817  FwOpcodeType opCode,
818  U32 cmdSeq
819  );
820 
822  virtual void Cancel_preMsgHook(
823  FwOpcodeType opCode,
824  U32 cmdSeq
825  );
826 
828  virtual void SendPartial_preMsgHook(
829  FwOpcodeType opCode,
830  U32 cmdSeq
831  );
832 
833  protected:
834 
835  // ----------------------------------------------------------------------
836  // Event logging functions
837  // ----------------------------------------------------------------------
838 
843  const Fw::StringBase& fileName
844  ) const;
845 
850  const Fw::StringBase& fileName,
851  I32 status
852  ) const;
853 
858  const Fw::StringBase& sourceFileName,
859  const Fw::StringBase& destFileName
860  ) const;
861 
866  const Fw::StringBase& sourceFileName,
867  const Fw::StringBase& destFileName
868  ) const;
869 
874  U32 startOffset,
875  U32 length,
876  U32 filesize,
877  const Fw::StringBase& sourceFileName,
878  const Fw::StringBase& destFileName
879  ) const;
880 
885  const Fw::StringBase& sourceFileName,
886  const Fw::StringBase& destFileName,
887  U32 startOffset,
888  U32 filesize
889  ) const;
890 
895  const Fw::StringBase& sourceFileName,
896  U32 byteOffset
897  ) const;
898 
903  U32 fileSize,
904  const Fw::StringBase& sourceFileName,
905  const Fw::StringBase& destFileName
906  ) const;
907 
912  const Fw::StringBase& sourceFileName
913  ) const;
914 
919 
924 
925  protected:
926 
927  // ----------------------------------------------------------------------
928  // Telemetry serialized write
929  // ----------------------------------------------------------------------
930 
935  void tlmWrite(
936  FwChanIdType id,
937  Fw::TlmBuffer& _tlmBuff,
938  Fw::Time _tlmTime = Fw::Time()
939  ) const;
940 
941  protected:
942 
943  // ----------------------------------------------------------------------
944  // Telemetry write functions
945  // ----------------------------------------------------------------------
946 
950  void tlmWrite_FilesSent(
951  U32 arg,
952  Fw::Time _tlmTime = Fw::Time()
953  ) const;
954 
959  U32 arg,
960  Fw::Time _tlmTime = Fw::Time()
961  ) const;
962 
966  void tlmWrite_Warnings(
967  U32 arg,
968  Fw::Time _tlmTime = Fw::Time()
969  ) const;
970 
971  protected:
972 
973  // ----------------------------------------------------------------------
974  // Time
975  // ----------------------------------------------------------------------
976 
980  Fw::Time getTime() const;
981 
982  protected:
983 
984  // ----------------------------------------------------------------------
985  // Mutex operations for guarded ports
986  //
987  // You can override these operations to provide more sophisticated
988  // synchronization
989  // ----------------------------------------------------------------------
990 
992  virtual void lock();
993 
995  virtual void unLock();
996 
997  private:
998 
999  // ----------------------------------------------------------------------
1000  // Message dispatch functions
1001  // ----------------------------------------------------------------------
1002 
1004  virtual MsgDispatchStatus doDispatch();
1005 
1006  private:
1007 
1008  // ----------------------------------------------------------------------
1009  // Calls for messages received on special input ports
1010  // ----------------------------------------------------------------------
1011 
1013  static void m_p_cmdIn_in(
1014  Fw::PassiveComponentBase* callComp,
1015  FwIndexType portNum,
1016  FwOpcodeType opCode,
1017  U32 cmdSeq,
1018  Fw::CmdArgBuffer& args
1019  );
1020 
1021  private:
1022 
1023  // ----------------------------------------------------------------------
1024  // Calls for messages received on typed input ports
1025  // ----------------------------------------------------------------------
1026 
1028  static void m_p_Run_in(
1029  Fw::PassiveComponentBase* callComp,
1030  FwIndexType portNum,
1031  U32 context
1032  );
1033 
1035  static Svc::SendFileResponse m_p_SendFile_in(
1036  Fw::PassiveComponentBase* callComp,
1037  FwIndexType portNum,
1038  const Fw::StringBase& sourceFileName,
1039  const Fw::StringBase& destFileName,
1040  U32 offset,
1041  U32 length
1042  );
1043 
1045  static void m_p_bufferReturn_in(
1046  Fw::PassiveComponentBase* callComp,
1047  FwIndexType portNum,
1048  Fw::Buffer& fwBuffer
1049  );
1050 
1052  static void m_p_pingIn_in(
1053  Fw::PassiveComponentBase* callComp,
1054  FwIndexType portNum,
1055  U32 key
1056  );
1057 
1058  private:
1059 
1060  // ----------------------------------------------------------------------
1061  // Invocation functions for special output ports
1062  // ----------------------------------------------------------------------
1063 
1065  void cmdRegOut_out(
1066  FwIndexType portNum,
1067  FwOpcodeType opCode
1068  ) const;
1069 
1071  void cmdResponseOut_out(
1072  FwIndexType portNum,
1073  FwOpcodeType opCode,
1074  U32 cmdSeq,
1075  const Fw::CmdResponse& response
1076  ) const;
1077 
1079  void eventOut_out(
1080  FwIndexType portNum,
1081  FwEventIdType id,
1082  Fw::Time& timeTag,
1083  const Fw::LogSeverity& severity,
1084  Fw::LogBuffer& args
1085  ) const;
1086 
1087 #if FW_ENABLE_TEXT_LOGGING
1088 
1090  void textEventOut_out(
1091  FwIndexType portNum,
1092  FwEventIdType id,
1093  Fw::Time& timeTag,
1094  const Fw::LogSeverity& severity,
1095  Fw::TextLogString& text
1096  ) const;
1097 
1098 #endif
1099 
1101  void timeCaller_out(
1102  FwIndexType portNum,
1103  Fw::Time& time
1104  ) const;
1105 
1107  void tlmOut_out(
1108  FwIndexType portNum,
1109  FwChanIdType id,
1110  Fw::Time& timeTag,
1111  Fw::TlmBuffer& val
1112  ) const;
1113 
1114 #if !FW_DIRECT_PORT_CALLS
1115 
1116  private:
1117 
1118  // ----------------------------------------------------------------------
1119  // Special input ports
1120  // ----------------------------------------------------------------------
1121 
1123  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
1124 
1125 #endif
1126 
1127 #if !FW_DIRECT_PORT_CALLS
1128 
1129  private:
1130 
1131  // ----------------------------------------------------------------------
1132  // Typed input ports
1133  // ----------------------------------------------------------------------
1134 
1136  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
1137 
1140 
1142  Fw::InputBufferSendPort m_bufferReturn_InputPort[NUM_BUFFERRETURN_INPUT_PORTS];
1143 
1145  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
1146 
1147 #endif
1148 
1149 #if !FW_DIRECT_PORT_CALLS
1150 
1151  private:
1152 
1153  // ----------------------------------------------------------------------
1154  // Special output ports
1155  // ----------------------------------------------------------------------
1156 
1158  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
1159 
1161  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
1162 
1164  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
1165 
1166 #if FW_ENABLE_TEXT_LOGGING == 1
1167 
1169  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
1170 
1171 #endif
1172 
1174  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
1175 
1177  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
1178 
1179 #endif
1180 
1181 #if !FW_DIRECT_PORT_CALLS
1182 
1183  private:
1184 
1185  // ----------------------------------------------------------------------
1186  // Typed output ports
1187  // ----------------------------------------------------------------------
1188 
1191 
1193  Fw::OutputBufferSendPort m_bufferSendOut_OutputPort[NUM_BUFFERSENDOUT_OUTPUT_PORTS];
1194 
1196  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
1197 
1198 #endif
1199 
1200  private:
1201 
1202  // ----------------------------------------------------------------------
1203  // Mutexes
1204  // ----------------------------------------------------------------------
1205 
1207  Os::Mutex m_guardedPortMutex;
1208 
1209  };
1210 
1211 }
1212 
1213 #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.