F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileDownlinkComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileDownlinkComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FileDownlink component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  FILEDOWNLINK_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  RUN_SCHED,
20  BUFFERRETURN_BUFFERSEND,
21  PINGIN_PING,
22  CMD_SENDFILE,
23  CMD_CANCEL,
24  CMD_SENDPARTIAL,
25  };
26 
27  // Get the max size by constructing a union of the async input, command, and
28  // internal port serialization sizes
29  union BuffUnion {
31  BYTE bufferReturnPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
34  };
35 
36  // Define a message buffer class large enough to handle all the
37  // asynchronous inputs to the component
38  class ComponentIpcSerializableBuffer :
40  {
41 
42  public:
43 
44  enum {
45  // Offset into data in buffer: Size of message ID and port number
46  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
47  // Max data size
48  MAX_DATA_SIZE = sizeof(BuffUnion),
49  // Max message size: Size of message id + size of port + max data size
50  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
51  };
52 
53  Fw::Serializable::SizeType getBuffCapacity() const {
54  return sizeof(m_buff);
55  }
56 
57  U8* getBuffAddr() {
58  return m_buff;
59  }
60 
61  const U8* getBuffAddr() const {
62  return m_buff;
63  }
64 
65  private:
66  // Should be the max of all the input ports serialized sizes...
67  U8 m_buff[SERIALIZATION_SIZE];
68 
69  };
70  }
71 
72  // ----------------------------------------------------------------------
73  // Component initialization
74  // ----------------------------------------------------------------------
75 
78  FwSizeType queueDepth,
79  FwEnumStoreType instance
80  )
81  {
82  // Initialize base class
84 
85  // Connect input port cmdIn
86  for (
87  FwIndexType port = 0;
88  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
89  port++
90  ) {
91  this->m_cmdIn_InputPort[port].init();
92  this->m_cmdIn_InputPort[port].addCallComp(
93  this,
94  m_p_cmdIn_in
95  );
96  this->m_cmdIn_InputPort[port].setPortNum(port);
97 
98 #if FW_OBJECT_NAMES == 1
99  Fw::ObjectName portName;
100  portName.format(
101  "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
102  this->m_objName.toChar(),
103  port
104  );
105  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
106 #endif
107  }
108 
109  // Connect input port Run
110  for (
111  FwIndexType port = 0;
112  port < static_cast<FwIndexType>(this->getNum_Run_InputPorts());
113  port++
114  ) {
115  this->m_Run_InputPort[port].init();
116  this->m_Run_InputPort[port].addCallComp(
117  this,
118  m_p_Run_in
119  );
120  this->m_Run_InputPort[port].setPortNum(port);
121 
122 #if FW_OBJECT_NAMES == 1
123  Fw::ObjectName portName;
124  portName.format(
125  "%s_Run_InputPort[%" PRI_PlatformIntType "]",
126  this->m_objName.toChar(),
127  port
128  );
129  this->m_Run_InputPort[port].setObjName(portName.toChar());
130 #endif
131  }
132 
133  // Connect input port SendFile
134  for (
135  FwIndexType port = 0;
136  port < static_cast<FwIndexType>(this->getNum_SendFile_InputPorts());
137  port++
138  ) {
139  this->m_SendFile_InputPort[port].init();
140  this->m_SendFile_InputPort[port].addCallComp(
141  this,
142  m_p_SendFile_in
143  );
144  this->m_SendFile_InputPort[port].setPortNum(port);
145 
146 #if FW_OBJECT_NAMES == 1
147  Fw::ObjectName portName;
148  portName.format(
149  "%s_SendFile_InputPort[%" PRI_PlatformIntType "]",
150  this->m_objName.toChar(),
151  port
152  );
153  this->m_SendFile_InputPort[port].setObjName(portName.toChar());
154 #endif
155  }
156 
157  // Connect input port bufferReturn
158  for (
159  FwIndexType port = 0;
160  port < static_cast<FwIndexType>(this->getNum_bufferReturn_InputPorts());
161  port++
162  ) {
163  this->m_bufferReturn_InputPort[port].init();
164  this->m_bufferReturn_InputPort[port].addCallComp(
165  this,
166  m_p_bufferReturn_in
167  );
168  this->m_bufferReturn_InputPort[port].setPortNum(port);
169 
170 #if FW_OBJECT_NAMES == 1
171  Fw::ObjectName portName;
172  portName.format(
173  "%s_bufferReturn_InputPort[%" PRI_PlatformIntType "]",
174  this->m_objName.toChar(),
175  port
176  );
177  this->m_bufferReturn_InputPort[port].setObjName(portName.toChar());
178 #endif
179  }
180 
181  // Connect input port pingIn
182  for (
183  FwIndexType port = 0;
184  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
185  port++
186  ) {
187  this->m_pingIn_InputPort[port].init();
188  this->m_pingIn_InputPort[port].addCallComp(
189  this,
190  m_p_pingIn_in
191  );
192  this->m_pingIn_InputPort[port].setPortNum(port);
193 
194 #if FW_OBJECT_NAMES == 1
195  Fw::ObjectName portName;
196  portName.format(
197  "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
198  this->m_objName.toChar(),
199  port
200  );
201  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
202 #endif
203  }
204 
205  // Connect output port cmdRegOut
206  for (
207  FwIndexType port = 0;
208  port < static_cast<FwIndexType>(this->getNum_cmdRegOut_OutputPorts());
209  port++
210  ) {
211  this->m_cmdRegOut_OutputPort[port].init();
212 
213 #if FW_OBJECT_NAMES == 1
214  Fw::ObjectName portName;
215  portName.format(
216  "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
217  this->m_objName.toChar(),
218  port
219  );
220  this->m_cmdRegOut_OutputPort[port].setObjName(portName.toChar());
221 #endif
222  }
223 
224  // Connect output port cmdResponseOut
225  for (
226  FwIndexType port = 0;
227  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
228  port++
229  ) {
230  this->m_cmdResponseOut_OutputPort[port].init();
231 
232 #if FW_OBJECT_NAMES == 1
233  Fw::ObjectName portName;
234  portName.format(
235  "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
236  this->m_objName.toChar(),
237  port
238  );
239  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
240 #endif
241  }
242 
243  // Connect output port eventOut
244  for (
245  FwIndexType port = 0;
246  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
247  port++
248  ) {
249  this->m_eventOut_OutputPort[port].init();
250 
251 #if FW_OBJECT_NAMES == 1
252  Fw::ObjectName portName;
253  portName.format(
254  "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
255  this->m_objName.toChar(),
256  port
257  );
258  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
259 #endif
260  }
261 
262 #if FW_ENABLE_TEXT_LOGGING == 1
263  // Connect output port textEventOut
264  for (
265  FwIndexType port = 0;
266  port < static_cast<FwIndexType>(this->getNum_textEventOut_OutputPorts());
267  port++
268  ) {
269  this->m_textEventOut_OutputPort[port].init();
270 
271 #if FW_OBJECT_NAMES == 1
272  Fw::ObjectName portName;
273  portName.format(
274  "%s_textEventOut_OutputPort[%" PRI_PlatformIntType "]",
275  this->m_objName.toChar(),
276  port
277  );
278  this->m_textEventOut_OutputPort[port].setObjName(portName.toChar());
279 #endif
280  }
281 #endif
282 
283  // Connect output port timeCaller
284  for (
285  FwIndexType port = 0;
286  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
287  port++
288  ) {
289  this->m_timeCaller_OutputPort[port].init();
290 
291 #if FW_OBJECT_NAMES == 1
292  Fw::ObjectName portName;
293  portName.format(
294  "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
295  this->m_objName.toChar(),
296  port
297  );
298  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
299 #endif
300  }
301 
302  // Connect output port tlmOut
303  for (
304  FwIndexType port = 0;
305  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
306  port++
307  ) {
308  this->m_tlmOut_OutputPort[port].init();
309 
310 #if FW_OBJECT_NAMES == 1
311  Fw::ObjectName portName;
312  portName.format(
313  "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
314  this->m_objName.toChar(),
315  port
316  );
317  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
318 #endif
319  }
320 
321  // Connect output port FileComplete
322  for (
323  FwIndexType port = 0;
324  port < static_cast<FwIndexType>(this->getNum_FileComplete_OutputPorts());
325  port++
326  ) {
327  this->m_FileComplete_OutputPort[port].init();
328 
329 #if FW_OBJECT_NAMES == 1
330  Fw::ObjectName portName;
331  portName.format(
332  "%s_FileComplete_OutputPort[%" PRI_PlatformIntType "]",
333  this->m_objName.toChar(),
334  port
335  );
336  this->m_FileComplete_OutputPort[port].setObjName(portName.toChar());
337 #endif
338  }
339 
340  // Connect output port bufferSendOut
341  for (
342  FwIndexType port = 0;
343  port < static_cast<FwIndexType>(this->getNum_bufferSendOut_OutputPorts());
344  port++
345  ) {
346  this->m_bufferSendOut_OutputPort[port].init();
347 
348 #if FW_OBJECT_NAMES == 1
349  Fw::ObjectName portName;
350  portName.format(
351  "%s_bufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
352  this->m_objName.toChar(),
353  port
354  );
355  this->m_bufferSendOut_OutputPort[port].setObjName(portName.toChar());
356 #endif
357  }
358 
359  // Connect output port pingOut
360  for (
361  FwIndexType port = 0;
362  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
363  port++
364  ) {
365  this->m_pingOut_OutputPort[port].init();
366 
367 #if FW_OBJECT_NAMES == 1
368  Fw::ObjectName portName;
369  portName.format(
370  "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
371  this->m_objName.toChar(),
372  port
373  );
374  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
375 #endif
376  }
377 
378  // Create the queue
379  Os::Queue::Status qStat = this->createQueue(
380  queueDepth,
381  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
382  );
383  FW_ASSERT(
384  Os::Queue::Status::OP_OK == qStat,
385  static_cast<FwAssertArgType>(qStat)
386  );
387  }
388 
389  // ----------------------------------------------------------------------
390  // Getters for special input ports
391  // ----------------------------------------------------------------------
392 
395  {
396  FW_ASSERT(
397  portNum < this->getNum_cmdIn_InputPorts(),
398  static_cast<FwAssertArgType>(portNum)
399  );
400 
401  return &this->m_cmdIn_InputPort[portNum];
402  }
403 
404  // ----------------------------------------------------------------------
405  // Getters for typed input ports
406  // ----------------------------------------------------------------------
407 
410  {
411  FW_ASSERT(
412  portNum < this->getNum_Run_InputPorts(),
413  static_cast<FwAssertArgType>(portNum)
414  );
415 
416  return &this->m_Run_InputPort[portNum];
417  }
418 
421  {
422  FW_ASSERT(
423  portNum < this->getNum_SendFile_InputPorts(),
424  static_cast<FwAssertArgType>(portNum)
425  );
426 
427  return &this->m_SendFile_InputPort[portNum];
428  }
429 
432  {
433  FW_ASSERT(
434  portNum < this->getNum_bufferReturn_InputPorts(),
435  static_cast<FwAssertArgType>(portNum)
436  );
437 
438  return &this->m_bufferReturn_InputPort[portNum];
439  }
440 
443  {
444  FW_ASSERT(
445  portNum < this->getNum_pingIn_InputPorts(),
446  static_cast<FwAssertArgType>(portNum)
447  );
448 
449  return &this->m_pingIn_InputPort[portNum];
450  }
451 
452  // ----------------------------------------------------------------------
453  // Connect input ports to special output ports
454  // ----------------------------------------------------------------------
455 
458  FwIndexType portNum,
459  Fw::InputCmdRegPort* port
460  )
461  {
462  FW_ASSERT(
463  portNum < this->getNum_cmdRegOut_OutputPorts(),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
468  }
469 
472  FwIndexType portNum,
474  )
475  {
476  FW_ASSERT(
477  portNum < this->getNum_cmdResponseOut_OutputPorts(),
478  static_cast<FwAssertArgType>(portNum)
479  );
480 
481  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
482  }
483 
486  FwIndexType portNum,
487  Fw::InputLogPort* port
488  )
489  {
490  FW_ASSERT(
491  portNum < this->getNum_eventOut_OutputPorts(),
492  static_cast<FwAssertArgType>(portNum)
493  );
494 
495  this->m_eventOut_OutputPort[portNum].addCallPort(port);
496  }
497 
498 #if FW_ENABLE_TEXT_LOGGING == 1
499 
500  void FileDownlinkComponentBase ::
501  set_textEventOut_OutputPort(
502  FwIndexType portNum,
504  )
505  {
506  FW_ASSERT(
507  portNum < this->getNum_textEventOut_OutputPorts(),
508  static_cast<FwAssertArgType>(portNum)
509  );
510 
511  this->m_textEventOut_OutputPort[portNum].addCallPort(port);
512  }
513 
514 #endif
515 
518  FwIndexType portNum,
519  Fw::InputTimePort* port
520  )
521  {
522  FW_ASSERT(
523  portNum < this->getNum_timeCaller_OutputPorts(),
524  static_cast<FwAssertArgType>(portNum)
525  );
526 
527  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
528  }
529 
532  FwIndexType portNum,
533  Fw::InputTlmPort* port
534  )
535  {
536  FW_ASSERT(
537  portNum < this->getNum_tlmOut_OutputPorts(),
538  static_cast<FwAssertArgType>(portNum)
539  );
540 
541  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
542  }
543 
544  // ----------------------------------------------------------------------
545  // Connect typed input ports to typed output ports
546  // ----------------------------------------------------------------------
547 
550  FwIndexType portNum,
552  )
553  {
554  FW_ASSERT(
555  portNum < this->getNum_FileComplete_OutputPorts(),
556  static_cast<FwAssertArgType>(portNum)
557  );
558 
559  this->m_FileComplete_OutputPort[portNum].addCallPort(port);
560  }
561 
564  FwIndexType portNum,
566  )
567  {
568  FW_ASSERT(
569  portNum < this->getNum_bufferSendOut_OutputPorts(),
570  static_cast<FwAssertArgType>(portNum)
571  );
572 
573  this->m_bufferSendOut_OutputPort[portNum].addCallPort(port);
574  }
575 
578  FwIndexType portNum,
579  Svc::InputPingPort* port
580  )
581  {
582  FW_ASSERT(
583  portNum < this->getNum_pingOut_OutputPorts(),
584  static_cast<FwAssertArgType>(portNum)
585  );
586 
587  this->m_pingOut_OutputPort[portNum].addCallPort(port);
588  }
589 
590 #if FW_PORT_SERIALIZATION
591 
592  // ----------------------------------------------------------------------
593  // Connect serial input ports to special output ports
594  // ----------------------------------------------------------------------
595 
598  FwIndexType portNum,
599  Fw::InputSerializePort* port
600  )
601  {
602  FW_ASSERT(
603  portNum < this->getNum_cmdRegOut_OutputPorts(),
604  static_cast<FwAssertArgType>(portNum)
605  );
606 
607  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
608  }
609 
612  FwIndexType portNum,
613  Fw::InputSerializePort* port
614  )
615  {
616  FW_ASSERT(
617  portNum < this->getNum_cmdResponseOut_OutputPorts(),
618  static_cast<FwAssertArgType>(portNum)
619  );
620 
621  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
622  }
623 
626  FwIndexType portNum,
627  Fw::InputSerializePort* port
628  )
629  {
630  FW_ASSERT(
631  portNum < this->getNum_eventOut_OutputPorts(),
632  static_cast<FwAssertArgType>(portNum)
633  );
634 
635  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
636  }
637 
638 #if FW_ENABLE_TEXT_LOGGING == 1
639 
640  void FileDownlinkComponentBase ::
641  set_textEventOut_OutputPort(
642  FwIndexType portNum,
643  Fw::InputSerializePort* port
644  )
645  {
646  FW_ASSERT(
647  portNum < this->getNum_textEventOut_OutputPorts(),
648  static_cast<FwAssertArgType>(portNum)
649  );
650 
651  this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
652  }
653 
654 #endif
655 
658  FwIndexType portNum,
659  Fw::InputSerializePort* port
660  )
661  {
662  FW_ASSERT(
663  portNum < this->getNum_timeCaller_OutputPorts(),
664  static_cast<FwAssertArgType>(portNum)
665  );
666 
667  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
668  }
669 
672  FwIndexType portNum,
673  Fw::InputSerializePort* port
674  )
675  {
676  FW_ASSERT(
677  portNum < this->getNum_tlmOut_OutputPorts(),
678  static_cast<FwAssertArgType>(portNum)
679  );
680 
681  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
682  }
683 
684 #endif
685 
686 #if FW_PORT_SERIALIZATION
687 
688  // ----------------------------------------------------------------------
689  // Connect serial input ports to typed output ports
690  // ----------------------------------------------------------------------
691 
694  FwIndexType portNum,
695  Fw::InputSerializePort* port
696  )
697  {
698  FW_ASSERT(
699  portNum < this->getNum_FileComplete_OutputPorts(),
700  static_cast<FwAssertArgType>(portNum)
701  );
702 
703  this->m_FileComplete_OutputPort[portNum].registerSerialPort(port);
704  }
705 
708  FwIndexType portNum,
709  Fw::InputSerializePort* port
710  )
711  {
712  FW_ASSERT(
713  portNum < this->getNum_bufferSendOut_OutputPorts(),
714  static_cast<FwAssertArgType>(portNum)
715  );
716 
717  this->m_bufferSendOut_OutputPort[portNum].registerSerialPort(port);
718  }
719 
722  FwIndexType portNum,
723  Fw::InputSerializePort* port
724  )
725  {
726  FW_ASSERT(
727  portNum < this->getNum_pingOut_OutputPorts(),
728  static_cast<FwAssertArgType>(portNum)
729  );
730 
731  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
732  }
733 
734 #endif
735 
736  // ----------------------------------------------------------------------
737  // Command registration
738  // ----------------------------------------------------------------------
739 
742  {
743  FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
744 
745  this->m_cmdRegOut_OutputPort[0].invoke(
746  this->getIdBase() + OPCODE_SENDFILE
747  );
748 
749  this->m_cmdRegOut_OutputPort[0].invoke(
750  this->getIdBase() + OPCODE_CANCEL
751  );
752 
753  this->m_cmdRegOut_OutputPort[0].invoke(
754  this->getIdBase() + OPCODE_SENDPARTIAL
755  );
756  }
757 
758  // ----------------------------------------------------------------------
759  // Component construction and destruction
760  // ----------------------------------------------------------------------
761 
763  FileDownlinkComponentBase(const char* compName) :
764  Fw::ActiveComponentBase(compName)
765  {
766 
767  }
768 
771  {
772 
773  }
774 
775  // ----------------------------------------------------------------------
776  // Getters for numbers of special input ports
777  // ----------------------------------------------------------------------
778 
781  {
782  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
783  }
784 
785  // ----------------------------------------------------------------------
786  // Getters for numbers of typed input ports
787  // ----------------------------------------------------------------------
788 
791  {
792  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Run_InputPort));
793  }
794 
797  {
798  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_SendFile_InputPort));
799  }
800 
803  {
804  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferReturn_InputPort));
805  }
806 
809  {
810  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
811  }
812 
813  // ----------------------------------------------------------------------
814  // Getters for numbers of special output ports
815  // ----------------------------------------------------------------------
816 
819  {
820  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
821  }
822 
825  {
826  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
827  }
828 
831  {
832  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
833  }
834 
835 #if FW_ENABLE_TEXT_LOGGING == 1
836 
837  FwIndexType FileDownlinkComponentBase ::
838  getNum_textEventOut_OutputPorts() const
839  {
840  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_textEventOut_OutputPort));
841  }
842 
843 #endif
844 
847  {
848  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
849  }
850 
853  {
854  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
855  }
856 
857  // ----------------------------------------------------------------------
858  // Getters for numbers of typed output ports
859  // ----------------------------------------------------------------------
860 
863  {
864  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_FileComplete_OutputPort));
865  }
866 
869  {
870  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOut_OutputPort));
871  }
872 
875  {
876  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
877  }
878 
879  // ----------------------------------------------------------------------
880  // Connection status queries for special output ports
881  // ----------------------------------------------------------------------
882 
885  {
886  FW_ASSERT(
887  portNum < this->getNum_cmdRegOut_OutputPorts(),
888  static_cast<FwAssertArgType>(portNum)
889  );
890 
891  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
892  }
893 
896  {
897  FW_ASSERT(
898  portNum < this->getNum_cmdResponseOut_OutputPorts(),
899  static_cast<FwAssertArgType>(portNum)
900  );
901 
902  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
903  }
904 
907  {
908  FW_ASSERT(
909  portNum < this->getNum_eventOut_OutputPorts(),
910  static_cast<FwAssertArgType>(portNum)
911  );
912 
913  return this->m_eventOut_OutputPort[portNum].isConnected();
914  }
915 
916 #if FW_ENABLE_TEXT_LOGGING == 1
917 
918  bool FileDownlinkComponentBase ::
919  isConnected_textEventOut_OutputPort(FwIndexType portNum)
920  {
921  FW_ASSERT(
922  portNum < this->getNum_textEventOut_OutputPorts(),
923  static_cast<FwAssertArgType>(portNum)
924  );
925 
926  return this->m_textEventOut_OutputPort[portNum].isConnected();
927  }
928 
929 #endif
930 
933  {
934  FW_ASSERT(
935  portNum < this->getNum_timeCaller_OutputPorts(),
936  static_cast<FwAssertArgType>(portNum)
937  );
938 
939  return this->m_timeCaller_OutputPort[portNum].isConnected();
940  }
941 
944  {
945  FW_ASSERT(
946  portNum < this->getNum_tlmOut_OutputPorts(),
947  static_cast<FwAssertArgType>(portNum)
948  );
949 
950  return this->m_tlmOut_OutputPort[portNum].isConnected();
951  }
952 
953  // ----------------------------------------------------------------------
954  // Connection status queries for typed output ports
955  // ----------------------------------------------------------------------
956 
959  {
960  FW_ASSERT(
961  portNum < this->getNum_FileComplete_OutputPorts(),
962  static_cast<FwAssertArgType>(portNum)
963  );
964 
965  return this->m_FileComplete_OutputPort[portNum].isConnected();
966  }
967 
970  {
971  FW_ASSERT(
972  portNum < this->getNum_bufferSendOut_OutputPorts(),
973  static_cast<FwAssertArgType>(portNum)
974  );
975 
976  return this->m_bufferSendOut_OutputPort[portNum].isConnected();
977  }
978 
981  {
982  FW_ASSERT(
983  portNum < this->getNum_pingOut_OutputPorts(),
984  static_cast<FwAssertArgType>(portNum)
985  );
986 
987  return this->m_pingOut_OutputPort[portNum].isConnected();
988  }
989 
990  // ----------------------------------------------------------------------
991  // Port handler base-class functions for typed input ports
992  //
993  // Call these functions directly to bypass the corresponding ports
994  // ----------------------------------------------------------------------
995 
998  FwIndexType portNum,
999  U32 context
1000  )
1001  {
1002  // Make sure port number is valid
1003  FW_ASSERT(
1004  portNum < this->getNum_Run_InputPorts(),
1005  static_cast<FwAssertArgType>(portNum)
1006  );
1007 
1008  // Call pre-message hook
1010  portNum,
1011  context
1012  );
1013  ComponentIpcSerializableBuffer msg;
1015 
1016  // Serialize message ID
1017  _status = msg.serialize(
1018  static_cast<FwEnumStoreType>(RUN_SCHED)
1019  );
1020  FW_ASSERT(
1021  _status == Fw::FW_SERIALIZE_OK,
1022  static_cast<FwAssertArgType>(_status)
1023  );
1024 
1025  // Serialize port number
1026  _status = msg.serialize(portNum);
1027  FW_ASSERT(
1028  _status == Fw::FW_SERIALIZE_OK,
1029  static_cast<FwAssertArgType>(_status)
1030  );
1031 
1032  // Serialize argument context
1033  _status = msg.serialize(context);
1034  FW_ASSERT(
1035  _status == Fw::FW_SERIALIZE_OK,
1036  static_cast<FwAssertArgType>(_status)
1037  );
1038 
1039  // Send message
1041  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1042 
1043  FW_ASSERT(
1044  qStatus == Os::Queue::OP_OK,
1045  static_cast<FwAssertArgType>(qStatus)
1046  );
1047  }
1048 
1051  FwIndexType portNum,
1052  const Fw::StringBase& sourceFileName,
1053  const Fw::StringBase& destFileName,
1054  U32 offset,
1055  U32 length
1056  )
1057  {
1058  // Make sure port number is valid
1059  FW_ASSERT(
1060  portNum < this->getNum_SendFile_InputPorts(),
1061  static_cast<FwAssertArgType>(portNum)
1062  );
1063 
1064  Svc::SendFileResponse retVal;
1065 
1066  // Lock guard mutex before calling
1067  this->lock();
1068 
1069  // Call handler function
1070  retVal = this->SendFile_handler(
1071  portNum,
1072  sourceFileName,
1073  destFileName,
1074  offset,
1075  length
1076  );
1077 
1078  // Unlock guard mutex
1079  this->unLock();
1080 
1081  return retVal;
1082  }
1083 
1086  FwIndexType portNum,
1087  Fw::Buffer& fwBuffer
1088  )
1089  {
1090  // Make sure port number is valid
1091  FW_ASSERT(
1092  portNum < this->getNum_bufferReturn_InputPorts(),
1093  static_cast<FwAssertArgType>(portNum)
1094  );
1095 
1096  // Call pre-message hook
1098  portNum,
1099  fwBuffer
1100  );
1101  ComponentIpcSerializableBuffer msg;
1103 
1104  // Serialize message ID
1105  _status = msg.serialize(
1106  static_cast<FwEnumStoreType>(BUFFERRETURN_BUFFERSEND)
1107  );
1108  FW_ASSERT(
1109  _status == Fw::FW_SERIALIZE_OK,
1110  static_cast<FwAssertArgType>(_status)
1111  );
1112 
1113  // Serialize port number
1114  _status = msg.serialize(portNum);
1115  FW_ASSERT(
1116  _status == Fw::FW_SERIALIZE_OK,
1117  static_cast<FwAssertArgType>(_status)
1118  );
1119 
1120  // Serialize argument fwBuffer
1121  _status = msg.serialize(fwBuffer);
1122  FW_ASSERT(
1123  _status == Fw::FW_SERIALIZE_OK,
1124  static_cast<FwAssertArgType>(_status)
1125  );
1126 
1127  // Send message
1129  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1130 
1131  FW_ASSERT(
1132  qStatus == Os::Queue::OP_OK,
1133  static_cast<FwAssertArgType>(qStatus)
1134  );
1135  }
1136 
1139  FwIndexType portNum,
1140  U32 key
1141  )
1142  {
1143  // Make sure port number is valid
1144  FW_ASSERT(
1145  portNum < this->getNum_pingIn_InputPorts(),
1146  static_cast<FwAssertArgType>(portNum)
1147  );
1148 
1149  // Call pre-message hook
1151  portNum,
1152  key
1153  );
1154  ComponentIpcSerializableBuffer msg;
1156 
1157  // Serialize message ID
1158  _status = msg.serialize(
1159  static_cast<FwEnumStoreType>(PINGIN_PING)
1160  );
1161  FW_ASSERT(
1162  _status == Fw::FW_SERIALIZE_OK,
1163  static_cast<FwAssertArgType>(_status)
1164  );
1165 
1166  // Serialize port number
1167  _status = msg.serialize(portNum);
1168  FW_ASSERT(
1169  _status == Fw::FW_SERIALIZE_OK,
1170  static_cast<FwAssertArgType>(_status)
1171  );
1172 
1173  // Serialize argument key
1174  _status = msg.serialize(key);
1175  FW_ASSERT(
1176  _status == Fw::FW_SERIALIZE_OK,
1177  static_cast<FwAssertArgType>(_status)
1178  );
1179 
1180  // Send message
1182  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1183 
1184  FW_ASSERT(
1185  qStatus == Os::Queue::OP_OK,
1186  static_cast<FwAssertArgType>(qStatus)
1187  );
1188  }
1189 
1190  // ----------------------------------------------------------------------
1191  // Pre-message hooks for typed async input ports
1192  //
1193  // Each of these functions is invoked just before processing a message
1194  // on the corresponding port. By default, they do nothing. You can
1195  // override them to provide specific pre-message behavior.
1196  // ----------------------------------------------------------------------
1197 
1200  FwIndexType portNum,
1201  U32 context
1202  )
1203  {
1204  // Default: no-op
1205  }
1206 
1209  FwIndexType portNum,
1210  Fw::Buffer& fwBuffer
1211  )
1212  {
1213  // Default: no-op
1214  }
1215 
1218  FwIndexType portNum,
1219  U32 key
1220  )
1221  {
1222  // Default: no-op
1223  }
1224 
1225  // ----------------------------------------------------------------------
1226  // Invocation functions for typed output ports
1227  // ----------------------------------------------------------------------
1228 
1231  FwIndexType portNum,
1232  const Svc::SendFileResponse& resp
1233  )
1234  {
1235  FW_ASSERT(
1236  portNum < this->getNum_FileComplete_OutputPorts(),
1237  static_cast<FwAssertArgType>(portNum)
1238  );
1239 
1240  FW_ASSERT(
1241  this->m_FileComplete_OutputPort[portNum].isConnected(),
1242  static_cast<FwAssertArgType>(portNum)
1243  );
1244  this->m_FileComplete_OutputPort[portNum].invoke(
1245  resp
1246  );
1247  }
1248 
1251  FwIndexType portNum,
1252  Fw::Buffer& fwBuffer
1253  )
1254  {
1255  FW_ASSERT(
1256  portNum < this->getNum_bufferSendOut_OutputPorts(),
1257  static_cast<FwAssertArgType>(portNum)
1258  );
1259 
1260  FW_ASSERT(
1261  this->m_bufferSendOut_OutputPort[portNum].isConnected(),
1262  static_cast<FwAssertArgType>(portNum)
1263  );
1264  this->m_bufferSendOut_OutputPort[portNum].invoke(
1265  fwBuffer
1266  );
1267  }
1268 
1271  FwIndexType portNum,
1272  U32 key
1273  )
1274  {
1275  FW_ASSERT(
1276  portNum < this->getNum_pingOut_OutputPorts(),
1277  static_cast<FwAssertArgType>(portNum)
1278  );
1279 
1280  FW_ASSERT(
1281  this->m_pingOut_OutputPort[portNum].isConnected(),
1282  static_cast<FwAssertArgType>(portNum)
1283  );
1284  this->m_pingOut_OutputPort[portNum].invoke(
1285  key
1286  );
1287  }
1288 
1289  // ----------------------------------------------------------------------
1290  // Command response
1291  // ----------------------------------------------------------------------
1292 
1295  FwOpcodeType opCode,
1296  U32 cmdSeq,
1297  Fw::CmdResponse response
1298  )
1299  {
1300  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1301  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1302  }
1303 
1304  // ----------------------------------------------------------------------
1305  // Command handler base-class functions
1306  //
1307  // Call these functions directly to bypass the command input port
1308  // ----------------------------------------------------------------------
1309 
1312  FwOpcodeType opCode,
1313  U32 cmdSeq,
1314  Fw::CmdArgBuffer& args
1315  )
1316  {
1317  // Call pre-message hook
1318  this->SendFile_preMsgHook(opCode,cmdSeq);
1319 
1320  // Defer deserializing arguments to the message dispatcher
1321  // to avoid deserializing and reserializing just for IPC
1322  ComponentIpcSerializableBuffer msg;
1324 
1325  // Serialize for IPC
1326  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_SENDFILE));
1327  FW_ASSERT (
1328  _status == Fw::FW_SERIALIZE_OK,
1329  static_cast<FwAssertArgType>(_status)
1330  );
1331 
1332  // Fake port number to make message dequeue work
1333  FwIndexType port = 0;
1334 
1335  _status = msg.serialize(port);
1336  FW_ASSERT (
1337  _status == Fw::FW_SERIALIZE_OK,
1338  static_cast<FwAssertArgType>(_status)
1339  );
1340 
1341  _status = msg.serialize(opCode);
1342  FW_ASSERT (
1343  _status == Fw::FW_SERIALIZE_OK,
1344  static_cast<FwAssertArgType>(_status)
1345  );
1346 
1347  _status = msg.serialize(cmdSeq);
1348  FW_ASSERT (
1349  _status == Fw::FW_SERIALIZE_OK,
1350  static_cast<FwAssertArgType>(_status)
1351  );
1352 
1353  _status = msg.serialize(args);
1354  FW_ASSERT (
1355  _status == Fw::FW_SERIALIZE_OK,
1356  static_cast<FwAssertArgType>(_status)
1357  );
1358 
1359  // Send message
1361  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1362 
1363  FW_ASSERT(
1364  qStatus == Os::Queue::OP_OK,
1365  static_cast<FwAssertArgType>(qStatus)
1366  );
1367  }
1368 
1371  FwOpcodeType opCode,
1372  U32 cmdSeq,
1373  Fw::CmdArgBuffer& args
1374  )
1375  {
1376  // Call pre-message hook
1377  this->Cancel_preMsgHook(opCode,cmdSeq);
1378 
1379  // Defer deserializing arguments to the message dispatcher
1380  // to avoid deserializing and reserializing just for IPC
1381  ComponentIpcSerializableBuffer msg;
1383 
1384  // Serialize for IPC
1385  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_CANCEL));
1386  FW_ASSERT (
1387  _status == Fw::FW_SERIALIZE_OK,
1388  static_cast<FwAssertArgType>(_status)
1389  );
1390 
1391  // Fake port number to make message dequeue work
1392  FwIndexType port = 0;
1393 
1394  _status = msg.serialize(port);
1395  FW_ASSERT (
1396  _status == Fw::FW_SERIALIZE_OK,
1397  static_cast<FwAssertArgType>(_status)
1398  );
1399 
1400  _status = msg.serialize(opCode);
1401  FW_ASSERT (
1402  _status == Fw::FW_SERIALIZE_OK,
1403  static_cast<FwAssertArgType>(_status)
1404  );
1405 
1406  _status = msg.serialize(cmdSeq);
1407  FW_ASSERT (
1408  _status == Fw::FW_SERIALIZE_OK,
1409  static_cast<FwAssertArgType>(_status)
1410  );
1411 
1412  _status = msg.serialize(args);
1413  FW_ASSERT (
1414  _status == Fw::FW_SERIALIZE_OK,
1415  static_cast<FwAssertArgType>(_status)
1416  );
1417 
1418  // Send message
1420  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1421 
1422  FW_ASSERT(
1423  qStatus == Os::Queue::OP_OK,
1424  static_cast<FwAssertArgType>(qStatus)
1425  );
1426  }
1427 
1430  FwOpcodeType opCode,
1431  U32 cmdSeq,
1432  Fw::CmdArgBuffer& args
1433  )
1434  {
1435  // Call pre-message hook
1436  this->SendPartial_preMsgHook(opCode,cmdSeq);
1437 
1438  // Defer deserializing arguments to the message dispatcher
1439  // to avoid deserializing and reserializing just for IPC
1440  ComponentIpcSerializableBuffer msg;
1442 
1443  // Serialize for IPC
1444  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_SENDPARTIAL));
1445  FW_ASSERT (
1446  _status == Fw::FW_SERIALIZE_OK,
1447  static_cast<FwAssertArgType>(_status)
1448  );
1449 
1450  // Fake port number to make message dequeue work
1451  FwIndexType port = 0;
1452 
1453  _status = msg.serialize(port);
1454  FW_ASSERT (
1455  _status == Fw::FW_SERIALIZE_OK,
1456  static_cast<FwAssertArgType>(_status)
1457  );
1458 
1459  _status = msg.serialize(opCode);
1460  FW_ASSERT (
1461  _status == Fw::FW_SERIALIZE_OK,
1462  static_cast<FwAssertArgType>(_status)
1463  );
1464 
1465  _status = msg.serialize(cmdSeq);
1466  FW_ASSERT (
1467  _status == Fw::FW_SERIALIZE_OK,
1468  static_cast<FwAssertArgType>(_status)
1469  );
1470 
1471  _status = msg.serialize(args);
1472  FW_ASSERT (
1473  _status == Fw::FW_SERIALIZE_OK,
1474  static_cast<FwAssertArgType>(_status)
1475  );
1476 
1477  // Send message
1479  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1480 
1481  FW_ASSERT(
1482  qStatus == Os::Queue::OP_OK,
1483  static_cast<FwAssertArgType>(qStatus)
1484  );
1485  }
1486 
1487  // ----------------------------------------------------------------------
1488  // Pre-message hooks for async commands
1489  //
1490  // Each of these functions is invoked just before processing the
1491  // corresponding command. By default they do nothing. You can
1492  // override them to provide specific pre-command behavior.
1493  // ----------------------------------------------------------------------
1494 
1497  FwOpcodeType opCode,
1498  U32 cmdSeq
1499  )
1500  {
1501  // Defaults to no-op; can be overridden
1502  (void) opCode;
1503  (void) cmdSeq;
1504  }
1505 
1508  FwOpcodeType opCode,
1509  U32 cmdSeq
1510  )
1511  {
1512  // Defaults to no-op; can be overridden
1513  (void) opCode;
1514  (void) cmdSeq;
1515  }
1516 
1519  FwOpcodeType opCode,
1520  U32 cmdSeq
1521  )
1522  {
1523  // Defaults to no-op; can be overridden
1524  (void) opCode;
1525  (void) cmdSeq;
1526  }
1527 
1528  // ----------------------------------------------------------------------
1529  // Event logging functions
1530  // ----------------------------------------------------------------------
1531 
1534  {
1535  // Get the time
1536  Fw::Time _logTime;
1537  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1538  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1539  }
1540 
1541  FwEventIdType _id = static_cast<FwEventIdType>(0);
1542 
1543  _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1544 
1545  // Emit the event on the log port
1546  if (this->m_eventOut_OutputPort[0].isConnected()) {
1547  Fw::LogBuffer _logBuff;
1549 
1550 #if FW_AMPCS_COMPATIBLE
1551  // Serialize the number of arguments
1552  _status = _logBuff.serialize(static_cast<U8>(1));
1553  FW_ASSERT(
1554  _status == Fw::FW_SERIALIZE_OK,
1555  static_cast<FwAssertArgType>(_status)
1556  );
1557 #endif
1558 
1559  _status = fileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1560  FW_ASSERT(
1561  _status == Fw::FW_SERIALIZE_OK,
1562  static_cast<FwAssertArgType>(_status)
1563  );
1564 
1565  this->m_eventOut_OutputPort[0].invoke(
1566  _id,
1567  _logTime,
1569  _logBuff
1570  );
1571  }
1572 
1573  // Emit the event on the text log port
1574 #if FW_ENABLE_TEXT_LOGGING
1575  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1576 #if FW_OBJECT_NAMES == 1
1577  const char* _formatString =
1578  "(%s) %s: Could not open file %s";
1579 #else
1580  const char* _formatString =
1581  "%s: Could not open file %s";
1582 #endif
1583 
1584  Fw::TextLogString _logString;
1585  _logString.format(
1586  _formatString,
1587 #if FW_OBJECT_NAMES == 1
1588  this->m_objName.toChar(),
1589 #endif
1590  "FileOpenError ",
1591  fileName.toChar()
1592  );
1593 
1594  this->m_textEventOut_OutputPort[0].invoke(
1595  _id,
1596  _logTime,
1598  _logString
1599  );
1600  }
1601 #endif
1602  }
1603 
1606  const Fw::StringBase& fileName,
1607  I32 status
1608  ) const
1609  {
1610  // Get the time
1611  Fw::Time _logTime;
1612  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1613  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1614  }
1615 
1616  FwEventIdType _id = static_cast<FwEventIdType>(0);
1617 
1618  _id = this->getIdBase() + EVENTID_FILEREADERROR;
1619 
1620  // Emit the event on the log port
1621  if (this->m_eventOut_OutputPort[0].isConnected()) {
1622  Fw::LogBuffer _logBuff;
1624 
1625 #if FW_AMPCS_COMPATIBLE
1626  // Serialize the number of arguments
1627  _status = _logBuff.serialize(static_cast<U8>(2));
1628  FW_ASSERT(
1629  _status == Fw::FW_SERIALIZE_OK,
1630  static_cast<FwAssertArgType>(_status)
1631  );
1632 #endif
1633 
1634  _status = fileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1635  FW_ASSERT(
1636  _status == Fw::FW_SERIALIZE_OK,
1637  static_cast<FwAssertArgType>(_status)
1638  );
1639 
1640 #if FW_AMPCS_COMPATIBLE
1641  // Serialize the argument size
1642  _status = _logBuff.serialize(
1643  static_cast<U8>(sizeof(I32))
1644  );
1645  FW_ASSERT(
1646  _status == Fw::FW_SERIALIZE_OK,
1647  static_cast<FwAssertArgType>(_status)
1648  );
1649 #endif
1650  _status = _logBuff.serialize(status);
1651  FW_ASSERT(
1652  _status == Fw::FW_SERIALIZE_OK,
1653  static_cast<FwAssertArgType>(_status)
1654  );
1655 
1656  this->m_eventOut_OutputPort[0].invoke(
1657  _id,
1658  _logTime,
1660  _logBuff
1661  );
1662  }
1663 
1664  // Emit the event on the text log port
1665 #if FW_ENABLE_TEXT_LOGGING
1666  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1667 #if FW_OBJECT_NAMES == 1
1668  const char* _formatString =
1669  "(%s) %s: Could not read file %s with status %" PRIi32 "";
1670 #else
1671  const char* _formatString =
1672  "%s: Could not read file %s with status %" PRIi32 "";
1673 #endif
1674 
1675  Fw::TextLogString _logString;
1676  _logString.format(
1677  _formatString,
1678 #if FW_OBJECT_NAMES == 1
1679  this->m_objName.toChar(),
1680 #endif
1681  "FileReadError ",
1682  fileName.toChar(),
1683  status
1684  );
1685 
1686  this->m_textEventOut_OutputPort[0].invoke(
1687  _id,
1688  _logTime,
1690  _logString
1691  );
1692  }
1693 #endif
1694  }
1695 
1698  const Fw::StringBase& sourceFileName,
1699  const Fw::StringBase& destFileName
1700  ) const
1701  {
1702  // Get the time
1703  Fw::Time _logTime;
1704  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1705  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1706  }
1707 
1708  FwEventIdType _id = static_cast<FwEventIdType>(0);
1709 
1710  _id = this->getIdBase() + EVENTID_FILESENT;
1711 
1712  // Emit the event on the log port
1713  if (this->m_eventOut_OutputPort[0].isConnected()) {
1714  Fw::LogBuffer _logBuff;
1716 
1717 #if FW_AMPCS_COMPATIBLE
1718  // Serialize the number of arguments
1719  _status = _logBuff.serialize(static_cast<U8>(2));
1720  FW_ASSERT(
1721  _status == Fw::FW_SERIALIZE_OK,
1722  static_cast<FwAssertArgType>(_status)
1723  );
1724 #endif
1725 
1726  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1727  FW_ASSERT(
1728  _status == Fw::FW_SERIALIZE_OK,
1729  static_cast<FwAssertArgType>(_status)
1730  );
1731 
1732  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1733  FW_ASSERT(
1734  _status == Fw::FW_SERIALIZE_OK,
1735  static_cast<FwAssertArgType>(_status)
1736  );
1737 
1738  this->m_eventOut_OutputPort[0].invoke(
1739  _id,
1740  _logTime,
1742  _logBuff
1743  );
1744  }
1745 
1746  // Emit the event on the text log port
1747 #if FW_ENABLE_TEXT_LOGGING
1748  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1749 #if FW_OBJECT_NAMES == 1
1750  const char* _formatString =
1751  "(%s) %s: Sent file %s to file %s";
1752 #else
1753  const char* _formatString =
1754  "%s: Sent file %s to file %s";
1755 #endif
1756 
1757  Fw::TextLogString _logString;
1758  _logString.format(
1759  _formatString,
1760 #if FW_OBJECT_NAMES == 1
1761  this->m_objName.toChar(),
1762 #endif
1763  "FileSent ",
1764  sourceFileName.toChar(),
1765  destFileName.toChar()
1766  );
1767 
1768  this->m_textEventOut_OutputPort[0].invoke(
1769  _id,
1770  _logTime,
1772  _logString
1773  );
1774  }
1775 #endif
1776  }
1777 
1780  const Fw::StringBase& sourceFileName,
1781  const Fw::StringBase& destFileName
1782  ) const
1783  {
1784  // Get the time
1785  Fw::Time _logTime;
1786  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1787  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1788  }
1789 
1790  FwEventIdType _id = static_cast<FwEventIdType>(0);
1791 
1792  _id = this->getIdBase() + EVENTID_DOWNLINKCANCELED;
1793 
1794  // Emit the event on the log port
1795  if (this->m_eventOut_OutputPort[0].isConnected()) {
1796  Fw::LogBuffer _logBuff;
1798 
1799 #if FW_AMPCS_COMPATIBLE
1800  // Serialize the number of arguments
1801  _status = _logBuff.serialize(static_cast<U8>(2));
1802  FW_ASSERT(
1803  _status == Fw::FW_SERIALIZE_OK,
1804  static_cast<FwAssertArgType>(_status)
1805  );
1806 #endif
1807 
1808  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1809  FW_ASSERT(
1810  _status == Fw::FW_SERIALIZE_OK,
1811  static_cast<FwAssertArgType>(_status)
1812  );
1813 
1814  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1815  FW_ASSERT(
1816  _status == Fw::FW_SERIALIZE_OK,
1817  static_cast<FwAssertArgType>(_status)
1818  );
1819 
1820  this->m_eventOut_OutputPort[0].invoke(
1821  _id,
1822  _logTime,
1824  _logBuff
1825  );
1826  }
1827 
1828  // Emit the event on the text log port
1829 #if FW_ENABLE_TEXT_LOGGING
1830  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1831 #if FW_OBJECT_NAMES == 1
1832  const char* _formatString =
1833  "(%s) %s: Canceled downlink of file %s to file %s";
1834 #else
1835  const char* _formatString =
1836  "%s: Canceled downlink of file %s to file %s";
1837 #endif
1838 
1839  Fw::TextLogString _logString;
1840  _logString.format(
1841  _formatString,
1842 #if FW_OBJECT_NAMES == 1
1843  this->m_objName.toChar(),
1844 #endif
1845  "DownlinkCanceled ",
1846  sourceFileName.toChar(),
1847  destFileName.toChar()
1848  );
1849 
1850  this->m_textEventOut_OutputPort[0].invoke(
1851  _id,
1852  _logTime,
1854  _logString
1855  );
1856  }
1857 #endif
1858  }
1859 
1862  const Fw::StringBase& sourceFileName,
1863  const Fw::StringBase& destFileName
1864  ) const
1865  {
1866  // Get the time
1867  Fw::Time _logTime;
1868  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1869  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1870  }
1871 
1872  FwEventIdType _id = static_cast<FwEventIdType>(0);
1873 
1874  _id = this->getIdBase() + EVENTID_DOWNLINKTIMEOUT;
1875 
1876  // Emit the event on the log port
1877  if (this->m_eventOut_OutputPort[0].isConnected()) {
1878  Fw::LogBuffer _logBuff;
1880 
1881 #if FW_AMPCS_COMPATIBLE
1882  // Serialize the number of arguments
1883  _status = _logBuff.serialize(static_cast<U8>(2));
1884  FW_ASSERT(
1885  _status == Fw::FW_SERIALIZE_OK,
1886  static_cast<FwAssertArgType>(_status)
1887  );
1888 #endif
1889 
1890  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1891  FW_ASSERT(
1892  _status == Fw::FW_SERIALIZE_OK,
1893  static_cast<FwAssertArgType>(_status)
1894  );
1895 
1896  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1897  FW_ASSERT(
1898  _status == Fw::FW_SERIALIZE_OK,
1899  static_cast<FwAssertArgType>(_status)
1900  );
1901 
1902  this->m_eventOut_OutputPort[0].invoke(
1903  _id,
1904  _logTime,
1906  _logBuff
1907  );
1908  }
1909 
1910  // Emit the event on the text log port
1911 #if FW_ENABLE_TEXT_LOGGING
1912  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1913 #if FW_OBJECT_NAMES == 1
1914  const char* _formatString =
1915  "(%s) %s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
1916 #else
1917  const char* _formatString =
1918  "%s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
1919 #endif
1920 
1921  Fw::TextLogString _logString;
1922  _logString.format(
1923  _formatString,
1924 #if FW_OBJECT_NAMES == 1
1925  this->m_objName.toChar(),
1926 #endif
1927  "DownlinkTimeout ",
1928  sourceFileName.toChar(),
1929  destFileName.toChar()
1930  );
1931 
1932  this->m_textEventOut_OutputPort[0].invoke(
1933  _id,
1934  _logTime,
1936  _logString
1937  );
1938  }
1939 #endif
1940  }
1941 
1944  U32 startOffset,
1945  U32 length,
1946  U32 filesize,
1947  const Fw::StringBase& sourceFileName,
1948  const Fw::StringBase& destFileName
1949  ) const
1950  {
1951  // Get the time
1952  Fw::Time _logTime;
1953  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1954  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1955  }
1956 
1957  FwEventIdType _id = static_cast<FwEventIdType>(0);
1958 
1959  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALWARNING;
1960 
1961  // Emit the event on the log port
1962  if (this->m_eventOut_OutputPort[0].isConnected()) {
1963  Fw::LogBuffer _logBuff;
1965 
1966 #if FW_AMPCS_COMPATIBLE
1967  // Serialize the number of arguments
1968  _status = _logBuff.serialize(static_cast<U8>(5));
1969  FW_ASSERT(
1970  _status == Fw::FW_SERIALIZE_OK,
1971  static_cast<FwAssertArgType>(_status)
1972  );
1973 #endif
1974 
1975 #if FW_AMPCS_COMPATIBLE
1976  // Serialize the argument size
1977  _status = _logBuff.serialize(
1978  static_cast<U8>(sizeof(U32))
1979  );
1980  FW_ASSERT(
1981  _status == Fw::FW_SERIALIZE_OK,
1982  static_cast<FwAssertArgType>(_status)
1983  );
1984 #endif
1985  _status = _logBuff.serialize(startOffset);
1986  FW_ASSERT(
1987  _status == Fw::FW_SERIALIZE_OK,
1988  static_cast<FwAssertArgType>(_status)
1989  );
1990 
1991 #if FW_AMPCS_COMPATIBLE
1992  // Serialize the argument size
1993  _status = _logBuff.serialize(
1994  static_cast<U8>(sizeof(U32))
1995  );
1996  FW_ASSERT(
1997  _status == Fw::FW_SERIALIZE_OK,
1998  static_cast<FwAssertArgType>(_status)
1999  );
2000 #endif
2001  _status = _logBuff.serialize(length);
2002  FW_ASSERT(
2003  _status == Fw::FW_SERIALIZE_OK,
2004  static_cast<FwAssertArgType>(_status)
2005  );
2006 
2007 #if FW_AMPCS_COMPATIBLE
2008  // Serialize the argument size
2009  _status = _logBuff.serialize(
2010  static_cast<U8>(sizeof(U32))
2011  );
2012  FW_ASSERT(
2013  _status == Fw::FW_SERIALIZE_OK,
2014  static_cast<FwAssertArgType>(_status)
2015  );
2016 #endif
2017  _status = _logBuff.serialize(filesize);
2018  FW_ASSERT(
2019  _status == Fw::FW_SERIALIZE_OK,
2020  static_cast<FwAssertArgType>(_status)
2021  );
2022 
2023  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2024  FW_ASSERT(
2025  _status == Fw::FW_SERIALIZE_OK,
2026  static_cast<FwAssertArgType>(_status)
2027  );
2028 
2029  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2030  FW_ASSERT(
2031  _status == Fw::FW_SERIALIZE_OK,
2032  static_cast<FwAssertArgType>(_status)
2033  );
2034 
2035  this->m_eventOut_OutputPort[0].invoke(
2036  _id,
2037  _logTime,
2039  _logBuff
2040  );
2041  }
2042 
2043  // Emit the event on the text log port
2044 #if FW_ENABLE_TEXT_LOGGING
2045  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2046 #if FW_OBJECT_NAMES == 1
2047  const char* _formatString =
2048  "(%s) %s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
2049 #else
2050  const char* _formatString =
2051  "%s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
2052 #endif
2053 
2054  Fw::TextLogString _logString;
2055  _logString.format(
2056  _formatString,
2057 #if FW_OBJECT_NAMES == 1
2058  this->m_objName.toChar(),
2059 #endif
2060  "DownlinkPartialWarning ",
2061  startOffset,
2062  length,
2063  filesize,
2064  sourceFileName.toChar(),
2065  destFileName.toChar()
2066  );
2067 
2068  this->m_textEventOut_OutputPort[0].invoke(
2069  _id,
2070  _logTime,
2072  _logString
2073  );
2074  }
2075 #endif
2076  }
2077 
2080  const Fw::StringBase& sourceFileName,
2081  const Fw::StringBase& destFileName,
2082  U32 startOffset,
2083  U32 filesize
2084  ) const
2085  {
2086  // Get the time
2087  Fw::Time _logTime;
2088  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2089  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2090  }
2091 
2092  FwEventIdType _id = static_cast<FwEventIdType>(0);
2093 
2094  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALFAIL;
2095 
2096  // Emit the event on the log port
2097  if (this->m_eventOut_OutputPort[0].isConnected()) {
2098  Fw::LogBuffer _logBuff;
2100 
2101 #if FW_AMPCS_COMPATIBLE
2102  // Serialize the number of arguments
2103  _status = _logBuff.serialize(static_cast<U8>(4));
2104  FW_ASSERT(
2105  _status == Fw::FW_SERIALIZE_OK,
2106  static_cast<FwAssertArgType>(_status)
2107  );
2108 #endif
2109 
2110  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2111  FW_ASSERT(
2112  _status == Fw::FW_SERIALIZE_OK,
2113  static_cast<FwAssertArgType>(_status)
2114  );
2115 
2116  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2117  FW_ASSERT(
2118  _status == Fw::FW_SERIALIZE_OK,
2119  static_cast<FwAssertArgType>(_status)
2120  );
2121 
2122 #if FW_AMPCS_COMPATIBLE
2123  // Serialize the argument size
2124  _status = _logBuff.serialize(
2125  static_cast<U8>(sizeof(U32))
2126  );
2127  FW_ASSERT(
2128  _status == Fw::FW_SERIALIZE_OK,
2129  static_cast<FwAssertArgType>(_status)
2130  );
2131 #endif
2132  _status = _logBuff.serialize(startOffset);
2133  FW_ASSERT(
2134  _status == Fw::FW_SERIALIZE_OK,
2135  static_cast<FwAssertArgType>(_status)
2136  );
2137 
2138 #if FW_AMPCS_COMPATIBLE
2139  // Serialize the argument size
2140  _status = _logBuff.serialize(
2141  static_cast<U8>(sizeof(U32))
2142  );
2143  FW_ASSERT(
2144  _status == Fw::FW_SERIALIZE_OK,
2145  static_cast<FwAssertArgType>(_status)
2146  );
2147 #endif
2148  _status = _logBuff.serialize(filesize);
2149  FW_ASSERT(
2150  _status == Fw::FW_SERIALIZE_OK,
2151  static_cast<FwAssertArgType>(_status)
2152  );
2153 
2154  this->m_eventOut_OutputPort[0].invoke(
2155  _id,
2156  _logTime,
2158  _logBuff
2159  );
2160  }
2161 
2162  // Emit the event on the text log port
2163 #if FW_ENABLE_TEXT_LOGGING
2164  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2165 #if FW_OBJECT_NAMES == 1
2166  const char* _formatString =
2167  "(%s) %s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2168 #else
2169  const char* _formatString =
2170  "%s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2171 #endif
2172 
2173  Fw::TextLogString _logString;
2174  _logString.format(
2175  _formatString,
2176 #if FW_OBJECT_NAMES == 1
2177  this->m_objName.toChar(),
2178 #endif
2179  "DownlinkPartialFail ",
2180  sourceFileName.toChar(),
2181  destFileName.toChar(),
2182  startOffset,
2183  filesize
2184  );
2185 
2186  this->m_textEventOut_OutputPort[0].invoke(
2187  _id,
2188  _logTime,
2190  _logString
2191  );
2192  }
2193 #endif
2194  }
2195 
2198  const Fw::StringBase& sourceFileName,
2199  U32 byteOffset
2200  ) const
2201  {
2202  // Get the time
2203  Fw::Time _logTime;
2204  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2205  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2206  }
2207 
2208  FwEventIdType _id = static_cast<FwEventIdType>(0);
2209 
2210  _id = this->getIdBase() + EVENTID_SENDDATAFAIL;
2211 
2212  // Emit the event on the log port
2213  if (this->m_eventOut_OutputPort[0].isConnected()) {
2214  Fw::LogBuffer _logBuff;
2216 
2217 #if FW_AMPCS_COMPATIBLE
2218  // Serialize the number of arguments
2219  _status = _logBuff.serialize(static_cast<U8>(2));
2220  FW_ASSERT(
2221  _status == Fw::FW_SERIALIZE_OK,
2222  static_cast<FwAssertArgType>(_status)
2223  );
2224 #endif
2225 
2226  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2227  FW_ASSERT(
2228  _status == Fw::FW_SERIALIZE_OK,
2229  static_cast<FwAssertArgType>(_status)
2230  );
2231 
2232 #if FW_AMPCS_COMPATIBLE
2233  // Serialize the argument size
2234  _status = _logBuff.serialize(
2235  static_cast<U8>(sizeof(U32))
2236  );
2237  FW_ASSERT(
2238  _status == Fw::FW_SERIALIZE_OK,
2239  static_cast<FwAssertArgType>(_status)
2240  );
2241 #endif
2242  _status = _logBuff.serialize(byteOffset);
2243  FW_ASSERT(
2244  _status == Fw::FW_SERIALIZE_OK,
2245  static_cast<FwAssertArgType>(_status)
2246  );
2247 
2248  this->m_eventOut_OutputPort[0].invoke(
2249  _id,
2250  _logTime,
2252  _logBuff
2253  );
2254  }
2255 
2256  // Emit the event on the text log port
2257 #if FW_ENABLE_TEXT_LOGGING
2258  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2259 #if FW_OBJECT_NAMES == 1
2260  const char* _formatString =
2261  "(%s) %s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2262 #else
2263  const char* _formatString =
2264  "%s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2265 #endif
2266 
2267  Fw::TextLogString _logString;
2268  _logString.format(
2269  _formatString,
2270 #if FW_OBJECT_NAMES == 1
2271  this->m_objName.toChar(),
2272 #endif
2273  "SendDataFail ",
2274  sourceFileName.toChar(),
2275  byteOffset
2276  );
2277 
2278  this->m_textEventOut_OutputPort[0].invoke(
2279  _id,
2280  _logTime,
2282  _logString
2283  );
2284  }
2285 #endif
2286  }
2287 
2290  U32 fileSize,
2291  const Fw::StringBase& sourceFileName,
2292  const Fw::StringBase& destFileName
2293  ) const
2294  {
2295  // Get the time
2296  Fw::Time _logTime;
2297  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2298  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2299  }
2300 
2301  FwEventIdType _id = static_cast<FwEventIdType>(0);
2302 
2303  _id = this->getIdBase() + EVENTID_SENDSTARTED;
2304 
2305  // Emit the event on the log port
2306  if (this->m_eventOut_OutputPort[0].isConnected()) {
2307  Fw::LogBuffer _logBuff;
2309 
2310 #if FW_AMPCS_COMPATIBLE
2311  // Serialize the number of arguments
2312  _status = _logBuff.serialize(static_cast<U8>(3));
2313  FW_ASSERT(
2314  _status == Fw::FW_SERIALIZE_OK,
2315  static_cast<FwAssertArgType>(_status)
2316  );
2317 #endif
2318 
2319 #if FW_AMPCS_COMPATIBLE
2320  // Serialize the argument size
2321  _status = _logBuff.serialize(
2322  static_cast<U8>(sizeof(U32))
2323  );
2324  FW_ASSERT(
2325  _status == Fw::FW_SERIALIZE_OK,
2326  static_cast<FwAssertArgType>(_status)
2327  );
2328 #endif
2329  _status = _logBuff.serialize(fileSize);
2330  FW_ASSERT(
2331  _status == Fw::FW_SERIALIZE_OK,
2332  static_cast<FwAssertArgType>(_status)
2333  );
2334 
2335  _status = sourceFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2336  FW_ASSERT(
2337  _status == Fw::FW_SERIALIZE_OK,
2338  static_cast<FwAssertArgType>(_status)
2339  );
2340 
2341  _status = destFileName.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2342  FW_ASSERT(
2343  _status == Fw::FW_SERIALIZE_OK,
2344  static_cast<FwAssertArgType>(_status)
2345  );
2346 
2347  this->m_eventOut_OutputPort[0].invoke(
2348  _id,
2349  _logTime,
2351  _logBuff
2352  );
2353  }
2354 
2355  // Emit the event on the text log port
2356 #if FW_ENABLE_TEXT_LOGGING
2357  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2358 #if FW_OBJECT_NAMES == 1
2359  const char* _formatString =
2360  "(%s) %s: Downlink of %" PRIu32 " bytes started from %s to %s";
2361 #else
2362  const char* _formatString =
2363  "%s: Downlink of %" PRIu32 " bytes started from %s to %s";
2364 #endif
2365 
2366  Fw::TextLogString _logString;
2367  _logString.format(
2368  _formatString,
2369 #if FW_OBJECT_NAMES == 1
2370  this->m_objName.toChar(),
2371 #endif
2372  "SendStarted ",
2373  fileSize,
2374  sourceFileName.toChar(),
2375  destFileName.toChar()
2376  );
2377 
2378  this->m_textEventOut_OutputPort[0].invoke(
2379  _id,
2380  _logTime,
2382  _logString
2383  );
2384  }
2385 #endif
2386  }
2387 
2388  // ----------------------------------------------------------------------
2389  // Telemetry write functions
2390  // ----------------------------------------------------------------------
2391 
2394  U32 arg,
2395  Fw::Time _tlmTime
2396  ) const
2397  {
2398  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2399  if (
2400  this->m_timeCaller_OutputPort[0].isConnected() &&
2401  (_tlmTime == Fw::ZERO_TIME)
2402  ) {
2403  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2404  }
2405 
2406  Fw::TlmBuffer _tlmBuff;
2407  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2408  FW_ASSERT(
2409  _stat == Fw::FW_SERIALIZE_OK,
2410  static_cast<FwAssertArgType>(_stat)
2411  );
2412 
2413  FwChanIdType _id;
2414 
2415  _id = this->getIdBase() + CHANNELID_FILESSENT;
2416 
2417  this->m_tlmOut_OutputPort[0].invoke(
2418  _id,
2419  _tlmTime,
2420  _tlmBuff
2421  );
2422  }
2423  }
2424 
2427  U32 arg,
2428  Fw::Time _tlmTime
2429  ) const
2430  {
2431  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2432  if (
2433  this->m_timeCaller_OutputPort[0].isConnected() &&
2434  (_tlmTime == Fw::ZERO_TIME)
2435  ) {
2436  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2437  }
2438 
2439  Fw::TlmBuffer _tlmBuff;
2440  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2441  FW_ASSERT(
2442  _stat == Fw::FW_SERIALIZE_OK,
2443  static_cast<FwAssertArgType>(_stat)
2444  );
2445 
2446  FwChanIdType _id;
2447 
2448  _id = this->getIdBase() + CHANNELID_PACKETSSENT;
2449 
2450  this->m_tlmOut_OutputPort[0].invoke(
2451  _id,
2452  _tlmTime,
2453  _tlmBuff
2454  );
2455  }
2456  }
2457 
2460  U32 arg,
2461  Fw::Time _tlmTime
2462  ) const
2463  {
2464  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2465  if (
2466  this->m_timeCaller_OutputPort[0].isConnected() &&
2467  (_tlmTime == Fw::ZERO_TIME)
2468  ) {
2469  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2470  }
2471 
2472  Fw::TlmBuffer _tlmBuff;
2473  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2474  FW_ASSERT(
2475  _stat == Fw::FW_SERIALIZE_OK,
2476  static_cast<FwAssertArgType>(_stat)
2477  );
2478 
2479  FwChanIdType _id;
2480 
2481  _id = this->getIdBase() + CHANNELID_WARNINGS;
2482 
2483  this->m_tlmOut_OutputPort[0].invoke(
2484  _id,
2485  _tlmTime,
2486  _tlmBuff
2487  );
2488  }
2489  }
2490 
2491  // ----------------------------------------------------------------------
2492  // Time
2493  // ----------------------------------------------------------------------
2494 
2497  {
2498  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2499  Fw::Time _time;
2500  this->m_timeCaller_OutputPort[0].invoke(_time);
2501  return _time;
2502  }
2503  else {
2504  return Fw::Time(TB_NONE, 0, 0);
2505  }
2506  }
2507 
2508  // ----------------------------------------------------------------------
2509  // Mutex operations for guarded ports
2510  //
2511  // You can override these operations to provide more sophisticated
2512  // synchronization
2513  // ----------------------------------------------------------------------
2514 
2517  {
2518  this->m_guardedPortMutex.lock();
2519  }
2520 
2523  {
2524  this->m_guardedPortMutex.unLock();
2525  }
2526 
2527  // ----------------------------------------------------------------------
2528  // Message dispatch functions
2529  // ----------------------------------------------------------------------
2530 
2531  Fw::QueuedComponentBase::MsgDispatchStatus FileDownlinkComponentBase ::
2532  doDispatch()
2533  {
2534  ComponentIpcSerializableBuffer _msg;
2535  FwQueuePriorityType _priority = 0;
2536 
2537  Os::Queue::Status _msgStatus = this->m_queue.receive(
2538  _msg,
2540  _priority
2541  );
2542  FW_ASSERT(
2543  _msgStatus == Os::Queue::OP_OK,
2544  static_cast<FwAssertArgType>(_msgStatus)
2545  );
2546 
2547  // Reset to beginning of buffer
2548  _msg.resetDeser();
2549 
2550  FwEnumStoreType _desMsg = 0;
2551  Fw::SerializeStatus _deserStatus = _msg.deserialize(_desMsg);
2552  FW_ASSERT(
2553  _deserStatus == Fw::FW_SERIALIZE_OK,
2554  static_cast<FwAssertArgType>(_deserStatus)
2555  );
2556 
2557  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2558 
2559  if (_msgType == FILEDOWNLINK_COMPONENT_EXIT) {
2560  return MSG_DISPATCH_EXIT;
2561  }
2562 
2563  FwIndexType portNum = 0;
2564  _deserStatus = _msg.deserialize(portNum);
2565  FW_ASSERT(
2566  _deserStatus == Fw::FW_SERIALIZE_OK,
2567  static_cast<FwAssertArgType>(_deserStatus)
2568  );
2569 
2570  switch (_msgType) {
2571  // Handle async input port Run
2572  case RUN_SCHED: {
2573  // Deserialize argument context
2574  U32 context;
2575  _deserStatus = _msg.deserialize(context);
2576  FW_ASSERT(
2577  _deserStatus == Fw::FW_SERIALIZE_OK,
2578  static_cast<FwAssertArgType>(_deserStatus)
2579  );
2580  // Call handler function
2581  this->Run_handler(
2582  portNum,
2583  context
2584  );
2585 
2586  break;
2587  }
2588 
2589  // Handle async input port bufferReturn
2590  case BUFFERRETURN_BUFFERSEND: {
2591  // Deserialize argument fwBuffer
2592  Fw::Buffer fwBuffer;
2593  _deserStatus = _msg.deserialize(fwBuffer);
2594  FW_ASSERT(
2595  _deserStatus == Fw::FW_SERIALIZE_OK,
2596  static_cast<FwAssertArgType>(_deserStatus)
2597  );
2598  // Call handler function
2599  this->bufferReturn_handler(
2600  portNum,
2601  fwBuffer
2602  );
2603 
2604  break;
2605  }
2606 
2607  // Handle async input port pingIn
2608  case PINGIN_PING: {
2609  // Deserialize argument key
2610  U32 key;
2611  _deserStatus = _msg.deserialize(key);
2612  FW_ASSERT(
2613  _deserStatus == Fw::FW_SERIALIZE_OK,
2614  static_cast<FwAssertArgType>(_deserStatus)
2615  );
2616  // Call handler function
2617  this->pingIn_handler(
2618  portNum,
2619  key
2620  );
2621 
2622  break;
2623  }
2624 
2625  // Handle command SendFile
2626  case CMD_SENDFILE: {
2627  // Deserialize opcode
2628  FwOpcodeType _opCode = 0;
2629  _deserStatus = _msg.deserialize(_opCode);
2630  FW_ASSERT (
2631  _deserStatus == Fw::FW_SERIALIZE_OK,
2632  static_cast<FwAssertArgType>(_deserStatus)
2633  );
2634 
2635  // Deserialize command sequence
2636  U32 _cmdSeq = 0;
2637  _deserStatus = _msg.deserialize(_cmdSeq);
2638  FW_ASSERT (
2639  _deserStatus == Fw::FW_SERIALIZE_OK,
2640  static_cast<FwAssertArgType>(_deserStatus)
2641  );
2642 
2643  // Deserialize command argument buffer
2644  Fw::CmdArgBuffer args;
2645  _deserStatus = _msg.deserialize(args);
2646  FW_ASSERT (
2647  _deserStatus == Fw::FW_SERIALIZE_OK,
2648  static_cast<FwAssertArgType>(_deserStatus)
2649  );
2650 
2651  // Reset buffer
2652  args.resetDeser();
2653 
2654  // Deserialize argument sourceFileName
2655  Fw::CmdStringArg sourceFileName;
2656  _deserStatus = args.deserialize(sourceFileName);
2657  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2658  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2659  this->cmdResponse_out(
2660  _opCode,
2661  _cmdSeq,
2663  );
2664  }
2665  // Don't crash the task if bad arguments were passed from the ground
2666  break;
2667  }
2668 
2669  // Deserialize argument destFileName
2670  Fw::CmdStringArg destFileName;
2671  _deserStatus = args.deserialize(destFileName);
2672  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2673  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2674  this->cmdResponse_out(
2675  _opCode,
2676  _cmdSeq,
2678  );
2679  }
2680  // Don't crash the task if bad arguments were passed from the ground
2681  break;
2682  }
2683 
2684  // Make sure there was no data left over.
2685  // That means the argument buffer size was incorrect.
2686 #if FW_CMD_CHECK_RESIDUAL
2687  if (args.getBuffLeft() != 0) {
2688  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2689  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2690  }
2691  // Don't crash the task if bad arguments were passed from the ground
2692  break;
2693  }
2694 #endif
2695 
2696  // Call handler function
2697  this->SendFile_cmdHandler(
2698  _opCode, _cmdSeq,
2699  sourceFileName,
2700  destFileName
2701  );
2702 
2703  break;
2704  }
2705 
2706  // Handle command Cancel
2707  case CMD_CANCEL: {
2708  // Deserialize opcode
2709  FwOpcodeType _opCode = 0;
2710  _deserStatus = _msg.deserialize(_opCode);
2711  FW_ASSERT (
2712  _deserStatus == Fw::FW_SERIALIZE_OK,
2713  static_cast<FwAssertArgType>(_deserStatus)
2714  );
2715 
2716  // Deserialize command sequence
2717  U32 _cmdSeq = 0;
2718  _deserStatus = _msg.deserialize(_cmdSeq);
2719  FW_ASSERT (
2720  _deserStatus == Fw::FW_SERIALIZE_OK,
2721  static_cast<FwAssertArgType>(_deserStatus)
2722  );
2723 
2724  // Deserialize command argument buffer
2725  Fw::CmdArgBuffer args;
2726  _deserStatus = _msg.deserialize(args);
2727  FW_ASSERT (
2728  _deserStatus == Fw::FW_SERIALIZE_OK,
2729  static_cast<FwAssertArgType>(_deserStatus)
2730  );
2731 
2732  // Reset buffer
2733  args.resetDeser();
2734 
2735  // Make sure there was no data left over.
2736  // That means the argument buffer size was incorrect.
2737 #if FW_CMD_CHECK_RESIDUAL
2738  if (args.getBuffLeft() != 0) {
2739  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2740  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2741  }
2742  // Don't crash the task if bad arguments were passed from the ground
2743  break;
2744  }
2745 #endif
2746 
2747  // Call handler function
2748  this->Cancel_cmdHandler(_opCode, _cmdSeq);
2749 
2750  break;
2751  }
2752 
2753  // Handle command SendPartial
2754  case CMD_SENDPARTIAL: {
2755  // Deserialize opcode
2756  FwOpcodeType _opCode = 0;
2757  _deserStatus = _msg.deserialize(_opCode);
2758  FW_ASSERT (
2759  _deserStatus == Fw::FW_SERIALIZE_OK,
2760  static_cast<FwAssertArgType>(_deserStatus)
2761  );
2762 
2763  // Deserialize command sequence
2764  U32 _cmdSeq = 0;
2765  _deserStatus = _msg.deserialize(_cmdSeq);
2766  FW_ASSERT (
2767  _deserStatus == Fw::FW_SERIALIZE_OK,
2768  static_cast<FwAssertArgType>(_deserStatus)
2769  );
2770 
2771  // Deserialize command argument buffer
2772  Fw::CmdArgBuffer args;
2773  _deserStatus = _msg.deserialize(args);
2774  FW_ASSERT (
2775  _deserStatus == Fw::FW_SERIALIZE_OK,
2776  static_cast<FwAssertArgType>(_deserStatus)
2777  );
2778 
2779  // Reset buffer
2780  args.resetDeser();
2781 
2782  // Deserialize argument sourceFileName
2783  Fw::CmdStringArg sourceFileName;
2784  _deserStatus = args.deserialize(sourceFileName);
2785  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2786  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2787  this->cmdResponse_out(
2788  _opCode,
2789  _cmdSeq,
2791  );
2792  }
2793  // Don't crash the task if bad arguments were passed from the ground
2794  break;
2795  }
2796 
2797  // Deserialize argument destFileName
2798  Fw::CmdStringArg destFileName;
2799  _deserStatus = args.deserialize(destFileName);
2800  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2801  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2802  this->cmdResponse_out(
2803  _opCode,
2804  _cmdSeq,
2806  );
2807  }
2808  // Don't crash the task if bad arguments were passed from the ground
2809  break;
2810  }
2811 
2812  // Deserialize argument startOffset
2813  U32 startOffset;
2814  _deserStatus = args.deserialize(startOffset);
2815  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2816  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2817  this->cmdResponse_out(
2818  _opCode,
2819  _cmdSeq,
2821  );
2822  }
2823  // Don't crash the task if bad arguments were passed from the ground
2824  break;
2825  }
2826 
2827  // Deserialize argument length
2828  U32 length;
2829  _deserStatus = args.deserialize(length);
2830  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2831  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2832  this->cmdResponse_out(
2833  _opCode,
2834  _cmdSeq,
2836  );
2837  }
2838  // Don't crash the task if bad arguments were passed from the ground
2839  break;
2840  }
2841 
2842  // Make sure there was no data left over.
2843  // That means the argument buffer size was incorrect.
2844 #if FW_CMD_CHECK_RESIDUAL
2845  if (args.getBuffLeft() != 0) {
2846  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2847  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2848  }
2849  // Don't crash the task if bad arguments were passed from the ground
2850  break;
2851  }
2852 #endif
2853 
2854  // Call handler function
2855  this->SendPartial_cmdHandler(
2856  _opCode, _cmdSeq,
2857  sourceFileName,
2858  destFileName,
2859  startOffset,
2860  length
2861  );
2862 
2863  break;
2864  }
2865 
2866  default:
2867  return MSG_DISPATCH_ERROR;
2868  }
2869 
2870  return MSG_DISPATCH_OK;
2871  }
2872 
2873  // ----------------------------------------------------------------------
2874  // Calls for messages received on special input ports
2875  // ----------------------------------------------------------------------
2876 
2877  void FileDownlinkComponentBase ::
2878  m_p_cmdIn_in(
2879  Fw::PassiveComponentBase* callComp,
2880  FwIndexType portNum,
2881  FwOpcodeType opCode,
2882  U32 cmdSeq,
2883  Fw::CmdArgBuffer& args
2884  )
2885  {
2886  FW_ASSERT(callComp);
2887  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2888 
2889  const U32 idBase = callComp->getIdBase();
2890  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2891 
2892  // Select base class function based on opcode
2893  switch (opCode - idBase) {
2894  case OPCODE_SENDFILE: {
2895  compPtr->SendFile_cmdHandlerBase(
2896  opCode,
2897  cmdSeq,
2898  args
2899  );
2900  break;
2901  }
2902 
2903  case OPCODE_CANCEL: {
2904  compPtr->Cancel_cmdHandlerBase(
2905  opCode,
2906  cmdSeq,
2907  args
2908  );
2909  break;
2910  }
2911 
2912  case OPCODE_SENDPARTIAL: {
2913  compPtr->SendPartial_cmdHandlerBase(
2914  opCode,
2915  cmdSeq,
2916  args
2917  );
2918  break;
2919  }
2920  }
2921  }
2922 
2923  // ----------------------------------------------------------------------
2924  // Calls for messages received on typed input ports
2925  // ----------------------------------------------------------------------
2926 
2927  void FileDownlinkComponentBase ::
2928  m_p_Run_in(
2929  Fw::PassiveComponentBase* callComp,
2930  FwIndexType portNum,
2931  U32 context
2932  )
2933  {
2934  FW_ASSERT(callComp);
2935  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2936  compPtr->Run_handlerBase(
2937  portNum,
2938  context
2939  );
2940  }
2941 
2942  Svc::SendFileResponse FileDownlinkComponentBase ::
2943  m_p_SendFile_in(
2944  Fw::PassiveComponentBase* callComp,
2945  FwIndexType portNum,
2946  const Fw::StringBase& sourceFileName,
2947  const Fw::StringBase& destFileName,
2948  U32 offset,
2949  U32 length
2950  )
2951  {
2952  FW_ASSERT(callComp);
2953  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2954  return compPtr->SendFile_handlerBase(
2955  portNum,
2956  sourceFileName,
2957  destFileName,
2958  offset,
2959  length
2960  );
2961  }
2962 
2963  void FileDownlinkComponentBase ::
2964  m_p_bufferReturn_in(
2965  Fw::PassiveComponentBase* callComp,
2966  FwIndexType portNum,
2967  Fw::Buffer& fwBuffer
2968  )
2969  {
2970  FW_ASSERT(callComp);
2971  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2972  compPtr->bufferReturn_handlerBase(
2973  portNum,
2974  fwBuffer
2975  );
2976  }
2977 
2978  void FileDownlinkComponentBase ::
2979  m_p_pingIn_in(
2980  Fw::PassiveComponentBase* callComp,
2981  FwIndexType portNum,
2982  U32 key
2983  )
2984  {
2985  FW_ASSERT(callComp);
2986  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2987  compPtr->pingIn_handlerBase(
2988  portNum,
2989  key
2990  );
2991  }
2992 
2993 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
Definition: Time.hpp:9
Operation succeeded.
Definition: Os.hpp:26
Status
status returned from the queue send function
Definition: Queue.hpp:30
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:40
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
const Time ZERO_TIME
Definition: Time.cpp:5
I32 FwEnumStoreType
Definition: FpConfig.h:64
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
Enum representing a command response.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
void init()
Initialization function.
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
Os::Queue m_queue
queue object for active component
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Object initializer.
Definition: ObjBase.cpp:26
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
Message will block until space is available.
Definition: Queue.hpp:46
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
void init()
Initialization function.
Definition: TimePortAc.cpp:128
message to exit active component task
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:87
A less serious but recoverable event.
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port interface.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
U32 FwOpcodeType
Definition: FpConfig.h:91
The size of the serial representations of the port arguments.
const char * toChar() const
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
No time base has been established.
Definition: FpConfig.h:70
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
void resetDeser()
reset deserialization to beginning
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:42
U32 FwEventIdType
Definition: FpConfig.h:103
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:32
BlockingType
message type
Definition: Queue.hpp:45
void init()
Initialization function.
Command failed to deserialize.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
Important informational events.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
PlatformQueuePriorityType FwQueuePriorityType
Definition: FpConfig.h:55
A message was sent requesting an exit of the loop.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Send file response struct.
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:85
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:35
void invoke(const Svc::SendFileResponse &resp) const
Invoke a port interface.
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const
serialization function
Definition: StringBase.cpp:142
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
Message will return with status when space is unavailable.
Definition: Queue.hpp:47
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
void init()
Initialization function.
void addCallPort(InputSendFileCompletePort *callPort)
Register an input port.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:148
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:319
virtual const CHAR * toChar() const =0
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34
U32 FwChanIdType
Definition: FpConfig.h:95