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