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