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