F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
BufferAccumulatorComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferAccumulatorComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for BufferAccumulator component base class
5 // ======================================================================
6 
7 #include <cstdio>
8 
10 #include "Fw/Types/Assert.hpp"
11 #if FW_ENABLE_TEXT_LOGGING
12 #include "Fw/Types/String.hpp"
13 #endif
14 
15 namespace Svc {
16 
17  namespace {
18  enum MsgTypeEnum {
19  BUFFERACCUMULATOR_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20  BUFFERSENDINFILL_BUFFERSEND,
21  BUFFERSENDINRETURN_BUFFERSEND,
22  PINGIN_PING,
23  CMD_BA_SETMODE,
24  CMD_BA_DRAINBUFFERS,
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 bufferSendInFillPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
31  BYTE bufferSendInReturnPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
34  };
35 
36  // Define a message buffer class large enough to handle all the
37  // asynchronous inputs to the component
38  class ComponentIpcSerializableBuffer :
40  {
41 
42  public:
43 
44  enum {
45  // Max. message size = size of data + message id + port
46  SERIALIZATION_SIZE =
47  sizeof(BuffUnion) +
48  sizeof(NATIVE_INT_TYPE) +
49  sizeof(NATIVE_INT_TYPE)
50  };
51 
52  NATIVE_UINT_TYPE getBuffCapacity() const {
53  return sizeof(m_buff);
54  }
55 
56  U8* getBuffAddr() {
57  return m_buff;
58  }
59 
60  const U8* getBuffAddr() const {
61  return m_buff;
62  }
63 
64  private:
65  // Should be the max of all the input ports serialized sizes...
66  U8 m_buff[SERIALIZATION_SIZE];
67 
68  };
69  }
70 
71  // ----------------------------------------------------------------------
72  // Component initialization
73  // ----------------------------------------------------------------------
74 
76  init(
77  NATIVE_INT_TYPE queueDepth,
78  NATIVE_INT_TYPE instance
79  )
80  {
81  // Initialize base class
83 
84  // Connect input port cmdIn
85  for (
86  PlatformIntType port = 0;
87  port < static_cast<PlatformIntType>(this->getNum_cmdIn_InputPorts());
88  port++
89  ) {
90  this->m_cmdIn_InputPort[port].init();
91  this->m_cmdIn_InputPort[port].addCallComp(
92  this,
93  m_p_cmdIn_in
94  );
95  this->m_cmdIn_InputPort[port].setPortNum(port);
96 
97 #if FW_OBJECT_NAMES == 1
98  // The port name consists of this->m_objName and some extra info.
99  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
100  // However, the compiler may assume that this->m_objName fills
101  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
102  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
103  // bytes to cover the extra info.
104  char portName[2*FW_OBJ_NAME_MAX_SIZE];
105  (void) snprintf(
106  portName,
107  sizeof(portName),
108  "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
109  this->m_objName,
110  port
111  );
112  this->m_cmdIn_InputPort[port].setObjName(portName);
113 #endif
114  }
115 
116  // Connect input port bufferSendInFill
117  for (
118  PlatformIntType port = 0;
119  port < static_cast<PlatformIntType>(this->getNum_bufferSendInFill_InputPorts());
120  port++
121  ) {
122  this->m_bufferSendInFill_InputPort[port].init();
123  this->m_bufferSendInFill_InputPort[port].addCallComp(
124  this,
125  m_p_bufferSendInFill_in
126  );
127  this->m_bufferSendInFill_InputPort[port].setPortNum(port);
128 
129 #if FW_OBJECT_NAMES == 1
130  // The port name consists of this->m_objName and some extra info.
131  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
132  // However, the compiler may assume that this->m_objName fills
133  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
134  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
135  // bytes to cover the extra info.
136  char portName[2*FW_OBJ_NAME_MAX_SIZE];
137  (void) snprintf(
138  portName,
139  sizeof(portName),
140  "%s_bufferSendInFill_InputPort[%" PRI_PlatformIntType "]",
141  this->m_objName,
142  port
143  );
144  this->m_bufferSendInFill_InputPort[port].setObjName(portName);
145 #endif
146  }
147 
148  // Connect input port bufferSendInReturn
149  for (
150  PlatformIntType port = 0;
151  port < static_cast<PlatformIntType>(this->getNum_bufferSendInReturn_InputPorts());
152  port++
153  ) {
154  this->m_bufferSendInReturn_InputPort[port].init();
155  this->m_bufferSendInReturn_InputPort[port].addCallComp(
156  this,
157  m_p_bufferSendInReturn_in
158  );
159  this->m_bufferSendInReturn_InputPort[port].setPortNum(port);
160 
161 #if FW_OBJECT_NAMES == 1
162  // The port name consists of this->m_objName and some extra info.
163  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
164  // However, the compiler may assume that this->m_objName fills
165  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
166  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
167  // bytes to cover the extra info.
168  char portName[2*FW_OBJ_NAME_MAX_SIZE];
169  (void) snprintf(
170  portName,
171  sizeof(portName),
172  "%s_bufferSendInReturn_InputPort[%" PRI_PlatformIntType "]",
173  this->m_objName,
174  port
175  );
176  this->m_bufferSendInReturn_InputPort[port].setObjName(portName);
177 #endif
178  }
179 
180  // Connect input port pingIn
181  for (
182  PlatformIntType port = 0;
183  port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
184  port++
185  ) {
186  this->m_pingIn_InputPort[port].init();
187  this->m_pingIn_InputPort[port].addCallComp(
188  this,
189  m_p_pingIn_in
190  );
191  this->m_pingIn_InputPort[port].setPortNum(port);
192 
193 #if FW_OBJECT_NAMES == 1
194  // The port name consists of this->m_objName and some extra info.
195  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
196  // However, the compiler may assume that this->m_objName fills
197  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
198  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
199  // bytes to cover the extra info.
200  char portName[2*FW_OBJ_NAME_MAX_SIZE];
201  (void) snprintf(
202  portName,
203  sizeof(portName),
204  "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
205  this->m_objName,
206  port
207  );
208  this->m_pingIn_InputPort[port].setObjName(portName);
209 #endif
210  }
211 
212  // Connect output port cmdRegOut
213  for (
214  PlatformIntType port = 0;
215  port < static_cast<PlatformIntType>(this->getNum_cmdRegOut_OutputPorts());
216  port++
217  ) {
218  this->m_cmdRegOut_OutputPort[port].init();
219 
220 #if FW_OBJECT_NAMES == 1
221  // The port name consists of this->m_objName and some extra info.
222  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
223  // However, the compiler may assume that this->m_objName fills
224  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
225  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
226  // bytes to cover the extra info.
227  char portName[2*FW_OBJ_NAME_MAX_SIZE];
228  (void) snprintf(
229  portName,
230  sizeof(portName),
231  "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
232  this->m_objName,
233  port
234  );
235  this->m_cmdRegOut_OutputPort[port].setObjName(portName);
236 #endif
237  }
238 
239  // Connect output port cmdResponseOut
240  for (
241  PlatformIntType port = 0;
242  port < static_cast<PlatformIntType>(this->getNum_cmdResponseOut_OutputPorts());
243  port++
244  ) {
245  this->m_cmdResponseOut_OutputPort[port].init();
246 
247 #if FW_OBJECT_NAMES == 1
248  // The port name consists of this->m_objName and some extra info.
249  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
250  // However, the compiler may assume that this->m_objName fills
251  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
252  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
253  // bytes to cover the extra info.
254  char portName[2*FW_OBJ_NAME_MAX_SIZE];
255  (void) snprintf(
256  portName,
257  sizeof(portName),
258  "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
259  this->m_objName,
260  port
261  );
262  this->m_cmdResponseOut_OutputPort[port].setObjName(portName);
263 #endif
264  }
265 
266  // Connect output port eventOut
267  for (
268  PlatformIntType port = 0;
269  port < static_cast<PlatformIntType>(this->getNum_eventOut_OutputPorts());
270  port++
271  ) {
272  this->m_eventOut_OutputPort[port].init();
273 
274 #if FW_OBJECT_NAMES == 1
275  // The port name consists of this->m_objName and some extra info.
276  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
277  // However, the compiler may assume that this->m_objName fills
278  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
279  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
280  // bytes to cover the extra info.
281  char portName[2*FW_OBJ_NAME_MAX_SIZE];
282  (void) snprintf(
283  portName,
284  sizeof(portName),
285  "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
286  this->m_objName,
287  port
288  );
289  this->m_eventOut_OutputPort[port].setObjName(portName);
290 #endif
291  }
292 
293 #if FW_ENABLE_TEXT_LOGGING == 1
294  // Connect output port eventOutText
295  for (
296  PlatformIntType port = 0;
297  port < static_cast<PlatformIntType>(this->getNum_eventOutText_OutputPorts());
298  port++
299  ) {
300  this->m_eventOutText_OutputPort[port].init();
301 
302 #if FW_OBJECT_NAMES == 1
303  // The port name consists of this->m_objName and some extra info.
304  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
305  // However, the compiler may assume that this->m_objName fills
306  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
307  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
308  // bytes to cover the extra info.
309  char portName[2*FW_OBJ_NAME_MAX_SIZE];
310  (void) snprintf(
311  portName,
312  sizeof(portName),
313  "%s_eventOutText_OutputPort[%" PRI_PlatformIntType "]",
314  this->m_objName,
315  port
316  );
317  this->m_eventOutText_OutputPort[port].setObjName(portName);
318 #endif
319  }
320 #endif
321 
322  // Connect output port timeCaller
323  for (
324  PlatformIntType port = 0;
325  port < static_cast<PlatformIntType>(this->getNum_timeCaller_OutputPorts());
326  port++
327  ) {
328  this->m_timeCaller_OutputPort[port].init();
329 
330 #if FW_OBJECT_NAMES == 1
331  // The port name consists of this->m_objName and some extra info.
332  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
333  // However, the compiler may assume that this->m_objName fills
334  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
335  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
336  // bytes to cover the extra info.
337  char portName[2*FW_OBJ_NAME_MAX_SIZE];
338  (void) snprintf(
339  portName,
340  sizeof(portName),
341  "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
342  this->m_objName,
343  port
344  );
345  this->m_timeCaller_OutputPort[port].setObjName(portName);
346 #endif
347  }
348 
349  // Connect output port tlmOut
350  for (
351  PlatformIntType port = 0;
352  port < static_cast<PlatformIntType>(this->getNum_tlmOut_OutputPorts());
353  port++
354  ) {
355  this->m_tlmOut_OutputPort[port].init();
356 
357 #if FW_OBJECT_NAMES == 1
358  // The port name consists of this->m_objName and some extra info.
359  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
360  // However, the compiler may assume that this->m_objName fills
361  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
362  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
363  // bytes to cover the extra info.
364  char portName[2*FW_OBJ_NAME_MAX_SIZE];
365  (void) snprintf(
366  portName,
367  sizeof(portName),
368  "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
369  this->m_objName,
370  port
371  );
372  this->m_tlmOut_OutputPort[port].setObjName(portName);
373 #endif
374  }
375 
376  // Connect output port bufferSendOutDrain
377  for (
378  PlatformIntType port = 0;
379  port < static_cast<PlatformIntType>(this->getNum_bufferSendOutDrain_OutputPorts());
380  port++
381  ) {
382  this->m_bufferSendOutDrain_OutputPort[port].init();
383 
384 #if FW_OBJECT_NAMES == 1
385  // The port name consists of this->m_objName and some extra info.
386  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
387  // However, the compiler may assume that this->m_objName fills
388  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
389  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
390  // bytes to cover the extra info.
391  char portName[2*FW_OBJ_NAME_MAX_SIZE];
392  (void) snprintf(
393  portName,
394  sizeof(portName),
395  "%s_bufferSendOutDrain_OutputPort[%" PRI_PlatformIntType "]",
396  this->m_objName,
397  port
398  );
399  this->m_bufferSendOutDrain_OutputPort[port].setObjName(portName);
400 #endif
401  }
402 
403  // Connect output port bufferSendOutReturn
404  for (
405  PlatformIntType port = 0;
406  port < static_cast<PlatformIntType>(this->getNum_bufferSendOutReturn_OutputPorts());
407  port++
408  ) {
409  this->m_bufferSendOutReturn_OutputPort[port].init();
410 
411 #if FW_OBJECT_NAMES == 1
412  // The port name consists of this->m_objName and some extra info.
413  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
414  // However, the compiler may assume that this->m_objName fills
415  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
416  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
417  // bytes to cover the extra info.
418  char portName[2*FW_OBJ_NAME_MAX_SIZE];
419  (void) snprintf(
420  portName,
421  sizeof(portName),
422  "%s_bufferSendOutReturn_OutputPort[%" PRI_PlatformIntType "]",
423  this->m_objName,
424  port
425  );
426  this->m_bufferSendOutReturn_OutputPort[port].setObjName(portName);
427 #endif
428  }
429 
430  // Connect output port pingOut
431  for (
432  PlatformIntType port = 0;
433  port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
434  port++
435  ) {
436  this->m_pingOut_OutputPort[port].init();
437 
438 #if FW_OBJECT_NAMES == 1
439  // The port name consists of this->m_objName and some extra info.
440  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
441  // However, the compiler may assume that this->m_objName fills
442  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
443  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
444  // bytes to cover the extra info.
445  char portName[2*FW_OBJ_NAME_MAX_SIZE];
446  (void) snprintf(
447  portName,
448  sizeof(portName),
449  "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
450  this->m_objName,
451  port
452  );
453  this->m_pingOut_OutputPort[port].setObjName(portName);
454 #endif
455  }
456 
457  Os::Queue::QueueStatus qStat = this->createQueue(
458  queueDepth,
459  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
460  );
461  FW_ASSERT(
462  Os::Queue::QUEUE_OK == qStat,
463  static_cast<FwAssertArgType>(qStat)
464  );
465  }
466 
467  // ----------------------------------------------------------------------
468  // Getters for special input ports
469  // ----------------------------------------------------------------------
470 
473  {
474  FW_ASSERT(
475  portNum < this->getNum_cmdIn_InputPorts(),
476  static_cast<FwAssertArgType>(portNum)
477  );
478 
479  return &this->m_cmdIn_InputPort[portNum];
480  }
481 
482  // ----------------------------------------------------------------------
483  // Getters for typed input ports
484  // ----------------------------------------------------------------------
485 
488  {
489  FW_ASSERT(
490  portNum < this->getNum_bufferSendInFill_InputPorts(),
491  static_cast<FwAssertArgType>(portNum)
492  );
493 
494  return &this->m_bufferSendInFill_InputPort[portNum];
495  }
496 
499  {
500  FW_ASSERT(
501  portNum < this->getNum_bufferSendInReturn_InputPorts(),
502  static_cast<FwAssertArgType>(portNum)
503  );
504 
505  return &this->m_bufferSendInReturn_InputPort[portNum];
506  }
507 
510  {
511  FW_ASSERT(
512  portNum < this->getNum_pingIn_InputPorts(),
513  static_cast<FwAssertArgType>(portNum)
514  );
515 
516  return &this->m_pingIn_InputPort[portNum];
517  }
518 
519  // ----------------------------------------------------------------------
520  // Connect input ports to special output ports
521  // ----------------------------------------------------------------------
522 
525  NATIVE_INT_TYPE portNum,
526  Fw::InputCmdRegPort* port
527  )
528  {
529  FW_ASSERT(
530  portNum < this->getNum_cmdRegOut_OutputPorts(),
531  static_cast<FwAssertArgType>(portNum)
532  );
533 
534  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
535  }
536 
539  NATIVE_INT_TYPE portNum,
541  )
542  {
543  FW_ASSERT(
544  portNum < this->getNum_cmdResponseOut_OutputPorts(),
545  static_cast<FwAssertArgType>(portNum)
546  );
547 
548  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
549  }
550 
553  NATIVE_INT_TYPE portNum,
554  Fw::InputLogPort* port
555  )
556  {
557  FW_ASSERT(
558  portNum < this->getNum_eventOut_OutputPorts(),
559  static_cast<FwAssertArgType>(portNum)
560  );
561 
562  this->m_eventOut_OutputPort[portNum].addCallPort(port);
563  }
564 
565 #if FW_ENABLE_TEXT_LOGGING == 1
566 
567  void BufferAccumulatorComponentBase ::
568  set_eventOutText_OutputPort(
569  NATIVE_INT_TYPE portNum,
571  )
572  {
573  FW_ASSERT(
574  portNum < this->getNum_eventOutText_OutputPorts(),
575  static_cast<FwAssertArgType>(portNum)
576  );
577 
578  this->m_eventOutText_OutputPort[portNum].addCallPort(port);
579  }
580 
581 #endif
582 
585  NATIVE_INT_TYPE portNum,
586  Fw::InputTimePort* port
587  )
588  {
589  FW_ASSERT(
590  portNum < this->getNum_timeCaller_OutputPorts(),
591  static_cast<FwAssertArgType>(portNum)
592  );
593 
594  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
595  }
596 
599  NATIVE_INT_TYPE portNum,
600  Fw::InputTlmPort* port
601  )
602  {
603  FW_ASSERT(
604  portNum < this->getNum_tlmOut_OutputPorts(),
605  static_cast<FwAssertArgType>(portNum)
606  );
607 
608  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
609  }
610 
611  // ----------------------------------------------------------------------
612  // Connect typed input ports to typed output ports
613  // ----------------------------------------------------------------------
614 
617  NATIVE_INT_TYPE portNum,
619  )
620  {
621  FW_ASSERT(
622  portNum < this->getNum_bufferSendOutDrain_OutputPorts(),
623  static_cast<FwAssertArgType>(portNum)
624  );
625 
626  this->m_bufferSendOutDrain_OutputPort[portNum].addCallPort(port);
627  }
628 
631  NATIVE_INT_TYPE portNum,
633  )
634  {
635  FW_ASSERT(
636  portNum < this->getNum_bufferSendOutReturn_OutputPorts(),
637  static_cast<FwAssertArgType>(portNum)
638  );
639 
640  this->m_bufferSendOutReturn_OutputPort[portNum].addCallPort(port);
641  }
642 
645  NATIVE_INT_TYPE portNum,
646  Svc::InputPingPort* port
647  )
648  {
649  FW_ASSERT(
650  portNum < this->getNum_pingOut_OutputPorts(),
651  static_cast<FwAssertArgType>(portNum)
652  );
653 
654  this->m_pingOut_OutputPort[portNum].addCallPort(port);
655  }
656 
657 #if FW_PORT_SERIALIZATION
658 
659  // ----------------------------------------------------------------------
660  // Connect serial input ports to special output ports
661  // ----------------------------------------------------------------------
662 
665  NATIVE_INT_TYPE portNum,
666  Fw::InputSerializePort* port
667  )
668  {
669  FW_ASSERT(
670  portNum < this->getNum_cmdRegOut_OutputPorts(),
671  static_cast<FwAssertArgType>(portNum)
672  );
673 
674  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
675  }
676 
679  NATIVE_INT_TYPE portNum,
680  Fw::InputSerializePort* port
681  )
682  {
683  FW_ASSERT(
684  portNum < this->getNum_cmdResponseOut_OutputPorts(),
685  static_cast<FwAssertArgType>(portNum)
686  );
687 
688  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
689  }
690 
693  NATIVE_INT_TYPE portNum,
694  Fw::InputSerializePort* port
695  )
696  {
697  FW_ASSERT(
698  portNum < this->getNum_eventOut_OutputPorts(),
699  static_cast<FwAssertArgType>(portNum)
700  );
701 
702  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
703  }
704 
705 #if FW_ENABLE_TEXT_LOGGING == 1
706 
707  void BufferAccumulatorComponentBase ::
708  set_eventOutText_OutputPort(
709  NATIVE_INT_TYPE portNum,
710  Fw::InputSerializePort* port
711  )
712  {
713  FW_ASSERT(
714  portNum < this->getNum_eventOutText_OutputPorts(),
715  static_cast<FwAssertArgType>(portNum)
716  );
717 
718  this->m_eventOutText_OutputPort[portNum].registerSerialPort(port);
719  }
720 
721 #endif
722 
725  NATIVE_INT_TYPE portNum,
726  Fw::InputSerializePort* port
727  )
728  {
729  FW_ASSERT(
730  portNum < this->getNum_timeCaller_OutputPorts(),
731  static_cast<FwAssertArgType>(portNum)
732  );
733 
734  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
735  }
736 
739  NATIVE_INT_TYPE portNum,
740  Fw::InputSerializePort* port
741  )
742  {
743  FW_ASSERT(
744  portNum < this->getNum_tlmOut_OutputPorts(),
745  static_cast<FwAssertArgType>(portNum)
746  );
747 
748  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
749  }
750 
751 #endif
752 
753 #if FW_PORT_SERIALIZATION
754 
755  // ----------------------------------------------------------------------
756  // Connect serial input ports to typed output ports
757  // ----------------------------------------------------------------------
758 
761  NATIVE_INT_TYPE portNum,
762  Fw::InputSerializePort* port
763  )
764  {
765  FW_ASSERT(
766  portNum < this->getNum_bufferSendOutDrain_OutputPorts(),
767  static_cast<FwAssertArgType>(portNum)
768  );
769 
770  this->m_bufferSendOutDrain_OutputPort[portNum].registerSerialPort(port);
771  }
772 
775  NATIVE_INT_TYPE portNum,
776  Fw::InputSerializePort* port
777  )
778  {
779  FW_ASSERT(
780  portNum < this->getNum_bufferSendOutReturn_OutputPorts(),
781  static_cast<FwAssertArgType>(portNum)
782  );
783 
784  this->m_bufferSendOutReturn_OutputPort[portNum].registerSerialPort(port);
785  }
786 
789  NATIVE_INT_TYPE portNum,
790  Fw::InputSerializePort* port
791  )
792  {
793  FW_ASSERT(
794  portNum < this->getNum_pingOut_OutputPorts(),
795  static_cast<FwAssertArgType>(portNum)
796  );
797 
798  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
799  }
800 
801 #endif
802 
803  // ----------------------------------------------------------------------
804  // Command registration
805  // ----------------------------------------------------------------------
806 
808  regCommands()
809  {
810  FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
811 
812  this->m_cmdRegOut_OutputPort[0].invoke(
813  this->getIdBase() + OPCODE_BA_SETMODE
814  );
815 
816  this->m_cmdRegOut_OutputPort[0].invoke(
818  );
819  }
820 
821  // ----------------------------------------------------------------------
822  // Component construction and destruction
823  // ----------------------------------------------------------------------
824 
826  BufferAccumulatorComponentBase(const char* compName) :
827  Fw::ActiveComponentBase(compName)
828  {
829 
830  }
831 
834  {
835 
836  }
837 
838  // ----------------------------------------------------------------------
839  // Getters for numbers of special input ports
840  // ----------------------------------------------------------------------
841 
844  {
845  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
846  }
847 
848  // ----------------------------------------------------------------------
849  // Getters for numbers of typed input ports
850  // ----------------------------------------------------------------------
851 
854  {
855  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendInFill_InputPort));
856  }
857 
860  {
861  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendInReturn_InputPort));
862  }
863 
866  {
867  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
868  }
869 
870  // ----------------------------------------------------------------------
871  // Getters for numbers of special output ports
872  // ----------------------------------------------------------------------
873 
876  {
877  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
878  }
879 
882  {
883  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
884  }
885 
888  {
889  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
890  }
891 
892 #if FW_ENABLE_TEXT_LOGGING == 1
893 
894  NATIVE_INT_TYPE BufferAccumulatorComponentBase ::
895  getNum_eventOutText_OutputPorts() const
896  {
897  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOutText_OutputPort));
898  }
899 
900 #endif
901 
904  {
905  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
906  }
907 
910  {
911  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
912  }
913 
914  // ----------------------------------------------------------------------
915  // Getters for numbers of typed output ports
916  // ----------------------------------------------------------------------
917 
920  {
921  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOutDrain_OutputPort));
922  }
923 
926  {
927  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOutReturn_OutputPort));
928  }
929 
932  {
933  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
934  }
935 
936  // ----------------------------------------------------------------------
937  // Connection status queries for special output ports
938  // ----------------------------------------------------------------------
939 
942  {
943  FW_ASSERT(
944  portNum < this->getNum_cmdRegOut_OutputPorts(),
945  static_cast<FwAssertArgType>(portNum)
946  );
947 
948  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
949  }
950 
953  {
954  FW_ASSERT(
955  portNum < this->getNum_cmdResponseOut_OutputPorts(),
956  static_cast<FwAssertArgType>(portNum)
957  );
958 
959  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
960  }
961 
964  {
965  FW_ASSERT(
966  portNum < this->getNum_eventOut_OutputPorts(),
967  static_cast<FwAssertArgType>(portNum)
968  );
969 
970  return this->m_eventOut_OutputPort[portNum].isConnected();
971  }
972 
973 #if FW_ENABLE_TEXT_LOGGING == 1
974 
975  bool BufferAccumulatorComponentBase ::
976  isConnected_eventOutText_OutputPort(NATIVE_INT_TYPE portNum)
977  {
978  FW_ASSERT(
979  portNum < this->getNum_eventOutText_OutputPorts(),
980  static_cast<FwAssertArgType>(portNum)
981  );
982 
983  return this->m_eventOutText_OutputPort[portNum].isConnected();
984  }
985 
986 #endif
987 
990  {
991  FW_ASSERT(
992  portNum < this->getNum_timeCaller_OutputPorts(),
993  static_cast<FwAssertArgType>(portNum)
994  );
995 
996  return this->m_timeCaller_OutputPort[portNum].isConnected();
997  }
998 
1001  {
1002  FW_ASSERT(
1003  portNum < this->getNum_tlmOut_OutputPorts(),
1004  static_cast<FwAssertArgType>(portNum)
1005  );
1006 
1007  return this->m_tlmOut_OutputPort[portNum].isConnected();
1008  }
1009 
1010  // ----------------------------------------------------------------------
1011  // Connection status queries for typed output ports
1012  // ----------------------------------------------------------------------
1013 
1016  {
1017  FW_ASSERT(
1018  portNum < this->getNum_bufferSendOutDrain_OutputPorts(),
1019  static_cast<FwAssertArgType>(portNum)
1020  );
1021 
1022  return this->m_bufferSendOutDrain_OutputPort[portNum].isConnected();
1023  }
1024 
1027  {
1028  FW_ASSERT(
1029  portNum < this->getNum_bufferSendOutReturn_OutputPorts(),
1030  static_cast<FwAssertArgType>(portNum)
1031  );
1032 
1033  return this->m_bufferSendOutReturn_OutputPort[portNum].isConnected();
1034  }
1035 
1038  {
1039  FW_ASSERT(
1040  portNum < this->getNum_pingOut_OutputPorts(),
1041  static_cast<FwAssertArgType>(portNum)
1042  );
1043 
1044  return this->m_pingOut_OutputPort[portNum].isConnected();
1045  }
1046 
1047  // ----------------------------------------------------------------------
1048  // Port handler base-class functions for typed input ports
1049  //
1050  // Call these functions directly to bypass the corresponding ports
1051  // ----------------------------------------------------------------------
1052 
1055  NATIVE_INT_TYPE portNum,
1056  Fw::Buffer& fwBuffer
1057  )
1058  {
1059  // Make sure port number is valid
1060  FW_ASSERT(
1061  portNum < this->getNum_bufferSendInFill_InputPorts(),
1062  static_cast<FwAssertArgType>(portNum)
1063  );
1064 
1065  // Call pre-message hook
1067  portNum,
1068  fwBuffer
1069  );
1070  ComponentIpcSerializableBuffer msg;
1072 
1073  // Serialize message ID
1074  _status = msg.serialize(
1075  static_cast<NATIVE_INT_TYPE>(BUFFERSENDINFILL_BUFFERSEND)
1076  );
1077  FW_ASSERT(
1078  _status == Fw::FW_SERIALIZE_OK,
1079  static_cast<FwAssertArgType>(_status)
1080  );
1081 
1082  // Serialize port number
1083  _status = msg.serialize(portNum);
1084  FW_ASSERT(
1085  _status == Fw::FW_SERIALIZE_OK,
1086  static_cast<FwAssertArgType>(_status)
1087  );
1088 
1089  // Serialize argument fwBuffer
1090  _status = msg.serialize(fwBuffer);
1091  FW_ASSERT(
1092  _status == Fw::FW_SERIALIZE_OK,
1093  static_cast<FwAssertArgType>(_status)
1094  );
1095 
1096  // Send message
1098  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1099 
1100  FW_ASSERT(
1101  qStatus == Os::Queue::QUEUE_OK,
1102  static_cast<FwAssertArgType>(qStatus)
1103  );
1104  }
1105 
1108  NATIVE_INT_TYPE portNum,
1109  Fw::Buffer& fwBuffer
1110  )
1111  {
1112  // Make sure port number is valid
1113  FW_ASSERT(
1114  portNum < this->getNum_bufferSendInReturn_InputPorts(),
1115  static_cast<FwAssertArgType>(portNum)
1116  );
1117 
1118  // Call pre-message hook
1120  portNum,
1121  fwBuffer
1122  );
1123  ComponentIpcSerializableBuffer msg;
1125 
1126  // Serialize message ID
1127  _status = msg.serialize(
1128  static_cast<NATIVE_INT_TYPE>(BUFFERSENDINRETURN_BUFFERSEND)
1129  );
1130  FW_ASSERT(
1131  _status == Fw::FW_SERIALIZE_OK,
1132  static_cast<FwAssertArgType>(_status)
1133  );
1134 
1135  // Serialize port number
1136  _status = msg.serialize(portNum);
1137  FW_ASSERT(
1138  _status == Fw::FW_SERIALIZE_OK,
1139  static_cast<FwAssertArgType>(_status)
1140  );
1141 
1142  // Serialize argument fwBuffer
1143  _status = msg.serialize(fwBuffer);
1144  FW_ASSERT(
1145  _status == Fw::FW_SERIALIZE_OK,
1146  static_cast<FwAssertArgType>(_status)
1147  );
1148 
1149  // Send message
1151  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1152 
1153  FW_ASSERT(
1154  qStatus == Os::Queue::QUEUE_OK,
1155  static_cast<FwAssertArgType>(qStatus)
1156  );
1157  }
1158 
1161  NATIVE_INT_TYPE portNum,
1162  U32 key
1163  )
1164  {
1165  // Make sure port number is valid
1166  FW_ASSERT(
1167  portNum < this->getNum_pingIn_InputPorts(),
1168  static_cast<FwAssertArgType>(portNum)
1169  );
1170 
1171  // Call pre-message hook
1173  portNum,
1174  key
1175  );
1176  ComponentIpcSerializableBuffer msg;
1178 
1179  // Serialize message ID
1180  _status = msg.serialize(
1181  static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
1182  );
1183  FW_ASSERT(
1184  _status == Fw::FW_SERIALIZE_OK,
1185  static_cast<FwAssertArgType>(_status)
1186  );
1187 
1188  // Serialize port number
1189  _status = msg.serialize(portNum);
1190  FW_ASSERT(
1191  _status == Fw::FW_SERIALIZE_OK,
1192  static_cast<FwAssertArgType>(_status)
1193  );
1194 
1195  // Serialize argument key
1196  _status = msg.serialize(key);
1197  FW_ASSERT(
1198  _status == Fw::FW_SERIALIZE_OK,
1199  static_cast<FwAssertArgType>(_status)
1200  );
1201 
1202  // Send message
1204  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1205 
1206  FW_ASSERT(
1207  qStatus == Os::Queue::QUEUE_OK,
1208  static_cast<FwAssertArgType>(qStatus)
1209  );
1210  }
1211 
1212  // ----------------------------------------------------------------------
1213  // Pre-message hooks for typed async input ports
1214  //
1215  // Each of these functions is invoked just before processing a message
1216  // on the corresponding port. By default, they do nothing. You can
1217  // override them to provide specific pre-message behavior.
1218  // ----------------------------------------------------------------------
1219 
1222  NATIVE_INT_TYPE portNum,
1223  Fw::Buffer& fwBuffer
1224  )
1225  {
1226  // Default: no-op
1227  }
1228 
1231  NATIVE_INT_TYPE portNum,
1232  Fw::Buffer& fwBuffer
1233  )
1234  {
1235  // Default: no-op
1236  }
1237 
1240  NATIVE_INT_TYPE portNum,
1241  U32 key
1242  )
1243  {
1244  // Default: no-op
1245  }
1246 
1247  // ----------------------------------------------------------------------
1248  // Invocation functions for typed output ports
1249  // ----------------------------------------------------------------------
1250 
1253  NATIVE_INT_TYPE portNum,
1254  Fw::Buffer& fwBuffer
1255  )
1256  {
1257  FW_ASSERT(
1258  portNum < this->getNum_bufferSendOutDrain_OutputPorts(),
1259  static_cast<FwAssertArgType>(portNum)
1260  );
1261  this->m_bufferSendOutDrain_OutputPort[portNum].invoke(
1262  fwBuffer
1263  );
1264  }
1265 
1268  NATIVE_INT_TYPE portNum,
1269  Fw::Buffer& fwBuffer
1270  )
1271  {
1272  FW_ASSERT(
1273  portNum < this->getNum_bufferSendOutReturn_OutputPorts(),
1274  static_cast<FwAssertArgType>(portNum)
1275  );
1276  this->m_bufferSendOutReturn_OutputPort[portNum].invoke(
1277  fwBuffer
1278  );
1279  }
1280 
1282  pingOut_out(
1283  NATIVE_INT_TYPE portNum,
1284  U32 key
1285  )
1286  {
1287  FW_ASSERT(
1288  portNum < this->getNum_pingOut_OutputPorts(),
1289  static_cast<FwAssertArgType>(portNum)
1290  );
1291  this->m_pingOut_OutputPort[portNum].invoke(
1292  key
1293  );
1294  }
1295 
1296  // ----------------------------------------------------------------------
1297  // Command response
1298  // ----------------------------------------------------------------------
1299 
1302  FwOpcodeType opCode,
1303  U32 cmdSeq,
1304  Fw::CmdResponse response
1305  )
1306  {
1307  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1308  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1309  }
1310 
1311  // ----------------------------------------------------------------------
1312  // Command handler base-class functions
1313  //
1314  // Call these functions directly to bypass the command input port
1315  // ----------------------------------------------------------------------
1316 
1319  FwOpcodeType opCode,
1320  U32 cmdSeq,
1321  Fw::CmdArgBuffer& args
1322  )
1323  {
1324  // Call pre-message hook
1325  this->BA_SetMode_preMsgHook(opCode,cmdSeq);
1326 
1327  // Defer deserializing arguments to the message dispatcher
1328  // to avoid deserializing and reserializing just for IPC
1329  ComponentIpcSerializableBuffer msg;
1331 
1332  // Serialize for IPC
1333  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_BA_SETMODE));
1334  FW_ASSERT (
1335  _status == Fw::FW_SERIALIZE_OK,
1336  static_cast<FwAssertArgType>(_status)
1337  );
1338 
1339  // Fake port number to make message dequeue work
1340  NATIVE_INT_TYPE port = 0;
1341 
1342  _status = msg.serialize(port);
1343  FW_ASSERT (
1344  _status == Fw::FW_SERIALIZE_OK,
1345  static_cast<FwAssertArgType>(_status)
1346  );
1347 
1348  _status = msg.serialize(opCode);
1349  FW_ASSERT (
1350  _status == Fw::FW_SERIALIZE_OK,
1351  static_cast<FwAssertArgType>(_status)
1352  );
1353 
1354  _status = msg.serialize(cmdSeq);
1355  FW_ASSERT (
1356  _status == Fw::FW_SERIALIZE_OK,
1357  static_cast<FwAssertArgType>(_status)
1358  );
1359 
1360  _status = msg.serialize(args);
1361  FW_ASSERT (
1362  _status == Fw::FW_SERIALIZE_OK,
1363  static_cast<FwAssertArgType>(_status)
1364  );
1365 
1366  // Send message
1368  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1369 
1370  FW_ASSERT(
1371  qStatus == Os::Queue::QUEUE_OK,
1372  static_cast<FwAssertArgType>(qStatus)
1373  );
1374  }
1375 
1378  FwOpcodeType opCode,
1379  U32 cmdSeq,
1380  Fw::CmdArgBuffer& args
1381  )
1382  {
1383  // Call pre-message hook
1384  this->BA_DrainBuffers_preMsgHook(opCode,cmdSeq);
1385 
1386  // Defer deserializing arguments to the message dispatcher
1387  // to avoid deserializing and reserializing just for IPC
1388  ComponentIpcSerializableBuffer msg;
1390 
1391  // Serialize for IPC
1392  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_BA_DRAINBUFFERS));
1393  FW_ASSERT (
1394  _status == Fw::FW_SERIALIZE_OK,
1395  static_cast<FwAssertArgType>(_status)
1396  );
1397 
1398  // Fake port number to make message dequeue work
1399  NATIVE_INT_TYPE port = 0;
1400 
1401  _status = msg.serialize(port);
1402  FW_ASSERT (
1403  _status == Fw::FW_SERIALIZE_OK,
1404  static_cast<FwAssertArgType>(_status)
1405  );
1406 
1407  _status = msg.serialize(opCode);
1408  FW_ASSERT (
1409  _status == Fw::FW_SERIALIZE_OK,
1410  static_cast<FwAssertArgType>(_status)
1411  );
1412 
1413  _status = msg.serialize(cmdSeq);
1414  FW_ASSERT (
1415  _status == Fw::FW_SERIALIZE_OK,
1416  static_cast<FwAssertArgType>(_status)
1417  );
1418 
1419  _status = msg.serialize(args);
1420  FW_ASSERT (
1421  _status == Fw::FW_SERIALIZE_OK,
1422  static_cast<FwAssertArgType>(_status)
1423  );
1424 
1425  // Send message
1427  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1428 
1429  FW_ASSERT(
1430  qStatus == Os::Queue::QUEUE_OK,
1431  static_cast<FwAssertArgType>(qStatus)
1432  );
1433  }
1434 
1435  // ----------------------------------------------------------------------
1436  // Pre-message hooks for async commands
1437  //
1438  // Each of these functions is invoked just before processing the
1439  // corresponding command. By default they do nothing. You can
1440  // override them to provide specific pre-command behavior.
1441  // ----------------------------------------------------------------------
1442 
1445  FwOpcodeType opCode,
1446  U32 cmdSeq
1447  )
1448  {
1449  // Defaults to no-op; can be overridden
1450  (void) opCode;
1451  (void) cmdSeq;
1452  }
1453 
1456  FwOpcodeType opCode,
1457  U32 cmdSeq
1458  )
1459  {
1460  // Defaults to no-op; can be overridden
1461  (void) opCode;
1462  (void) cmdSeq;
1463  }
1464 
1465  // ----------------------------------------------------------------------
1466  // Event logging functions
1467  // ----------------------------------------------------------------------
1468 
1471  {
1472  // Get the time
1473  Fw::Time _logTime;
1474  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1475  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1476  }
1477 
1478  FwEventIdType _id = static_cast<FwEventIdType>(0);
1479 
1480  _id = this->getIdBase() + EVENTID_BA_BUFFERACCEPTED;
1481 
1482  // Emit the event on the log port
1483  if (this->m_eventOut_OutputPort[0].isConnected()) {
1484  Fw::LogBuffer _logBuff;
1485 
1486 #if FW_AMPCS_COMPATIBLE
1488  // Serialize the number of arguments
1489  _status = _logBuff.serialize(static_cast<U8>(0));
1490  FW_ASSERT(
1491  _status == Fw::FW_SERIALIZE_OK,
1492  static_cast<FwAssertArgType>(_status)
1493  );
1494 #endif
1495 
1496  this->m_eventOut_OutputPort[0].invoke(
1497  _id,
1498  _logTime,
1500  _logBuff
1501  );
1502  }
1503 
1504  // Emit the event on the text log port
1505 #if FW_ENABLE_TEXT_LOGGING
1506  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1507 #if FW_OBJECT_NAMES == 1
1508  const char* _formatString =
1509  "(%s) %s: Buffer accepted";
1510 #else
1511  const char* _formatString =
1512  "%s: Buffer accepted";
1513 #endif
1514 
1515  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1516 
1517  (void) snprintf(
1518  _textBuffer,
1520  _formatString,
1521 #if FW_OBJECT_NAMES == 1
1522  this->m_objName,
1523 #endif
1524  "BA_BufferAccepted "
1525  );
1526 
1527  // Null terminate
1528  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1529  Fw::TextLogString _logString = _textBuffer;
1530  this->m_eventOutText_OutputPort[0].invoke(
1531  _id,
1532  _logTime,
1534  _logString
1535  );
1536  }
1537 #endif
1538  }
1539 
1542  {
1543  // Get the time
1544  Fw::Time _logTime;
1545  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1546  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1547  }
1548 
1549  FwEventIdType _id = static_cast<FwEventIdType>(0);
1550 
1551  _id = this->getIdBase() + EVENTID_BA_QUEUEFULL;
1552 
1553  // Emit the event on the log port
1554  if (this->m_eventOut_OutputPort[0].isConnected()) {
1555  Fw::LogBuffer _logBuff;
1556 
1557 #if FW_AMPCS_COMPATIBLE
1559  // Serialize the number of arguments
1560  _status = _logBuff.serialize(static_cast<U8>(0));
1561  FW_ASSERT(
1562  _status == Fw::FW_SERIALIZE_OK,
1563  static_cast<FwAssertArgType>(_status)
1564  );
1565 #endif
1566 
1567  this->m_eventOut_OutputPort[0].invoke(
1568  _id,
1569  _logTime,
1571  _logBuff
1572  );
1573  }
1574 
1575  // Emit the event on the text log port
1576 #if FW_ENABLE_TEXT_LOGGING
1577  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1578 #if FW_OBJECT_NAMES == 1
1579  const char* _formatString =
1580  "(%s) %s: Queue full";
1581 #else
1582  const char* _formatString =
1583  "%s: Queue full";
1584 #endif
1585 
1586  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1587 
1588  (void) snprintf(
1589  _textBuffer,
1591  _formatString,
1592 #if FW_OBJECT_NAMES == 1
1593  this->m_objName,
1594 #endif
1595  "BA_QueueFull "
1596  );
1597 
1598  // Null terminate
1599  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1600  Fw::TextLogString _logString = _textBuffer;
1601  this->m_eventOutText_OutputPort[0].invoke(
1602  _id,
1603  _logTime,
1605  _logString
1606  );
1607  }
1608 #endif
1609  }
1610 
1613  U32 numDrained,
1614  U32 numToDrain
1615  )
1616  {
1617  // Get the time
1618  Fw::Time _logTime;
1619  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1620  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1621  }
1622 
1623  FwEventIdType _id = static_cast<FwEventIdType>(0);
1624 
1625  _id = this->getIdBase() + EVENTID_BA_STILLDRAINING;
1626 
1627  // Emit the event on the log port
1628  if (this->m_eventOut_OutputPort[0].isConnected()) {
1629  Fw::LogBuffer _logBuff;
1631 
1632 #if FW_AMPCS_COMPATIBLE
1633  // Serialize the number of arguments
1634  _status = _logBuff.serialize(static_cast<U8>(2));
1635  FW_ASSERT(
1636  _status == Fw::FW_SERIALIZE_OK,
1637  static_cast<FwAssertArgType>(_status)
1638  );
1639 #endif
1640 
1641 #if FW_AMPCS_COMPATIBLE
1642  // Serialize the argument size
1643  _status = _logBuff.serialize(
1644  static_cast<U8>(sizeof(U32))
1645  );
1646  FW_ASSERT(
1647  _status == Fw::FW_SERIALIZE_OK,
1648  static_cast<FwAssertArgType>(_status)
1649  );
1650 #endif
1651  _status = _logBuff.serialize(numDrained);
1652  FW_ASSERT(
1653  _status == Fw::FW_SERIALIZE_OK,
1654  static_cast<FwAssertArgType>(_status)
1655  );
1656 
1657 #if FW_AMPCS_COMPATIBLE
1658  // Serialize the argument size
1659  _status = _logBuff.serialize(
1660  static_cast<U8>(sizeof(U32))
1661  );
1662  FW_ASSERT(
1663  _status == Fw::FW_SERIALIZE_OK,
1664  static_cast<FwAssertArgType>(_status)
1665  );
1666 #endif
1667  _status = _logBuff.serialize(numToDrain);
1668  FW_ASSERT(
1669  _status == Fw::FW_SERIALIZE_OK,
1670  static_cast<FwAssertArgType>(_status)
1671  );
1672 
1673  this->m_eventOut_OutputPort[0].invoke(
1674  _id,
1675  _logTime,
1677  _logBuff
1678  );
1679  }
1680 
1681  // Emit the event on the text log port
1682 #if FW_ENABLE_TEXT_LOGGING
1683  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1684 #if FW_OBJECT_NAMES == 1
1685  const char* _formatString =
1686  "(%s) %s: Still draining %" PRIu32 " of %" PRIu32 "";
1687 #else
1688  const char* _formatString =
1689  "%s: Still draining %" PRIu32 " of %" PRIu32 "";
1690 #endif
1691 
1692  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1693 
1694  (void) snprintf(
1695  _textBuffer,
1697  _formatString,
1698 #if FW_OBJECT_NAMES == 1
1699  this->m_objName,
1700 #endif
1701  "BA_StillDraining ",
1702  numDrained,
1703  numToDrain
1704  );
1705 
1706  // Null terminate
1707  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1708  Fw::TextLogString _logString = _textBuffer;
1709  this->m_eventOutText_OutputPort[0].invoke(
1710  _id,
1711  _logTime,
1713  _logString
1714  );
1715  }
1716 #endif
1717  }
1718 
1721  {
1722  // Get the time
1723  Fw::Time _logTime;
1724  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1725  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1726  }
1727 
1728  FwEventIdType _id = static_cast<FwEventIdType>(0);
1729 
1730  _id = this->getIdBase() + EVENTID_BA_ALREADYDRAINING;
1731 
1732  // Emit the event on the log port
1733  if (this->m_eventOut_OutputPort[0].isConnected()) {
1734  Fw::LogBuffer _logBuff;
1735 
1736 #if FW_AMPCS_COMPATIBLE
1738  // Serialize the number of arguments
1739  _status = _logBuff.serialize(static_cast<U8>(0));
1740  FW_ASSERT(
1741  _status == Fw::FW_SERIALIZE_OK,
1742  static_cast<FwAssertArgType>(_status)
1743  );
1744 #endif
1745 
1746  this->m_eventOut_OutputPort[0].invoke(
1747  _id,
1748  _logTime,
1750  _logBuff
1751  );
1752  }
1753 
1754  // Emit the event on the text log port
1755 #if FW_ENABLE_TEXT_LOGGING
1756  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1757 #if FW_OBJECT_NAMES == 1
1758  const char* _formatString =
1759  "(%s) %s: Already in DRAIN mode";
1760 #else
1761  const char* _formatString =
1762  "%s: Already in DRAIN mode";
1763 #endif
1764 
1765  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1766 
1767  (void) snprintf(
1768  _textBuffer,
1770  _formatString,
1771 #if FW_OBJECT_NAMES == 1
1772  this->m_objName,
1773 #endif
1774  "BA_AlreadyDraining "
1775  );
1776 
1777  // Null terminate
1778  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1779  Fw::TextLogString _logString = _textBuffer;
1780  this->m_eventOutText_OutputPort[0].invoke(
1781  _id,
1782  _logTime,
1784  _logString
1785  );
1786  }
1787 #endif
1788  }
1789 
1792  U32 numDrained,
1793  U32 numToDrain
1794  )
1795  {
1796  // Get the time
1797  Fw::Time _logTime;
1798  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1799  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1800  }
1801 
1802  FwEventIdType _id = static_cast<FwEventIdType>(0);
1803 
1804  _id = this->getIdBase() + EVENTID_BA_DRAINSTALLED;
1805 
1806  // Emit the event on the log port
1807  if (this->m_eventOut_OutputPort[0].isConnected()) {
1808  Fw::LogBuffer _logBuff;
1810 
1811 #if FW_AMPCS_COMPATIBLE
1812  // Serialize the number of arguments
1813  _status = _logBuff.serialize(static_cast<U8>(2));
1814  FW_ASSERT(
1815  _status == Fw::FW_SERIALIZE_OK,
1816  static_cast<FwAssertArgType>(_status)
1817  );
1818 #endif
1819 
1820 #if FW_AMPCS_COMPATIBLE
1821  // Serialize the argument size
1822  _status = _logBuff.serialize(
1823  static_cast<U8>(sizeof(U32))
1824  );
1825  FW_ASSERT(
1826  _status == Fw::FW_SERIALIZE_OK,
1827  static_cast<FwAssertArgType>(_status)
1828  );
1829 #endif
1830  _status = _logBuff.serialize(numDrained);
1831  FW_ASSERT(
1832  _status == Fw::FW_SERIALIZE_OK,
1833  static_cast<FwAssertArgType>(_status)
1834  );
1835 
1836 #if FW_AMPCS_COMPATIBLE
1837  // Serialize the argument size
1838  _status = _logBuff.serialize(
1839  static_cast<U8>(sizeof(U32))
1840  );
1841  FW_ASSERT(
1842  _status == Fw::FW_SERIALIZE_OK,
1843  static_cast<FwAssertArgType>(_status)
1844  );
1845 #endif
1846  _status = _logBuff.serialize(numToDrain);
1847  FW_ASSERT(
1848  _status == Fw::FW_SERIALIZE_OK,
1849  static_cast<FwAssertArgType>(_status)
1850  );
1851 
1852  this->m_eventOut_OutputPort[0].invoke(
1853  _id,
1854  _logTime,
1856  _logBuff
1857  );
1858  }
1859 
1860  // Emit the event on the text log port
1861 #if FW_ENABLE_TEXT_LOGGING
1862  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1863 #if FW_OBJECT_NAMES == 1
1864  const char* _formatString =
1865  "(%s) %s: Drain stalling - only drained %" PRIu32 " of %" PRIu32 "";
1866 #else
1867  const char* _formatString =
1868  "%s: Drain stalling - only drained %" PRIu32 " of %" PRIu32 "";
1869 #endif
1870 
1871  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1872 
1873  (void) snprintf(
1874  _textBuffer,
1876  _formatString,
1877 #if FW_OBJECT_NAMES == 1
1878  this->m_objName,
1879 #endif
1880  "BA_DrainStalled ",
1881  numDrained,
1882  numToDrain
1883  );
1884 
1885  // Null terminate
1886  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1887  Fw::TextLogString _logString = _textBuffer;
1888  this->m_eventOutText_OutputPort[0].invoke(
1889  _id,
1890  _logTime,
1892  _logString
1893  );
1894  }
1895 #endif
1896  }
1897 
1900  {
1901  // Get the time
1902  Fw::Time _logTime;
1903  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1904  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1905  }
1906 
1907  FwEventIdType _id = static_cast<FwEventIdType>(0);
1908 
1909  _id = this->getIdBase() + EVENTID_BA_PARTIALDRAINDONE;
1910 
1911  // Emit the event on the log port
1912  if (this->m_eventOut_OutputPort[0].isConnected()) {
1913  Fw::LogBuffer _logBuff;
1915 
1916 #if FW_AMPCS_COMPATIBLE
1917  // Serialize the number of arguments
1918  _status = _logBuff.serialize(static_cast<U8>(1));
1919  FW_ASSERT(
1920  _status == Fw::FW_SERIALIZE_OK,
1921  static_cast<FwAssertArgType>(_status)
1922  );
1923 #endif
1924 
1925 #if FW_AMPCS_COMPATIBLE
1926  // Serialize the argument size
1927  _status = _logBuff.serialize(
1928  static_cast<U8>(sizeof(U32))
1929  );
1930  FW_ASSERT(
1931  _status == Fw::FW_SERIALIZE_OK,
1932  static_cast<FwAssertArgType>(_status)
1933  );
1934 #endif
1935  _status = _logBuff.serialize(numDrained);
1936  FW_ASSERT(
1937  _status == Fw::FW_SERIALIZE_OK,
1938  static_cast<FwAssertArgType>(_status)
1939  );
1940 
1941  this->m_eventOut_OutputPort[0].invoke(
1942  _id,
1943  _logTime,
1945  _logBuff
1946  );
1947  }
1948 
1949  // Emit the event on the text log port
1950 #if FW_ENABLE_TEXT_LOGGING
1951  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1952 #if FW_OBJECT_NAMES == 1
1953  const char* _formatString =
1954  "(%s) %s: Partial drain of %" PRIu32 " finished";
1955 #else
1956  const char* _formatString =
1957  "%s: Partial drain of %" PRIu32 " finished";
1958 #endif
1959 
1960  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1961 
1962  (void) snprintf(
1963  _textBuffer,
1965  _formatString,
1966 #if FW_OBJECT_NAMES == 1
1967  this->m_objName,
1968 #endif
1969  "BA_PartialDrainDone ",
1970  numDrained
1971  );
1972 
1973  // Null terminate
1974  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1975  Fw::TextLogString _logString = _textBuffer;
1976  this->m_eventOutText_OutputPort[0].invoke(
1977  _id,
1978  _logTime,
1980  _logString
1981  );
1982  }
1983 #endif
1984  }
1985 
1988  U32 numWillDrain,
1989  U32 numReqDrain
1990  )
1991  {
1992  // Get the time
1993  Fw::Time _logTime;
1994  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1995  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1996  }
1997 
1998  FwEventIdType _id = static_cast<FwEventIdType>(0);
1999 
2000  _id = this->getIdBase() + EVENTID_BA_NONBLOCKDRAIN;
2001 
2002  // Emit the event on the log port
2003  if (this->m_eventOut_OutputPort[0].isConnected()) {
2004  Fw::LogBuffer _logBuff;
2006 
2007 #if FW_AMPCS_COMPATIBLE
2008  // Serialize the number of arguments
2009  _status = _logBuff.serialize(static_cast<U8>(2));
2010  FW_ASSERT(
2011  _status == Fw::FW_SERIALIZE_OK,
2012  static_cast<FwAssertArgType>(_status)
2013  );
2014 #endif
2015 
2016 #if FW_AMPCS_COMPATIBLE
2017  // Serialize the argument size
2018  _status = _logBuff.serialize(
2019  static_cast<U8>(sizeof(U32))
2020  );
2021  FW_ASSERT(
2022  _status == Fw::FW_SERIALIZE_OK,
2023  static_cast<FwAssertArgType>(_status)
2024  );
2025 #endif
2026  _status = _logBuff.serialize(numWillDrain);
2027  FW_ASSERT(
2028  _status == Fw::FW_SERIALIZE_OK,
2029  static_cast<FwAssertArgType>(_status)
2030  );
2031 
2032 #if FW_AMPCS_COMPATIBLE
2033  // Serialize the argument size
2034  _status = _logBuff.serialize(
2035  static_cast<U8>(sizeof(U32))
2036  );
2037  FW_ASSERT(
2038  _status == Fw::FW_SERIALIZE_OK,
2039  static_cast<FwAssertArgType>(_status)
2040  );
2041 #endif
2042  _status = _logBuff.serialize(numReqDrain);
2043  FW_ASSERT(
2044  _status == Fw::FW_SERIALIZE_OK,
2045  static_cast<FwAssertArgType>(_status)
2046  );
2047 
2048  this->m_eventOut_OutputPort[0].invoke(
2049  _id,
2050  _logTime,
2052  _logBuff
2053  );
2054  }
2055 
2056  // Emit the event on the text log port
2057 #if FW_ENABLE_TEXT_LOGGING
2058  if (this->m_eventOutText_OutputPort[0].isConnected()) {
2059 #if FW_OBJECT_NAMES == 1
2060  const char* _formatString =
2061  "(%s) %s: Only have %" PRIu32 "; requested drain of %" PRIu32 "";
2062 #else
2063  const char* _formatString =
2064  "%s: Only have %" PRIu32 "; requested drain of %" PRIu32 "";
2065 #endif
2066 
2067  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2068 
2069  (void) snprintf(
2070  _textBuffer,
2072  _formatString,
2073 #if FW_OBJECT_NAMES == 1
2074  this->m_objName,
2075 #endif
2076  "BA_NonBlockDrain ",
2077  numWillDrain,
2078  numReqDrain
2079  );
2080 
2081  // Null terminate
2082  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2083  Fw::TextLogString _logString = _textBuffer;
2084  this->m_eventOutText_OutputPort[0].invoke(
2085  _id,
2086  _logTime,
2088  _logString
2089  );
2090  }
2091 #endif
2092  }
2093 
2094  // ----------------------------------------------------------------------
2095  // Telemetry write functions
2096  // ----------------------------------------------------------------------
2097 
2100  U32 arg,
2101  Fw::Time _tlmTime
2102  )
2103  {
2104  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2105  if (
2106  this->m_timeCaller_OutputPort[0].isConnected() &&
2107  (_tlmTime == Fw::ZERO_TIME)
2108  ) {
2109  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2110  }
2111 
2112  Fw::TlmBuffer _tlmBuff;
2113  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2114  FW_ASSERT(
2115  _stat == Fw::FW_SERIALIZE_OK,
2116  static_cast<FwAssertArgType>(_stat)
2117  );
2118 
2119  FwChanIdType _id;
2120 
2121  _id = this->getIdBase() + CHANNELID_BA_NUMQUEUEDBUFFERS;
2122 
2123  this->m_tlmOut_OutputPort[0].invoke(
2124  _id,
2125  _tlmTime,
2126  _tlmBuff
2127  );
2128  }
2129  }
2130 
2131  // ----------------------------------------------------------------------
2132  // Time
2133  // ----------------------------------------------------------------------
2134 
2136  getTime()
2137  {
2138  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2139  Fw::Time _time;
2140  this->m_timeCaller_OutputPort[0].invoke(_time);
2141  return _time;
2142  }
2143  else {
2144  return Fw::Time(TB_NONE, 0, 0);
2145  }
2146  }
2147 
2148  // ----------------------------------------------------------------------
2149  // Message dispatch functions
2150  // ----------------------------------------------------------------------
2151 
2152  Fw::QueuedComponentBase::MsgDispatchStatus BufferAccumulatorComponentBase ::
2153  doDispatch()
2154  {
2155  ComponentIpcSerializableBuffer msg;
2156  NATIVE_INT_TYPE priority = 0;
2157 
2158  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
2159  msg,
2160  priority,
2162  );
2163  FW_ASSERT(
2164  msgStatus == Os::Queue::QUEUE_OK,
2165  static_cast<FwAssertArgType>(msgStatus)
2166  );
2167 
2168  // Reset to beginning of buffer
2169  msg.resetDeser();
2170 
2171  NATIVE_INT_TYPE desMsg = 0;
2172  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2173  FW_ASSERT(
2174  deserStatus == Fw::FW_SERIALIZE_OK,
2175  static_cast<FwAssertArgType>(deserStatus)
2176  );
2177 
2178  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2179 
2180  if (msgType == BUFFERACCUMULATOR_COMPONENT_EXIT) {
2181  return MSG_DISPATCH_EXIT;
2182  }
2183 
2184  NATIVE_INT_TYPE portNum = 0;
2185  deserStatus = msg.deserialize(portNum);
2186  FW_ASSERT(
2187  deserStatus == Fw::FW_SERIALIZE_OK,
2188  static_cast<FwAssertArgType>(deserStatus)
2189  );
2190 
2191  switch (msgType) {
2192  // Handle async input port bufferSendInFill
2193  case BUFFERSENDINFILL_BUFFERSEND: {
2194  // Deserialize argument fwBuffer
2195  Fw::Buffer fwBuffer;
2196  deserStatus = msg.deserialize(fwBuffer);
2197  FW_ASSERT(
2198  deserStatus == Fw::FW_SERIALIZE_OK,
2199  static_cast<FwAssertArgType>(deserStatus)
2200  );
2201  // Call handler function
2203  portNum,
2204  fwBuffer
2205  );
2206 
2207  break;
2208  }
2209 
2210  // Handle async input port bufferSendInReturn
2211  case BUFFERSENDINRETURN_BUFFERSEND: {
2212  // Deserialize argument fwBuffer
2213  Fw::Buffer fwBuffer;
2214  deserStatus = msg.deserialize(fwBuffer);
2215  FW_ASSERT(
2216  deserStatus == Fw::FW_SERIALIZE_OK,
2217  static_cast<FwAssertArgType>(deserStatus)
2218  );
2219  // Call handler function
2221  portNum,
2222  fwBuffer
2223  );
2224 
2225  break;
2226  }
2227 
2228  // Handle async input port pingIn
2229  case PINGIN_PING: {
2230  // Deserialize argument key
2231  U32 key;
2232  deserStatus = msg.deserialize(key);
2233  FW_ASSERT(
2234  deserStatus == Fw::FW_SERIALIZE_OK,
2235  static_cast<FwAssertArgType>(deserStatus)
2236  );
2237  // Call handler function
2238  this->pingIn_handler(
2239  portNum,
2240  key
2241  );
2242 
2243  break;
2244  }
2245 
2246  // Handle command BA_SetMode
2247  case CMD_BA_SETMODE: {
2248  // Deserialize opcode
2249  FwOpcodeType opCode = 0;
2250  deserStatus = msg.deserialize(opCode);
2251  FW_ASSERT (
2252  deserStatus == Fw::FW_SERIALIZE_OK,
2253  static_cast<FwAssertArgType>(deserStatus)
2254  );
2255 
2256  // Deserialize command sequence
2257  U32 cmdSeq = 0;
2258  deserStatus = msg.deserialize(cmdSeq);
2259  FW_ASSERT (
2260  deserStatus == Fw::FW_SERIALIZE_OK,
2261  static_cast<FwAssertArgType>(deserStatus)
2262  );
2263 
2264  // Deserialize command argument buffer
2265  Fw::CmdArgBuffer args;
2266  deserStatus = msg.deserialize(args);
2267  FW_ASSERT (
2268  deserStatus == Fw::FW_SERIALIZE_OK,
2269  static_cast<FwAssertArgType>(deserStatus)
2270  );
2271 
2272  // Reset buffer
2273  args.resetDeser();
2274 
2275  // Deserialize argument mode
2277  deserStatus = args.deserialize(mode);
2278  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2279  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2280  this->cmdResponse_out(
2281  opCode,
2282  cmdSeq,
2284  );
2285  }
2286  // Don't crash the task if bad arguments were passed from the ground
2287  break;
2288  }
2289 
2290  // Make sure there was no data left over.
2291  // That means the argument buffer size was incorrect.
2292 #if FW_CMD_CHECK_RESIDUAL
2293  if (args.getBuffLeft() != 0) {
2294  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2295  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2296  }
2297  // Don't crash the task if bad arguments were passed from the ground
2298  break;
2299  }
2300 #endif
2301 
2302  // Call handler function
2303  this->BA_SetMode_cmdHandler(
2304  opCode, cmdSeq,
2305  mode
2306  );
2307 
2308  break;
2309  }
2310 
2311  // Handle command BA_DrainBuffers
2312  case CMD_BA_DRAINBUFFERS: {
2313  // Deserialize opcode
2314  FwOpcodeType opCode = 0;
2315  deserStatus = msg.deserialize(opCode);
2316  FW_ASSERT (
2317  deserStatus == Fw::FW_SERIALIZE_OK,
2318  static_cast<FwAssertArgType>(deserStatus)
2319  );
2320 
2321  // Deserialize command sequence
2322  U32 cmdSeq = 0;
2323  deserStatus = msg.deserialize(cmdSeq);
2324  FW_ASSERT (
2325  deserStatus == Fw::FW_SERIALIZE_OK,
2326  static_cast<FwAssertArgType>(deserStatus)
2327  );
2328 
2329  // Deserialize command argument buffer
2330  Fw::CmdArgBuffer args;
2331  deserStatus = msg.deserialize(args);
2332  FW_ASSERT (
2333  deserStatus == Fw::FW_SERIALIZE_OK,
2334  static_cast<FwAssertArgType>(deserStatus)
2335  );
2336 
2337  // Reset buffer
2338  args.resetDeser();
2339 
2340  // Deserialize argument numToDrain
2341  U32 numToDrain;
2342  deserStatus = args.deserialize(numToDrain);
2343  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2344  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2345  this->cmdResponse_out(
2346  opCode,
2347  cmdSeq,
2349  );
2350  }
2351  // Don't crash the task if bad arguments were passed from the ground
2352  break;
2353  }
2354 
2355  // Deserialize argument blockMode
2357  deserStatus = args.deserialize(blockMode);
2358  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2359  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2360  this->cmdResponse_out(
2361  opCode,
2362  cmdSeq,
2364  );
2365  }
2366  // Don't crash the task if bad arguments were passed from the ground
2367  break;
2368  }
2369 
2370  // Make sure there was no data left over.
2371  // That means the argument buffer size was incorrect.
2372 #if FW_CMD_CHECK_RESIDUAL
2373  if (args.getBuffLeft() != 0) {
2374  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2375  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2376  }
2377  // Don't crash the task if bad arguments were passed from the ground
2378  break;
2379  }
2380 #endif
2381 
2382  // Call handler function
2384  opCode, cmdSeq,
2385  numToDrain,
2386  blockMode
2387  );
2388 
2389  break;
2390  }
2391 
2392  default:
2393  return MSG_DISPATCH_ERROR;
2394  }
2395 
2396  return MSG_DISPATCH_OK;
2397  }
2398 
2399  // ----------------------------------------------------------------------
2400  // Calls for messages received on special input ports
2401  // ----------------------------------------------------------------------
2402 
2403  void BufferAccumulatorComponentBase ::
2404  m_p_cmdIn_in(
2405  Fw::PassiveComponentBase* callComp,
2406  NATIVE_INT_TYPE portNum,
2407  FwOpcodeType opCode,
2408  U32 cmdSeq,
2409  Fw::CmdArgBuffer& args
2410  )
2411  {
2412  FW_ASSERT(callComp);
2413  BufferAccumulatorComponentBase* compPtr = static_cast<BufferAccumulatorComponentBase*>(callComp);
2414 
2415  const U32 idBase = callComp->getIdBase();
2416  FW_ASSERT(opCode >= idBase, opCode, idBase);
2417 
2418  // Select base class function based on opcode
2419  switch (opCode - idBase) {
2420  case OPCODE_BA_SETMODE: {
2421  compPtr->BA_SetMode_cmdHandlerBase(
2422  opCode,
2423  cmdSeq,
2424  args
2425  );
2426  break;
2427  }
2428 
2429  case OPCODE_BA_DRAINBUFFERS: {
2430  compPtr->BA_DrainBuffers_cmdHandlerBase(
2431  opCode,
2432  cmdSeq,
2433  args
2434  );
2435  break;
2436  }
2437  }
2438  }
2439 
2440  // ----------------------------------------------------------------------
2441  // Calls for messages received on typed input ports
2442  // ----------------------------------------------------------------------
2443 
2444  void BufferAccumulatorComponentBase ::
2445  m_p_bufferSendInFill_in(
2446  Fw::PassiveComponentBase* callComp,
2447  NATIVE_INT_TYPE portNum,
2448  Fw::Buffer& fwBuffer
2449  )
2450  {
2451  FW_ASSERT(callComp);
2452  BufferAccumulatorComponentBase* compPtr = static_cast<BufferAccumulatorComponentBase*>(callComp);
2453  compPtr->bufferSendInFill_handlerBase(
2454  portNum,
2455  fwBuffer
2456  );
2457  }
2458 
2459  void BufferAccumulatorComponentBase ::
2460  m_p_bufferSendInReturn_in(
2461  Fw::PassiveComponentBase* callComp,
2462  NATIVE_INT_TYPE portNum,
2463  Fw::Buffer& fwBuffer
2464  )
2465  {
2466  FW_ASSERT(callComp);
2467  BufferAccumulatorComponentBase* compPtr = static_cast<BufferAccumulatorComponentBase*>(callComp);
2468  compPtr->bufferSendInReturn_handlerBase(
2469  portNum,
2470  fwBuffer
2471  );
2472  }
2473 
2474  void BufferAccumulatorComponentBase ::
2475  m_p_pingIn_in(
2476  Fw::PassiveComponentBase* callComp,
2477  NATIVE_INT_TYPE portNum,
2478  U32 key
2479  )
2480  {
2481  FW_ASSERT(callComp);
2482  BufferAccumulatorComponentBase* compPtr = static_cast<BufferAccumulatorComponentBase*>(callComp);
2483  compPtr->pingIn_handlerBase(
2484  portNum,
2485  key
2486  );
2487  }
2488 
2489 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
U8 BYTE
byte type
Definition: BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwChanIdType
Definition: FpConfig.h:59
U32 FwEventIdType
Definition: FpConfig.h:62
U32 FwOpcodeType
Definition: FpConfig.h:56
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition: FpConfig.h:299
#define FW_OBJ_NAME_MAX_SIZE
Size of object name (if object names enabled). AC Limits to 80, truncation occurs above 80.
Definition: FpConfig.h:184
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:88
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Definition: Buffer.cpp:134
Enum representing a command response.
@ FORMAT_ERROR
Command failed to deserialize.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ WARNING_LO
A less serious but recoverable event.
void init()
Object initializer.
Definition: ObjBase.cpp:27
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Buffer &fwBuffer)
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
void invoke(FwOpcodeType opCode)
Invoke a port interface.
void init()
Initialization function.
void init()
Initialization function.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke a port interface.
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected()
Definition: PortBase.cpp:41
Os::Queue::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
@ MSG_DISPATCH_OK
Dispatch was normal.
@ MSG_DISPATCH_EXIT
A message was sent requesting an exit of the loop.
@ MSG_DISPATCH_ERROR
Errors dispatching messages.
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Time.hpp:9
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
bool isConnected_timeCaller_OutputPort(NATIVE_INT_TYPE portNum)
bool isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
void log_WARNING_HI_BA_StillDraining(U32 numDrained, U32 numToDrain)
Svc::InputPingPort * get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
BufferAccumulatorComponentBase(const char *compName="")
Construct BufferAccumulatorComponentBase object.
bool isConnected_tlmOut_OutputPort(NATIVE_INT_TYPE portNum)
virtual void bufferSendInFill_preMsgHook(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendInFill.
void pingIn_handlerBase(NATIVE_INT_TYPE portNum, U32 key)
Handler base-class function for input port pingIn.
void bufferSendOutReturn_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutReturn.
void set_tlmOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
virtual void pingIn_handler(NATIVE_INT_TYPE portNum, U32 key)=0
Handler for input port pingIn.
bool isConnected_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum)
Fw::InputCmdPort * get_cmdIn_InputPort(NATIVE_INT_TYPE portNum)
virtual void BA_DrainBuffers_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 numToDrain, Svc::BufferAccumulator_BlockMode blockMode)=0
Fw::InputBufferSendPort * get_bufferSendInFill_InputPort(NATIVE_INT_TYPE portNum)
void bufferSendOutDrain_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutDrain.
Fw::InputBufferSendPort * get_bufferSendInReturn_InputPort(NATIVE_INT_TYPE portNum)
bool isConnected_eventOut_OutputPort(NATIVE_INT_TYPE portNum)
virtual void BA_DrainBuffers_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BA_DrainBuffers.
void set_pingOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
virtual void pingIn_preMsgHook(NATIVE_INT_TYPE portNum, U32 key)
Pre-message hook for async input port pingIn.
virtual void bufferSendInReturn_handler(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendInReturn.
void pingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port pingOut.
void set_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
virtual void BA_SetMode_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::BufferAccumulator_OpState mode)=0
void BA_DrainBuffers_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum)
@ EVENTID_BA_BUFFERACCEPTED
The Buffer Accumulator instance accepted and enqueued a buffer. To avoid uncontrolled sending of even...
@ EVENTID_BA_DRAINSTALLED
Ran out of buffers while executing DrainBuffers command.
@ EVENTID_BA_PARTIALDRAINDONE
Finished DrainBuffers command.
@ EVENTID_BA_QUEUEFULL
The Buffer Accumulator instance received a buffer when its queue was full. To avoid uncontrolled send...
@ EVENTID_BA_STILLDRAINING
Got DrainBuffers command while executing DrainBuffers command.
@ EVENTID_BA_NONBLOCKDRAIN
Not enough buffers to complete requested drain, and NOBLOCK was set; will only drain what we have.
@ EVENTID_BA_ALREADYDRAINING
Got DrainBuffers command while in DRAIN mode.
virtual ~BufferAccumulatorComponentBase()
Destroy BufferAccumulatorComponentBase object.
void set_eventOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
@ CHANNELID_BA_NUMQUEUEDBUFFERS
Channel ID for BA_NumQueuedBuffers.
void bufferSendInFill_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendInFill.
@ OPCODE_BA_DRAINBUFFERS
Drain the commanded number of buffers.
void log_WARNING_LO_BA_NonBlockDrain(U32 numWillDrain, U32 numReqDrain)
void set_bufferSendOutReturn_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOutReturn[portNum].
void log_WARNING_HI_BA_DrainStalled(U32 numDrained, U32 numToDrain)
void set_timeCaller_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
virtual void bufferSendInFill_handler(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendInFill.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void tlmWrite_BA_NumQueuedBuffers(U32 arg, Fw::Time _tlmTime=Fw::Time())
void set_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
void bufferSendInReturn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendInReturn.
bool isConnected_bufferSendOutReturn_OutputPort(NATIVE_INT_TYPE portNum)
virtual void BA_SetMode_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BA_SetMode.
void set_bufferSendOutDrain_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOutDrain[portNum].
NATIVE_INT_TYPE getNum_bufferSendOutReturn_OutputPorts() const
void BA_SetMode_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void regCommands()
Register commands with the Command Dispatcher.
virtual void bufferSendInReturn_preMsgHook(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendInReturn.
bool isConnected_bufferSendOutDrain_OutputPort(NATIVE_INT_TYPE portNum)
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void init()
Initialization function.
Definition: PingPortAc.cpp:56
void invoke(U32 key)
Invoke a port interface.
Definition: PingPortAc.cpp:147
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5