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  // Call handler function
513  this->schedIn_handler(
514  portNum,
515  context
516  );
517  }
518 
519  // ----------------------------------------------------------------------
520  // Event logging functions
521  // ----------------------------------------------------------------------
522 
525  {
526  // Check throttle value
527  if (this->m_NoBuffsAvailableThrottle >= EVENTID_NOBUFFSAVAILABLE_THROTTLE) {
528  return;
529  }
530  else {
531  this->m_NoBuffsAvailableThrottle++;
532  }
533 
534  // Get the time
535  Fw::Time _logTime;
536  if (this->isConnected_timeCaller_OutputPort(0)) {
537  this->timeCaller_out(0, _logTime);
538  }
539 
540  const FwEventIdType _id = this->getIdBase() + EVENTID_NOBUFFSAVAILABLE;
541 
542  // Emit the event on the log port
543  if (this->isConnected_eventOut_OutputPort(0)) {
544  Fw::LogBuffer _logBuff;
546 
547 #if FW_AMPCS_COMPATIBLE
548  // Serialize the number of arguments
549  _status = _logBuff.serializeFrom(static_cast<U8>(1));
550  FW_ASSERT(
551  _status == Fw::FW_SERIALIZE_OK,
552  static_cast<FwAssertArgType>(_status)
553  );
554 #endif
555 
556 #if FW_AMPCS_COMPATIBLE
557  // Serialize the argument size
558  _status = _logBuff.serializeFrom(
559  static_cast<U8>(sizeof(FwSizeType))
560  );
561  FW_ASSERT(
562  _status == Fw::FW_SERIALIZE_OK,
563  static_cast<FwAssertArgType>(_status)
564  );
565 #endif
566  _status = _logBuff.serializeFrom(size);
567  FW_ASSERT(
568  _status == Fw::FW_SERIALIZE_OK,
569  static_cast<FwAssertArgType>(_status)
570  );
571 
572  this->eventOut_out(
573  0,
574  _id,
575  _logTime,
577  _logBuff
578  );
579  }
580 
581  // Emit the event on the text log port
582 #if FW_ENABLE_TEXT_LOGGING
583  if (this->isConnected_textEventOut_OutputPort(0)) {
584 #if FW_OBJECT_NAMES == 1
585  const char* _formatString =
586  "(%s) %s: No available buffers of size %" PRIu64 "";
587 #else
588  const char* _formatString =
589  "%s: No available buffers of size %" PRIu64 "";
590 #endif
591 
592  Fw::TextLogString _logString;
593  _logString.format(
594  _formatString,
595 #if FW_OBJECT_NAMES == 1
596  this->m_objName.toChar(),
597 #endif
598  "NoBuffsAvailable ",
599  size
600  );
601 
602  this->textEventOut_out(
603  0,
604  _id,
605  _logTime,
607  _logString
608  );
609  }
610 #endif
611  }
612 
615  {
616  // Check throttle value
617  if (this->m_NullEmptyBufferThrottle >= EVENTID_NULLEMPTYBUFFER_THROTTLE) {
618  return;
619  }
620  else {
621  this->m_NullEmptyBufferThrottle++;
622  }
623 
624  // Get the time
625  Fw::Time _logTime;
626  if (this->isConnected_timeCaller_OutputPort(0)) {
627  this->timeCaller_out(0, _logTime);
628  }
629 
630  const FwEventIdType _id = this->getIdBase() + EVENTID_NULLEMPTYBUFFER;
631 
632  // Emit the event on the log port
633  if (this->isConnected_eventOut_OutputPort(0)) {
634  Fw::LogBuffer _logBuff;
635 
636 #if FW_AMPCS_COMPATIBLE
638  // Serialize the number of arguments
639  _status = _logBuff.serializeFrom(static_cast<U8>(0));
640  FW_ASSERT(
641  _status == Fw::FW_SERIALIZE_OK,
642  static_cast<FwAssertArgType>(_status)
643  );
644 #endif
645 
646  this->eventOut_out(
647  0,
648  _id,
649  _logTime,
651  _logBuff
652  );
653  }
654 
655  // Emit the event on the text log port
656 #if FW_ENABLE_TEXT_LOGGING
657  if (this->isConnected_textEventOut_OutputPort(0)) {
658 #if FW_OBJECT_NAMES == 1
659  const char* _formatString =
660  "(%s) %s: Received null pointer and zero size buffer";
661 #else
662  const char* _formatString =
663  "%s: Received null pointer and zero size buffer";
664 #endif
665 
666  Fw::TextLogString _logString;
667  _logString.format(
668  _formatString,
669 #if FW_OBJECT_NAMES == 1
670  this->m_objName.toChar(),
671 #endif
672  "NullEmptyBuffer "
673  );
674 
675  this->textEventOut_out(
676  0,
677  _id,
678  _logTime,
680  _logString
681  );
682  }
683 #endif
684  }
685 
686  // ----------------------------------------------------------------------
687  // Event throttle reset functions
688  // ----------------------------------------------------------------------
689 
692  {
693  // Reset throttle counter
694  this->m_NoBuffsAvailableThrottle = 0;
695  }
696 
699  {
700  // Reset throttle counter
701  this->m_NullEmptyBufferThrottle = 0;
702  }
703 
704  // ----------------------------------------------------------------------
705  // Telemetry serialized write
706  // ----------------------------------------------------------------------
707 
710  FwChanIdType id,
711  Fw::TlmBuffer& _tlmBuff,
712  Fw::Time _tlmTime
713  ) const
714  {
715  if (this->isConnected_tlmOut_OutputPort(0)) {
716  if (
718  (_tlmTime == Fw::ZERO_TIME)
719  ) {
720  this->timeCaller_out(0, _tlmTime);
721  }
722 
723  FwChanIdType _id;
724  _id = this->getIdBase() + id;
725 
726  this->tlmOut_out(
727  0,
728  _id,
729  _tlmTime,
730  _tlmBuff
731  );
732  }
733  }
734 
735  // ----------------------------------------------------------------------
736  // Telemetry write functions
737  // ----------------------------------------------------------------------
738 
741  U32 arg,
742  Fw::Time _tlmTime
743  )
744  {
745  // Check to see if it is the first time
746  if (not this->m_first_update_TotalBuffs) {
747  // Check to see if value has changed. If not, don't write it.
748  if (arg == this->m_last_TotalBuffs) {
749  return;
750  }
751  else {
752  this->m_last_TotalBuffs = arg;
753  }
754  }
755  else {
756  this->m_first_update_TotalBuffs = false;
757  this->m_last_TotalBuffs = arg;
758  }
759 
760  if (this->isConnected_tlmOut_OutputPort(0)) {
761  Fw::TlmBuffer _tlmBuff;
762  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
763  FW_ASSERT(
764  _stat == Fw::FW_SERIALIZE_OK,
765  static_cast<FwAssertArgType>(_stat)
766  );
767 
768  this->tlmWrite(
770  _tlmBuff,
771  _tlmTime
772  );
773  }
774  }
775 
778  U32 arg,
779  Fw::Time _tlmTime
780  )
781  {
782  // Check to see if it is the first time
783  if (not this->m_first_update_CurrBuffs) {
784  // Check to see if value has changed. If not, don't write it.
785  if (arg == this->m_last_CurrBuffs) {
786  return;
787  }
788  else {
789  this->m_last_CurrBuffs = arg;
790  }
791  }
792  else {
793  this->m_first_update_CurrBuffs = false;
794  this->m_last_CurrBuffs = arg;
795  }
796 
797  if (this->isConnected_tlmOut_OutputPort(0)) {
798  Fw::TlmBuffer _tlmBuff;
799  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
800  FW_ASSERT(
801  _stat == Fw::FW_SERIALIZE_OK,
802  static_cast<FwAssertArgType>(_stat)
803  );
804 
805  this->tlmWrite(
807  _tlmBuff,
808  _tlmTime
809  );
810  }
811  }
812 
815  U32 arg,
816  Fw::Time _tlmTime
817  )
818  {
819  // Check to see if it is the first time
820  if (not this->m_first_update_HiBuffs) {
821  // Check to see if value has changed. If not, don't write it.
822  if (arg == this->m_last_HiBuffs) {
823  return;
824  }
825  else {
826  this->m_last_HiBuffs = arg;
827  }
828  }
829  else {
830  this->m_first_update_HiBuffs = false;
831  this->m_last_HiBuffs = arg;
832  }
833 
834  if (this->isConnected_tlmOut_OutputPort(0)) {
835  Fw::TlmBuffer _tlmBuff;
836  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
837  FW_ASSERT(
838  _stat == Fw::FW_SERIALIZE_OK,
839  static_cast<FwAssertArgType>(_stat)
840  );
841 
842  this->tlmWrite(
844  _tlmBuff,
845  _tlmTime
846  );
847  }
848  }
849 
852  U32 arg,
853  Fw::Time _tlmTime
854  )
855  {
856  // Check to see if it is the first time
857  if (not this->m_first_update_NoBuffs) {
858  // Check to see if value has changed. If not, don't write it.
859  if (arg == this->m_last_NoBuffs) {
860  return;
861  }
862  else {
863  this->m_last_NoBuffs = arg;
864  }
865  }
866  else {
867  this->m_first_update_NoBuffs = false;
868  this->m_last_NoBuffs = arg;
869  }
870 
871  if (this->isConnected_tlmOut_OutputPort(0)) {
872  Fw::TlmBuffer _tlmBuff;
873  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
874  FW_ASSERT(
875  _stat == Fw::FW_SERIALIZE_OK,
876  static_cast<FwAssertArgType>(_stat)
877  );
878 
879  this->tlmWrite(
881  _tlmBuff,
882  _tlmTime
883  );
884  }
885  }
886 
889  U32 arg,
890  Fw::Time _tlmTime
891  )
892  {
893  // Check to see if it is the first time
894  if (not this->m_first_update_EmptyBuffs) {
895  // Check to see if value has changed. If not, don't write it.
896  if (arg == this->m_last_EmptyBuffs) {
897  return;
898  }
899  else {
900  this->m_last_EmptyBuffs = arg;
901  }
902  }
903  else {
904  this->m_first_update_EmptyBuffs = false;
905  this->m_last_EmptyBuffs = arg;
906  }
907 
908  if (this->isConnected_tlmOut_OutputPort(0)) {
909  Fw::TlmBuffer _tlmBuff;
910  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
911  FW_ASSERT(
912  _stat == Fw::FW_SERIALIZE_OK,
913  static_cast<FwAssertArgType>(_stat)
914  );
915 
916  this->tlmWrite(
918  _tlmBuff,
919  _tlmTime
920  );
921  }
922  }
923 
924  // ----------------------------------------------------------------------
925  // Time
926  // ----------------------------------------------------------------------
927 
929  getTime() const
930  {
931  if (this->isConnected_timeCaller_OutputPort(0)) {
932  Fw::Time _time;
933  this->timeCaller_out(0, _time);
934  return _time;
935  }
936  else {
937  return Fw::Time(TimeBase::TB_NONE, 0, 0);
938  }
939  }
940 
941  // ----------------------------------------------------------------------
942  // Mutex operations for guarded ports
943  //
944  // You can override these operations to provide more sophisticated
945  // synchronization
946  // ----------------------------------------------------------------------
947 
950  {
951  this->m_guardedPortMutex.lock();
952  }
953 
956  {
957  this->m_guardedPortMutex.unLock();
958  }
959 
960  // ----------------------------------------------------------------------
961  // Calls for messages received on typed input ports
962  // ----------------------------------------------------------------------
963 
964  Fw::Buffer BufferManagerComponentBase ::
965  m_p_bufferGetCallee_in(
966  Fw::PassiveComponentBase* callComp,
967  FwIndexType portNum,
968  FwSizeType size
969  )
970  {
971  FW_ASSERT(callComp);
972  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
973  return compPtr->bufferGetCallee_handlerBase(
974  portNum,
975  size
976  );
977  }
978 
979  void BufferManagerComponentBase ::
980  m_p_bufferSendIn_in(
981  Fw::PassiveComponentBase* callComp,
982  FwIndexType portNum,
983  Fw::Buffer& fwBuffer
984  )
985  {
986  FW_ASSERT(callComp);
987  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
988  compPtr->bufferSendIn_handlerBase(
989  portNum,
990  fwBuffer
991  );
992  }
993 
994  void BufferManagerComponentBase ::
995  m_p_schedIn_in(
996  Fw::PassiveComponentBase* callComp,
997  FwIndexType portNum,
998  U32 context
999  )
1000  {
1001  FW_ASSERT(callComp);
1002  BufferManagerComponentBase* compPtr = static_cast<BufferManagerComponentBase*>(callComp);
1003  compPtr->schedIn_handlerBase(
1004  portNum,
1005  context
1006  );
1007  }
1008 
1009 #if !FW_DIRECT_PORT_CALLS
1010 
1011  // ----------------------------------------------------------------------
1012  // Invocation functions for special output ports
1013  // ----------------------------------------------------------------------
1014 
1015  void BufferManagerComponentBase ::
1016  eventOut_out(
1017  FwIndexType portNum,
1018  FwEventIdType id,
1019  Fw::Time& timeTag,
1020  const Fw::LogSeverity& severity,
1021  Fw::LogBuffer& args
1022  ) const
1023  {
1024  FW_ASSERT(
1025  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
1026  static_cast<FwAssertArgType>(portNum)
1027  );
1028 
1029  FW_ASSERT(
1030  this->m_eventOut_OutputPort[portNum].isConnected(),
1031  static_cast<FwAssertArgType>(portNum)
1032  );
1033  this->m_eventOut_OutputPort[portNum].invoke(
1034  id,
1035  timeTag,
1036  severity,
1037  args
1038  );
1039  }
1040 
1041 #if FW_ENABLE_TEXT_LOGGING
1042 
1043  void BufferManagerComponentBase ::
1044  textEventOut_out(
1045  FwIndexType portNum,
1046  FwEventIdType id,
1047  Fw::Time& timeTag,
1048  const Fw::LogSeverity& severity,
1049  Fw::TextLogString& text
1050  ) const
1051  {
1052  FW_ASSERT(
1053  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
1054  static_cast<FwAssertArgType>(portNum)
1055  );
1056 
1057  FW_ASSERT(
1058  this->m_textEventOut_OutputPort[portNum].isConnected(),
1059  static_cast<FwAssertArgType>(portNum)
1060  );
1061  this->m_textEventOut_OutputPort[portNum].invoke(
1062  id,
1063  timeTag,
1064  severity,
1065  text
1066  );
1067  }
1068 
1069 #endif
1070 
1071  void BufferManagerComponentBase ::
1072  timeCaller_out(
1073  FwIndexType portNum,
1074  Fw::Time& time
1075  ) const
1076  {
1077  FW_ASSERT(
1078  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1079  static_cast<FwAssertArgType>(portNum)
1080  );
1081 
1082  FW_ASSERT(
1083  this->m_timeCaller_OutputPort[portNum].isConnected(),
1084  static_cast<FwAssertArgType>(portNum)
1085  );
1086  this->m_timeCaller_OutputPort[portNum].invoke(
1087  time
1088  );
1089  }
1090 
1091  void BufferManagerComponentBase ::
1092  tlmOut_out(
1093  FwIndexType portNum,
1094  FwChanIdType id,
1095  Fw::Time& timeTag,
1096  Fw::TlmBuffer& val
1097  ) const
1098  {
1099  FW_ASSERT(
1100  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
1101  static_cast<FwAssertArgType>(portNum)
1102  );
1103 
1104  FW_ASSERT(
1105  this->m_tlmOut_OutputPort[portNum].isConnected(),
1106  static_cast<FwAssertArgType>(portNum)
1107  );
1108  this->m_tlmOut_OutputPort[portNum].invoke(
1109  id,
1110  timeTag,
1111  val
1112  );
1113  }
1114 
1115 #endif
1116 
1117 }
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.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
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.
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)
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)
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
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
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:39
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.
The buffer manager received a null pointer and zero-sized buffer as a return. Probably undetected fai...
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.
The BufferManager was unable to allocate a requested buffer.
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