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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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(static_cast<FwSizeType>(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 
2204  {
2205  // Get the time
2206  Fw::Time _logTime;
2207  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2208  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2209  }
2210 
2211  FwEventIdType _id = static_cast<FwEventIdType>(0);
2212 
2213  _id = this->getIdBase() + EVENTID_DOWNLINKZEROSIZEFILE;
2214 
2215  // Emit the event on the log port
2216  if (this->m_eventOut_OutputPort[0].isConnected()) {
2217  Fw::LogBuffer _logBuff;
2219 
2220 #if FW_AMPCS_COMPATIBLE
2221  // Serialize the number of arguments
2222  _status = _logBuff.serializeFrom(static_cast<U8>(1));
2223  FW_ASSERT(
2224  _status == Fw::FW_SERIALIZE_OK,
2225  static_cast<FwAssertArgType>(_status)
2226  );
2227 #endif
2228 
2229  _status = sourceFileName.serializeTo(_logBuff, FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 100));
2230  FW_ASSERT(
2231  _status == Fw::FW_SERIALIZE_OK,
2232  static_cast<FwAssertArgType>(_status)
2233  );
2234 
2235  this->m_eventOut_OutputPort[0].invoke(
2236  _id,
2237  _logTime,
2239  _logBuff
2240  );
2241  }
2242 
2243  // Emit the event on the text log port
2244 #if FW_ENABLE_TEXT_LOGGING
2245  if (this->m_textEventOut_OutputPort[0].isConnected()) {
2246 #if FW_OBJECT_NAMES == 1
2247  const char* _formatString =
2248  "(%s) %s: Downlink of file %s stopped due to zero-size.";
2249 #else
2250  const char* _formatString =
2251  "%s: Downlink of file %s stopped due to zero-size.";
2252 #endif
2253 
2254  Fw::TextLogString _logString;
2255  _logString.format(
2256  _formatString,
2257 #if FW_OBJECT_NAMES == 1
2258  this->m_objName.toChar(),
2259 #endif
2260  "DownlinkZeroSizeFile ",
2261  sourceFileName.toChar()
2262  );
2263 
2264  this->m_textEventOut_OutputPort[0].invoke(
2265  _id,
2266  _logTime,
2268  _logString
2269  );
2270  }
2271 #endif
2272  }
2273 
2274  // ----------------------------------------------------------------------
2275  // Telemetry write functions
2276  // ----------------------------------------------------------------------
2277 
2280  U32 arg,
2281  Fw::Time _tlmTime
2282  ) const
2283  {
2284  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2285  if (
2286  this->m_timeCaller_OutputPort[0].isConnected() &&
2287  (_tlmTime == Fw::ZERO_TIME)
2288  ) {
2289  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2290  }
2291 
2292  Fw::TlmBuffer _tlmBuff;
2293  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2294  FW_ASSERT(
2295  _stat == Fw::FW_SERIALIZE_OK,
2296  static_cast<FwAssertArgType>(_stat)
2297  );
2298 
2299  FwChanIdType _id;
2300 
2301  _id = this->getIdBase() + CHANNELID_FILESSENT;
2302 
2303  this->m_tlmOut_OutputPort[0].invoke(
2304  _id,
2305  _tlmTime,
2306  _tlmBuff
2307  );
2308  }
2309  }
2310 
2313  U32 arg,
2314  Fw::Time _tlmTime
2315  ) const
2316  {
2317  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2318  if (
2319  this->m_timeCaller_OutputPort[0].isConnected() &&
2320  (_tlmTime == Fw::ZERO_TIME)
2321  ) {
2322  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2323  }
2324 
2325  Fw::TlmBuffer _tlmBuff;
2326  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2327  FW_ASSERT(
2328  _stat == Fw::FW_SERIALIZE_OK,
2329  static_cast<FwAssertArgType>(_stat)
2330  );
2331 
2332  FwChanIdType _id;
2333 
2334  _id = this->getIdBase() + CHANNELID_PACKETSSENT;
2335 
2336  this->m_tlmOut_OutputPort[0].invoke(
2337  _id,
2338  _tlmTime,
2339  _tlmBuff
2340  );
2341  }
2342  }
2343 
2346  U32 arg,
2347  Fw::Time _tlmTime
2348  ) const
2349  {
2350  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2351  if (
2352  this->m_timeCaller_OutputPort[0].isConnected() &&
2353  (_tlmTime == Fw::ZERO_TIME)
2354  ) {
2355  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2356  }
2357 
2358  Fw::TlmBuffer _tlmBuff;
2359  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2360  FW_ASSERT(
2361  _stat == Fw::FW_SERIALIZE_OK,
2362  static_cast<FwAssertArgType>(_stat)
2363  );
2364 
2365  FwChanIdType _id;
2366 
2367  _id = this->getIdBase() + CHANNELID_WARNINGS;
2368 
2369  this->m_tlmOut_OutputPort[0].invoke(
2370  _id,
2371  _tlmTime,
2372  _tlmBuff
2373  );
2374  }
2375  }
2376 
2377  // ----------------------------------------------------------------------
2378  // Time
2379  // ----------------------------------------------------------------------
2380 
2382  getTime() const
2383  {
2384  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2385  Fw::Time _time;
2386  this->m_timeCaller_OutputPort[0].invoke(_time);
2387  return _time;
2388  }
2389  else {
2390  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2391  }
2392  }
2393 
2394  // ----------------------------------------------------------------------
2395  // Mutex operations for guarded ports
2396  //
2397  // You can override these operations to provide more sophisticated
2398  // synchronization
2399  // ----------------------------------------------------------------------
2400 
2403  {
2404  this->m_guardedPortMutex.lock();
2405  }
2406 
2409  {
2410  this->m_guardedPortMutex.unLock();
2411  }
2412 
2413  // ----------------------------------------------------------------------
2414  // Message dispatch functions
2415  // ----------------------------------------------------------------------
2416 
2417  Fw::QueuedComponentBase::MsgDispatchStatus FileDownlinkComponentBase ::
2418  doDispatch()
2419  {
2420  ComponentIpcSerializableBuffer _msg;
2421  FwQueuePriorityType _priority = 0;
2422 
2423  Os::Queue::Status _msgStatus = this->m_queue.receive(
2424  _msg,
2426  _priority
2427  );
2428  FW_ASSERT(
2429  _msgStatus == Os::Queue::OP_OK,
2430  static_cast<FwAssertArgType>(_msgStatus)
2431  );
2432 
2433  // Reset to beginning of buffer
2434  _msg.resetDeser();
2435 
2436  FwEnumStoreType _desMsg = 0;
2437  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2438  FW_ASSERT(
2439  _deserStatus == Fw::FW_SERIALIZE_OK,
2440  static_cast<FwAssertArgType>(_deserStatus)
2441  );
2442 
2443  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2444 
2445  if (_msgType == FILEDOWNLINK_COMPONENT_EXIT) {
2446  return MSG_DISPATCH_EXIT;
2447  }
2448 
2449  FwIndexType portNum = 0;
2450  _deserStatus = _msg.deserializeTo(portNum);
2451  FW_ASSERT(
2452  _deserStatus == Fw::FW_SERIALIZE_OK,
2453  static_cast<FwAssertArgType>(_deserStatus)
2454  );
2455 
2456  switch (_msgType) {
2457  // Handle async input port Run
2458  case RUN_SCHED: {
2459  // Deserialize argument context
2460  U32 context;
2461  _deserStatus = _msg.deserializeTo(context);
2462  FW_ASSERT(
2463  _deserStatus == Fw::FW_SERIALIZE_OK,
2464  static_cast<FwAssertArgType>(_deserStatus)
2465  );
2466  // Call handler function
2467  this->Run_handler(
2468  portNum,
2469  context
2470  );
2471 
2472  break;
2473  }
2474 
2475  // Handle async input port bufferReturn
2476  case BUFFERRETURN_BUFFERSEND: {
2477  // Deserialize argument fwBuffer
2478  Fw::Buffer fwBuffer;
2479  _deserStatus = _msg.deserializeTo(fwBuffer);
2480  FW_ASSERT(
2481  _deserStatus == Fw::FW_SERIALIZE_OK,
2482  static_cast<FwAssertArgType>(_deserStatus)
2483  );
2484  // Call handler function
2485  this->bufferReturn_handler(
2486  portNum,
2487  fwBuffer
2488  );
2489 
2490  break;
2491  }
2492 
2493  // Handle async input port pingIn
2494  case PINGIN_PING: {
2495  // Deserialize argument key
2496  U32 key;
2497  _deserStatus = _msg.deserializeTo(key);
2498  FW_ASSERT(
2499  _deserStatus == Fw::FW_SERIALIZE_OK,
2500  static_cast<FwAssertArgType>(_deserStatus)
2501  );
2502  // Call handler function
2503  this->pingIn_handler(
2504  portNum,
2505  key
2506  );
2507 
2508  break;
2509  }
2510 
2511  // Handle command SendFile
2512  case CMD_SENDFILE: {
2513  // Deserialize opcode
2514  FwOpcodeType _opCode = 0;
2515  _deserStatus = _msg.deserializeTo(_opCode);
2516  FW_ASSERT (
2517  _deserStatus == Fw::FW_SERIALIZE_OK,
2518  static_cast<FwAssertArgType>(_deserStatus)
2519  );
2520 
2521  // Deserialize command sequence
2522  U32 _cmdSeq = 0;
2523  _deserStatus = _msg.deserializeTo(_cmdSeq);
2524  FW_ASSERT (
2525  _deserStatus == Fw::FW_SERIALIZE_OK,
2526  static_cast<FwAssertArgType>(_deserStatus)
2527  );
2528 
2529  // Deserialize command argument buffer
2530  Fw::CmdArgBuffer args;
2531  _deserStatus = _msg.deserializeTo(args);
2532  FW_ASSERT (
2533  _deserStatus == Fw::FW_SERIALIZE_OK,
2534  static_cast<FwAssertArgType>(_deserStatus)
2535  );
2536 
2537  // Reset buffer
2538  args.resetDeser();
2539 
2540  // Deserialize argument sourceFileName
2541  Fw::CmdStringArg sourceFileName;
2542  _deserStatus = args.deserializeTo(sourceFileName);
2543  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2544  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2545  this->cmdResponse_out(
2546  _opCode,
2547  _cmdSeq,
2549  );
2550  }
2551  // Don't crash the task if bad arguments were passed from the ground
2552  break;
2553  }
2554 
2555  // Deserialize argument destFileName
2556  Fw::CmdStringArg destFileName;
2557  _deserStatus = args.deserializeTo(destFileName);
2558  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2559  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2560  this->cmdResponse_out(
2561  _opCode,
2562  _cmdSeq,
2564  );
2565  }
2566  // Don't crash the task if bad arguments were passed from the ground
2567  break;
2568  }
2569 
2570  // Make sure there was no data left over.
2571  // That means the argument buffer size was incorrect.
2572 #if FW_CMD_CHECK_RESIDUAL
2573  if (args.getDeserializeSizeLeft() != 0) {
2574  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2575  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2576  }
2577  // Don't crash the task if bad arguments were passed from the ground
2578  break;
2579  }
2580 #endif
2581 
2582  // Call handler function
2583  this->SendFile_cmdHandler(
2584  _opCode, _cmdSeq,
2585  sourceFileName,
2586  destFileName
2587  );
2588 
2589  break;
2590  }
2591 
2592  // Handle command Cancel
2593  case CMD_CANCEL: {
2594  // Deserialize opcode
2595  FwOpcodeType _opCode = 0;
2596  _deserStatus = _msg.deserializeTo(_opCode);
2597  FW_ASSERT (
2598  _deserStatus == Fw::FW_SERIALIZE_OK,
2599  static_cast<FwAssertArgType>(_deserStatus)
2600  );
2601 
2602  // Deserialize command sequence
2603  U32 _cmdSeq = 0;
2604  _deserStatus = _msg.deserializeTo(_cmdSeq);
2605  FW_ASSERT (
2606  _deserStatus == Fw::FW_SERIALIZE_OK,
2607  static_cast<FwAssertArgType>(_deserStatus)
2608  );
2609 
2610  // Deserialize command argument buffer
2611  Fw::CmdArgBuffer args;
2612  _deserStatus = _msg.deserializeTo(args);
2613  FW_ASSERT (
2614  _deserStatus == Fw::FW_SERIALIZE_OK,
2615  static_cast<FwAssertArgType>(_deserStatus)
2616  );
2617 
2618  // Reset buffer
2619  args.resetDeser();
2620 
2621  // Make sure there was no data left over.
2622  // That means the argument buffer size was incorrect.
2623 #if FW_CMD_CHECK_RESIDUAL
2624  if (args.getDeserializeSizeLeft() != 0) {
2625  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2626  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2627  }
2628  // Don't crash the task if bad arguments were passed from the ground
2629  break;
2630  }
2631 #endif
2632 
2633  // Call handler function
2634  this->Cancel_cmdHandler(_opCode, _cmdSeq);
2635 
2636  break;
2637  }
2638 
2639  // Handle command SendPartial
2640  case CMD_SENDPARTIAL: {
2641  // Deserialize opcode
2642  FwOpcodeType _opCode = 0;
2643  _deserStatus = _msg.deserializeTo(_opCode);
2644  FW_ASSERT (
2645  _deserStatus == Fw::FW_SERIALIZE_OK,
2646  static_cast<FwAssertArgType>(_deserStatus)
2647  );
2648 
2649  // Deserialize command sequence
2650  U32 _cmdSeq = 0;
2651  _deserStatus = _msg.deserializeTo(_cmdSeq);
2652  FW_ASSERT (
2653  _deserStatus == Fw::FW_SERIALIZE_OK,
2654  static_cast<FwAssertArgType>(_deserStatus)
2655  );
2656 
2657  // Deserialize command argument buffer
2658  Fw::CmdArgBuffer args;
2659  _deserStatus = _msg.deserializeTo(args);
2660  FW_ASSERT (
2661  _deserStatus == Fw::FW_SERIALIZE_OK,
2662  static_cast<FwAssertArgType>(_deserStatus)
2663  );
2664 
2665  // Reset buffer
2666  args.resetDeser();
2667 
2668  // Deserialize argument sourceFileName
2669  Fw::CmdStringArg sourceFileName;
2670  _deserStatus = args.deserializeTo(sourceFileName);
2671  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2672  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2673  this->cmdResponse_out(
2674  _opCode,
2675  _cmdSeq,
2677  );
2678  }
2679  // Don't crash the task if bad arguments were passed from the ground
2680  break;
2681  }
2682 
2683  // Deserialize argument destFileName
2684  Fw::CmdStringArg destFileName;
2685  _deserStatus = args.deserializeTo(destFileName);
2686  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2687  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2688  this->cmdResponse_out(
2689  _opCode,
2690  _cmdSeq,
2692  );
2693  }
2694  // Don't crash the task if bad arguments were passed from the ground
2695  break;
2696  }
2697 
2698  // Deserialize argument startOffset
2699  U32 startOffset;
2700  _deserStatus = args.deserializeTo(startOffset);
2701  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2702  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2703  this->cmdResponse_out(
2704  _opCode,
2705  _cmdSeq,
2707  );
2708  }
2709  // Don't crash the task if bad arguments were passed from the ground
2710  break;
2711  }
2712 
2713  // Deserialize argument length
2714  U32 length;
2715  _deserStatus = args.deserializeTo(length);
2716  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2717  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2718  this->cmdResponse_out(
2719  _opCode,
2720  _cmdSeq,
2722  );
2723  }
2724  // Don't crash the task if bad arguments were passed from the ground
2725  break;
2726  }
2727 
2728  // Make sure there was no data left over.
2729  // That means the argument buffer size was incorrect.
2730 #if FW_CMD_CHECK_RESIDUAL
2731  if (args.getDeserializeSizeLeft() != 0) {
2732  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2733  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2734  }
2735  // Don't crash the task if bad arguments were passed from the ground
2736  break;
2737  }
2738 #endif
2739 
2740  // Call handler function
2741  this->SendPartial_cmdHandler(
2742  _opCode, _cmdSeq,
2743  sourceFileName,
2744  destFileName,
2745  startOffset,
2746  length
2747  );
2748 
2749  break;
2750  }
2751 
2752  default:
2753  return MSG_DISPATCH_ERROR;
2754  }
2755 
2756  return MSG_DISPATCH_OK;
2757  }
2758 
2759  // ----------------------------------------------------------------------
2760  // Calls for messages received on special input ports
2761  // ----------------------------------------------------------------------
2762 
2763  void FileDownlinkComponentBase ::
2764  m_p_cmdIn_in(
2765  Fw::PassiveComponentBase* callComp,
2766  FwIndexType portNum,
2767  FwOpcodeType opCode,
2768  U32 cmdSeq,
2769  Fw::CmdArgBuffer& args
2770  )
2771  {
2772  FW_ASSERT(callComp);
2773  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2774 
2775  const U32 idBase = callComp->getIdBase();
2776  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2777 
2778  // Select base class function based on opcode
2779  switch (opCode - idBase) {
2780  case OPCODE_SENDFILE: {
2781  compPtr->SendFile_cmdHandlerBase(
2782  opCode,
2783  cmdSeq,
2784  args
2785  );
2786  break;
2787  }
2788 
2789  case OPCODE_CANCEL: {
2790  compPtr->Cancel_cmdHandlerBase(
2791  opCode,
2792  cmdSeq,
2793  args
2794  );
2795  break;
2796  }
2797 
2798  case OPCODE_SENDPARTIAL: {
2799  compPtr->SendPartial_cmdHandlerBase(
2800  opCode,
2801  cmdSeq,
2802  args
2803  );
2804  break;
2805  }
2806  }
2807  }
2808 
2809  // ----------------------------------------------------------------------
2810  // Calls for messages received on typed input ports
2811  // ----------------------------------------------------------------------
2812 
2813  void FileDownlinkComponentBase ::
2814  m_p_Run_in(
2815  Fw::PassiveComponentBase* callComp,
2816  FwIndexType portNum,
2817  U32 context
2818  )
2819  {
2820  FW_ASSERT(callComp);
2821  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2822  compPtr->Run_handlerBase(
2823  portNum,
2824  context
2825  );
2826  }
2827 
2828  Svc::SendFileResponse FileDownlinkComponentBase ::
2829  m_p_SendFile_in(
2830  Fw::PassiveComponentBase* callComp,
2831  FwIndexType portNum,
2832  const Fw::StringBase& sourceFileName,
2833  const Fw::StringBase& destFileName,
2834  U32 offset,
2835  U32 length
2836  )
2837  {
2838  FW_ASSERT(callComp);
2839  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2840  return compPtr->SendFile_handlerBase(
2841  portNum,
2842  sourceFileName,
2843  destFileName,
2844  offset,
2845  length
2846  );
2847  }
2848 
2849  void FileDownlinkComponentBase ::
2850  m_p_bufferReturn_in(
2851  Fw::PassiveComponentBase* callComp,
2852  FwIndexType portNum,
2853  Fw::Buffer& fwBuffer
2854  )
2855  {
2856  FW_ASSERT(callComp);
2857  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2858  compPtr->bufferReturn_handlerBase(
2859  portNum,
2860  fwBuffer
2861  );
2862  }
2863 
2864  void FileDownlinkComponentBase ::
2865  m_p_pingIn_in(
2866  Fw::PassiveComponentBase* callComp,
2867  FwIndexType portNum,
2868  U32 key
2869  )
2870  {
2871  FW_ASSERT(callComp);
2872  FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
2873  compPtr->pingIn_handlerBase(
2874  portNum,
2875  key
2876  );
2877  }
2878 
2879 }
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.
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
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
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:31
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.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
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
#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.
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.
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
PlatformIndexType FwIndexType
message to exit active component task
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
The size of the serial representations of the port arguments.
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.
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.