F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
BufferManagerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferManagerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for BufferManager 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  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
22  {
23  // Initialize base class
25 
26 #if !FW_DIRECT_PORT_CALLS
27  // Connect input port bufferGetCallee
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(this->getNum_bufferGetCallee_InputPorts());
31  port++
32  ) {
33  this->m_bufferGetCallee_InputPort[port].init();
34  this->m_bufferGetCallee_InputPort[port].addCallComp(
35  this,
36  m_p_bufferGetCallee_in
37  );
38  this->m_bufferGetCallee_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  Fw::ObjectName portName;
42  portName.format(
43  "%s_bufferGetCallee_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_bufferGetCallee_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect input port bufferSendIn
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_bufferSendIn_InputPorts());
57  port++
58  ) {
59  this->m_bufferSendIn_InputPort[port].init();
60  this->m_bufferSendIn_InputPort[port].addCallComp(
61  this,
62  m_p_bufferSendIn_in
63  );
64  this->m_bufferSendIn_InputPort[port].setPortNum(port);
65 
66 #if FW_OBJECT_NAMES == 1
67  Fw::ObjectName portName;
68  portName.format(
69  "%s_bufferSendIn_InputPort[%" PRI_FwIndexType "]",
70  this->m_objName.toChar(),
71  port
72  );
73  this->m_bufferSendIn_InputPort[port].setObjName(portName.toChar());
74 #endif
75  }
76 #endif
77 
78 #if !FW_DIRECT_PORT_CALLS
79  // Connect input port schedIn
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(this->getNum_schedIn_InputPorts());
83  port++
84  ) {
85  this->m_schedIn_InputPort[port].init();
86  this->m_schedIn_InputPort[port].addCallComp(
87  this,
88  m_p_schedIn_in
89  );
90  this->m_schedIn_InputPort[port].setPortNum(port);
91 
92 #if FW_OBJECT_NAMES == 1
93  Fw::ObjectName portName;
94  portName.format(
95  "%s_schedIn_InputPort[%" PRI_FwIndexType "]",
96  this->m_objName.toChar(),
97  port
98  );
99  this->m_schedIn_InputPort[port].setObjName(portName.toChar());
100 #endif
101  }
102 #endif
103 
104 #if !FW_DIRECT_PORT_CALLS
105  // Connect output port eventOut
106  for (
107  FwIndexType port = 0;
108  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
109  port++
110  ) {
111  this->m_eventOut_OutputPort[port].init();
112 
113 #if FW_OBJECT_NAMES == 1
114  Fw::ObjectName portName;
115  portName.format(
116  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
117  this->m_objName.toChar(),
118  port
119  );
120  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
121 #endif
122  }
123 #endif
124 
125 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
126  // Connect output port textEventOut
127  for (
128  FwIndexType port = 0;
129  port < static_cast<FwIndexType>(this->getNum_textEventOut_OutputPorts());
130  port++
131  ) {
132  this->m_textEventOut_OutputPort[port].init();
133 
134 #if FW_OBJECT_NAMES == 1
135  Fw::ObjectName portName;
136  portName.format(
137  "%s_textEventOut_OutputPort[%" PRI_FwIndexType "]",
138  this->m_objName.toChar(),
139  port
140  );
141  this->m_textEventOut_OutputPort[port].setObjName(portName.toChar());
142 #endif
143  }
144 #endif
145 
146 #if !FW_DIRECT_PORT_CALLS
147  // Connect output port timeCaller
148  for (
149  FwIndexType port = 0;
150  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
151  port++
152  ) {
153  this->m_timeCaller_OutputPort[port].init();
154 
155 #if FW_OBJECT_NAMES == 1
156  Fw::ObjectName portName;
157  portName.format(
158  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
159  this->m_objName.toChar(),
160  port
161  );
162  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
163 #endif
164  }
165 #endif
166 
167 #if !FW_DIRECT_PORT_CALLS
168  // Connect output port tlmOut
169  for (
170  FwIndexType port = 0;
171  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
172  port++
173  ) {
174  this->m_tlmOut_OutputPort[port].init();
175 
176 #if FW_OBJECT_NAMES == 1
177  Fw::ObjectName portName;
178  portName.format(
179  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
180  this->m_objName.toChar(),
181  port
182  );
183  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
184 #endif
185  }
186 #endif
187  }
188 
189 #if !FW_DIRECT_PORT_CALLS
190 
191  // ----------------------------------------------------------------------
192  // Getters for typed input ports
193  // ----------------------------------------------------------------------
194 
197  {
198  FW_ASSERT(
199  (0 <= portNum) && (portNum < this->getNum_bufferGetCallee_InputPorts()),
200  static_cast<FwAssertArgType>(portNum)
201  );
202 
203  return &this->m_bufferGetCallee_InputPort[portNum];
204  }
205 
208  {
209  FW_ASSERT(
210  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
211  static_cast<FwAssertArgType>(portNum)
212  );
213 
214  return &this->m_bufferSendIn_InputPort[portNum];
215  }
216 
219  {
220  FW_ASSERT(
221  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
222  static_cast<FwAssertArgType>(portNum)
223  );
224 
225  return &this->m_schedIn_InputPort[portNum];
226  }
227 
228 #endif
229 
230 #if !FW_DIRECT_PORT_CALLS
231 
232  // ----------------------------------------------------------------------
233  // Connect input ports to special output ports
234  // ----------------------------------------------------------------------
235 
238  FwIndexType portNum,
239  Fw::InputLogPort* port
240  )
241  {
242  FW_ASSERT(
243  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
244  static_cast<FwAssertArgType>(portNum)
245  );
246 
247  this->m_eventOut_OutputPort[portNum].addCallPort(port);
248  }
249 
250 #if FW_ENABLE_TEXT_LOGGING == 1
251 
252  void BufferManagerComponentBase ::
253  set_textEventOut_OutputPort(
254  FwIndexType portNum,
256  )
257  {
258  FW_ASSERT(
259  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
260  static_cast<FwAssertArgType>(portNum)
261  );
262 
263  this->m_textEventOut_OutputPort[portNum].addCallPort(port);
264  }
265 
266 #endif
267 
270  FwIndexType portNum,
271  Fw::InputTimePort* port
272  )
273  {
274  FW_ASSERT(
275  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
276  static_cast<FwAssertArgType>(portNum)
277  );
278 
279  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
280  }
281 
284  FwIndexType portNum,
285  Fw::InputTlmPort* port
286  )
287  {
288  FW_ASSERT(
289  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
290  static_cast<FwAssertArgType>(portNum)
291  );
292 
293  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
294  }
295 
296 #endif
297 
298 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
299 
300  // ----------------------------------------------------------------------
301  // Connect serial input ports to special output ports
302  // ----------------------------------------------------------------------
303 
306  FwIndexType portNum,
307  Fw::InputSerializePort* port
308  )
309  {
310  FW_ASSERT(
311  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
312  static_cast<FwAssertArgType>(portNum)
313  );
314 
315  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
316  }
317 
318 #if FW_ENABLE_TEXT_LOGGING == 1
319 
320  void BufferManagerComponentBase ::
321  set_textEventOut_OutputPort(
322  FwIndexType portNum,
323  Fw::InputSerializePort* port
324  )
325  {
326  FW_ASSERT(
327  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
328  static_cast<FwAssertArgType>(portNum)
329  );
330 
331  this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
332  }
333 
334 #endif
335 
338  FwIndexType portNum,
339  Fw::InputSerializePort* port
340  )
341  {
342  FW_ASSERT(
343  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
344  static_cast<FwAssertArgType>(portNum)
345  );
346 
347  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
348  }
349 
352  FwIndexType portNum,
353  Fw::InputSerializePort* port
354  )
355  {
356  FW_ASSERT(
357  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
358  static_cast<FwAssertArgType>(portNum)
359  );
360 
361  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
362  }
363 
364 #endif
365 
366  // ----------------------------------------------------------------------
367  // Component construction and destruction
368  // ----------------------------------------------------------------------
369 
371  BufferManagerComponentBase(const char* compName) :
372  Fw::PassiveComponentBase(compName)
373  {
374  this->m_NoBuffsAvailableThrottle = 0;
375  this->m_NullEmptyBufferThrottle = 0;
376  }
377 
380  {
381 
382  }
383 
384 #if !FW_DIRECT_PORT_CALLS
385 
386  // ----------------------------------------------------------------------
387  // Connection status queries for special output ports
388  // ----------------------------------------------------------------------
389 
392  {
393  FW_ASSERT(
394  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
395  static_cast<FwAssertArgType>(portNum)
396  );
397 
398  return this->m_eventOut_OutputPort[portNum].isConnected();
399  }
400 
401 #if FW_ENABLE_TEXT_LOGGING == 1
402 
403  bool BufferManagerComponentBase ::
404  isConnected_textEventOut_OutputPort(FwIndexType portNum) const
405  {
406  FW_ASSERT(
407  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
408  static_cast<FwAssertArgType>(portNum)
409  );
410 
411  return this->m_textEventOut_OutputPort[portNum].isConnected();
412  }
413 
414 #endif
415 
418  {
419  FW_ASSERT(
420  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
421  static_cast<FwAssertArgType>(portNum)
422  );
423 
424  return this->m_timeCaller_OutputPort[portNum].isConnected();
425  }
426 
429  {
430  FW_ASSERT(
431  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
432  static_cast<FwAssertArgType>(portNum)
433  );
434 
435  return this->m_tlmOut_OutputPort[portNum].isConnected();
436  }
437 
438 #endif
439 
440  // ----------------------------------------------------------------------
441  // Port handler base-class functions for typed input ports
442  //
443  // Call these functions directly to bypass the corresponding ports
444  // ----------------------------------------------------------------------
445 
448  FwIndexType portNum,
449  FwSizeType size
450  )
451  {
452  // Make sure port number is valid
453  FW_ASSERT(
454  (0 <= portNum) && (portNum < this->getNum_bufferGetCallee_InputPorts()),
455  static_cast<FwAssertArgType>(portNum)
456  );
457 
458  Fw::Buffer retVal;
459 
460  // Lock guard mutex before calling
461  this->lock();
462 
463  // Call handler function
464  retVal = this->bufferGetCallee_handler(
465  portNum,
466  size
467  );
468 
469  // Unlock guard mutex
470  this->unLock();
471 
472  return retVal;
473  }
474 
477  FwIndexType portNum,
478  Fw::Buffer& fwBuffer
479  )
480  {
481  // Make sure port number is valid
482  FW_ASSERT(
483  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
484  static_cast<FwAssertArgType>(portNum)
485  );
486 
487  // Lock guard mutex before calling
488  this->lock();
489 
490  // Call handler function
491  this->bufferSendIn_handler(
492  portNum,
493  fwBuffer
494  );
495 
496  // Unlock guard mutex
497  this->unLock();
498  }
499 
502  FwIndexType portNum,
503  U32 context
504  )
505  {
506  // Make sure port number is valid
507  FW_ASSERT(
508  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
509  static_cast<FwAssertArgType>(portNum)
510  );
511 
512  // Lock guard mutex before calling
513  this->lock();
514 
515  // Call handler function
516  this->schedIn_handler(
517  portNum,
518  context
519  );
520 
521  // Unlock guard mutex
522  this->unLock();
523  }
524 
525  // ----------------------------------------------------------------------
526  // Event logging functions
527  // ----------------------------------------------------------------------
528 
531  {
532  // Check throttle value
533  if (this->m_NoBuffsAvailableThrottle >= EVENTID_NOBUFFSAVAILABLE_THROTTLE) {
534  return;
535  }
536  else {
537  this->m_NoBuffsAvailableThrottle++;
538  }
539 
540  // Get the time
541  Fw::Time _logTime;
542  if (this->isConnected_timeCaller_OutputPort(0)) {
543  this->timeCaller_out(0, _logTime);
544  }
545 
546  const FwEventIdType _id = this->getIdBase() + EVENTID_NOBUFFSAVAILABLE;
547 
548  // Emit the event on the log port
549  if (this->isConnected_eventOut_OutputPort(0)) {
550  Fw::LogBuffer _logBuff;
552 
553 #if FW_AMPCS_COMPATIBLE
554  // Serialize the number of arguments
555  _status = _logBuff.serializeFrom(static_cast<U8>(1));
556  FW_ASSERT(
557  _status == Fw::FW_SERIALIZE_OK,
558  static_cast<FwAssertArgType>(_status)
559  );
560 #endif
561 
562 #if FW_AMPCS_COMPATIBLE
563  // Serialize the argument size
564  _status = _logBuff.serializeFrom(
565  static_cast<U8>(sizeof(FwSizeType))
566  );
567  FW_ASSERT(
568  _status == Fw::FW_SERIALIZE_OK,
569  static_cast<FwAssertArgType>(_status)
570  );
571 #endif
572  _status = _logBuff.serializeFrom(size);
573  FW_ASSERT(
574  _status == Fw::FW_SERIALIZE_OK,
575  static_cast<FwAssertArgType>(_status)
576  );
577 
578  this->eventOut_out(
579  0,
580  _id,
581  _logTime,
583  _logBuff
584  );
585  }
586 
587  // Emit the event on the text log port
588 #if FW_ENABLE_TEXT_LOGGING
589  if (this->isConnected_textEventOut_OutputPort(0)) {
590 #if FW_OBJECT_NAMES == 1
591  const char* _formatString =
592  "(%s) %s: No available buffers of size %" PRIu64 "";
593 #else
594  const char* _formatString =
595  "%s: No available buffers of size %" PRIu64 "";
596 #endif
597 
598  Fw::TextLogString _logString;
599  (void) _logString.format(
600  _formatString,
601 #if FW_OBJECT_NAMES == 1
602  this->m_objName.toChar(),
603 #endif
604  "NoBuffsAvailable ",
605  size
606  );
607 
608  this->textEventOut_out(
609  0,
610  _id,
611  _logTime,
613  _logString
614  );
615  }
616 #endif
617  }
618 
621  {
622  // Check throttle value
623  if (this->m_NullEmptyBufferThrottle >= EVENTID_NULLEMPTYBUFFER_THROTTLE) {
624  return;
625  }
626  else {
627  this->m_NullEmptyBufferThrottle++;
628  }
629 
630  // Get the time
631  Fw::Time _logTime;
632  if (this->isConnected_timeCaller_OutputPort(0)) {
633  this->timeCaller_out(0, _logTime);
634  }
635 
636  const FwEventIdType _id = this->getIdBase() + EVENTID_NULLEMPTYBUFFER;
637 
638  // Emit the event on the log port
639  if (this->isConnected_eventOut_OutputPort(0)) {
640  Fw::LogBuffer _logBuff;
641 
642 #if FW_AMPCS_COMPATIBLE
644  // Serialize the number of arguments
645  _status = _logBuff.serializeFrom(static_cast<U8>(0));
646  FW_ASSERT(
647  _status == Fw::FW_SERIALIZE_OK,
648  static_cast<FwAssertArgType>(_status)
649  );
650 #endif
651 
652  this->eventOut_out(
653  0,
654  _id,
655  _logTime,
657  _logBuff
658  );
659  }
660 
661  // Emit the event on the text log port
662 #if FW_ENABLE_TEXT_LOGGING
663  if (this->isConnected_textEventOut_OutputPort(0)) {
664 #if FW_OBJECT_NAMES == 1
665  const char* _formatString =
666  "(%s) %s: Received null pointer and zero size buffer";
667 #else
668  const char* _formatString =
669  "%s: Received null pointer and zero size buffer";
670 #endif
671 
672  Fw::TextLogString _logString;
673  (void) _logString.format(
674  _formatString,
675 #if FW_OBJECT_NAMES == 1
676  this->m_objName.toChar(),
677 #endif
678  "NullEmptyBuffer "
679  );
680 
681  this->textEventOut_out(
682  0,
683  _id,
684  _logTime,
686  _logString
687  );
688  }
689 #endif
690  }
691 
692  // ----------------------------------------------------------------------
693  // Event throttle reset functions
694  // ----------------------------------------------------------------------
695 
698  {
699  // Reset throttle counter
700  this->m_NoBuffsAvailableThrottle = 0;
701  }
702 
705  {
706  // Reset throttle counter
707  this->m_NullEmptyBufferThrottle = 0;
708  }
709 
710  // ----------------------------------------------------------------------
711  // Telemetry serialized write
712  // ----------------------------------------------------------------------
713 
716  FwChanIdType id,
717  Fw::TlmBuffer& _tlmBuff,
718  Fw::Time _tlmTime
719  ) const
720  {
721  if (this->isConnected_tlmOut_OutputPort(0)) {
722  if (
724  (_tlmTime == Fw::ZERO_TIME)
725  ) {
726  this->timeCaller_out(0, _tlmTime);
727  }
728 
729  FwChanIdType _id;
730  _id = this->getIdBase() + id;
731 
732  this->tlmOut_out(
733  0,
734  _id,
735  _tlmTime,
736  _tlmBuff
737  );
738  }
739  }
740 
741  // ----------------------------------------------------------------------
742  // Telemetry write functions
743  // ----------------------------------------------------------------------
744 
747  U32 arg,
748  Fw::Time _tlmTime
749  )
750  {
751  // Check to see if it is the first time
752  if (not this->m_first_update_TotalBuffs) {
753  // Check to see if value has changed. If not, don't write it.
754  if (arg == this->m_last_TotalBuffs) {
755  return;
756  }
757  else {
758  this->m_last_TotalBuffs = arg;
759  }
760  }
761  else {
762  this->m_first_update_TotalBuffs = false;
763  this->m_last_TotalBuffs = arg;
764  }
765 
766  if (this->isConnected_tlmOut_OutputPort(0)) {
767  Fw::TlmBuffer _tlmBuff;
768  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
769  FW_ASSERT(
770  _stat == Fw::FW_SERIALIZE_OK,
771  static_cast<FwAssertArgType>(_stat)
772  );
773 
774  this->tlmWrite(
776  _tlmBuff,
777  _tlmTime
778  );
779  }
780  }
781 
784  U32 arg,
785  Fw::Time _tlmTime
786  )
787  {
788  // Check to see if it is the first time
789  if (not this->m_first_update_CurrBuffs) {
790  // Check to see if value has changed. If not, don't write it.
791  if (arg == this->m_last_CurrBuffs) {
792  return;
793  }
794  else {
795  this->m_last_CurrBuffs = arg;
796  }
797  }
798  else {
799  this->m_first_update_CurrBuffs = false;
800  this->m_last_CurrBuffs = arg;
801  }
802 
803  if (this->isConnected_tlmOut_OutputPort(0)) {
804  Fw::TlmBuffer _tlmBuff;
805  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
806  FW_ASSERT(
807  _stat == Fw::FW_SERIALIZE_OK,
808  static_cast<FwAssertArgType>(_stat)
809  );
810 
811  this->tlmWrite(
813  _tlmBuff,
814  _tlmTime
815  );
816  }
817  }
818 
821  U32 arg,
822  Fw::Time _tlmTime
823  )
824  {
825  // Check to see if it is the first time
826  if (not this->m_first_update_HiBuffs) {
827  // Check to see if value has changed. If not, don't write it.
828  if (arg == this->m_last_HiBuffs) {
829  return;
830  }
831  else {
832  this->m_last_HiBuffs = arg;
833  }
834  }
835  else {
836  this->m_first_update_HiBuffs = false;
837  this->m_last_HiBuffs = arg;
838  }
839 
840  if (this->isConnected_tlmOut_OutputPort(0)) {
841  Fw::TlmBuffer _tlmBuff;
842  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
843  FW_ASSERT(
844  _stat == Fw::FW_SERIALIZE_OK,
845  static_cast<FwAssertArgType>(_stat)
846  );
847 
848  this->tlmWrite(
850  _tlmBuff,
851  _tlmTime
852  );
853  }
854  }
855 
858  U32 arg,
859  Fw::Time _tlmTime
860  )
861  {
862  // Check to see if it is the first time
863  if (not this->m_first_update_NoBuffs) {
864  // Check to see if value has changed. If not, don't write it.
865  if (arg == this->m_last_NoBuffs) {
866  return;
867  }
868  else {
869  this->m_last_NoBuffs = arg;
870  }
871  }
872  else {
873  this->m_first_update_NoBuffs = false;
874  this->m_last_NoBuffs = arg;
875  }
876 
877  if (this->isConnected_tlmOut_OutputPort(0)) {
878  Fw::TlmBuffer _tlmBuff;
879  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
880  FW_ASSERT(
881  _stat == Fw::FW_SERIALIZE_OK,
882  static_cast<FwAssertArgType>(_stat)
883  );
884 
885  this->tlmWrite(
887  _tlmBuff,
888  _tlmTime
889  );
890  }
891  }
892 
895  U32 arg,
896  Fw::Time _tlmTime
897  )
898  {
899  // Check to see if it is the first time
900  if (not this->m_first_update_EmptyBuffs) {
901  // Check to see if value has changed. If not, don't write it.
902  if (arg == this->m_last_EmptyBuffs) {
903  return;
904  }
905  else {
906  this->m_last_EmptyBuffs = arg;
907  }
908  }
909  else {
910  this->m_first_update_EmptyBuffs = false;
911  this->m_last_EmptyBuffs = arg;
912  }
913 
914  if (this->isConnected_tlmOut_OutputPort(0)) {
915  Fw::TlmBuffer _tlmBuff;
916  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
917  FW_ASSERT(
918  _stat == Fw::FW_SERIALIZE_OK,
919  static_cast<FwAssertArgType>(_stat)
920  );
921 
922  this->tlmWrite(
924  _tlmBuff,
925  _tlmTime
926  );
927  }
928  }
929 
930  // ----------------------------------------------------------------------
931  // Time
932  // ----------------------------------------------------------------------
933 
935  getTime() const
936  {
937  if (this->isConnected_timeCaller_OutputPort(0)) {
938  Fw::Time _time;
939  this->timeCaller_out(0, _time);
940  return _time;
941  }
942  else {
943  return Fw::Time(TimeBase::TB_NONE, 0, 0);
944  }
945  }
946 
947  // ----------------------------------------------------------------------
948  // Mutex operations for guarded ports
949  //
950  // You can override these operations to provide more sophisticated
951  // synchronization
952  // ----------------------------------------------------------------------
953 
956  {
957  this->m_guardedPortMutex.lock();
958  }
959 
962  {
963  this->m_guardedPortMutex.unLock();
964  }
965 
966  // ----------------------------------------------------------------------
967  // Calls for messages received on typed input ports
968  // ----------------------------------------------------------------------
969 
970  Fw::Buffer BufferManagerComponentBase ::
971  m_p_bufferGetCallee_in(
972  Fw::PassiveComponentBase* callComp,
973  FwIndexType portNum,
974  FwSizeType size
975  )
976  {
977  FW_ASSERT(callComp != nullptr);
978  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
979  return compPtr->bufferGetCallee_handlerBase(
980  portNum,
981  size
982  );
983  }
984 
985  void BufferManagerComponentBase ::
986  m_p_bufferSendIn_in(
987  Fw::PassiveComponentBase* callComp,
988  FwIndexType portNum,
989  Fw::Buffer& fwBuffer
990  )
991  {
992  FW_ASSERT(callComp != nullptr);
993  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
994  compPtr->bufferSendIn_handlerBase(
995  portNum,
996  fwBuffer
997  );
998  }
999 
1000  void BufferManagerComponentBase ::
1001  m_p_schedIn_in(
1002  Fw::PassiveComponentBase* callComp,
1003  FwIndexType portNum,
1004  U32 context
1005  )
1006  {
1007  FW_ASSERT(callComp != nullptr);
1008  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
1009  compPtr->schedIn_handlerBase(
1010  portNum,
1011  context
1012  );
1013  }
1014 
1015 #if !FW_DIRECT_PORT_CALLS
1016 
1017  // ----------------------------------------------------------------------
1018  // Invocation functions for special output ports
1019  // ----------------------------------------------------------------------
1020 
1021  void BufferManagerComponentBase ::
1022  eventOut_out(
1023  FwIndexType portNum,
1024  FwEventIdType id,
1025  Fw::Time& timeTag,
1026  const Fw::LogSeverity& severity,
1027  Fw::LogBuffer& args
1028  ) const
1029  {
1030  FW_ASSERT(
1031  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
1032  static_cast<FwAssertArgType>(portNum)
1033  );
1034 
1035  FW_ASSERT(
1036  this->m_eventOut_OutputPort[portNum].isConnected(),
1037  static_cast<FwAssertArgType>(portNum)
1038  );
1039  this->m_eventOut_OutputPort[portNum].invoke(
1040  id,
1041  timeTag,
1042  severity,
1043  args
1044  );
1045  }
1046 
1047 #if FW_ENABLE_TEXT_LOGGING
1048 
1049  void BufferManagerComponentBase ::
1050  textEventOut_out(
1051  FwIndexType portNum,
1052  FwEventIdType id,
1053  Fw::Time& timeTag,
1054  const Fw::LogSeverity& severity,
1055  Fw::TextLogString& text
1056  ) const
1057  {
1058  FW_ASSERT(
1059  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
1060  static_cast<FwAssertArgType>(portNum)
1061  );
1062 
1063  FW_ASSERT(
1064  this->m_textEventOut_OutputPort[portNum].isConnected(),
1065  static_cast<FwAssertArgType>(portNum)
1066  );
1067  this->m_textEventOut_OutputPort[portNum].invoke(
1068  id,
1069  timeTag,
1070  severity,
1071  text
1072  );
1073  }
1074 
1075 #endif
1076 
1077  void BufferManagerComponentBase ::
1078  timeCaller_out(
1079  FwIndexType portNum,
1080  Fw::Time& time
1081  ) const
1082  {
1083  FW_ASSERT(
1084  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1085  static_cast<FwAssertArgType>(portNum)
1086  );
1087 
1088  FW_ASSERT(
1089  this->m_timeCaller_OutputPort[portNum].isConnected(),
1090  static_cast<FwAssertArgType>(portNum)
1091  );
1092  this->m_timeCaller_OutputPort[portNum].invoke(
1093  time
1094  );
1095  }
1096 
1097  void BufferManagerComponentBase ::
1098  tlmOut_out(
1099  FwIndexType portNum,
1100  FwChanIdType id,
1101  Fw::Time& timeTag,
1102  Fw::TlmBuffer& val
1103  ) const
1104  {
1105  FW_ASSERT(
1106  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
1107  static_cast<FwAssertArgType>(portNum)
1108  );
1109 
1110  FW_ASSERT(
1111  this->m_tlmOut_OutputPort[portNum].isConnected(),
1112  static_cast<FwAssertArgType>(portNum)
1113  );
1114  this->m_tlmOut_OutputPort[portNum].invoke(
1115  id,
1116  timeTag,
1117  val
1118  );
1119  }
1120 
1121 #endif
1122 
1123 }
void log_WARNING_HI_NoBuffsAvailable(FwSizeType size)
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_bufferGetCallee_InputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
virtual ~BufferManagerComponentBase()
Destroy BufferManagerComponentBase object.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
The BufferManager was unable to allocate a requested buffer.
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
Fw::Buffer bufferGetCallee_handlerBase(FwIndexType portNum, FwSizeType size)
Handler base-class function for input port bufferGetCallee.
void init()
Initialization function.
Definition: SchedPortAc.cpp:73
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
static constexpr FwIndexType getNum_schedIn_InputPorts()
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
const Time ZERO_TIME
Definition: Time.cpp:5
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
virtual void bufferSendIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendIn.
The buffer manager received a null pointer and zero-sized buffer as a return. Probably undetected fai...
void init()
Initialization function.
Definition: TlmPortAc.cpp:171
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
No time base has been established (Required)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
FwIdType FwEventIdType
The type of an event identifier.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void init()
Initialization function.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
void log_WARNING_HI_NoBuffsAvailable_ThrottleClear()
Reset throttle value for NoBuffsAvailable.
Fw::InputBufferGetPort * get_bufferGetCallee_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void schedIn_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port schedIn.
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
A serious but recoverable event.
void tlmWrite_NoBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port connection.
Definition: TlmPortAc.cpp:190
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
static constexpr FwIndexType getNum_bufferSendIn_InputPorts()
void tlmWrite_CurrBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_HiBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
virtual void unLock()
Unlock the guarded mutex.
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void setPortNum(FwIndexType portNum)
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
virtual void lock()
Lock the guarded mutex.
void init()
Initialization function.
static constexpr FwIndexType getNum_eventOut_OutputPorts()
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:79
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
void tlmWrite_EmptyBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
PlatformIndexType FwIndexType
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void log_WARNING_HI_NullEmptyBuffer_ThrottleClear()
Reset throttle value for NullEmptyBuffer.
RateGroupDivider component implementation.
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
virtual Fw::Buffer bufferGetCallee_handler(FwIndexType portNum, FwSizeType size)=0
Handler for input port bufferGetCallee.
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
Auto-generated base for BufferManager component.
Implementation of malloc based allocator.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
BufferManagerComponentBase(const char *compName="")
Construct BufferManagerComponentBase object.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34