F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComQueueComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComQueueComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComQueue 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  COMQUEUE_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  BUFFERQUEUEIN_BUFFERSEND,
20  COMPACKETQUEUEIN_COM,
21  COMSTATUSIN_SUCCESSCONDITION,
22  RUN_SCHED,
23  CMD_FLUSH_QUEUE,
24  CMD_FLUSH_ALL_QUEUES,
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 {
30  BYTE bufferQueueInPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
31  BYTE comPacketQueueInPortSize[Fw::InputComPort::SERIALIZED_SIZE];
35  };
36 
37  // Define a message buffer class large enough to handle all the
38  // asynchronous inputs to the component
39  class ComponentIpcSerializableBuffer :
41  {
42 
43  public:
44 
45  enum {
46  // Offset into data in buffer: Size of message ID and port number
47  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
48  // Max data size
49  MAX_DATA_SIZE = sizeof(BuffUnion),
50  // Max message size: Size of message id + size of port + max data size
51  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
52  };
53 
54  Fw::Serializable::SizeType getCapacity() const {
55  return sizeof(m_buff);
56  }
57 
58  U8* getBuffAddr() {
59  return m_buff;
60  }
61 
62  const U8* getBuffAddr() const {
63  return m_buff;
64  }
65 
66  private:
67  // Should be the max of all the input ports serialized sizes...
68  U8 m_buff[SERIALIZATION_SIZE];
69 
70  };
71  }
72 
73  // ----------------------------------------------------------------------
74  // Component initialization
75  // ----------------------------------------------------------------------
76 
79  FwSizeType queueDepth,
80  FwEnumStoreType instance
81  )
82  {
83  // Initialize base class
85 
86  // Connect input port CmdDisp
87  for (
88  FwIndexType port = 0;
89  port < static_cast<FwIndexType>(this->getNum_CmdDisp_InputPorts());
90  port++
91  ) {
92  this->m_CmdDisp_InputPort[port].init();
93  this->m_CmdDisp_InputPort[port].addCallComp(
94  this,
95  m_p_CmdDisp_in
96  );
97  this->m_CmdDisp_InputPort[port].setPortNum(port);
98 
99 #if FW_OBJECT_NAMES == 1
100  Fw::ObjectName portName;
101  portName.format(
102  "%s_CmdDisp_InputPort[%" PRI_FwIndexType "]",
103  this->m_objName.toChar(),
104  port
105  );
106  this->m_CmdDisp_InputPort[port].setObjName(portName.toChar());
107 #endif
108  }
109 
110  // Connect input port bufferQueueIn
111  for (
112  FwIndexType port = 0;
113  port < static_cast<FwIndexType>(this->getNum_bufferQueueIn_InputPorts());
114  port++
115  ) {
116  this->m_bufferQueueIn_InputPort[port].init();
117  this->m_bufferQueueIn_InputPort[port].addCallComp(
118  this,
119  m_p_bufferQueueIn_in
120  );
121  this->m_bufferQueueIn_InputPort[port].setPortNum(port);
122 
123 #if FW_OBJECT_NAMES == 1
124  Fw::ObjectName portName;
125  portName.format(
126  "%s_bufferQueueIn_InputPort[%" PRI_FwIndexType "]",
127  this->m_objName.toChar(),
128  port
129  );
130  this->m_bufferQueueIn_InputPort[port].setObjName(portName.toChar());
131 #endif
132  }
133 
134  // Connect input port comPacketQueueIn
135  for (
136  FwIndexType port = 0;
137  port < static_cast<FwIndexType>(this->getNum_comPacketQueueIn_InputPorts());
138  port++
139  ) {
140  this->m_comPacketQueueIn_InputPort[port].init();
141  this->m_comPacketQueueIn_InputPort[port].addCallComp(
142  this,
143  m_p_comPacketQueueIn_in
144  );
145  this->m_comPacketQueueIn_InputPort[port].setPortNum(port);
146 
147 #if FW_OBJECT_NAMES == 1
148  Fw::ObjectName portName;
149  portName.format(
150  "%s_comPacketQueueIn_InputPort[%" PRI_FwIndexType "]",
151  this->m_objName.toChar(),
152  port
153  );
154  this->m_comPacketQueueIn_InputPort[port].setObjName(portName.toChar());
155 #endif
156  }
157 
158  // Connect input port comStatusIn
159  for (
160  FwIndexType port = 0;
161  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
162  port++
163  ) {
164  this->m_comStatusIn_InputPort[port].init();
165  this->m_comStatusIn_InputPort[port].addCallComp(
166  this,
167  m_p_comStatusIn_in
168  );
169  this->m_comStatusIn_InputPort[port].setPortNum(port);
170 
171 #if FW_OBJECT_NAMES == 1
172  Fw::ObjectName portName;
173  portName.format(
174  "%s_comStatusIn_InputPort[%" PRI_FwIndexType "]",
175  this->m_objName.toChar(),
176  port
177  );
178  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
179 #endif
180  }
181 
182  // Connect input port dataReturnIn
183  for (
184  FwIndexType port = 0;
185  port < static_cast<FwIndexType>(this->getNum_dataReturnIn_InputPorts());
186  port++
187  ) {
188  this->m_dataReturnIn_InputPort[port].init();
189  this->m_dataReturnIn_InputPort[port].addCallComp(
190  this,
191  m_p_dataReturnIn_in
192  );
193  this->m_dataReturnIn_InputPort[port].setPortNum(port);
194 
195 #if FW_OBJECT_NAMES == 1
196  Fw::ObjectName portName;
197  portName.format(
198  "%s_dataReturnIn_InputPort[%" PRI_FwIndexType "]",
199  this->m_objName.toChar(),
200  port
201  );
202  this->m_dataReturnIn_InputPort[port].setObjName(portName.toChar());
203 #endif
204  }
205 
206  // Connect input port run
207  for (
208  FwIndexType port = 0;
209  port < static_cast<FwIndexType>(this->getNum_run_InputPorts());
210  port++
211  ) {
212  this->m_run_InputPort[port].init();
213  this->m_run_InputPort[port].addCallComp(
214  this,
215  m_p_run_in
216  );
217  this->m_run_InputPort[port].setPortNum(port);
218 
219 #if FW_OBJECT_NAMES == 1
220  Fw::ObjectName portName;
221  portName.format(
222  "%s_run_InputPort[%" PRI_FwIndexType "]",
223  this->m_objName.toChar(),
224  port
225  );
226  this->m_run_InputPort[port].setObjName(portName.toChar());
227 #endif
228  }
229 
230  // Connect output port CmdReg
231  for (
232  FwIndexType port = 0;
233  port < static_cast<FwIndexType>(this->getNum_CmdReg_OutputPorts());
234  port++
235  ) {
236  this->m_CmdReg_OutputPort[port].init();
237 
238 #if FW_OBJECT_NAMES == 1
239  Fw::ObjectName portName;
240  portName.format(
241  "%s_CmdReg_OutputPort[%" PRI_FwIndexType "]",
242  this->m_objName.toChar(),
243  port
244  );
245  this->m_CmdReg_OutputPort[port].setObjName(portName.toChar());
246 #endif
247  }
248 
249  // Connect output port CmdStatus
250  for (
251  FwIndexType port = 0;
252  port < static_cast<FwIndexType>(this->getNum_CmdStatus_OutputPorts());
253  port++
254  ) {
255  this->m_CmdStatus_OutputPort[port].init();
256 
257 #if FW_OBJECT_NAMES == 1
258  Fw::ObjectName portName;
259  portName.format(
260  "%s_CmdStatus_OutputPort[%" PRI_FwIndexType "]",
261  this->m_objName.toChar(),
262  port
263  );
264  this->m_CmdStatus_OutputPort[port].setObjName(portName.toChar());
265 #endif
266  }
267 
268  // Connect output port Log
269  for (
270  FwIndexType port = 0;
271  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
272  port++
273  ) {
274  this->m_Log_OutputPort[port].init();
275 
276 #if FW_OBJECT_NAMES == 1
277  Fw::ObjectName portName;
278  portName.format(
279  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
280  this->m_objName.toChar(),
281  port
282  );
283  this->m_Log_OutputPort[port].setObjName(portName.toChar());
284 #endif
285  }
286 
287 #if FW_ENABLE_TEXT_LOGGING == 1
288  // Connect output port LogText
289  for (
290  FwIndexType port = 0;
291  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
292  port++
293  ) {
294  this->m_LogText_OutputPort[port].init();
295 
296 #if FW_OBJECT_NAMES == 1
297  Fw::ObjectName portName;
298  portName.format(
299  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
300  this->m_objName.toChar(),
301  port
302  );
303  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
304 #endif
305  }
306 #endif
307 
308  // Connect output port Time
309  for (
310  FwIndexType port = 0;
311  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
312  port++
313  ) {
314  this->m_Time_OutputPort[port].init();
315 
316 #if FW_OBJECT_NAMES == 1
317  Fw::ObjectName portName;
318  portName.format(
319  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
320  this->m_objName.toChar(),
321  port
322  );
323  this->m_Time_OutputPort[port].setObjName(portName.toChar());
324 #endif
325  }
326 
327  // Connect output port Tlm
328  for (
329  FwIndexType port = 0;
330  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
331  port++
332  ) {
333  this->m_Tlm_OutputPort[port].init();
334 
335 #if FW_OBJECT_NAMES == 1
336  Fw::ObjectName portName;
337  portName.format(
338  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
339  this->m_objName.toChar(),
340  port
341  );
342  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
343 #endif
344  }
345 
346  // Connect output port bufferReturnOut
347  for (
348  FwIndexType port = 0;
349  port < static_cast<FwIndexType>(this->getNum_bufferReturnOut_OutputPorts());
350  port++
351  ) {
352  this->m_bufferReturnOut_OutputPort[port].init();
353 
354 #if FW_OBJECT_NAMES == 1
355  Fw::ObjectName portName;
356  portName.format(
357  "%s_bufferReturnOut_OutputPort[%" PRI_FwIndexType "]",
358  this->m_objName.toChar(),
359  port
360  );
361  this->m_bufferReturnOut_OutputPort[port].setObjName(portName.toChar());
362 #endif
363  }
364 
365  // Connect output port dataOut
366  for (
367  FwIndexType port = 0;
368  port < static_cast<FwIndexType>(this->getNum_dataOut_OutputPorts());
369  port++
370  ) {
371  this->m_dataOut_OutputPort[port].init();
372 
373 #if FW_OBJECT_NAMES == 1
374  Fw::ObjectName portName;
375  portName.format(
376  "%s_dataOut_OutputPort[%" PRI_FwIndexType "]",
377  this->m_objName.toChar(),
378  port
379  );
380  this->m_dataOut_OutputPort[port].setObjName(portName.toChar());
381 #endif
382  }
383 
384  // Create the queue
385  Os::Queue::Status qStat = this->createQueue(
386  queueDepth,
387  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
388  );
389  FW_ASSERT(
390  Os::Queue::Status::OP_OK == qStat,
391  static_cast<FwAssertArgType>(qStat)
392  );
393  }
394 
395  // ----------------------------------------------------------------------
396  // Getters for special input ports
397  // ----------------------------------------------------------------------
398 
401  {
402  FW_ASSERT(
403  (0 <= portNum) && (portNum < this->getNum_CmdDisp_InputPorts()),
404  static_cast<FwAssertArgType>(portNum)
405  );
406 
407  return &this->m_CmdDisp_InputPort[portNum];
408  }
409 
410  // ----------------------------------------------------------------------
411  // Getters for typed input ports
412  // ----------------------------------------------------------------------
413 
416  {
417  FW_ASSERT(
418  (0 <= portNum) && (portNum < this->getNum_bufferQueueIn_InputPorts()),
419  static_cast<FwAssertArgType>(portNum)
420  );
421 
422  return &this->m_bufferQueueIn_InputPort[portNum];
423  }
424 
427  {
428  FW_ASSERT(
429  (0 <= portNum) && (portNum < this->getNum_comPacketQueueIn_InputPorts()),
430  static_cast<FwAssertArgType>(portNum)
431  );
432 
433  return &this->m_comPacketQueueIn_InputPort[portNum];
434  }
435 
438  {
439  FW_ASSERT(
440  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
441  static_cast<FwAssertArgType>(portNum)
442  );
443 
444  return &this->m_comStatusIn_InputPort[portNum];
445  }
446 
449  {
450  FW_ASSERT(
451  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
452  static_cast<FwAssertArgType>(portNum)
453  );
454 
455  return &this->m_dataReturnIn_InputPort[portNum];
456  }
457 
460  {
461  FW_ASSERT(
462  (0 <= portNum) && (portNum < this->getNum_run_InputPorts()),
463  static_cast<FwAssertArgType>(portNum)
464  );
465 
466  return &this->m_run_InputPort[portNum];
467  }
468 
469  // ----------------------------------------------------------------------
470  // Connect input ports to special output ports
471  // ----------------------------------------------------------------------
472 
475  FwIndexType portNum,
476  Fw::InputCmdRegPort* port
477  )
478  {
479  FW_ASSERT(
480  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
481  static_cast<FwAssertArgType>(portNum)
482  );
483 
484  this->m_CmdReg_OutputPort[portNum].addCallPort(port);
485  }
486 
489  FwIndexType portNum,
491  )
492  {
493  FW_ASSERT(
494  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
495  static_cast<FwAssertArgType>(portNum)
496  );
497 
498  this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
499  }
500 
503  FwIndexType portNum,
504  Fw::InputLogPort* port
505  )
506  {
507  FW_ASSERT(
508  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
509  static_cast<FwAssertArgType>(portNum)
510  );
511 
512  this->m_Log_OutputPort[portNum].addCallPort(port);
513  }
514 
515 #if FW_ENABLE_TEXT_LOGGING == 1
516 
517  void ComQueueComponentBase ::
518  set_LogText_OutputPort(
519  FwIndexType portNum,
521  )
522  {
523  FW_ASSERT(
524  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
525  static_cast<FwAssertArgType>(portNum)
526  );
527 
528  this->m_LogText_OutputPort[portNum].addCallPort(port);
529  }
530 
531 #endif
532 
535  FwIndexType portNum,
536  Fw::InputTimePort* port
537  )
538  {
539  FW_ASSERT(
540  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
541  static_cast<FwAssertArgType>(portNum)
542  );
543 
544  this->m_Time_OutputPort[portNum].addCallPort(port);
545  }
546 
549  FwIndexType portNum,
550  Fw::InputTlmPort* port
551  )
552  {
553  FW_ASSERT(
554  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
555  static_cast<FwAssertArgType>(portNum)
556  );
557 
558  this->m_Tlm_OutputPort[portNum].addCallPort(port);
559  }
560 
561  // ----------------------------------------------------------------------
562  // Connect typed input ports to typed output ports
563  // ----------------------------------------------------------------------
564 
567  FwIndexType portNum,
569  )
570  {
571  FW_ASSERT(
572  (0 <= portNum) && (portNum < this->getNum_bufferReturnOut_OutputPorts()),
573  static_cast<FwAssertArgType>(portNum)
574  );
575 
576  this->m_bufferReturnOut_OutputPort[portNum].addCallPort(port);
577  }
578 
581  FwIndexType portNum,
583  )
584  {
585  FW_ASSERT(
586  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
587  static_cast<FwAssertArgType>(portNum)
588  );
589 
590  this->m_dataOut_OutputPort[portNum].addCallPort(port);
591  }
592 
593 #if FW_PORT_SERIALIZATION
594 
595  // ----------------------------------------------------------------------
596  // Connect serial input ports to special output ports
597  // ----------------------------------------------------------------------
598 
601  FwIndexType portNum,
602  Fw::InputSerializePort* port
603  )
604  {
605  FW_ASSERT(
606  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
607  static_cast<FwAssertArgType>(portNum)
608  );
609 
610  this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
611  }
612 
615  FwIndexType portNum,
616  Fw::InputSerializePort* port
617  )
618  {
619  FW_ASSERT(
620  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
621  static_cast<FwAssertArgType>(portNum)
622  );
623 
624  this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
625  }
626 
629  FwIndexType portNum,
630  Fw::InputSerializePort* port
631  )
632  {
633  FW_ASSERT(
634  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
635  static_cast<FwAssertArgType>(portNum)
636  );
637 
638  this->m_Log_OutputPort[portNum].registerSerialPort(port);
639  }
640 
641 #if FW_ENABLE_TEXT_LOGGING == 1
642 
643  void ComQueueComponentBase ::
644  set_LogText_OutputPort(
645  FwIndexType portNum,
646  Fw::InputSerializePort* port
647  )
648  {
649  FW_ASSERT(
650  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
651  static_cast<FwAssertArgType>(portNum)
652  );
653 
654  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
655  }
656 
657 #endif
658 
661  FwIndexType portNum,
662  Fw::InputSerializePort* port
663  )
664  {
665  FW_ASSERT(
666  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
667  static_cast<FwAssertArgType>(portNum)
668  );
669 
670  this->m_Time_OutputPort[portNum].registerSerialPort(port);
671  }
672 
675  FwIndexType portNum,
676  Fw::InputSerializePort* port
677  )
678  {
679  FW_ASSERT(
680  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
681  static_cast<FwAssertArgType>(portNum)
682  );
683 
684  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
685  }
686 
687 #endif
688 
689 #if FW_PORT_SERIALIZATION
690 
691  // ----------------------------------------------------------------------
692  // Connect serial input ports to typed output ports
693  // ----------------------------------------------------------------------
694 
697  FwIndexType portNum,
698  Fw::InputSerializePort* port
699  )
700  {
701  FW_ASSERT(
702  (0 <= portNum) && (portNum < this->getNum_bufferReturnOut_OutputPorts()),
703  static_cast<FwAssertArgType>(portNum)
704  );
705 
706  this->m_bufferReturnOut_OutputPort[portNum].registerSerialPort(port);
707  }
708 
711  FwIndexType portNum,
712  Fw::InputSerializePort* port
713  )
714  {
715  FW_ASSERT(
716  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
717  static_cast<FwAssertArgType>(portNum)
718  );
719 
720  this->m_dataOut_OutputPort[portNum].registerSerialPort(port);
721  }
722 
723 #endif
724 
725  // ----------------------------------------------------------------------
726  // Command registration
727  // ----------------------------------------------------------------------
728 
731  {
732  FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
733 
734  this->m_CmdReg_OutputPort[0].invoke(
735  this->getIdBase() + OPCODE_FLUSH_QUEUE
736  );
737 
738  this->m_CmdReg_OutputPort[0].invoke(
740  );
741  }
742 
743  // ----------------------------------------------------------------------
744  // Component construction and destruction
745  // ----------------------------------------------------------------------
746 
748  ComQueueComponentBase(const char* compName) :
749  Fw::ActiveComponentBase(compName)
750  {
751 
752  }
753 
756  {
757 
758  }
759 
760  // ----------------------------------------------------------------------
761  // Connection status queries for special output ports
762  // ----------------------------------------------------------------------
763 
766  {
767  FW_ASSERT(
768  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
769  static_cast<FwAssertArgType>(portNum)
770  );
771 
772  return this->m_CmdReg_OutputPort[portNum].isConnected();
773  }
774 
777  {
778  FW_ASSERT(
779  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
780  static_cast<FwAssertArgType>(portNum)
781  );
782 
783  return this->m_CmdStatus_OutputPort[portNum].isConnected();
784  }
785 
788  {
789  FW_ASSERT(
790  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
791  static_cast<FwAssertArgType>(portNum)
792  );
793 
794  return this->m_Log_OutputPort[portNum].isConnected();
795  }
796 
797 #if FW_ENABLE_TEXT_LOGGING == 1
798 
799  bool ComQueueComponentBase ::
800  isConnected_LogText_OutputPort(FwIndexType portNum)
801  {
802  FW_ASSERT(
803  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
804  static_cast<FwAssertArgType>(portNum)
805  );
806 
807  return this->m_LogText_OutputPort[portNum].isConnected();
808  }
809 
810 #endif
811 
814  {
815  FW_ASSERT(
816  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
817  static_cast<FwAssertArgType>(portNum)
818  );
819 
820  return this->m_Time_OutputPort[portNum].isConnected();
821  }
822 
825  {
826  FW_ASSERT(
827  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
828  static_cast<FwAssertArgType>(portNum)
829  );
830 
831  return this->m_Tlm_OutputPort[portNum].isConnected();
832  }
833 
834  // ----------------------------------------------------------------------
835  // Connection status queries for typed output ports
836  // ----------------------------------------------------------------------
837 
840  {
841  FW_ASSERT(
842  (0 <= portNum) && (portNum < this->getNum_bufferReturnOut_OutputPorts()),
843  static_cast<FwAssertArgType>(portNum)
844  );
845 
846  return this->m_bufferReturnOut_OutputPort[portNum].isConnected();
847  }
848 
851  {
852  FW_ASSERT(
853  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
854  static_cast<FwAssertArgType>(portNum)
855  );
856 
857  return this->m_dataOut_OutputPort[portNum].isConnected();
858  }
859 
860  // ----------------------------------------------------------------------
861  // Port handler base-class functions for typed input ports
862  //
863  // Call these functions directly to bypass the corresponding ports
864  // ----------------------------------------------------------------------
865 
868  FwIndexType portNum,
869  Fw::Buffer& fwBuffer
870  )
871  {
872  // Make sure port number is valid
873  FW_ASSERT(
874  (0 <= portNum) && (portNum < this->getNum_bufferQueueIn_InputPorts()),
875  static_cast<FwAssertArgType>(portNum)
876  );
877 
878  // Call pre-message hook
880  portNum,
881  fwBuffer
882  );
883  ComponentIpcSerializableBuffer msg;
885 
886  // Serialize message ID
887  _status = msg.serializeFrom(
888  static_cast<FwEnumStoreType>(BUFFERQUEUEIN_BUFFERSEND)
889  );
890  FW_ASSERT(
891  _status == Fw::FW_SERIALIZE_OK,
892  static_cast<FwAssertArgType>(_status)
893  );
894 
895  // Serialize port number
896  _status = msg.serializeFrom(portNum);
897  FW_ASSERT(
898  _status == Fw::FW_SERIALIZE_OK,
899  static_cast<FwAssertArgType>(_status)
900  );
901 
902  // Serialize argument fwBuffer
903  _status = msg.serializeFrom(fwBuffer);
904  FW_ASSERT(
905  _status == Fw::FW_SERIALIZE_OK,
906  static_cast<FwAssertArgType>(_status)
907  );
908 
909  // Send message
911  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
912 
913  if (qStatus == Os::Queue::Status::FULL) {
914  this->bufferQueueIn_overflowHook(portNum, fwBuffer);
915  return;
916  }
917 
918  FW_ASSERT(
919  qStatus == Os::Queue::OP_OK,
920  static_cast<FwAssertArgType>(qStatus)
921  );
922  }
923 
926  FwIndexType portNum,
927  Fw::ComBuffer& data,
928  U32 context
929  )
930  {
931  // Make sure port number is valid
932  FW_ASSERT(
933  (0 <= portNum) && (portNum < this->getNum_comPacketQueueIn_InputPorts()),
934  static_cast<FwAssertArgType>(portNum)
935  );
936 
937  // Call pre-message hook
939  portNum,
940  data,
941  context
942  );
943  ComponentIpcSerializableBuffer msg;
945 
946  // Serialize message ID
947  _status = msg.serializeFrom(
948  static_cast<FwEnumStoreType>(COMPACKETQUEUEIN_COM)
949  );
950  FW_ASSERT(
951  _status == Fw::FW_SERIALIZE_OK,
952  static_cast<FwAssertArgType>(_status)
953  );
954 
955  // Serialize port number
956  _status = msg.serializeFrom(portNum);
957  FW_ASSERT(
958  _status == Fw::FW_SERIALIZE_OK,
959  static_cast<FwAssertArgType>(_status)
960  );
961 
962  // Serialize argument data
963  _status = msg.serializeFrom(data);
964  FW_ASSERT(
965  _status == Fw::FW_SERIALIZE_OK,
966  static_cast<FwAssertArgType>(_status)
967  );
968 
969  // Serialize argument context
970  _status = msg.serializeFrom(context);
971  FW_ASSERT(
972  _status == Fw::FW_SERIALIZE_OK,
973  static_cast<FwAssertArgType>(_status)
974  );
975 
976  // Send message
978  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
979 
980  if (qStatus == Os::Queue::Status::FULL) {
981  this->incNumMsgDropped();
982  return;
983  }
984 
985  FW_ASSERT(
986  qStatus == Os::Queue::OP_OK,
987  static_cast<FwAssertArgType>(qStatus)
988  );
989  }
990 
993  FwIndexType portNum,
994  Fw::Success& condition
995  )
996  {
997  // Make sure port number is valid
998  FW_ASSERT(
999  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
1000  static_cast<FwAssertArgType>(portNum)
1001  );
1002 
1003  // Call pre-message hook
1005  portNum,
1006  condition
1007  );
1008  ComponentIpcSerializableBuffer msg;
1010 
1011  // Serialize message ID
1012  _status = msg.serializeFrom(
1013  static_cast<FwEnumStoreType>(COMSTATUSIN_SUCCESSCONDITION)
1014  );
1015  FW_ASSERT(
1016  _status == Fw::FW_SERIALIZE_OK,
1017  static_cast<FwAssertArgType>(_status)
1018  );
1019 
1020  // Serialize port number
1021  _status = msg.serializeFrom(portNum);
1022  FW_ASSERT(
1023  _status == Fw::FW_SERIALIZE_OK,
1024  static_cast<FwAssertArgType>(_status)
1025  );
1026 
1027  // Serialize argument condition
1028  _status = msg.serializeFrom(condition);
1029  FW_ASSERT(
1030  _status == Fw::FW_SERIALIZE_OK,
1031  static_cast<FwAssertArgType>(_status)
1032  );
1033 
1034  // Send message
1036  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1037 
1038  FW_ASSERT(
1039  qStatus == Os::Queue::OP_OK,
1040  static_cast<FwAssertArgType>(qStatus)
1041  );
1042  }
1043 
1046  FwIndexType portNum,
1047  Fw::Buffer& data,
1048  const ComCfg::FrameContext& context
1049  )
1050  {
1051  // Make sure port number is valid
1052  FW_ASSERT(
1053  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
1054  static_cast<FwAssertArgType>(portNum)
1055  );
1056 
1057  // Call handler function
1058  this->dataReturnIn_handler(
1059  portNum,
1060  data,
1061  context
1062  );
1063  }
1064 
1067  FwIndexType portNum,
1068  U32 context
1069  )
1070  {
1071  // Make sure port number is valid
1072  FW_ASSERT(
1073  (0 <= portNum) && (portNum < this->getNum_run_InputPorts()),
1074  static_cast<FwAssertArgType>(portNum)
1075  );
1076 
1077  // Call pre-message hook
1079  portNum,
1080  context
1081  );
1082  ComponentIpcSerializableBuffer msg;
1084 
1085  // Serialize message ID
1086  _status = msg.serializeFrom(
1087  static_cast<FwEnumStoreType>(RUN_SCHED)
1088  );
1089  FW_ASSERT(
1090  _status == Fw::FW_SERIALIZE_OK,
1091  static_cast<FwAssertArgType>(_status)
1092  );
1093 
1094  // Serialize port number
1095  _status = msg.serializeFrom(portNum);
1096  FW_ASSERT(
1097  _status == Fw::FW_SERIALIZE_OK,
1098  static_cast<FwAssertArgType>(_status)
1099  );
1100 
1101  // Serialize argument context
1102  _status = msg.serializeFrom(context);
1103  FW_ASSERT(
1104  _status == Fw::FW_SERIALIZE_OK,
1105  static_cast<FwAssertArgType>(_status)
1106  );
1107 
1108  // Send message
1110  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1111 
1112  if (qStatus == Os::Queue::Status::FULL) {
1113  this->incNumMsgDropped();
1114  return;
1115  }
1116 
1117  FW_ASSERT(
1118  qStatus == Os::Queue::OP_OK,
1119  static_cast<FwAssertArgType>(qStatus)
1120  );
1121  }
1122 
1123  // ----------------------------------------------------------------------
1124  // Pre-message hooks for typed async input ports
1125  //
1126  // Each of these functions is invoked just before processing a message
1127  // on the corresponding port. By default, they do nothing. You can
1128  // override them to provide specific pre-message behavior.
1129  // ----------------------------------------------------------------------
1130 
1133  FwIndexType portNum,
1134  Fw::Buffer& fwBuffer
1135  )
1136  {
1137  // Default: no-op
1138  }
1139 
1142  FwIndexType portNum,
1143  Fw::ComBuffer& data,
1144  U32 context
1145  )
1146  {
1147  // Default: no-op
1148  }
1149 
1152  FwIndexType portNum,
1153  Fw::Success& condition
1154  )
1155  {
1156  // Default: no-op
1157  }
1158 
1161  FwIndexType portNum,
1162  U32 context
1163  )
1164  {
1165  // Default: no-op
1166  }
1167 
1168  // ----------------------------------------------------------------------
1169  // Invocation functions for typed output ports
1170  // ----------------------------------------------------------------------
1171 
1174  FwIndexType portNum,
1175  Fw::Buffer& fwBuffer
1176  )
1177  {
1178  FW_ASSERT(
1179  (0 <= portNum) && (portNum < this->getNum_bufferReturnOut_OutputPorts()),
1180  static_cast<FwAssertArgType>(portNum)
1181  );
1182 
1183  FW_ASSERT(
1184  this->m_bufferReturnOut_OutputPort[portNum].isConnected(),
1185  static_cast<FwAssertArgType>(portNum)
1186  );
1187  this->m_bufferReturnOut_OutputPort[portNum].invoke(
1188  fwBuffer
1189  );
1190  }
1191 
1194  FwIndexType portNum,
1195  Fw::Buffer& data,
1196  const ComCfg::FrameContext& context
1197  )
1198  {
1199  FW_ASSERT(
1200  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
1201  static_cast<FwAssertArgType>(portNum)
1202  );
1203 
1204  FW_ASSERT(
1205  this->m_dataOut_OutputPort[portNum].isConnected(),
1206  static_cast<FwAssertArgType>(portNum)
1207  );
1208  this->m_dataOut_OutputPort[portNum].invoke(
1209  data,
1210  context
1211  );
1212  }
1213 
1214  // ----------------------------------------------------------------------
1215  // Command response
1216  // ----------------------------------------------------------------------
1217 
1220  FwOpcodeType opCode,
1221  U32 cmdSeq,
1222  Fw::CmdResponse response
1223  )
1224  {
1225  FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
1226  this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
1227  }
1228 
1229  // ----------------------------------------------------------------------
1230  // Command handler base-class functions
1231  //
1232  // Call these functions directly to bypass the command input port
1233  // ----------------------------------------------------------------------
1234 
1237  FwOpcodeType opCode,
1238  U32 cmdSeq,
1239  Fw::CmdArgBuffer& args
1240  )
1241  {
1242  // Call pre-message hook
1243  this->FLUSH_QUEUE_preMsgHook(opCode,cmdSeq);
1244 
1245  // Defer deserializing arguments to the message dispatcher
1246  // to avoid deserializing and reserializing just for IPC
1247  ComponentIpcSerializableBuffer msg;
1249 
1250  // Serialize for IPC
1251  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_FLUSH_QUEUE));
1252  FW_ASSERT (
1253  _status == Fw::FW_SERIALIZE_OK,
1254  static_cast<FwAssertArgType>(_status)
1255  );
1256 
1257  // Fake port number to make message dequeue work
1258  FwIndexType port = 0;
1259 
1260  _status = msg.serializeFrom(port);
1261  FW_ASSERT (
1262  _status == Fw::FW_SERIALIZE_OK,
1263  static_cast<FwAssertArgType>(_status)
1264  );
1265 
1266  _status = msg.serializeFrom(opCode);
1267  FW_ASSERT (
1268  _status == Fw::FW_SERIALIZE_OK,
1269  static_cast<FwAssertArgType>(_status)
1270  );
1271 
1272  _status = msg.serializeFrom(cmdSeq);
1273  FW_ASSERT (
1274  _status == Fw::FW_SERIALIZE_OK,
1275  static_cast<FwAssertArgType>(_status)
1276  );
1277 
1278  _status = msg.serializeFrom(args);
1279  FW_ASSERT (
1280  _status == Fw::FW_SERIALIZE_OK,
1281  static_cast<FwAssertArgType>(_status)
1282  );
1283 
1284  // Send message
1286  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1287 
1288  FW_ASSERT(
1289  qStatus == Os::Queue::OP_OK,
1290  static_cast<FwAssertArgType>(qStatus)
1291  );
1292  }
1293 
1296  FwOpcodeType opCode,
1297  U32 cmdSeq,
1298  Fw::CmdArgBuffer& args
1299  )
1300  {
1301  // Call pre-message hook
1302  this->FLUSH_ALL_QUEUES_preMsgHook(opCode,cmdSeq);
1303 
1304  // Defer deserializing arguments to the message dispatcher
1305  // to avoid deserializing and reserializing just for IPC
1306  ComponentIpcSerializableBuffer msg;
1308 
1309  // Serialize for IPC
1310  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_FLUSH_ALL_QUEUES));
1311  FW_ASSERT (
1312  _status == Fw::FW_SERIALIZE_OK,
1313  static_cast<FwAssertArgType>(_status)
1314  );
1315 
1316  // Fake port number to make message dequeue work
1317  FwIndexType port = 0;
1318 
1319  _status = msg.serializeFrom(port);
1320  FW_ASSERT (
1321  _status == Fw::FW_SERIALIZE_OK,
1322  static_cast<FwAssertArgType>(_status)
1323  );
1324 
1325  _status = msg.serializeFrom(opCode);
1326  FW_ASSERT (
1327  _status == Fw::FW_SERIALIZE_OK,
1328  static_cast<FwAssertArgType>(_status)
1329  );
1330 
1331  _status = msg.serializeFrom(cmdSeq);
1332  FW_ASSERT (
1333  _status == Fw::FW_SERIALIZE_OK,
1334  static_cast<FwAssertArgType>(_status)
1335  );
1336 
1337  _status = msg.serializeFrom(args);
1338  FW_ASSERT (
1339  _status == Fw::FW_SERIALIZE_OK,
1340  static_cast<FwAssertArgType>(_status)
1341  );
1342 
1343  // Send message
1345  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1346 
1347  FW_ASSERT(
1348  qStatus == Os::Queue::OP_OK,
1349  static_cast<FwAssertArgType>(qStatus)
1350  );
1351  }
1352 
1353  // ----------------------------------------------------------------------
1354  // Pre-message hooks for async commands
1355  //
1356  // Each of these functions is invoked just before processing the
1357  // corresponding command. By default they do nothing. You can
1358  // override them to provide specific pre-command behavior.
1359  // ----------------------------------------------------------------------
1360 
1363  FwOpcodeType opCode,
1364  U32 cmdSeq
1365  )
1366  {
1367  // Defaults to no-op; can be overridden
1368  (void) opCode;
1369  (void) cmdSeq;
1370  }
1371 
1374  FwOpcodeType opCode,
1375  U32 cmdSeq
1376  )
1377  {
1378  // Defaults to no-op; can be overridden
1379  (void) opCode;
1380  (void) cmdSeq;
1381  }
1382 
1383  // ----------------------------------------------------------------------
1384  // Event logging functions
1385  // ----------------------------------------------------------------------
1386 
1389  Svc::QueueType queueType,
1390  U32 index
1391  ) const
1392  {
1393  // Get the time
1394  Fw::Time _logTime;
1395  if (this->m_Time_OutputPort[0].isConnected()) {
1396  this->m_Time_OutputPort[0].invoke(_logTime);
1397  }
1398 
1399  FwEventIdType _id = static_cast<FwEventIdType>(0);
1400 
1401  _id = this->getIdBase() + EVENTID_QUEUEOVERFLOW;
1402 
1403  // Emit the event on the log port
1404  if (this->m_Log_OutputPort[0].isConnected()) {
1405  Fw::LogBuffer _logBuff;
1407 
1408 #if FW_AMPCS_COMPATIBLE
1409  // Serialize the number of arguments
1410  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1411  FW_ASSERT(
1412  _status == Fw::FW_SERIALIZE_OK,
1413  static_cast<FwAssertArgType>(_status)
1414  );
1415 #endif
1416 
1417 #if FW_AMPCS_COMPATIBLE
1418  // Serialize the argument size
1419  _status = _logBuff.serializeFrom(
1420  static_cast<U8>(Svc::QueueType::SERIALIZED_SIZE)
1421  );
1422  FW_ASSERT(
1423  _status == Fw::FW_SERIALIZE_OK,
1424  static_cast<FwAssertArgType>(_status)
1425  );
1426 #endif
1427  _status = _logBuff.serializeFrom(queueType);
1428  FW_ASSERT(
1429  _status == Fw::FW_SERIALIZE_OK,
1430  static_cast<FwAssertArgType>(_status)
1431  );
1432 
1433 #if FW_AMPCS_COMPATIBLE
1434  // Serialize the argument size
1435  _status = _logBuff.serializeFrom(
1436  static_cast<U8>(sizeof(U32))
1437  );
1438  FW_ASSERT(
1439  _status == Fw::FW_SERIALIZE_OK,
1440  static_cast<FwAssertArgType>(_status)
1441  );
1442 #endif
1443  _status = _logBuff.serializeFrom(index);
1444  FW_ASSERT(
1445  _status == Fw::FW_SERIALIZE_OK,
1446  static_cast<FwAssertArgType>(_status)
1447  );
1448 
1449  this->m_Log_OutputPort[0].invoke(
1450  _id,
1451  _logTime,
1453  _logBuff
1454  );
1455  }
1456 
1457  // Emit the event on the text log port
1458 #if FW_ENABLE_TEXT_LOGGING
1459  if (this->m_LogText_OutputPort[0].isConnected()) {
1460 #if FW_OBJECT_NAMES == 1
1461  const char* _formatString =
1462  "(%s) %s: The %s queue at index %" PRIu32 " overflowed";
1463 #else
1464  const char* _formatString =
1465  "%s: The %s queue at index %" PRIu32 " overflowed";
1466 #endif
1467 
1468  Fw::String queueTypeStr;
1469  queueType.toString(queueTypeStr);
1470 
1471  Fw::TextLogString _logString;
1472  _logString.format(
1473  _formatString,
1474 #if FW_OBJECT_NAMES == 1
1475  this->m_objName.toChar(),
1476 #endif
1477  "QueueOverflow ",
1478  queueTypeStr.toChar(),
1479  index
1480  );
1481 
1482  this->m_LogText_OutputPort[0].invoke(
1483  _id,
1484  _logTime,
1486  _logString
1487  );
1488  }
1489 #endif
1490  }
1491 
1492  // ----------------------------------------------------------------------
1493  // Telemetry write functions
1494  // ----------------------------------------------------------------------
1495 
1498  const Svc::ComQueueDepth& arg,
1499  Fw::Time _tlmTime
1500  ) const
1501  {
1502  if (this->m_Tlm_OutputPort[0].isConnected()) {
1503  if (
1504  this->m_Time_OutputPort[0].isConnected() &&
1505  (_tlmTime == Fw::ZERO_TIME)
1506  ) {
1507  this->m_Time_OutputPort[0].invoke(_tlmTime);
1508  }
1509 
1510  Fw::TlmBuffer _tlmBuff;
1511  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1512  FW_ASSERT(
1513  _stat == Fw::FW_SERIALIZE_OK,
1514  static_cast<FwAssertArgType>(_stat)
1515  );
1516 
1517  FwChanIdType _id;
1518 
1519  _id = this->getIdBase() + CHANNELID_COMQUEUEDEPTH;
1520 
1521  this->m_Tlm_OutputPort[0].invoke(
1522  _id,
1523  _tlmTime,
1524  _tlmBuff
1525  );
1526  }
1527  }
1528 
1531  const Svc::BuffQueueDepth& arg,
1532  Fw::Time _tlmTime
1533  ) const
1534  {
1535  if (this->m_Tlm_OutputPort[0].isConnected()) {
1536  if (
1537  this->m_Time_OutputPort[0].isConnected() &&
1538  (_tlmTime == Fw::ZERO_TIME)
1539  ) {
1540  this->m_Time_OutputPort[0].invoke(_tlmTime);
1541  }
1542 
1543  Fw::TlmBuffer _tlmBuff;
1544  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1545  FW_ASSERT(
1546  _stat == Fw::FW_SERIALIZE_OK,
1547  static_cast<FwAssertArgType>(_stat)
1548  );
1549 
1550  FwChanIdType _id;
1551 
1552  _id = this->getIdBase() + CHANNELID_BUFFQUEUEDEPTH;
1553 
1554  this->m_Tlm_OutputPort[0].invoke(
1555  _id,
1556  _tlmTime,
1557  _tlmBuff
1558  );
1559  }
1560  }
1561 
1562  // ----------------------------------------------------------------------
1563  // Time
1564  // ----------------------------------------------------------------------
1565 
1567  getTime() const
1568  {
1569  if (this->m_Time_OutputPort[0].isConnected()) {
1570  Fw::Time _time;
1571  this->m_Time_OutputPort[0].invoke(_time);
1572  return _time;
1573  }
1574  else {
1575  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1576  }
1577  }
1578 
1579  // ----------------------------------------------------------------------
1580  // Message dispatch functions
1581  // ----------------------------------------------------------------------
1582 
1583  Fw::QueuedComponentBase::MsgDispatchStatus ComQueueComponentBase ::
1584  doDispatch()
1585  {
1586  ComponentIpcSerializableBuffer _msg;
1587  FwQueuePriorityType _priority = 0;
1588 
1589  Os::Queue::Status _msgStatus = this->m_queue.receive(
1590  _msg,
1592  _priority
1593  );
1594  FW_ASSERT(
1595  _msgStatus == Os::Queue::OP_OK,
1596  static_cast<FwAssertArgType>(_msgStatus)
1597  );
1598 
1599  // Reset to beginning of buffer
1600  _msg.resetDeser();
1601 
1602  FwEnumStoreType _desMsg = 0;
1603  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1604  FW_ASSERT(
1605  _deserStatus == Fw::FW_SERIALIZE_OK,
1606  static_cast<FwAssertArgType>(_deserStatus)
1607  );
1608 
1609  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1610 
1611  if (_msgType == COMQUEUE_COMPONENT_EXIT) {
1612  return MSG_DISPATCH_EXIT;
1613  }
1614 
1615  FwIndexType portNum = 0;
1616  _deserStatus = _msg.deserializeTo(portNum);
1617  FW_ASSERT(
1618  _deserStatus == Fw::FW_SERIALIZE_OK,
1619  static_cast<FwAssertArgType>(_deserStatus)
1620  );
1621 
1622  switch (_msgType) {
1623  // Handle async input port bufferQueueIn
1624  case BUFFERQUEUEIN_BUFFERSEND: {
1625  // Deserialize argument fwBuffer
1626  Fw::Buffer fwBuffer;
1627  _deserStatus = _msg.deserializeTo(fwBuffer);
1628  FW_ASSERT(
1629  _deserStatus == Fw::FW_SERIALIZE_OK,
1630  static_cast<FwAssertArgType>(_deserStatus)
1631  );
1632  // Call handler function
1633  this->bufferQueueIn_handler(
1634  portNum,
1635  fwBuffer
1636  );
1637 
1638  break;
1639  }
1640 
1641  // Handle async input port comPacketQueueIn
1642  case COMPACKETQUEUEIN_COM: {
1643  // Deserialize argument data
1644  Fw::ComBuffer data;
1645  _deserStatus = _msg.deserializeTo(data);
1646  FW_ASSERT(
1647  _deserStatus == Fw::FW_SERIALIZE_OK,
1648  static_cast<FwAssertArgType>(_deserStatus)
1649  );
1650 
1651  // Deserialize argument context
1652  U32 context;
1653  _deserStatus = _msg.deserializeTo(context);
1654  FW_ASSERT(
1655  _deserStatus == Fw::FW_SERIALIZE_OK,
1656  static_cast<FwAssertArgType>(_deserStatus)
1657  );
1658  // Call handler function
1660  portNum,
1661  data,
1662  context
1663  );
1664 
1665  break;
1666  }
1667 
1668  // Handle async input port comStatusIn
1669  case COMSTATUSIN_SUCCESSCONDITION: {
1670  // Deserialize argument condition
1671  Fw::Success condition;
1672  _deserStatus = _msg.deserializeTo(condition);
1673  FW_ASSERT(
1674  _deserStatus == Fw::FW_SERIALIZE_OK,
1675  static_cast<FwAssertArgType>(_deserStatus)
1676  );
1677  // Call handler function
1678  this->comStatusIn_handler(
1679  portNum,
1680  condition
1681  );
1682 
1683  break;
1684  }
1685 
1686  // Handle async input port run
1687  case RUN_SCHED: {
1688  // Deserialize argument context
1689  U32 context;
1690  _deserStatus = _msg.deserializeTo(context);
1691  FW_ASSERT(
1692  _deserStatus == Fw::FW_SERIALIZE_OK,
1693  static_cast<FwAssertArgType>(_deserStatus)
1694  );
1695  // Call handler function
1696  this->run_handler(
1697  portNum,
1698  context
1699  );
1700 
1701  break;
1702  }
1703 
1704  // Handle command FLUSH_QUEUE
1705  case CMD_FLUSH_QUEUE: {
1706  // Deserialize opcode
1707  FwOpcodeType _opCode = 0;
1708  _deserStatus = _msg.deserializeTo(_opCode);
1709  FW_ASSERT (
1710  _deserStatus == Fw::FW_SERIALIZE_OK,
1711  static_cast<FwAssertArgType>(_deserStatus)
1712  );
1713 
1714  // Deserialize command sequence
1715  U32 _cmdSeq = 0;
1716  _deserStatus = _msg.deserializeTo(_cmdSeq);
1717  FW_ASSERT (
1718  _deserStatus == Fw::FW_SERIALIZE_OK,
1719  static_cast<FwAssertArgType>(_deserStatus)
1720  );
1721 
1722  // Deserialize command argument buffer
1723  Fw::CmdArgBuffer args;
1724  _deserStatus = _msg.deserializeTo(args);
1725  FW_ASSERT (
1726  _deserStatus == Fw::FW_SERIALIZE_OK,
1727  static_cast<FwAssertArgType>(_deserStatus)
1728  );
1729 
1730  // Reset buffer
1731  args.resetDeser();
1732 
1733  // Deserialize argument queueType
1734  Svc::QueueType queueType;
1735  _deserStatus = args.deserializeTo(queueType);
1736  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
1737  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
1738  this->cmdResponse_out(
1739  _opCode,
1740  _cmdSeq,
1742  );
1743  }
1744  // Don't crash the task if bad arguments were passed from the ground
1745  break;
1746  }
1747 
1748  // Deserialize argument indexType
1749  FwIndexType indexType;
1750  _deserStatus = args.deserializeTo(indexType);
1751  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
1752  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
1753  this->cmdResponse_out(
1754  _opCode,
1755  _cmdSeq,
1757  );
1758  }
1759  // Don't crash the task if bad arguments were passed from the ground
1760  break;
1761  }
1762 
1763  // Make sure there was no data left over.
1764  // That means the argument buffer size was incorrect.
1765 #if FW_CMD_CHECK_RESIDUAL
1766  if (args.getDeserializeSizeLeft() != 0) {
1767  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
1768  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1769  }
1770  // Don't crash the task if bad arguments were passed from the ground
1771  break;
1772  }
1773 #endif
1774 
1775  // Call handler function
1776  this->FLUSH_QUEUE_cmdHandler(
1777  _opCode, _cmdSeq,
1778  queueType,
1779  indexType
1780  );
1781 
1782  break;
1783  }
1784 
1785  // Handle command FLUSH_ALL_QUEUES
1786  case CMD_FLUSH_ALL_QUEUES: {
1787  // Deserialize opcode
1788  FwOpcodeType _opCode = 0;
1789  _deserStatus = _msg.deserializeTo(_opCode);
1790  FW_ASSERT (
1791  _deserStatus == Fw::FW_SERIALIZE_OK,
1792  static_cast<FwAssertArgType>(_deserStatus)
1793  );
1794 
1795  // Deserialize command sequence
1796  U32 _cmdSeq = 0;
1797  _deserStatus = _msg.deserializeTo(_cmdSeq);
1798  FW_ASSERT (
1799  _deserStatus == Fw::FW_SERIALIZE_OK,
1800  static_cast<FwAssertArgType>(_deserStatus)
1801  );
1802 
1803  // Deserialize command argument buffer
1804  Fw::CmdArgBuffer args;
1805  _deserStatus = _msg.deserializeTo(args);
1806  FW_ASSERT (
1807  _deserStatus == Fw::FW_SERIALIZE_OK,
1808  static_cast<FwAssertArgType>(_deserStatus)
1809  );
1810 
1811  // Reset buffer
1812  args.resetDeser();
1813 
1814  // Make sure there was no data left over.
1815  // That means the argument buffer size was incorrect.
1816 #if FW_CMD_CHECK_RESIDUAL
1817  if (args.getDeserializeSizeLeft() != 0) {
1818  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
1819  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1820  }
1821  // Don't crash the task if bad arguments were passed from the ground
1822  break;
1823  }
1824 #endif
1825 
1826  // Call handler function
1827  this->FLUSH_ALL_QUEUES_cmdHandler(_opCode, _cmdSeq);
1828 
1829  break;
1830  }
1831 
1832  default:
1833  return MSG_DISPATCH_ERROR;
1834  }
1835 
1836  return MSG_DISPATCH_OK;
1837  }
1838 
1839  // ----------------------------------------------------------------------
1840  // Calls for messages received on special input ports
1841  // ----------------------------------------------------------------------
1842 
1843  void ComQueueComponentBase ::
1844  m_p_CmdDisp_in(
1845  Fw::PassiveComponentBase* callComp,
1846  FwIndexType portNum,
1847  FwOpcodeType opCode,
1848  U32 cmdSeq,
1849  Fw::CmdArgBuffer& args
1850  )
1851  {
1852  FW_ASSERT(callComp);
1853  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1854 
1855  const U32 idBase = callComp->getIdBase();
1856  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
1857 
1858  // Select base class function based on opcode
1859  switch (opCode - idBase) {
1860  case OPCODE_FLUSH_QUEUE: {
1861  compPtr->FLUSH_QUEUE_cmdHandlerBase(
1862  opCode,
1863  cmdSeq,
1864  args
1865  );
1866  break;
1867  }
1868 
1869  case OPCODE_FLUSH_ALL_QUEUES: {
1870  compPtr->FLUSH_ALL_QUEUES_cmdHandlerBase(
1871  opCode,
1872  cmdSeq,
1873  args
1874  );
1875  break;
1876  }
1877  }
1878  }
1879 
1880  // ----------------------------------------------------------------------
1881  // Calls for messages received on typed input ports
1882  // ----------------------------------------------------------------------
1883 
1884  void ComQueueComponentBase ::
1885  m_p_bufferQueueIn_in(
1886  Fw::PassiveComponentBase* callComp,
1887  FwIndexType portNum,
1888  Fw::Buffer& fwBuffer
1889  )
1890  {
1891  FW_ASSERT(callComp);
1892  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1893  compPtr->bufferQueueIn_handlerBase(
1894  portNum,
1895  fwBuffer
1896  );
1897  }
1898 
1899  void ComQueueComponentBase ::
1900  m_p_comPacketQueueIn_in(
1901  Fw::PassiveComponentBase* callComp,
1902  FwIndexType portNum,
1903  Fw::ComBuffer& data,
1904  U32 context
1905  )
1906  {
1907  FW_ASSERT(callComp);
1908  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1909  compPtr->comPacketQueueIn_handlerBase(
1910  portNum,
1911  data,
1912  context
1913  );
1914  }
1915 
1916  void ComQueueComponentBase ::
1917  m_p_comStatusIn_in(
1918  Fw::PassiveComponentBase* callComp,
1919  FwIndexType portNum,
1920  Fw::Success& condition
1921  )
1922  {
1923  FW_ASSERT(callComp);
1924  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1925  compPtr->comStatusIn_handlerBase(
1926  portNum,
1927  condition
1928  );
1929  }
1930 
1931  void ComQueueComponentBase ::
1932  m_p_dataReturnIn_in(
1933  Fw::PassiveComponentBase* callComp,
1934  FwIndexType portNum,
1935  Fw::Buffer& data,
1936  const ComCfg::FrameContext& context
1937  )
1938  {
1939  FW_ASSERT(callComp);
1940  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1941  compPtr->dataReturnIn_handlerBase(
1942  portNum,
1943  data,
1944  context
1945  );
1946  }
1947 
1948  void ComQueueComponentBase ::
1949  m_p_run_in(
1950  Fw::PassiveComponentBase* callComp,
1951  FwIndexType portNum,
1952  U32 context
1953  )
1954  {
1955  FW_ASSERT(callComp);
1956  ComQueueComponentBase* compPtr = static_cast<ComQueueComponentBase*>(callComp);
1957  compPtr->run_handlerBase(
1958  portNum,
1959  context
1960  );
1961  }
1962 
1963 }
Serialization/Deserialization operation was successful.
virtual void comStatusIn_handler(FwIndexType portNum, Fw::Success &condition)=0
Handler for input port comStatusIn.
static constexpr FwIndexType getNum_Tlm_OutputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual ~ComQueueComponentBase()
Destroy ComQueueComponentBase object.
void FLUSH_QUEUE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
FwIdType FwOpcodeType
The type of a command opcode.
static constexpr FwIndexType getNum_dataReturnIn_InputPorts()
Operation succeeded.
Definition: Os.hpp:26
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
static constexpr FwIndexType getNum_bufferReturnOut_OutputPorts()
PlatformSizeType FwSizeType
void tlmWrite_buffQueueDepth(const Svc::BuffQueueDepth &arg, Fw::Time _tlmTime=Fw::Time()) const
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
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
static constexpr FwIndexType getNum_CmdDisp_InputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
virtual void FLUSH_ALL_QUEUES_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command FLUSH_ALL_QUEUES.
static constexpr FwIndexType getNum_CmdReg_OutputPorts()
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
const char * toChar() const
Convert to a C-style char*.
Definition: String.hpp:50
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
virtual void FLUSH_QUEUE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::QueueType queueType, FwIndexType indexType)=0
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
virtual void dataReturnIn_handler(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)=0
Handler for input port dataReturnIn.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void dataOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataOut.
void dataReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Handler base-class function for input port dataReturnIn.
void set_CmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
Svc::InputSchedPort * get_run_InputPort(FwIndexType portNum)
virtual void FLUSH_ALL_QUEUES_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
static constexpr FwIndexType getNum_comPacketQueueIn_InputPorts()
void set_bufferReturnOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferReturnOut[portNum].
const Time ZERO_TIME
Definition: Time.cpp:5
bool isConnected_bufferReturnOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
Enum representing a command response.
virtual void FLUSH_QUEUE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command FLUSH_QUEUE.
void set_dataOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataOut[portNum].
No time base has been established (Required)
void FLUSH_ALL_QUEUES_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
message to exit active component task
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
Os::Queue m_queue
queue object for active component
void addCallPort(InputComDataWithContextPort *callPort)
Register an input port.
Array of queue depths for Fw::Com types.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
An enumeration of queue data types.
bool isConnected_Log_OutputPort(FwIndexType portNum)
void init()
Object initializer.
Definition: ObjBase.cpp:24
void init()
Initialization function.
Definition: ComPortAc.cpp:56
void comStatusIn_handlerBase(FwIndexType portNum, Fw::Success &condition)
Handler base-class function for input port comStatusIn.
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
virtual void bufferQueueIn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferQueueIn.
FwIdType FwEventIdType
The type of an event identifier.
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:26
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
bool isConnected_Time_OutputPort(FwIndexType portNum)
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port interface.
static constexpr FwIndexType getNum_CmdStatus_OutputPorts()
virtual void run_handler(FwIndexType portNum, U32 context)=0
Handler for input port run.
void run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port run.
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
static constexpr FwIndexType getNum_bufferQueueIn_InputPorts()
Array of queue depths for Fw::Buffer types.
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
virtual void run_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port run.
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 invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port interface.
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 log_WARNING_HI_QueueOverflow(Svc::QueueType queueType, U32 index) const
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
Fw::InputComPort * get_comPacketQueueIn_InputPort(FwIndexType portNum)
A serious but recoverable event.
void init()
Initialization function.
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
virtual void bufferQueueIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferQueueIn.
virtual void comPacketQueueIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comPacketQueueIn.
void comPacketQueueIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comPacketQueueIn.
Svc::InputComDataWithContextPort * get_dataReturnIn_InputPort(FwIndexType portNum)
#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
virtual void comPacketQueueIn_preMsgHook(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Pre-message hook for async input port comPacketQueueIn.
void setPortNum(FwIndexType portNum)
Fw::InputBufferSendPort * get_bufferQueueIn_InputPort(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
BlockingType
message type
Definition: Queue.hpp:46
static constexpr FwIndexType getNum_dataOut_OutputPorts()
Command failed to deserialize.
void init()
Initialization function.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void init()
Initialization function.
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_comStatusIn_InputPorts()
static constexpr FwIndexType getNum_Log_OutputPorts()
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
Fw::InputSuccessConditionPort * get_comStatusIn_InputPort(FwIndexType portNum)
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
The size of the serial representations of the port arguments.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
A message was sent requesting an exit of the loop.
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
ComQueueComponentBase(const char *compName="")
Construct ComQueueComponentBase object.
PlatformIndexType FwIndexType
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void init()
Initialization function.
Type used to pass context info between components during framing/deframing.
void incNumMsgDropped()
increment the number of messages dropped
void tlmWrite_comQueueDepth(const Svc::ComQueueDepth &arg, Fw::Time _tlmTime=Fw::Time()) const
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
static constexpr FwIndexType getNum_Time_OutputPorts()
The size of the serial representations of the port arguments.
void regCommands()
Register commands with the Command Dispatcher.
virtual void comStatusIn_preMsgHook(FwIndexType portNum, Fw::Success &condition)
Pre-message hook for async input port comStatusIn.
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
virtual void bufferQueueIn_overflowHook(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Overflow hook for async input port bufferQueueIn.
void init()
Initialization function.
bool isConnected_dataOut_OutputPort(FwIndexType portNum)
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.
The size of the serial representation.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_run_InputPorts()
The size of the serial representations of the port arguments.
Definition: ComPortAc.hpp:37
void init()
Initialization function.
void bufferQueueIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferQueueIn.
void bufferReturnOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferReturnOut.