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 getBuffCapacity() const {
54  return sizeof(m_buff);
55  }
56 
57  U8* getBuffAddr() {
58  return m_buff;
59  }
60 
61  const U8* getBuffAddr() const {
62  return m_buff;
63  }
64 
65  private:
66  // Should be the max of all the input ports serialized sizes...
67  U8 m_buff[SERIALIZATION_SIZE];
68 
69  };
70  }
71 
72  // ----------------------------------------------------------------------
73  // Component initialization
74  // ----------------------------------------------------------------------
75 
78  FwSizeType queueDepth,
79  FwEnumStoreType instance
80  )
81  {
82  // Initialize base class
84 
85  // Connect input port cmdIn
86  for (
87  FwIndexType port = 0;
88  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
89  port++
90  ) {
91  this->m_cmdIn_InputPort[port].init();
92  this->m_cmdIn_InputPort[port].addCallComp(
93  this,
94  m_p_cmdIn_in
95  );
96  this->m_cmdIn_InputPort[port].setPortNum(port);
97 
98 #if FW_OBJECT_NAMES == 1
99  Fw::ObjectName portName;
100  portName.format(
101  "%s_cmdIn_InputPort[%" PRI_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  const Fw::StringBase& sourceFileName,
1759  const Fw::StringBase& destFileName
1760  ) const
1761  {
1762  // Get the time
1763  Fw::Time _logTime;
1764  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1765  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1766  }
1767 
1768  FwEventIdType _id = static_cast<FwEventIdType>(0);
1769 
1770  _id = this->getIdBase() + EVENTID_DOWNLINKTIMEOUT;
1771 
1772  // Emit the event on the log port
1773  if (this->m_eventOut_OutputPort[0].isConnected()) {
1774  Fw::LogBuffer _logBuff;
1776 
1777 #if FW_AMPCS_COMPATIBLE
1778  // Serialize the number of arguments
1779  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1780  FW_ASSERT(
1781  _status == Fw::FW_SERIALIZE_OK,
1782  static_cast<FwAssertArgType>(_status)
1783  );
1784 #endif
1785 
1786  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1787  FW_ASSERT(
1788  _status == Fw::FW_SERIALIZE_OK,
1789  static_cast<FwAssertArgType>(_status)
1790  );
1791 
1792  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1793  FW_ASSERT(
1794  _status == Fw::FW_SERIALIZE_OK,
1795  static_cast<FwAssertArgType>(_status)
1796  );
1797 
1798  this->m_eventOut_OutputPort[0].invoke(
1799  _id,
1800  _logTime,
1802  _logBuff
1803  );
1804  }
1805 
1806  // Emit the event on the text log port
1807 #if FW_ENABLE_TEXT_LOGGING
1808  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1809 #if FW_OBJECT_NAMES == 1
1810  const char* _formatString =
1811  "(%s) %s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
1812 #else
1813  const char* _formatString =
1814  "%s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
1815 #endif
1816 
1817  Fw::TextLogString _logString;
1818  _logString.format(
1819  _formatString,
1820 #if FW_OBJECT_NAMES == 1
1821  this->m_objName.toChar(),
1822 #endif
1823  "DownlinkTimeout ",
1824  sourceFileName.toChar(),
1825  destFileName.toChar()
1826  );
1827 
1828  this->m_textEventOut_OutputPort[0].invoke(
1829  _id,
1830  _logTime,
1832  _logString
1833  );
1834  }
1835 #endif
1836  }
1837 
1840  U32 startOffset,
1841  U32 length,
1842  U32 filesize,
1843  const Fw::StringBase& sourceFileName,
1844  const Fw::StringBase& destFileName
1845  ) const
1846  {
1847  // Get the time
1848  Fw::Time _logTime;
1849  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1850  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1851  }
1852 
1853  FwEventIdType _id = static_cast<FwEventIdType>(0);
1854 
1855  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALWARNING;
1856 
1857  // Emit the event on the log port
1858  if (this->m_eventOut_OutputPort[0].isConnected()) {
1859  Fw::LogBuffer _logBuff;
1861 
1862 #if FW_AMPCS_COMPATIBLE
1863  // Serialize the number of arguments
1864  _status = _logBuff.serializeFrom(static_cast<U8>(5));
1865  FW_ASSERT(
1866  _status == Fw::FW_SERIALIZE_OK,
1867  static_cast<FwAssertArgType>(_status)
1868  );
1869 #endif
1870 
1871 #if FW_AMPCS_COMPATIBLE
1872  // Serialize the argument size
1873  _status = _logBuff.serializeFrom(
1874  static_cast<U8>(sizeof(U32))
1875  );
1876  FW_ASSERT(
1877  _status == Fw::FW_SERIALIZE_OK,
1878  static_cast<FwAssertArgType>(_status)
1879  );
1880 #endif
1881  _status = _logBuff.serializeFrom(startOffset);
1882  FW_ASSERT(
1883  _status == Fw::FW_SERIALIZE_OK,
1884  static_cast<FwAssertArgType>(_status)
1885  );
1886 
1887 #if FW_AMPCS_COMPATIBLE
1888  // Serialize the argument size
1889  _status = _logBuff.serializeFrom(
1890  static_cast<U8>(sizeof(U32))
1891  );
1892  FW_ASSERT(
1893  _status == Fw::FW_SERIALIZE_OK,
1894  static_cast<FwAssertArgType>(_status)
1895  );
1896 #endif
1897  _status = _logBuff.serializeFrom(length);
1898  FW_ASSERT(
1899  _status == Fw::FW_SERIALIZE_OK,
1900  static_cast<FwAssertArgType>(_status)
1901  );
1902 
1903 #if FW_AMPCS_COMPATIBLE
1904  // Serialize the argument size
1905  _status = _logBuff.serializeFrom(
1906  static_cast<U8>(sizeof(U32))
1907  );
1908  FW_ASSERT(
1909  _status == Fw::FW_SERIALIZE_OK,
1910  static_cast<FwAssertArgType>(_status)
1911  );
1912 #endif
1913  _status = _logBuff.serializeFrom(filesize);
1914  FW_ASSERT(
1915  _status == Fw::FW_SERIALIZE_OK,
1916  static_cast<FwAssertArgType>(_status)
1917  );
1918 
1919  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1920  FW_ASSERT(
1921  _status == Fw::FW_SERIALIZE_OK,
1922  static_cast<FwAssertArgType>(_status)
1923  );
1924 
1925  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
1926  FW_ASSERT(
1927  _status == Fw::FW_SERIALIZE_OK,
1928  static_cast<FwAssertArgType>(_status)
1929  );
1930 
1931  this->m_eventOut_OutputPort[0].invoke(
1932  _id,
1933  _logTime,
1935  _logBuff
1936  );
1937  }
1938 
1939  // Emit the event on the text log port
1940 #if FW_ENABLE_TEXT_LOGGING
1941  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1942 #if FW_OBJECT_NAMES == 1
1943  const char* _formatString =
1944  "(%s) %s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
1945 #else
1946  const char* _formatString =
1947  "%s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
1948 #endif
1949 
1950  Fw::TextLogString _logString;
1951  _logString.format(
1952  _formatString,
1953 #if FW_OBJECT_NAMES == 1
1954  this->m_objName.toChar(),
1955 #endif
1956  "DownlinkPartialWarning ",
1957  startOffset,
1958  length,
1959  filesize,
1960  sourceFileName.toChar(),
1961  destFileName.toChar()
1962  );
1963 
1964  this->m_textEventOut_OutputPort[0].invoke(
1965  _id,
1966  _logTime,
1968  _logString
1969  );
1970  }
1971 #endif
1972  }
1973 
1976  const Fw::StringBase& sourceFileName,
1977  const Fw::StringBase& destFileName,
1978  U32 startOffset,
1979  U32 filesize
1980  ) const
1981  {
1982  // Get the time
1983  Fw::Time _logTime;
1984  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1985  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1986  }
1987 
1988  FwEventIdType _id = static_cast<FwEventIdType>(0);
1989 
1990  _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALFAIL;
1991 
1992  // Emit the event on the log port
1993  if (this->m_eventOut_OutputPort[0].isConnected()) {
1994  Fw::LogBuffer _logBuff;
1996 
1997 #if FW_AMPCS_COMPATIBLE
1998  // Serialize the number of arguments
1999  _status = _logBuff.serializeFrom(static_cast<U8>(4));
2000  FW_ASSERT(
2001  _status == Fw::FW_SERIALIZE_OK,
2002  static_cast<FwAssertArgType>(_status)
2003  );
2004 #endif
2005 
2006  _status = sourceFileName.serializeTo(_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.serializeTo(_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 #if FW_AMPCS_COMPATIBLE
2019  // Serialize the argument size
2020  _status = _logBuff.serializeFrom(
2021  static_cast<U8>(sizeof(U32))
2022  );
2023  FW_ASSERT(
2024  _status == Fw::FW_SERIALIZE_OK,
2025  static_cast<FwAssertArgType>(_status)
2026  );
2027 #endif
2028  _status = _logBuff.serializeFrom(startOffset);
2029  FW_ASSERT(
2030  _status == Fw::FW_SERIALIZE_OK,
2031  static_cast<FwAssertArgType>(_status)
2032  );
2033 
2034 #if FW_AMPCS_COMPATIBLE
2035  // Serialize the argument size
2036  _status = _logBuff.serializeFrom(
2037  static_cast<U8>(sizeof(U32))
2038  );
2039  FW_ASSERT(
2040  _status == Fw::FW_SERIALIZE_OK,
2041  static_cast<FwAssertArgType>(_status)
2042  );
2043 #endif
2044  _status = _logBuff.serializeFrom(filesize);
2045  FW_ASSERT(
2046  _status == Fw::FW_SERIALIZE_OK,
2047  static_cast<FwAssertArgType>(_status)
2048  );
2049 
2050  this->m_eventOut_OutputPort[0].invoke(
2051  _id,
2052  _logTime,
2054  _logBuff
2055  );
2056  }
2057 
2058  // Emit the event on the text log port
2059 #if FW_ENABLE_TEXT_LOGGING
2060  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2061 #if FW_OBJECT_NAMES == 1
2062  const char* _formatString =
2063  "(%s) %s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2064 #else
2065  const char* _formatString =
2066  "%s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2067 #endif
2068 
2069  Fw::TextLogString _logString;
2070  _logString.format(
2071  _formatString,
2072 #if FW_OBJECT_NAMES == 1
2073  this->m_objName.toChar(),
2074 #endif
2075  "DownlinkPartialFail ",
2076  sourceFileName.toChar(),
2077  destFileName.toChar(),
2078  startOffset,
2079  filesize
2080  );
2081 
2082  this->m_textEventOut_OutputPort[0].invoke(
2083  _id,
2084  _logTime,
2086  _logString
2087  );
2088  }
2089 #endif
2090  }
2091 
2094  const Fw::StringBase& sourceFileName,
2095  U32 byteOffset
2096  ) const
2097  {
2098  // Get the time
2099  Fw::Time _logTime;
2100  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2101  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2102  }
2103 
2104  FwEventIdType _id = static_cast<FwEventIdType>(0);
2105 
2106  _id = this->getIdBase() + EVENTID_SENDDATAFAIL;
2107 
2108  // Emit the event on the log port
2109  if (this->m_eventOut_OutputPort[0].isConnected()) {
2110  Fw::LogBuffer _logBuff;
2112 
2113 #if FW_AMPCS_COMPATIBLE
2114  // Serialize the number of arguments
2115  _status = _logBuff.serializeFrom(static_cast<U8>(2));
2116  FW_ASSERT(
2117  _status == Fw::FW_SERIALIZE_OK,
2118  static_cast<FwAssertArgType>(_status)
2119  );
2120 #endif
2121 
2122  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2123  FW_ASSERT(
2124  _status == Fw::FW_SERIALIZE_OK,
2125  static_cast<FwAssertArgType>(_status)
2126  );
2127 
2128 #if FW_AMPCS_COMPATIBLE
2129  // Serialize the argument size
2130  _status = _logBuff.serializeFrom(
2131  static_cast<U8>(sizeof(U32))
2132  );
2133  FW_ASSERT(
2134  _status == Fw::FW_SERIALIZE_OK,
2135  static_cast<FwAssertArgType>(_status)
2136  );
2137 #endif
2138  _status = _logBuff.serializeFrom(byteOffset);
2139  FW_ASSERT(
2140  _status == Fw::FW_SERIALIZE_OK,
2141  static_cast<FwAssertArgType>(_status)
2142  );
2143 
2144  this->m_eventOut_OutputPort[0].invoke(
2145  _id,
2146  _logTime,
2148  _logBuff
2149  );
2150  }
2151 
2152  // Emit the event on the text log port
2153 #if FW_ENABLE_TEXT_LOGGING
2154  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2155 #if FW_OBJECT_NAMES == 1
2156  const char* _formatString =
2157  "(%s) %s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2158 #else
2159  const char* _formatString =
2160  "%s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2161 #endif
2162 
2163  Fw::TextLogString _logString;
2164  _logString.format(
2165  _formatString,
2166 #if FW_OBJECT_NAMES == 1
2167  this->m_objName.toChar(),
2168 #endif
2169  "SendDataFail ",
2170  sourceFileName.toChar(),
2171  byteOffset
2172  );
2173 
2174  this->m_textEventOut_OutputPort[0].invoke(
2175  _id,
2176  _logTime,
2178  _logString
2179  );
2180  }
2181 #endif
2182  }
2183 
2186  U32 fileSize,
2187  const Fw::StringBase& sourceFileName,
2188  const Fw::StringBase& destFileName
2189  ) const
2190  {
2191  // Get the time
2192  Fw::Time _logTime;
2193  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2194  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2195  }
2196 
2197  FwEventIdType _id = static_cast<FwEventIdType>(0);
2198 
2199  _id = this->getIdBase() + EVENTID_SENDSTARTED;
2200 
2201  // Emit the event on the log port
2202  if (this->m_eventOut_OutputPort[0].isConnected()) {
2203  Fw::LogBuffer _logBuff;
2205 
2206 #if FW_AMPCS_COMPATIBLE
2207  // Serialize the number of arguments
2208  _status = _logBuff.serializeFrom(static_cast<U8>(3));
2209  FW_ASSERT(
2210  _status == Fw::FW_SERIALIZE_OK,
2211  static_cast<FwAssertArgType>(_status)
2212  );
2213 #endif
2214 
2215 #if FW_AMPCS_COMPATIBLE
2216  // Serialize the argument size
2217  _status = _logBuff.serializeFrom(
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.serializeFrom(fileSize);
2226  FW_ASSERT(
2227  _status == Fw::FW_SERIALIZE_OK,
2228  static_cast<FwAssertArgType>(_status)
2229  );
2230 
2231  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2232  FW_ASSERT(
2233  _status == Fw::FW_SERIALIZE_OK,
2234  static_cast<FwAssertArgType>(_status)
2235  );
2236 
2237  _status = destFileName.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 100));
2238  FW_ASSERT(
2239  _status == Fw::FW_SERIALIZE_OK,
2240  static_cast<FwAssertArgType>(_status)
2241  );
2242 
2243  this->m_eventOut_OutputPort[0].invoke(
2244  _id,
2245  _logTime,
2247  _logBuff
2248  );
2249  }
2250 
2251  // Emit the event on the text log port
2252 #if FW_ENABLE_TEXT_LOGGING
2253  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2254 #if FW_OBJECT_NAMES == 1
2255  const char* _formatString =
2256  "(%s) %s: Downlink of %" PRIu32 " bytes started from %s to %s";
2257 #else
2258  const char* _formatString =
2259  "%s: Downlink of %" PRIu32 " bytes started from %s to %s";
2260 #endif
2261 
2262  Fw::TextLogString _logString;
2263  _logString.format(
2264  _formatString,
2265 #if FW_OBJECT_NAMES == 1
2266  this->m_objName.toChar(),
2267 #endif
2268  "SendStarted ",
2269  fileSize,
2270  sourceFileName.toChar(),
2271  destFileName.toChar()
2272  );
2273 
2274  this->m_textEventOut_OutputPort[0].invoke(
2275  _id,
2276  _logTime,
2278  _logString
2279  );
2280  }
2281 #endif
2282  }
2283 
2284  // ----------------------------------------------------------------------
2285  // Telemetry write functions
2286  // ----------------------------------------------------------------------
2287 
2290  U32 arg,
2291  Fw::Time _tlmTime
2292  ) const
2293  {
2294  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2295  if (
2296  this->m_timeCaller_OutputPort[0].isConnected() &&
2297  (_tlmTime == Fw::ZERO_TIME)
2298  ) {
2299  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2300  }
2301 
2302  Fw::TlmBuffer _tlmBuff;
2303  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2304  FW_ASSERT(
2305  _stat == Fw::FW_SERIALIZE_OK,
2306  static_cast<FwAssertArgType>(_stat)
2307  );
2308 
2309  FwChanIdType _id;
2310 
2311  _id = this->getIdBase() + CHANNELID_FILESSENT;
2312 
2313  this->m_tlmOut_OutputPort[0].invoke(
2314  _id,
2315  _tlmTime,
2316  _tlmBuff
2317  );
2318  }
2319  }
2320 
2323  U32 arg,
2324  Fw::Time _tlmTime
2325  ) const
2326  {
2327  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2328  if (
2329  this->m_timeCaller_OutputPort[0].isConnected() &&
2330  (_tlmTime == Fw::ZERO_TIME)
2331  ) {
2332  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2333  }
2334 
2335  Fw::TlmBuffer _tlmBuff;
2336  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2337  FW_ASSERT(
2338  _stat == Fw::FW_SERIALIZE_OK,
2339  static_cast<FwAssertArgType>(_stat)
2340  );
2341 
2342  FwChanIdType _id;
2343 
2344  _id = this->getIdBase() + CHANNELID_PACKETSSENT;
2345 
2346  this->m_tlmOut_OutputPort[0].invoke(
2347  _id,
2348  _tlmTime,
2349  _tlmBuff
2350  );
2351  }
2352  }
2353 
2356  U32 arg,
2357  Fw::Time _tlmTime
2358  ) const
2359  {
2360  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2361  if (
2362  this->m_timeCaller_OutputPort[0].isConnected() &&
2363  (_tlmTime == Fw::ZERO_TIME)
2364  ) {
2365  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2366  }
2367 
2368  Fw::TlmBuffer _tlmBuff;
2369  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2370  FW_ASSERT(
2371  _stat == Fw::FW_SERIALIZE_OK,
2372  static_cast<FwAssertArgType>(_stat)
2373  );
2374 
2375  FwChanIdType _id;
2376 
2377  _id = this->getIdBase() + CHANNELID_WARNINGS;
2378 
2379  this->m_tlmOut_OutputPort[0].invoke(
2380  _id,
2381  _tlmTime,
2382  _tlmBuff
2383  );
2384  }
2385  }
2386 
2387  // ----------------------------------------------------------------------
2388  // Time
2389  // ----------------------------------------------------------------------
2390 
2392  getTime() const
2393  {
2394  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2395  Fw::Time _time;
2396  this->m_timeCaller_OutputPort[0].invoke(_time);
2397  return _time;
2398  }
2399  else {
2400  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2401  }
2402  }
2403 
2404  // ----------------------------------------------------------------------
2405  // Mutex operations for guarded ports
2406  //
2407  // You can override these operations to provide more sophisticated
2408  // synchronization
2409  // ----------------------------------------------------------------------
2410 
2413  {
2414  this->m_guardedPortMutex.lock();
2415  }
2416 
2419  {
2420  this->m_guardedPortMutex.unLock();
2421  }
2422 
2423  // ----------------------------------------------------------------------
2424  // Message dispatch functions
2425  // ----------------------------------------------------------------------
2426 
2427  Fw::QueuedComponentBase::MsgDispatchStatus FileDownlinkComponentBase ::
2428  doDispatch()
2429  {
2430  ComponentIpcSerializableBuffer _msg;
2431  FwQueuePriorityType _priority = 0;
2432 
2433  Os::Queue::Status _msgStatus = this->m_queue.receive(
2434  _msg,
2436  _priority
2437  );
2438  FW_ASSERT(
2439  _msgStatus == Os::Queue::OP_OK,
2440  static_cast<FwAssertArgType>(_msgStatus)
2441  );
2442 
2443  // Reset to beginning of buffer
2444  _msg.resetDeser();
2445 
2446  FwEnumStoreType _desMsg = 0;
2447  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2448  FW_ASSERT(
2449  _deserStatus == Fw::FW_SERIALIZE_OK,
2450  static_cast<FwAssertArgType>(_deserStatus)
2451  );
2452 
2453  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2454 
2455  if (_msgType == FILEDOWNLINK_COMPONENT_EXIT) {
2456  return MSG_DISPATCH_EXIT;
2457  }
2458 
2459  FwIndexType portNum = 0;
2460  _deserStatus = _msg.deserializeTo(portNum);
2461  FW_ASSERT(
2462  _deserStatus == Fw::FW_SERIALIZE_OK,
2463  static_cast<FwAssertArgType>(_deserStatus)
2464  );
2465 
2466  switch (_msgType) {
2467  // Handle async input port Run
2468  case RUN_SCHED: {
2469  // Deserialize argument context
2470  U32 context;
2471  _deserStatus = _msg.deserializeTo(context);
2472  FW_ASSERT(
2473  _deserStatus == Fw::FW_SERIALIZE_OK,
2474  static_cast<FwAssertArgType>(_deserStatus)
2475  );
2476  // Call handler function
2477  this->Run_handler(
2478  portNum,
2479  context
2480  );
2481 
2482  break;
2483  }
2484 
2485  // Handle async input port bufferReturn
2486  case BUFFERRETURN_BUFFERSEND: {
2487  // Deserialize argument fwBuffer
2488  Fw::Buffer fwBuffer;
2489  _deserStatus = _msg.deserializeTo(fwBuffer);
2490  FW_ASSERT(
2491  _deserStatus == Fw::FW_SERIALIZE_OK,
2492  static_cast<FwAssertArgType>(_deserStatus)
2493  );
2494  // Call handler function
2495  this->bufferReturn_handler(
2496  portNum,
2497  fwBuffer
2498  );
2499 
2500  break;
2501  }
2502 
2503  // Handle async input port pingIn
2504  case PINGIN_PING: {
2505  // Deserialize argument key
2506  U32 key;
2507  _deserStatus = _msg.deserializeTo(key);
2508  FW_ASSERT(
2509  _deserStatus == Fw::FW_SERIALIZE_OK,
2510  static_cast<FwAssertArgType>(_deserStatus)
2511  );
2512  // Call handler function
2513  this->pingIn_handler(
2514  portNum,
2515  key
2516  );
2517 
2518  break;
2519  }
2520 
2521  // Handle command SendFile
2522  case CMD_SENDFILE: {
2523  // Deserialize opcode
2524  FwOpcodeType _opCode = 0;
2525  _deserStatus = _msg.deserializeTo(_opCode);
2526  FW_ASSERT (
2527  _deserStatus == Fw::FW_SERIALIZE_OK,
2528  static_cast<FwAssertArgType>(_deserStatus)
2529  );
2530 
2531  // Deserialize command sequence
2532  U32 _cmdSeq = 0;
2533  _deserStatus = _msg.deserializeTo(_cmdSeq);
2534  FW_ASSERT (
2535  _deserStatus == Fw::FW_SERIALIZE_OK,
2536  static_cast<FwAssertArgType>(_deserStatus)
2537  );
2538 
2539  // Deserialize command argument buffer
2540  Fw::CmdArgBuffer args;
2541  _deserStatus = _msg.deserializeTo(args);
2542  FW_ASSERT (
2543  _deserStatus == Fw::FW_SERIALIZE_OK,
2544  static_cast<FwAssertArgType>(_deserStatus)
2545  );
2546 
2547  // Reset buffer
2548  args.resetDeser();
2549 
2550  // Deserialize argument sourceFileName
2551  Fw::CmdStringArg sourceFileName;
2552  _deserStatus = args.deserializeTo(sourceFileName);
2553  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2554  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2555  this->cmdResponse_out(
2556  _opCode,
2557  _cmdSeq,
2559  );
2560  }
2561  // Don't crash the task if bad arguments were passed from the ground
2562  break;
2563  }
2564 
2565  // Deserialize argument destFileName
2566  Fw::CmdStringArg destFileName;
2567  _deserStatus = args.deserializeTo(destFileName);
2568  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2569  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2570  this->cmdResponse_out(
2571  _opCode,
2572  _cmdSeq,
2574  );
2575  }
2576  // Don't crash the task if bad arguments were passed from the ground
2577  break;
2578  }
2579 
2580  // Make sure there was no data left over.
2581  // That means the argument buffer size was incorrect.
2582 #if FW_CMD_CHECK_RESIDUAL
2583  if (args.getBuffLeft() != 0) {
2584  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2585  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2586  }
2587  // Don't crash the task if bad arguments were passed from the ground
2588  break;
2589  }
2590 #endif
2591 
2592  // Call handler function
2593  this->SendFile_cmdHandler(
2594  _opCode, _cmdSeq,
2595  sourceFileName,
2596  destFileName
2597  );
2598 
2599  break;
2600  }
2601 
2602  // Handle command Cancel
2603  case CMD_CANCEL: {
2604  // Deserialize opcode
2605  FwOpcodeType _opCode = 0;
2606  _deserStatus = _msg.deserializeTo(_opCode);
2607  FW_ASSERT (
2608  _deserStatus == Fw::FW_SERIALIZE_OK,
2609  static_cast<FwAssertArgType>(_deserStatus)
2610  );
2611 
2612  // Deserialize command sequence
2613  U32 _cmdSeq = 0;
2614  _deserStatus = _msg.deserializeTo(_cmdSeq);
2615  FW_ASSERT (
2616  _deserStatus == Fw::FW_SERIALIZE_OK,
2617  static_cast<FwAssertArgType>(_deserStatus)
2618  );
2619 
2620  // Deserialize command argument buffer
2621  Fw::CmdArgBuffer args;
2622  _deserStatus = _msg.deserializeTo(args);
2623  FW_ASSERT (
2624  _deserStatus == Fw::FW_SERIALIZE_OK,
2625  static_cast<FwAssertArgType>(_deserStatus)
2626  );
2627 
2628  // Reset buffer
2629  args.resetDeser();
2630 
2631  // Make sure there was no data left over.
2632  // That means the argument buffer size was incorrect.
2633 #if FW_CMD_CHECK_RESIDUAL
2634  if (args.getBuffLeft() != 0) {
2635  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2636  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2637  }
2638  // Don't crash the task if bad arguments were passed from the ground
2639  break;
2640  }
2641 #endif
2642 
2643  // Call handler function
2644  this->Cancel_cmdHandler(_opCode, _cmdSeq);
2645 
2646  break;
2647  }
2648 
2649  // Handle command SendPartial
2650  case CMD_SENDPARTIAL: {
2651  // Deserialize opcode
2652  FwOpcodeType _opCode = 0;
2653  _deserStatus = _msg.deserializeTo(_opCode);
2654  FW_ASSERT (
2655  _deserStatus == Fw::FW_SERIALIZE_OK,
2656  static_cast<FwAssertArgType>(_deserStatus)
2657  );
2658 
2659  // Deserialize command sequence
2660  U32 _cmdSeq = 0;
2661  _deserStatus = _msg.deserializeTo(_cmdSeq);
2662  FW_ASSERT (
2663  _deserStatus == Fw::FW_SERIALIZE_OK,
2664  static_cast<FwAssertArgType>(_deserStatus)
2665  );
2666 
2667  // Deserialize command argument buffer
2668  Fw::CmdArgBuffer args;
2669  _deserStatus = _msg.deserializeTo(args);
2670  FW_ASSERT (
2671  _deserStatus == Fw::FW_SERIALIZE_OK,
2672  static_cast<FwAssertArgType>(_deserStatus)
2673  );
2674 
2675  // Reset buffer
2676  args.resetDeser();
2677 
2678  // Deserialize argument sourceFileName
2679  Fw::CmdStringArg sourceFileName;
2680  _deserStatus = args.deserializeTo(sourceFileName);
2681  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2682  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2683  this->cmdResponse_out(
2684  _opCode,
2685  _cmdSeq,
2687  );
2688  }
2689  // Don't crash the task if bad arguments were passed from the ground
2690  break;
2691  }
2692 
2693  // Deserialize argument destFileName
2694  Fw::CmdStringArg destFileName;
2695  _deserStatus = args.deserializeTo(destFileName);
2696  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2697  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2698  this->cmdResponse_out(
2699  _opCode,
2700  _cmdSeq,
2702  );
2703  }
2704  // Don't crash the task if bad arguments were passed from the ground
2705  break;
2706  }
2707 
2708  // Deserialize argument startOffset
2709  U32 startOffset;
2710  _deserStatus = args.deserializeTo(startOffset);
2711  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2712  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2713  this->cmdResponse_out(
2714  _opCode,
2715  _cmdSeq,
2717  );
2718  }
2719  // Don't crash the task if bad arguments were passed from the ground
2720  break;
2721  }
2722 
2723  // Deserialize argument length
2724  U32 length;
2725  _deserStatus = args.deserializeTo(length);
2726  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2727  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2728  this->cmdResponse_out(
2729  _opCode,
2730  _cmdSeq,
2732  );
2733  }
2734  // Don't crash the task if bad arguments were passed from the ground
2735  break;
2736  }
2737 
2738  // Make sure there was no data left over.
2739  // That means the argument buffer size was incorrect.
2740 #if FW_CMD_CHECK_RESIDUAL
2741  if (args.getBuffLeft() != 0) {
2742  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2743  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2744  }
2745  // Don't crash the task if bad arguments were passed from the ground
2746  break;
2747  }
2748 #endif
2749 
2750  // Call handler function
2751  this->SendPartial_cmdHandler(
2752  _opCode, _cmdSeq,
2753  sourceFileName,
2754  destFileName,
2755  startOffset,
2756  length
2757  );
2758 
2759  break;
2760  }
2761 
2762  default:
2763  return MSG_DISPATCH_ERROR;
2764  }
2765 
2766  return MSG_DISPATCH_OK;
2767  }
2768 
2769  // ----------------------------------------------------------------------
2770  // Calls for messages received on special input ports
2771  // ----------------------------------------------------------------------
2772 
2773  void FileDownlinkComponentBase ::
2774  m_p_cmdIn_in(
2775  Fw::PassiveComponentBase* callComp,
2776  FwIndexType portNum,
2777  FwOpcodeType opCode,
2778  U32 cmdSeq,
2779  Fw::CmdArgBuffer& args
2780  )
2781  {
2782  FW_ASSERT(callComp);
2783  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2784 
2785  const U32 idBase = callComp->getIdBase();
2786  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2787 
2788  // Select base class function based on opcode
2789  switch (opCode - idBase) {
2790  case OPCODE_SENDFILE: {
2791  compPtr->SendFile_cmdHandlerBase(
2792  opCode,
2793  cmdSeq,
2794  args
2795  );
2796  break;
2797  }
2798 
2799  case OPCODE_CANCEL: {
2800  compPtr->Cancel_cmdHandlerBase(
2801  opCode,
2802  cmdSeq,
2803  args
2804  );
2805  break;
2806  }
2807 
2808  case OPCODE_SENDPARTIAL: {
2809  compPtr->SendPartial_cmdHandlerBase(
2810  opCode,
2811  cmdSeq,
2812  args
2813  );
2814  break;
2815  }
2816  }
2817  }
2818 
2819  // ----------------------------------------------------------------------
2820  // Calls for messages received on typed input ports
2821  // ----------------------------------------------------------------------
2822 
2823  void FileDownlinkComponentBase ::
2824  m_p_Run_in(
2825  Fw::PassiveComponentBase* callComp,
2826  FwIndexType portNum,
2827  U32 context
2828  )
2829  {
2830  FW_ASSERT(callComp);
2831  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2832  compPtr->Run_handlerBase(
2833  portNum,
2834  context
2835  );
2836  }
2837 
2838  Svc::SendFileResponse FileDownlinkComponentBase ::
2839  m_p_SendFile_in(
2840  Fw::PassiveComponentBase* callComp,
2841  FwIndexType portNum,
2842  const Fw::StringBase& sourceFileName,
2843  const Fw::StringBase& destFileName,
2844  U32 offset,
2845  U32 length
2846  )
2847  {
2848  FW_ASSERT(callComp);
2849  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2850  return compPtr->SendFile_handlerBase(
2851  portNum,
2852  sourceFileName,
2853  destFileName,
2854  offset,
2855  length
2856  );
2857  }
2858 
2859  void FileDownlinkComponentBase ::
2860  m_p_bufferReturn_in(
2861  Fw::PassiveComponentBase* callComp,
2862  FwIndexType portNum,
2863  Fw::Buffer& fwBuffer
2864  )
2865  {
2866  FW_ASSERT(callComp);
2867  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2868  compPtr->bufferReturn_handlerBase(
2869  portNum,
2870  fwBuffer
2871  );
2872  }
2873 
2874  void FileDownlinkComponentBase ::
2875  m_p_pingIn_in(
2876  Fw::PassiveComponentBase* callComp,
2877  FwIndexType portNum,
2878  U32 key
2879  )
2880  {
2881  FW_ASSERT(callComp);
2882  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2883  compPtr->pingIn_handlerBase(
2884  portNum,
2885  key
2886  );
2887  }
2888 
2889 }
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
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:63
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:206
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)
deserialize 8-bit unsigned int
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
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
The size of the serial representations of the port arguments.
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:40
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
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
const char * toChar() const
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:46
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
void resetDeser()
reset deserialization to beginning
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:38
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
message to exit active component task
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
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.
PlatformIndexType FwIndexType
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
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
SerializeStatus serializeTo(SerializeBufferBase &buffer, Endianness mode=Endianness::BIG) const override
serialize contents to buffer
Definition: StringBase.cpp:142
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
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.
void init()
Initialization function.
void addCallPort(InputSendFileCompletePort *callPort)
Register an input port.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual const CHAR * toChar() const =0
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34