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