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 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #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 getCapacity() 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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  // Connection status queries for special output ports
777  // ----------------------------------------------------------------------
778 
781  {
782  FW_ASSERT(
783  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
784  static_cast<FwAssertArgType>(portNum)
785  );
786 
787  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
788  }
789 
792  {
793  FW_ASSERT(
794  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
795  static_cast<FwAssertArgType>(portNum)
796  );
797 
798  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
799  }
800 
803  {
804  FW_ASSERT(
805  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
806  static_cast<FwAssertArgType>(portNum)
807  );
808 
809  return this->m_eventOut_OutputPort[portNum].isConnected();
810  }
811 
812 #if FW_ENABLE_TEXT_LOGGING == 1
813 
814  bool FileDownlinkComponentBase ::
815  isConnected_textEventOut_OutputPort(FwIndexType portNum)
816  {
817  FW_ASSERT(
818  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
819  static_cast<FwAssertArgType>(portNum)
820  );
821 
822  return this->m_textEventOut_OutputPort[portNum].isConnected();
823  }
824 
825 #endif
826 
829  {
830  FW_ASSERT(
831  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
832  static_cast<FwAssertArgType>(portNum)
833  );
834 
835  return this->m_timeCaller_OutputPort[portNum].isConnected();
836  }
837 
840  {
841  FW_ASSERT(
842  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
843  static_cast<FwAssertArgType>(portNum)
844  );
845 
846  return this->m_tlmOut_OutputPort[portNum].isConnected();
847  }
848 
849  // ----------------------------------------------------------------------
850  // Connection status queries for typed output ports
851  // ----------------------------------------------------------------------
852 
855  {
856  FW_ASSERT(
857  (0 <= portNum) && (portNum < this->getNum_FileComplete_OutputPorts()),
858  static_cast<FwAssertArgType>(portNum)
859  );
860 
861  return this->m_FileComplete_OutputPort[portNum].isConnected();
862  }
863 
866  {
867  FW_ASSERT(
868  (0 <= portNum) && (portNum < this->getNum_bufferSendOut_OutputPorts()),
869  static_cast<FwAssertArgType>(portNum)
870  );
871 
872  return this->m_bufferSendOut_OutputPort[portNum].isConnected();
873  }
874 
877  {
878  FW_ASSERT(
879  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
880  static_cast<FwAssertArgType>(portNum)
881  );
882 
883  return this->m_pingOut_OutputPort[portNum].isConnected();
884  }
885 
886  // ----------------------------------------------------------------------
887  // Port handler base-class functions for typed input ports
888  //
889  // Call these functions directly to bypass the corresponding ports
890  // ----------------------------------------------------------------------
891 
894  FwIndexType portNum,
895  U32 context
896  )
897  {
898  // Make sure port number is valid
899  FW_ASSERT(
900  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
901  static_cast<FwAssertArgType>(portNum)
902  );
903 
904  // Call pre-message hook
906  portNum,
907  context
908  );
909  ComponentIpcSerializableBuffer msg;
911 
912  // Serialize message ID
913  _status = msg.serializeFrom(
914  static_cast<FwEnumStoreType>(RUN_SCHED)
915  );
916  FW_ASSERT(
917  _status == Fw::FW_SERIALIZE_OK,
918  static_cast<FwAssertArgType>(_status)
919  );
920 
921  // Serialize port number
922  _status = msg.serializeFrom(portNum);
923  FW_ASSERT(
924  _status == Fw::FW_SERIALIZE_OK,
925  static_cast<FwAssertArgType>(_status)
926  );
927 
928  // Serialize argument context
929  _status = msg.serializeFrom(context);
930  FW_ASSERT(
931  _status == Fw::FW_SERIALIZE_OK,
932  static_cast<FwAssertArgType>(_status)
933  );
934 
935  // Send message
937  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
938 
939  FW_ASSERT(
940  qStatus == Os::Queue::OP_OK,
941  static_cast<FwAssertArgType>(qStatus)
942  );
943  }
944 
947  FwIndexType portNum,
948  const Fw::StringBase& sourceFileName,
949  const Fw::StringBase& destFileName,
950  U32 offset,
951  U32 length
952  )
953  {
954  // Make sure port number is valid
955  FW_ASSERT(
956  (0 <= portNum) && (portNum < this->getNum_SendFile_InputPorts()),
957  static_cast<FwAssertArgType>(portNum)
958  );
959 
960  Svc::SendFileResponse retVal;
961 
962  // Lock guard mutex before calling
963  this->lock();
964 
965  // Call handler function
966  retVal = this->SendFile_handler(
967  portNum,
968  sourceFileName,
969  destFileName,
970  offset,
971  length
972  );
973 
974  // Unlock guard mutex
975  this->unLock();
976 
977  return retVal;
978  }
979 
982  FwIndexType portNum,
983  Fw::Buffer& fwBuffer
984  )
985  {
986  // Make sure port number is valid
987  FW_ASSERT(
988  (0 <= portNum) && (portNum < this->getNum_bufferReturn_InputPorts()),
989  static_cast<FwAssertArgType>(portNum)
990  );
991 
992  // Call pre-message hook
994  portNum,
995  fwBuffer
996  );
997  ComponentIpcSerializableBuffer msg;
999 
1000  // Serialize message ID
1001  _status = msg.serializeFrom(
1002  static_cast<FwEnumStoreType>(BUFFERRETURN_BUFFERSEND)
1003  );
1004  FW_ASSERT(
1005  _status == Fw::FW_SERIALIZE_OK,
1006  static_cast<FwAssertArgType>(_status)
1007  );
1008 
1009  // Serialize port number
1010  _status = msg.serializeFrom(portNum);
1011  FW_ASSERT(
1012  _status == Fw::FW_SERIALIZE_OK,
1013  static_cast<FwAssertArgType>(_status)
1014  );
1015 
1016  // Serialize argument fwBuffer
1017  _status = msg.serializeFrom(fwBuffer);
1018  FW_ASSERT(
1019  _status == Fw::FW_SERIALIZE_OK,
1020  static_cast<FwAssertArgType>(_status)
1021  );
1022 
1023  // Send message
1025  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1026 
1027  FW_ASSERT(
1028  qStatus == Os::Queue::OP_OK,
1029  static_cast<FwAssertArgType>(qStatus)
1030  );
1031  }
1032 
1035  FwIndexType portNum,
1036  U32 key
1037  )
1038  {
1039  // Make sure port number is valid
1040  FW_ASSERT(
1041  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
1042  static_cast<FwAssertArgType>(portNum)
1043  );
1044 
1045  // Call pre-message hook
1047  portNum,
1048  key
1049  );
1050  ComponentIpcSerializableBuffer msg;
1052 
1053  // Serialize message ID
1054  _status = msg.serializeFrom(
1055  static_cast<FwEnumStoreType>(PINGIN_PING)
1056  );
1057  FW_ASSERT(
1058  _status == Fw::FW_SERIALIZE_OK,
1059  static_cast<FwAssertArgType>(_status)
1060  );
1061 
1062  // Serialize port number
1063  _status = msg.serializeFrom(portNum);
1064  FW_ASSERT(
1065  _status == Fw::FW_SERIALIZE_OK,
1066  static_cast<FwAssertArgType>(_status)
1067  );
1068 
1069  // Serialize argument key
1070  _status = msg.serializeFrom(key);
1071  FW_ASSERT(
1072  _status == Fw::FW_SERIALIZE_OK,
1073  static_cast<FwAssertArgType>(_status)
1074  );
1075 
1076  // Send message
1078  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1079 
1080  FW_ASSERT(
1081  qStatus == Os::Queue::OP_OK,
1082  static_cast<FwAssertArgType>(qStatus)
1083  );
1084  }
1085 
1086  // ----------------------------------------------------------------------
1087  // Pre-message hooks for typed async input ports
1088  //
1089  // Each of these functions is invoked just before processing a message
1090  // on the corresponding port. By default, they do nothing. You can
1091  // override them to provide specific pre-message behavior.
1092  // ----------------------------------------------------------------------
1093 
1096  FwIndexType portNum,
1097  U32 context
1098  )
1099  {
1100  // Default: no-op
1101  }
1102 
1105  FwIndexType portNum,
1106  Fw::Buffer& fwBuffer
1107  )
1108  {
1109  // Default: no-op
1110  }
1111 
1114  FwIndexType portNum,
1115  U32 key
1116  )
1117  {
1118  // Default: no-op
1119  }
1120 
1121  // ----------------------------------------------------------------------
1122  // Invocation functions for typed output ports
1123  // ----------------------------------------------------------------------
1124 
1127  FwIndexType portNum,
1128  const Svc::SendFileResponse& resp
1129  )
1130  {
1131  FW_ASSERT(
1132  (0 <= portNum) && (portNum < this->getNum_FileComplete_OutputPorts()),
1133  static_cast<FwAssertArgType>(portNum)
1134  );
1135 
1136  FW_ASSERT(
1137  this->m_FileComplete_OutputPort[portNum].isConnected(),
1138  static_cast<FwAssertArgType>(portNum)
1139  );
1140  this->m_FileComplete_OutputPort[portNum].invoke(
1141  resp
1142  );
1143  }
1144 
1147  FwIndexType portNum,
1148  Fw::Buffer& fwBuffer
1149  )
1150  {
1151  FW_ASSERT(
1152  (0 <= portNum) && (portNum < this->getNum_bufferSendOut_OutputPorts()),
1153  static_cast<FwAssertArgType>(portNum)
1154  );
1155 
1156  FW_ASSERT(
1157  this->m_bufferSendOut_OutputPort[portNum].isConnected(),
1158  static_cast<FwAssertArgType>(portNum)
1159  );
1160  this->m_bufferSendOut_OutputPort[portNum].invoke(
1161  fwBuffer
1162  );
1163  }
1164 
1167  FwIndexType portNum,
1168  U32 key
1169  )
1170  {
1171  FW_ASSERT(
1172  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
1173  static_cast<FwAssertArgType>(portNum)
1174  );
1175 
1176  FW_ASSERT(
1177  this->m_pingOut_OutputPort[portNum].isConnected(),
1178  static_cast<FwAssertArgType>(portNum)
1179  );
1180  this->m_pingOut_OutputPort[portNum].invoke(
1181  key
1182  );
1183  }
1184 
1185  // ----------------------------------------------------------------------
1186  // Command response
1187  // ----------------------------------------------------------------------
1188 
1191  FwOpcodeType opCode,
1192  U32 cmdSeq,
1193  Fw::CmdResponse response
1194  )
1195  {
1196  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1197  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1198  }
1199 
1200  // ----------------------------------------------------------------------
1201  // Command handler base-class functions
1202  //
1203  // Call these functions directly to bypass the command input port
1204  // ----------------------------------------------------------------------
1205 
1208  FwOpcodeType opCode,
1209  U32 cmdSeq,
1210  Fw::CmdArgBuffer& args
1211  )
1212  {
1213  // Call pre-message hook
1214  this->SendFile_preMsgHook(opCode,cmdSeq);
1215 
1216  // Defer deserializing arguments to the message dispatcher
1217  // to avoid deserializing and reserializing just for IPC
1218  ComponentIpcSerializableBuffer msg;
1220 
1221  // Serialize for IPC
1222  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_SENDFILE));
1223  FW_ASSERT (
1224  _status == Fw::FW_SERIALIZE_OK,
1225  static_cast<FwAssertArgType>(_status)
1226  );
1227 
1228  // Fake port number to make message dequeue work
1229  FwIndexType port = 0;
1230 
1231  _status = msg.serializeFrom(port);
1232  FW_ASSERT (
1233  _status == Fw::FW_SERIALIZE_OK,
1234  static_cast<FwAssertArgType>(_status)
1235  );
1236 
1237  _status = msg.serializeFrom(opCode);
1238  FW_ASSERT (
1239  _status == Fw::FW_SERIALIZE_OK,
1240  static_cast<FwAssertArgType>(_status)
1241  );
1242 
1243  _status = msg.serializeFrom(cmdSeq);
1244  FW_ASSERT (
1245  _status == Fw::FW_SERIALIZE_OK,
1246  static_cast<FwAssertArgType>(_status)
1247  );
1248 
1249  _status = msg.serializeFrom(args);
1250  FW_ASSERT (
1251  _status == Fw::FW_SERIALIZE_OK,
1252  static_cast<FwAssertArgType>(_status)
1253  );
1254 
1255  // Send message
1257  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1258 
1259  FW_ASSERT(
1260  qStatus == Os::Queue::OP_OK,
1261  static_cast<FwAssertArgType>(qStatus)
1262  );
1263  }
1264 
1267  FwOpcodeType opCode,
1268  U32 cmdSeq,
1269  Fw::CmdArgBuffer& args
1270  )
1271  {
1272  // Call pre-message hook
1273  this->Cancel_preMsgHook(opCode,cmdSeq);
1274 
1275  // Defer deserializing arguments to the message dispatcher
1276  // to avoid deserializing and reserializing just for IPC
1277  ComponentIpcSerializableBuffer msg;
1279 
1280  // Serialize for IPC
1281  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_CANCEL));
1282  FW_ASSERT (
1283  _status == Fw::FW_SERIALIZE_OK,
1284  static_cast<FwAssertArgType>(_status)
1285  );
1286 
1287  // Fake port number to make message dequeue work
1288  FwIndexType port = 0;
1289 
1290  _status = msg.serializeFrom(port);
1291  FW_ASSERT (
1292  _status == Fw::FW_SERIALIZE_OK,
1293  static_cast<FwAssertArgType>(_status)
1294  );
1295 
1296  _status = msg.serializeFrom(opCode);
1297  FW_ASSERT (
1298  _status == Fw::FW_SERIALIZE_OK,
1299  static_cast<FwAssertArgType>(_status)
1300  );
1301 
1302  _status = msg.serializeFrom(cmdSeq);
1303  FW_ASSERT (
1304  _status == Fw::FW_SERIALIZE_OK,
1305  static_cast<FwAssertArgType>(_status)
1306  );
1307 
1308  _status = msg.serializeFrom(args);
1309  FW_ASSERT (
1310  _status == Fw::FW_SERIALIZE_OK,
1311  static_cast<FwAssertArgType>(_status)
1312  );
1313 
1314  // Send message
1316  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1317 
1318  FW_ASSERT(
1319  qStatus == Os::Queue::OP_OK,
1320  static_cast<FwAssertArgType>(qStatus)
1321  );
1322  }
1323 
1326  FwOpcodeType opCode,
1327  U32 cmdSeq,
1328  Fw::CmdArgBuffer& args
1329  )
1330  {
1331  // Call pre-message hook
1332  this->SendPartial_preMsgHook(opCode,cmdSeq);
1333 
1334  // Defer deserializing arguments to the message dispatcher
1335  // to avoid deserializing and reserializing just for IPC
1336  ComponentIpcSerializableBuffer msg;
1338 
1339  // Serialize for IPC
1340  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_SENDPARTIAL));
1341  FW_ASSERT (
1342  _status == Fw::FW_SERIALIZE_OK,
1343  static_cast<FwAssertArgType>(_status)
1344  );
1345 
1346  // Fake port number to make message dequeue work
1347  FwIndexType port = 0;
1348 
1349  _status = msg.serializeFrom(port);
1350  FW_ASSERT (
1351  _status == Fw::FW_SERIALIZE_OK,
1352  static_cast<FwAssertArgType>(_status)
1353  );
1354 
1355  _status = msg.serializeFrom(opCode);
1356  FW_ASSERT (
1357  _status == Fw::FW_SERIALIZE_OK,
1358  static_cast<FwAssertArgType>(_status)
1359  );
1360 
1361  _status = msg.serializeFrom(cmdSeq);
1362  FW_ASSERT (
1363  _status == Fw::FW_SERIALIZE_OK,
1364  static_cast<FwAssertArgType>(_status)
1365  );
1366 
1367  _status = msg.serializeFrom(args);
1368  FW_ASSERT (
1369  _status == Fw::FW_SERIALIZE_OK,
1370  static_cast<FwAssertArgType>(_status)
1371  );
1372 
1373  // Send message
1375  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1376 
1377  FW_ASSERT(
1378  qStatus == Os::Queue::OP_OK,
1379  static_cast<FwAssertArgType>(qStatus)
1380  );
1381  }
1382 
1383  // ----------------------------------------------------------------------
1384  // Pre-message hooks for async commands
1385  //
1386  // Each of these functions is invoked just before processing the
1387  // corresponding command. By default they do nothing. You can
1388  // override them to provide specific pre-command behavior.
1389  // ----------------------------------------------------------------------
1390 
1393  FwOpcodeType opCode,
1394  U32 cmdSeq
1395  )
1396  {
1397  // Defaults to no-op; can be overridden
1398  (void) opCode;
1399  (void) cmdSeq;
1400  }
1401 
1404  FwOpcodeType opCode,
1405  U32 cmdSeq
1406  )
1407  {
1408  // Defaults to no-op; can be overridden
1409  (void) opCode;
1410  (void) cmdSeq;
1411  }
1412 
1415  FwOpcodeType opCode,
1416  U32 cmdSeq
1417  )
1418  {
1419  // Defaults to no-op; can be overridden
1420  (void) opCode;
1421  (void) cmdSeq;
1422  }
1423 
1424  // ----------------------------------------------------------------------
1425  // Event logging functions
1426  // ----------------------------------------------------------------------
1427 
1430  {
1431  // Get the time
1432  Fw::Time _logTime;
1433  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1434  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1435  }
1436 
1437  FwEventIdType _id = static_cast<FwEventIdType>(0);
1438 
1439  _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1440 
1441  // Emit the event on the log port
1442  if (this->m_eventOut_OutputPort[0].isConnected()) {
1443  Fw::LogBuffer _logBuff;
1445 
1446 #if FW_AMPCS_COMPATIBLE
1447  // Serialize the number of arguments
1448  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1449  FW_ASSERT(
1450  _status == Fw::FW_SERIALIZE_OK,
1451  static_cast<FwAssertArgType>(_status)
1452  );
1453 #endif
1454 
1455  _status = fileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1456  FW_ASSERT(
1457  _status == Fw::FW_SERIALIZE_OK,
1458  static_cast<FwAssertArgType>(_status)
1459  );
1460 
1461  this->m_eventOut_OutputPort[0].invoke(
1462  _id,
1463  _logTime,
1465  _logBuff
1466  );
1467  }
1468 
1469  // Emit the event on the text log port
1470 #if FW_ENABLE_TEXT_LOGGING
1471  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1472 #if FW_OBJECT_NAMES == 1
1473  const char* _formatString =
1474  "(%s) %s: Could not open file %s";
1475 #else
1476  const char* _formatString =
1477  "%s: Could not open file %s";
1478 #endif
1479 
1480  Fw::TextLogString _logString;
1481  _logString.format(
1482  _formatString,
1483 #if FW_OBJECT_NAMES == 1
1484  this->m_objName.toChar(),
1485 #endif
1486  "FileOpenError ",
1487  fileName.toChar()
1488  );
1489 
1490  this->m_textEventOut_OutputPort[0].invoke(
1491  _id,
1492  _logTime,
1494  _logString
1495  );
1496  }
1497 #endif
1498  }
1499 
1502  const Fw::StringBase& fileName,
1503  I32 status
1504  ) const
1505  {
1506  // Get the time
1507  Fw::Time _logTime;
1508  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1509  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1510  }
1511 
1512  FwEventIdType _id = static_cast<FwEventIdType>(0);
1513 
1514  _id = this->getIdBase() + EVENTID_FILEREADERROR;
1515 
1516  // Emit the event on the log port
1517  if (this->m_eventOut_OutputPort[0].isConnected()) {
1518  Fw::LogBuffer _logBuff;
1520 
1521 #if FW_AMPCS_COMPATIBLE
1522  // Serialize the number of arguments
1523  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1524  FW_ASSERT(
1525  _status == Fw::FW_SERIALIZE_OK,
1526  static_cast<FwAssertArgType>(_status)
1527  );
1528 #endif
1529 
1530  _status = fileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1531  FW_ASSERT(
1532  _status == Fw::FW_SERIALIZE_OK,
1533  static_cast<FwAssertArgType>(_status)
1534  );
1535 
1536 #if FW_AMPCS_COMPATIBLE
1537  // Serialize the argument size
1538  _status = _logBuff.serializeFrom(
1539  static_cast<U8>(sizeof(I32))
1540  );
1541  FW_ASSERT(
1542  _status == Fw::FW_SERIALIZE_OK,
1543  static_cast<FwAssertArgType>(_status)
1544  );
1545 #endif
1546  _status = _logBuff.serializeFrom(status);
1547  FW_ASSERT(
1548  _status == Fw::FW_SERIALIZE_OK,
1549  static_cast<FwAssertArgType>(_status)
1550  );
1551 
1552  this->m_eventOut_OutputPort[0].invoke(
1553  _id,
1554  _logTime,
1556  _logBuff
1557  );
1558  }
1559 
1560  // Emit the event on the text log port
1561 #if FW_ENABLE_TEXT_LOGGING
1562  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1563 #if FW_OBJECT_NAMES == 1
1564  const char* _formatString =
1565  "(%s) %s: Could not read file %s with status %" PRIi32 "";
1566 #else
1567  const char* _formatString =
1568  "%s: Could not read file %s with status %" PRIi32 "";
1569 #endif
1570 
1571  Fw::TextLogString _logString;
1572  _logString.format(
1573  _formatString,
1574 #if FW_OBJECT_NAMES == 1
1575  this->m_objName.toChar(),
1576 #endif
1577  "FileReadError ",
1578  fileName.toChar(),
1579  status
1580  );
1581 
1582  this->m_textEventOut_OutputPort[0].invoke(
1583  _id,
1584  _logTime,
1586  _logString
1587  );
1588  }
1589 #endif
1590  }
1591 
1594  const Fw::StringBase& sourceFileName,
1595  const Fw::StringBase& destFileName
1596  ) const
1597  {
1598  // Get the time
1599  Fw::Time _logTime;
1600  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1601  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1602  }
1603 
1604  FwEventIdType _id = static_cast<FwEventIdType>(0);
1605 
1606  _id = this->getIdBase() + EVENTID_FILESENT;
1607 
1608  // Emit the event on the log port
1609  if (this->m_eventOut_OutputPort[0].isConnected()) {
1610  Fw::LogBuffer _logBuff;
1612 
1613 #if FW_AMPCS_COMPATIBLE
1614  // Serialize the number of arguments
1615  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1616  FW_ASSERT(
1617  _status == Fw::FW_SERIALIZE_OK,
1618  static_cast<FwAssertArgType>(_status)
1619  );
1620 #endif
1621 
1622  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1623  FW_ASSERT(
1624  _status == Fw::FW_SERIALIZE_OK,
1625  static_cast<FwAssertArgType>(_status)
1626  );
1627 
1628  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1629  FW_ASSERT(
1630  _status == Fw::FW_SERIALIZE_OK,
1631  static_cast<FwAssertArgType>(_status)
1632  );
1633 
1634  this->m_eventOut_OutputPort[0].invoke(
1635  _id,
1636  _logTime,
1638  _logBuff
1639  );
1640  }
1641 
1642  // Emit the event on the text log port
1643 #if FW_ENABLE_TEXT_LOGGING
1644  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1645 #if FW_OBJECT_NAMES == 1
1646  const char* _formatString =
1647  "(%s) %s: Sent file %s to file %s";
1648 #else
1649  const char* _formatString =
1650  "%s: Sent file %s to file %s";
1651 #endif
1652 
1653  Fw::TextLogString _logString;
1654  _logString.format(
1655  _formatString,
1656 #if FW_OBJECT_NAMES == 1
1657  this->m_objName.toChar(),
1658 #endif
1659  "FileSent ",
1660  sourceFileName.toChar(),
1661  destFileName.toChar()
1662  );
1663 
1664  this->m_textEventOut_OutputPort[0].invoke(
1665  _id,
1666  _logTime,
1668  _logString
1669  );
1670  }
1671 #endif
1672  }
1673 
1676  const Fw::StringBase& sourceFileName,
1677  const Fw::StringBase& destFileName
1678  ) const
1679  {
1680  // Get the time
1681  Fw::Time _logTime;
1682  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1683  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1684  }
1685 
1686  FwEventIdType _id = static_cast<FwEventIdType>(0);
1687 
1688  _id = this->getIdBase() + EVENTID_DOWNLINKCANCELED;
1689 
1690  // Emit the event on the log port
1691  if (this->m_eventOut_OutputPort[0].isConnected()) {
1692  Fw::LogBuffer _logBuff;
1694 
1695 #if FW_AMPCS_COMPATIBLE
1696  // Serialize the number of arguments
1697  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1698  FW_ASSERT(
1699  _status == Fw::FW_SERIALIZE_OK,
1700  static_cast<FwAssertArgType>(_status)
1701  );
1702 #endif
1703 
1704  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1705  FW_ASSERT(
1706  _status == Fw::FW_SERIALIZE_OK,
1707  static_cast<FwAssertArgType>(_status)
1708  );
1709 
1710  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1711  FW_ASSERT(
1712  _status == Fw::FW_SERIALIZE_OK,
1713  static_cast<FwAssertArgType>(_status)
1714  );
1715 
1716  this->m_eventOut_OutputPort[0].invoke(
1717  _id,
1718  _logTime,
1720  _logBuff
1721  );
1722  }
1723 
1724  // Emit the event on the text log port
1725 #if FW_ENABLE_TEXT_LOGGING
1726  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1727 #if FW_OBJECT_NAMES == 1
1728  const char* _formatString =
1729  "(%s) %s: Canceled downlink of file %s to file %s";
1730 #else
1731  const char* _formatString =
1732  "%s: Canceled downlink of file %s to file %s";
1733 #endif
1734 
1735  Fw::TextLogString _logString;
1736  _logString.format(
1737  _formatString,
1738 #if FW_OBJECT_NAMES == 1
1739  this->m_objName.toChar(),
1740 #endif
1741  "DownlinkCanceled ",
1742  sourceFileName.toChar(),
1743  destFileName.toChar()
1744  );
1745 
1746  this->m_textEventOut_OutputPort[0].invoke(
1747  _id,
1748  _logTime,
1750  _logString
1751  );
1752  }
1753 #endif
1754  }
1755 
1758  U32 startOffset,
1759  U32 length,
1760  U32 filesize,
1761  const Fw::StringBase& sourceFileName,
1762  const Fw::StringBase& destFileName
1763  ) const
1764  {
1765  // Get the time
1766  Fw::Time _logTime;
1767  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1768  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1769  }
1770 
1771  FwEventIdType _id = static_cast<FwEventIdType>(0);
1772 
1773  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALWARNING;
1774 
1775  // Emit the event on the log port
1776  if (this->m_eventOut_OutputPort[0].isConnected()) {
1777  Fw::LogBuffer _logBuff;
1779 
1780 #if FW_AMPCS_COMPATIBLE
1781  // Serialize the number of arguments
1782  _status = _logBuff.serializeFrom(static_cast<U8>(5));
1783  FW_ASSERT(
1784  _status == Fw::FW_SERIALIZE_OK,
1785  static_cast<FwAssertArgType>(_status)
1786  );
1787 #endif
1788 
1789 #if FW_AMPCS_COMPATIBLE
1790  // Serialize the argument size
1791  _status = _logBuff.serializeFrom(
1792  static_cast<U8>(sizeof(U32))
1793  );
1794  FW_ASSERT(
1795  _status == Fw::FW_SERIALIZE_OK,
1796  static_cast<FwAssertArgType>(_status)
1797  );
1798 #endif
1799  _status = _logBuff.serializeFrom(startOffset);
1800  FW_ASSERT(
1801  _status == Fw::FW_SERIALIZE_OK,
1802  static_cast<FwAssertArgType>(_status)
1803  );
1804 
1805 #if FW_AMPCS_COMPATIBLE
1806  // Serialize the argument size
1807  _status = _logBuff.serializeFrom(
1808  static_cast<U8>(sizeof(U32))
1809  );
1810  FW_ASSERT(
1811  _status == Fw::FW_SERIALIZE_OK,
1812  static_cast<FwAssertArgType>(_status)
1813  );
1814 #endif
1815  _status = _logBuff.serializeFrom(length);
1816  FW_ASSERT(
1817  _status == Fw::FW_SERIALIZE_OK,
1818  static_cast<FwAssertArgType>(_status)
1819  );
1820 
1821 #if FW_AMPCS_COMPATIBLE
1822  // Serialize the argument size
1823  _status = _logBuff.serializeFrom(
1824  static_cast<U8>(sizeof(U32))
1825  );
1826  FW_ASSERT(
1827  _status == Fw::FW_SERIALIZE_OK,
1828  static_cast<FwAssertArgType>(_status)
1829  );
1830 #endif
1831  _status = _logBuff.serializeFrom(filesize);
1832  FW_ASSERT(
1833  _status == Fw::FW_SERIALIZE_OK,
1834  static_cast<FwAssertArgType>(_status)
1835  );
1836 
1837  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1838  FW_ASSERT(
1839  _status == Fw::FW_SERIALIZE_OK,
1840  static_cast<FwAssertArgType>(_status)
1841  );
1842 
1843  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1844  FW_ASSERT(
1845  _status == Fw::FW_SERIALIZE_OK,
1846  static_cast<FwAssertArgType>(_status)
1847  );
1848 
1849  this->m_eventOut_OutputPort[0].invoke(
1850  _id,
1851  _logTime,
1853  _logBuff
1854  );
1855  }
1856 
1857  // Emit the event on the text log port
1858 #if FW_ENABLE_TEXT_LOGGING
1859  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1860 #if FW_OBJECT_NAMES == 1
1861  const char* _formatString =
1862  "(%s) %s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
1863 #else
1864  const char* _formatString =
1865  "%s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
1866 #endif
1867 
1868  Fw::TextLogString _logString;
1869  _logString.format(
1870  _formatString,
1871 #if FW_OBJECT_NAMES == 1
1872  this->m_objName.toChar(),
1873 #endif
1874  "DownlinkPartialWarning ",
1875  startOffset,
1876  length,
1877  filesize,
1878  sourceFileName.toChar(),
1879  destFileName.toChar()
1880  );
1881 
1882  this->m_textEventOut_OutputPort[0].invoke(
1883  _id,
1884  _logTime,
1886  _logString
1887  );
1888  }
1889 #endif
1890  }
1891 
1894  const Fw::StringBase& sourceFileName,
1895  const Fw::StringBase& destFileName,
1896  U32 startOffset,
1897  U32 filesize
1898  ) const
1899  {
1900  // Get the time
1901  Fw::Time _logTime;
1902  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1903  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1904  }
1905 
1906  FwEventIdType _id = static_cast<FwEventIdType>(0);
1907 
1908  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALFAIL;
1909 
1910  // Emit the event on the log port
1911  if (this->m_eventOut_OutputPort[0].isConnected()) {
1912  Fw::LogBuffer _logBuff;
1914 
1915 #if FW_AMPCS_COMPATIBLE
1916  // Serialize the number of arguments
1917  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1918  FW_ASSERT(
1919  _status == Fw::FW_SERIALIZE_OK,
1920  static_cast<FwAssertArgType>(_status)
1921  );
1922 #endif
1923 
1924  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1925  FW_ASSERT(
1926  _status == Fw::FW_SERIALIZE_OK,
1927  static_cast<FwAssertArgType>(_status)
1928  );
1929 
1930  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1931  FW_ASSERT(
1932  _status == Fw::FW_SERIALIZE_OK,
1933  static_cast<FwAssertArgType>(_status)
1934  );
1935 
1936 #if FW_AMPCS_COMPATIBLE
1937  // Serialize the argument size
1938  _status = _logBuff.serializeFrom(
1939  static_cast<U8>(sizeof(U32))
1940  );
1941  FW_ASSERT(
1942  _status == Fw::FW_SERIALIZE_OK,
1943  static_cast<FwAssertArgType>(_status)
1944  );
1945 #endif
1946  _status = _logBuff.serializeFrom(startOffset);
1947  FW_ASSERT(
1948  _status == Fw::FW_SERIALIZE_OK,
1949  static_cast<FwAssertArgType>(_status)
1950  );
1951 
1952 #if FW_AMPCS_COMPATIBLE
1953  // Serialize the argument size
1954  _status = _logBuff.serializeFrom(
1955  static_cast<U8>(sizeof(U32))
1956  );
1957  FW_ASSERT(
1958  _status == Fw::FW_SERIALIZE_OK,
1959  static_cast<FwAssertArgType>(_status)
1960  );
1961 #endif
1962  _status = _logBuff.serializeFrom(filesize);
1963  FW_ASSERT(
1964  _status == Fw::FW_SERIALIZE_OK,
1965  static_cast<FwAssertArgType>(_status)
1966  );
1967 
1968  this->m_eventOut_OutputPort[0].invoke(
1969  _id,
1970  _logTime,
1972  _logBuff
1973  );
1974  }
1975 
1976  // Emit the event on the text log port
1977 #if FW_ENABLE_TEXT_LOGGING
1978  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1979 #if FW_OBJECT_NAMES == 1
1980  const char* _formatString =
1981  "(%s) %s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
1982 #else
1983  const char* _formatString =
1984  "%s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
1985 #endif
1986 
1987  Fw::TextLogString _logString;
1988  _logString.format(
1989  _formatString,
1990 #if FW_OBJECT_NAMES == 1
1991  this->m_objName.toChar(),
1992 #endif
1993  "DownlinkPartialFail ",
1994  sourceFileName.toChar(),
1995  destFileName.toChar(),
1996  startOffset,
1997  filesize
1998  );
1999 
2000  this->m_textEventOut_OutputPort[0].invoke(
2001  _id,
2002  _logTime,
2004  _logString
2005  );
2006  }
2007 #endif
2008  }
2009 
2012  const Fw::StringBase& sourceFileName,
2013  U32 byteOffset
2014  ) const
2015  {
2016  // Get the time
2017  Fw::Time _logTime;
2018  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2019  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2020  }
2021 
2022  FwEventIdType _id = static_cast<FwEventIdType>(0);
2023 
2024  _id = this->getIdBase() + EVENTID_SENDDATAFAIL;
2025 
2026  // Emit the event on the log port
2027  if (this->m_eventOut_OutputPort[0].isConnected()) {
2028  Fw::LogBuffer _logBuff;
2030 
2031 #if FW_AMPCS_COMPATIBLE
2032  // Serialize the number of arguments
2033  _status = _logBuff.serializeFrom(static_cast<U8>(2));
2034  FW_ASSERT(
2035  _status == Fw::FW_SERIALIZE_OK,
2036  static_cast<FwAssertArgType>(_status)
2037  );
2038 #endif
2039 
2040  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2041  FW_ASSERT(
2042  _status == Fw::FW_SERIALIZE_OK,
2043  static_cast<FwAssertArgType>(_status)
2044  );
2045 
2046 #if FW_AMPCS_COMPATIBLE
2047  // Serialize the argument size
2048  _status = _logBuff.serializeFrom(
2049  static_cast<U8>(sizeof(U32))
2050  );
2051  FW_ASSERT(
2052  _status == Fw::FW_SERIALIZE_OK,
2053  static_cast<FwAssertArgType>(_status)
2054  );
2055 #endif
2056  _status = _logBuff.serializeFrom(byteOffset);
2057  FW_ASSERT(
2058  _status == Fw::FW_SERIALIZE_OK,
2059  static_cast<FwAssertArgType>(_status)
2060  );
2061 
2062  this->m_eventOut_OutputPort[0].invoke(
2063  _id,
2064  _logTime,
2066  _logBuff
2067  );
2068  }
2069 
2070  // Emit the event on the text log port
2071 #if FW_ENABLE_TEXT_LOGGING
2072  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2073 #if FW_OBJECT_NAMES == 1
2074  const char* _formatString =
2075  "(%s) %s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2076 #else
2077  const char* _formatString =
2078  "%s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2079 #endif
2080 
2081  Fw::TextLogString _logString;
2082  _logString.format(
2083  _formatString,
2084 #if FW_OBJECT_NAMES == 1
2085  this->m_objName.toChar(),
2086 #endif
2087  "SendDataFail ",
2088  sourceFileName.toChar(),
2089  byteOffset
2090  );
2091 
2092  this->m_textEventOut_OutputPort[0].invoke(
2093  _id,
2094  _logTime,
2096  _logString
2097  );
2098  }
2099 #endif
2100  }
2101 
2104  U32 fileSize,
2105  const Fw::StringBase& sourceFileName,
2106  const Fw::StringBase& destFileName
2107  ) const
2108  {
2109  // Get the time
2110  Fw::Time _logTime;
2111  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2112  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2113  }
2114 
2115  FwEventIdType _id = static_cast<FwEventIdType>(0);
2116 
2117  _id = this->getIdBase() + EVENTID_SENDSTARTED;
2118 
2119  // Emit the event on the log port
2120  if (this->m_eventOut_OutputPort[0].isConnected()) {
2121  Fw::LogBuffer _logBuff;
2123 
2124 #if FW_AMPCS_COMPATIBLE
2125  // Serialize the number of arguments
2126  _status = _logBuff.serializeFrom(static_cast<U8>(3));
2127  FW_ASSERT(
2128  _status == Fw::FW_SERIALIZE_OK,
2129  static_cast<FwAssertArgType>(_status)
2130  );
2131 #endif
2132 
2133 #if FW_AMPCS_COMPATIBLE
2134  // Serialize the argument size
2135  _status = _logBuff.serializeFrom(
2136  static_cast<U8>(sizeof(U32))
2137  );
2138  FW_ASSERT(
2139  _status == Fw::FW_SERIALIZE_OK,
2140  static_cast<FwAssertArgType>(_status)
2141  );
2142 #endif
2143  _status = _logBuff.serializeFrom(fileSize);
2144  FW_ASSERT(
2145  _status == Fw::FW_SERIALIZE_OK,
2146  static_cast<FwAssertArgType>(_status)
2147  );
2148 
2149  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2150  FW_ASSERT(
2151  _status == Fw::FW_SERIALIZE_OK,
2152  static_cast<FwAssertArgType>(_status)
2153  );
2154 
2155  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2156  FW_ASSERT(
2157  _status == Fw::FW_SERIALIZE_OK,
2158  static_cast<FwAssertArgType>(_status)
2159  );
2160 
2161  this->m_eventOut_OutputPort[0].invoke(
2162  _id,
2163  _logTime,
2165  _logBuff
2166  );
2167  }
2168 
2169  // Emit the event on the text log port
2170 #if FW_ENABLE_TEXT_LOGGING
2171  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2172 #if FW_OBJECT_NAMES == 1
2173  const char* _formatString =
2174  "(%s) %s: Downlink of %" PRIu32 " bytes started from %s to %s";
2175 #else
2176  const char* _formatString =
2177  "%s: Downlink of %" PRIu32 " bytes started from %s to %s";
2178 #endif
2179 
2180  Fw::TextLogString _logString;
2181  _logString.format(
2182  _formatString,
2183 #if FW_OBJECT_NAMES == 1
2184  this->m_objName.toChar(),
2185 #endif
2186  "SendStarted ",
2187  fileSize,
2188  sourceFileName.toChar(),
2189  destFileName.toChar()
2190  );
2191 
2192  this->m_textEventOut_OutputPort[0].invoke(
2193  _id,
2194  _logTime,
2196  _logString
2197  );
2198  }
2199 #endif
2200  }
2201 
2202  // ----------------------------------------------------------------------
2203  // Telemetry write functions
2204  // ----------------------------------------------------------------------
2205 
2208  U32 arg,
2209  Fw::Time _tlmTime
2210  ) const
2211  {
2212  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2213  if (
2214  this->m_timeCaller_OutputPort[0].isConnected() &&
2215  (_tlmTime == Fw::ZERO_TIME)
2216  ) {
2217  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2218  }
2219 
2220  Fw::TlmBuffer _tlmBuff;
2221  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2222  FW_ASSERT(
2223  _stat == Fw::FW_SERIALIZE_OK,
2224  static_cast<FwAssertArgType>(_stat)
2225  );
2226 
2227  FwChanIdType _id;
2228 
2229  _id = this->getIdBase() + CHANNELID_FILESSENT;
2230 
2231  this->m_tlmOut_OutputPort[0].invoke(
2232  _id,
2233  _tlmTime,
2234  _tlmBuff
2235  );
2236  }
2237  }
2238 
2241  U32 arg,
2242  Fw::Time _tlmTime
2243  ) const
2244  {
2245  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2246  if (
2247  this->m_timeCaller_OutputPort[0].isConnected() &&
2248  (_tlmTime == Fw::ZERO_TIME)
2249  ) {
2250  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2251  }
2252 
2253  Fw::TlmBuffer _tlmBuff;
2254  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2255  FW_ASSERT(
2256  _stat == Fw::FW_SERIALIZE_OK,
2257  static_cast<FwAssertArgType>(_stat)
2258  );
2259 
2260  FwChanIdType _id;
2261 
2262  _id = this->getIdBase() + CHANNELID_PACKETSSENT;
2263 
2264  this->m_tlmOut_OutputPort[0].invoke(
2265  _id,
2266  _tlmTime,
2267  _tlmBuff
2268  );
2269  }
2270  }
2271 
2274  U32 arg,
2275  Fw::Time _tlmTime
2276  ) const
2277  {
2278  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2279  if (
2280  this->m_timeCaller_OutputPort[0].isConnected() &&
2281  (_tlmTime == Fw::ZERO_TIME)
2282  ) {
2283  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2284  }
2285 
2286  Fw::TlmBuffer _tlmBuff;
2287  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2288  FW_ASSERT(
2289  _stat == Fw::FW_SERIALIZE_OK,
2290  static_cast<FwAssertArgType>(_stat)
2291  );
2292 
2293  FwChanIdType _id;
2294 
2295  _id = this->getIdBase() + CHANNELID_WARNINGS;
2296 
2297  this->m_tlmOut_OutputPort[0].invoke(
2298  _id,
2299  _tlmTime,
2300  _tlmBuff
2301  );
2302  }
2303  }
2304 
2305  // ----------------------------------------------------------------------
2306  // Time
2307  // ----------------------------------------------------------------------
2308 
2310  getTime() const
2311  {
2312  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2313  Fw::Time _time;
2314  this->m_timeCaller_OutputPort[0].invoke(_time);
2315  return _time;
2316  }
2317  else {
2318  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2319  }
2320  }
2321 
2322  // ----------------------------------------------------------------------
2323  // Mutex operations for guarded ports
2324  //
2325  // You can override these operations to provide more sophisticated
2326  // synchronization
2327  // ----------------------------------------------------------------------
2328 
2331  {
2332  this->m_guardedPortMutex.lock();
2333  }
2334 
2337  {
2338  this->m_guardedPortMutex.unLock();
2339  }
2340 
2341  // ----------------------------------------------------------------------
2342  // Message dispatch functions
2343  // ----------------------------------------------------------------------
2344 
2345  Fw::QueuedComponentBase::MsgDispatchStatus FileDownlinkComponentBase ::
2346  doDispatch()
2347  {
2348  ComponentIpcSerializableBuffer _msg;
2349  FwQueuePriorityType _priority = 0;
2350 
2351  Os::Queue::Status _msgStatus = this->m_queue.receive(
2352  _msg,
2354  _priority
2355  );
2356  FW_ASSERT(
2357  _msgStatus == Os::Queue::OP_OK,
2358  static_cast<FwAssertArgType>(_msgStatus)
2359  );
2360 
2361  // Reset to beginning of buffer
2362  _msg.resetDeser();
2363 
2364  FwEnumStoreType _desMsg = 0;
2365  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2366  FW_ASSERT(
2367  _deserStatus == Fw::FW_SERIALIZE_OK,
2368  static_cast<FwAssertArgType>(_deserStatus)
2369  );
2370 
2371  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2372 
2373  if (_msgType == FILEDOWNLINK_COMPONENT_EXIT) {
2374  return MSG_DISPATCH_EXIT;
2375  }
2376 
2377  FwIndexType portNum = 0;
2378  _deserStatus = _msg.deserializeTo(portNum);
2379  FW_ASSERT(
2380  _deserStatus == Fw::FW_SERIALIZE_OK,
2381  static_cast<FwAssertArgType>(_deserStatus)
2382  );
2383 
2384  switch (_msgType) {
2385  // Handle async input port Run
2386  case RUN_SCHED: {
2387  // Deserialize argument context
2388  U32 context;
2389  _deserStatus = _msg.deserializeTo(context);
2390  FW_ASSERT(
2391  _deserStatus == Fw::FW_SERIALIZE_OK,
2392  static_cast<FwAssertArgType>(_deserStatus)
2393  );
2394  // Call handler function
2395  this->Run_handler(
2396  portNum,
2397  context
2398  );
2399 
2400  break;
2401  }
2402 
2403  // Handle async input port bufferReturn
2404  case BUFFERRETURN_BUFFERSEND: {
2405  // Deserialize argument fwBuffer
2406  Fw::Buffer fwBuffer;
2407  _deserStatus = _msg.deserializeTo(fwBuffer);
2408  FW_ASSERT(
2409  _deserStatus == Fw::FW_SERIALIZE_OK,
2410  static_cast<FwAssertArgType>(_deserStatus)
2411  );
2412  // Call handler function
2413  this->bufferReturn_handler(
2414  portNum,
2415  fwBuffer
2416  );
2417 
2418  break;
2419  }
2420 
2421  // Handle async input port pingIn
2422  case PINGIN_PING: {
2423  // Deserialize argument key
2424  U32 key;
2425  _deserStatus = _msg.deserializeTo(key);
2426  FW_ASSERT(
2427  _deserStatus == Fw::FW_SERIALIZE_OK,
2428  static_cast<FwAssertArgType>(_deserStatus)
2429  );
2430  // Call handler function
2431  this->pingIn_handler(
2432  portNum,
2433  key
2434  );
2435 
2436  break;
2437  }
2438 
2439  // Handle command SendFile
2440  case CMD_SENDFILE: {
2441  // Deserialize opcode
2442  FwOpcodeType _opCode = 0;
2443  _deserStatus = _msg.deserializeTo(_opCode);
2444  FW_ASSERT (
2445  _deserStatus == Fw::FW_SERIALIZE_OK,
2446  static_cast<FwAssertArgType>(_deserStatus)
2447  );
2448 
2449  // Deserialize command sequence
2450  U32 _cmdSeq = 0;
2451  _deserStatus = _msg.deserializeTo(_cmdSeq);
2452  FW_ASSERT (
2453  _deserStatus == Fw::FW_SERIALIZE_OK,
2454  static_cast<FwAssertArgType>(_deserStatus)
2455  );
2456 
2457  // Deserialize command argument buffer
2458  Fw::CmdArgBuffer args;
2459  _deserStatus = _msg.deserializeTo(args);
2460  FW_ASSERT (
2461  _deserStatus == Fw::FW_SERIALIZE_OK,
2462  static_cast<FwAssertArgType>(_deserStatus)
2463  );
2464 
2465  // Reset buffer
2466  args.resetDeser();
2467 
2468  // Deserialize argument sourceFileName
2469  Fw::CmdStringArg sourceFileName;
2470  _deserStatus = args.deserializeTo(sourceFileName);
2471  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2472  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2473  this->cmdResponse_out(
2474  _opCode,
2475  _cmdSeq,
2477  );
2478  }
2479  // Don't crash the task if bad arguments were passed from the ground
2480  break;
2481  }
2482 
2483  // Deserialize argument destFileName
2484  Fw::CmdStringArg destFileName;
2485  _deserStatus = args.deserializeTo(destFileName);
2486  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2487  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2488  this->cmdResponse_out(
2489  _opCode,
2490  _cmdSeq,
2492  );
2493  }
2494  // Don't crash the task if bad arguments were passed from the ground
2495  break;
2496  }
2497 
2498  // Make sure there was no data left over.
2499  // That means the argument buffer size was incorrect.
2500 #if FW_CMD_CHECK_RESIDUAL
2501  if (args.getDeserializeSizeLeft() != 0) {
2502  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2503  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2504  }
2505  // Don't crash the task if bad arguments were passed from the ground
2506  break;
2507  }
2508 #endif
2509 
2510  // Call handler function
2511  this->SendFile_cmdHandler(
2512  _opCode, _cmdSeq,
2513  sourceFileName,
2514  destFileName
2515  );
2516 
2517  break;
2518  }
2519 
2520  // Handle command Cancel
2521  case CMD_CANCEL: {
2522  // Deserialize opcode
2523  FwOpcodeType _opCode = 0;
2524  _deserStatus = _msg.deserializeTo(_opCode);
2525  FW_ASSERT (
2526  _deserStatus == Fw::FW_SERIALIZE_OK,
2527  static_cast<FwAssertArgType>(_deserStatus)
2528  );
2529 
2530  // Deserialize command sequence
2531  U32 _cmdSeq = 0;
2532  _deserStatus = _msg.deserializeTo(_cmdSeq);
2533  FW_ASSERT (
2534  _deserStatus == Fw::FW_SERIALIZE_OK,
2535  static_cast<FwAssertArgType>(_deserStatus)
2536  );
2537 
2538  // Deserialize command argument buffer
2539  Fw::CmdArgBuffer args;
2540  _deserStatus = _msg.deserializeTo(args);
2541  FW_ASSERT (
2542  _deserStatus == Fw::FW_SERIALIZE_OK,
2543  static_cast<FwAssertArgType>(_deserStatus)
2544  );
2545 
2546  // Reset buffer
2547  args.resetDeser();
2548 
2549  // Make sure there was no data left over.
2550  // That means the argument buffer size was incorrect.
2551 #if FW_CMD_CHECK_RESIDUAL
2552  if (args.getDeserializeSizeLeft() != 0) {
2553  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2554  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2555  }
2556  // Don't crash the task if bad arguments were passed from the ground
2557  break;
2558  }
2559 #endif
2560 
2561  // Call handler function
2562  this->Cancel_cmdHandler(_opCode, _cmdSeq);
2563 
2564  break;
2565  }
2566 
2567  // Handle command SendPartial
2568  case CMD_SENDPARTIAL: {
2569  // Deserialize opcode
2570  FwOpcodeType _opCode = 0;
2571  _deserStatus = _msg.deserializeTo(_opCode);
2572  FW_ASSERT (
2573  _deserStatus == Fw::FW_SERIALIZE_OK,
2574  static_cast<FwAssertArgType>(_deserStatus)
2575  );
2576 
2577  // Deserialize command sequence
2578  U32 _cmdSeq = 0;
2579  _deserStatus = _msg.deserializeTo(_cmdSeq);
2580  FW_ASSERT (
2581  _deserStatus == Fw::FW_SERIALIZE_OK,
2582  static_cast<FwAssertArgType>(_deserStatus)
2583  );
2584 
2585  // Deserialize command argument buffer
2586  Fw::CmdArgBuffer args;
2587  _deserStatus = _msg.deserializeTo(args);
2588  FW_ASSERT (
2589  _deserStatus == Fw::FW_SERIALIZE_OK,
2590  static_cast<FwAssertArgType>(_deserStatus)
2591  );
2592 
2593  // Reset buffer
2594  args.resetDeser();
2595 
2596  // Deserialize argument sourceFileName
2597  Fw::CmdStringArg sourceFileName;
2598  _deserStatus = args.deserializeTo(sourceFileName);
2599  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2600  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2601  this->cmdResponse_out(
2602  _opCode,
2603  _cmdSeq,
2605  );
2606  }
2607  // Don't crash the task if bad arguments were passed from the ground
2608  break;
2609  }
2610 
2611  // Deserialize argument destFileName
2612  Fw::CmdStringArg destFileName;
2613  _deserStatus = args.deserializeTo(destFileName);
2614  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2615  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2616  this->cmdResponse_out(
2617  _opCode,
2618  _cmdSeq,
2620  );
2621  }
2622  // Don't crash the task if bad arguments were passed from the ground
2623  break;
2624  }
2625 
2626  // Deserialize argument startOffset
2627  U32 startOffset;
2628  _deserStatus = args.deserializeTo(startOffset);
2629  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2630  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2631  this->cmdResponse_out(
2632  _opCode,
2633  _cmdSeq,
2635  );
2636  }
2637  // Don't crash the task if bad arguments were passed from the ground
2638  break;
2639  }
2640 
2641  // Deserialize argument length
2642  U32 length;
2643  _deserStatus = args.deserializeTo(length);
2644  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2645  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2646  this->cmdResponse_out(
2647  _opCode,
2648  _cmdSeq,
2650  );
2651  }
2652  // Don't crash the task if bad arguments were passed from the ground
2653  break;
2654  }
2655 
2656  // Make sure there was no data left over.
2657  // That means the argument buffer size was incorrect.
2658 #if FW_CMD_CHECK_RESIDUAL
2659  if (args.getDeserializeSizeLeft() != 0) {
2660  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2661  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2662  }
2663  // Don't crash the task if bad arguments were passed from the ground
2664  break;
2665  }
2666 #endif
2667 
2668  // Call handler function
2669  this->SendPartial_cmdHandler(
2670  _opCode, _cmdSeq,
2671  sourceFileName,
2672  destFileName,
2673  startOffset,
2674  length
2675  );
2676 
2677  break;
2678  }
2679 
2680  default:
2681  return MSG_DISPATCH_ERROR;
2682  }
2683 
2684  return MSG_DISPATCH_OK;
2685  }
2686 
2687  // ----------------------------------------------------------------------
2688  // Calls for messages received on special input ports
2689  // ----------------------------------------------------------------------
2690 
2691  void FileDownlinkComponentBase ::
2692  m_p_cmdIn_in(
2693  Fw::PassiveComponentBase* callComp,
2694  FwIndexType portNum,
2695  FwOpcodeType opCode,
2696  U32 cmdSeq,
2697  Fw::CmdArgBuffer& args
2698  )
2699  {
2700  FW_ASSERT(callComp);
2701  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2702 
2703  const U32 idBase = callComp->getIdBase();
2704  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2705 
2706  // Select base class function based on opcode
2707  switch (opCode - idBase) {
2708  case OPCODE_SENDFILE: {
2709  compPtr->SendFile_cmdHandlerBase(
2710  opCode,
2711  cmdSeq,
2712  args
2713  );
2714  break;
2715  }
2716 
2717  case OPCODE_CANCEL: {
2718  compPtr->Cancel_cmdHandlerBase(
2719  opCode,
2720  cmdSeq,
2721  args
2722  );
2723  break;
2724  }
2725 
2726  case OPCODE_SENDPARTIAL: {
2727  compPtr->SendPartial_cmdHandlerBase(
2728  opCode,
2729  cmdSeq,
2730  args
2731  );
2732  break;
2733  }
2734  }
2735  }
2736 
2737  // ----------------------------------------------------------------------
2738  // Calls for messages received on typed input ports
2739  // ----------------------------------------------------------------------
2740 
2741  void FileDownlinkComponentBase ::
2742  m_p_Run_in(
2743  Fw::PassiveComponentBase* callComp,
2744  FwIndexType portNum,
2745  U32 context
2746  )
2747  {
2748  FW_ASSERT(callComp);
2749  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2750  compPtr->Run_handlerBase(
2751  portNum,
2752  context
2753  );
2754  }
2755 
2756  Svc::SendFileResponse FileDownlinkComponentBase ::
2757  m_p_SendFile_in(
2758  Fw::PassiveComponentBase* callComp,
2759  FwIndexType portNum,
2760  const Fw::StringBase& sourceFileName,
2761  const Fw::StringBase& destFileName,
2762  U32 offset,
2763  U32 length
2764  )
2765  {
2766  FW_ASSERT(callComp);
2767  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2768  return compPtr->SendFile_handlerBase(
2769  portNum,
2770  sourceFileName,
2771  destFileName,
2772  offset,
2773  length
2774  );
2775  }
2776 
2777  void FileDownlinkComponentBase ::
2778  m_p_bufferReturn_in(
2779  Fw::PassiveComponentBase* callComp,
2780  FwIndexType portNum,
2781  Fw::Buffer& fwBuffer
2782  )
2783  {
2784  FW_ASSERT(callComp);
2785  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2786  compPtr->bufferReturn_handlerBase(
2787  portNum,
2788  fwBuffer
2789  );
2790  }
2791 
2792  void FileDownlinkComponentBase ::
2793  m_p_pingIn_in(
2794  Fw::PassiveComponentBase* callComp,
2795  FwIndexType portNum,
2796  U32 key
2797  )
2798  {
2799  FW_ASSERT(callComp);
2800  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2801  compPtr->pingIn_handlerBase(
2802  portNum,
2803  key
2804  );
2805  }
2806 
2807 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
FwIdType FwOpcodeType
The type of a command opcode.
Operation succeeded.
Definition: Os.hpp:26
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
const Time ZERO_TIME
Definition: Time.cpp:5
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
Enum representing a command response.
No time base has been established (Required)
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
void init()
Initialization function.
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:24
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:47
FwIdType FwEventIdType
The type of an event identifier.
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:26
void init()
Initialization function.
Definition: TimePortAc.cpp:128
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:92
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
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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
Definition: Queue.cpp:54
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
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:38
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
The size of the serial representations of the port arguments.
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
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
A message was sent requesting an exit of the loop.
message to exit active component task
PlatformIndexType FwIndexType
Send file response struct.
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
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
U8 BYTE
byte type
Definition: BasicTypes.h:56
void invoke(const Svc::SendFileResponse &resp) const
Invoke a port interface.
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:48
Implementation of malloc based allocator.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
void init()
Initialization function.
void addCallPort(InputSendFileCompletePort *callPort)
Register an input port.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.