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