F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
BufferRepeaterComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title BufferRepeaterComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for BufferRepeater 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 {
21 };
22
23 // Define a message buffer class large enough to handle all the
24 // asynchronous inputs to the component
25 class ComponentIpcSerializableBuffer :
27 {
28
29 public:
30
31 enum {
32 // Max. message size = size of data + message id + port
33 SERIALIZATION_SIZE =
34 sizeof(BuffUnion) +
35 sizeof(NATIVE_INT_TYPE) +
36 sizeof(NATIVE_INT_TYPE)
37 };
38
39 NATIVE_UINT_TYPE getBuffCapacity() const {
40 return sizeof(m_buff);
41 }
42
43 U8* getBuffAddr() {
44 return m_buff;
45 }
46
47 const U8* getBuffAddr() const {
48 return m_buff;
49 }
50
51 private:
52 // Should be the max of all the input ports serialized sizes...
53 U8 m_buff[SERIALIZATION_SIZE];
54
55 };
56 }
57
58 // ----------------------------------------------------------------------
59 // Component initialization
60 // ----------------------------------------------------------------------
61
62 void BufferRepeaterComponentBase ::
63 init(NATIVE_INT_TYPE instance)
64 {
65 // Initialize base class
67
68 // Connect input port portIn
69 for (
70 PlatformIntType port = 0;
71 port < static_cast<PlatformIntType>(this->getNum_portIn_InputPorts());
72 port++
73 ) {
74 this->m_portIn_InputPort[port].init();
75 this->m_portIn_InputPort[port].addCallComp(
76 this,
77 m_p_portIn_in
78 );
79 this->m_portIn_InputPort[port].setPortNum(port);
80
81#if FW_OBJECT_NAMES == 1
82 char portName[120];
83 (void) snprintf(
84 portName,
85 sizeof(portName),
86 "%s_portIn_InputPort[%" PRI_PlatformIntType "]",
87 this->m_objName,
88 port
89 );
90 this->m_portIn_InputPort[port].setObjName(portName);
91#endif
92 }
93
94 // Connect output port Log
95 for (
96 PlatformIntType port = 0;
97 port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
98 port++
99 ) {
100 this->m_Log_OutputPort[port].init();
101
102#if FW_OBJECT_NAMES == 1
103 char portName[120];
104 (void) snprintf(
105 portName,
106 sizeof(portName),
107 "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
108 this->m_objName,
109 port
110 );
111 this->m_Log_OutputPort[port].setObjName(portName);
112#endif
113 }
114
115#if FW_ENABLE_TEXT_LOGGING == 1
116 // Connect output port LogText
117 for (
118 PlatformIntType port = 0;
119 port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
120 port++
121 ) {
122 this->m_LogText_OutputPort[port].init();
123
124#if FW_OBJECT_NAMES == 1
125 char portName[120];
126 (void) snprintf(
127 portName,
128 sizeof(portName),
129 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
130 this->m_objName,
131 port
132 );
133 this->m_LogText_OutputPort[port].setObjName(portName);
134#endif
135 }
136#endif
137
138 // Connect output port Time
139 for (
140 PlatformIntType port = 0;
141 port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
142 port++
143 ) {
144 this->m_Time_OutputPort[port].init();
145
146#if FW_OBJECT_NAMES == 1
147 char portName[120];
148 (void) snprintf(
149 portName,
150 sizeof(portName),
151 "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
152 this->m_objName,
153 port
154 );
155 this->m_Time_OutputPort[port].setObjName(portName);
156#endif
157 }
158
159 // Connect output port allocate
160 for (
161 PlatformIntType port = 0;
162 port < static_cast<PlatformIntType>(this->getNum_allocate_OutputPorts());
163 port++
164 ) {
165 this->m_allocate_OutputPort[port].init();
166
167#if FW_OBJECT_NAMES == 1
168 char portName[120];
169 (void) snprintf(
170 portName,
171 sizeof(portName),
172 "%s_allocate_OutputPort[%" PRI_PlatformIntType "]",
173 this->m_objName,
174 port
175 );
176 this->m_allocate_OutputPort[port].setObjName(portName);
177#endif
178 }
179
180 // Connect output port deallocate
181 for (
182 PlatformIntType port = 0;
183 port < static_cast<PlatformIntType>(this->getNum_deallocate_OutputPorts());
184 port++
185 ) {
186 this->m_deallocate_OutputPort[port].init();
187
188#if FW_OBJECT_NAMES == 1
189 char portName[120];
190 (void) snprintf(
191 portName,
192 sizeof(portName),
193 "%s_deallocate_OutputPort[%" PRI_PlatformIntType "]",
194 this->m_objName,
195 port
196 );
197 this->m_deallocate_OutputPort[port].setObjName(portName);
198#endif
199 }
200
201 // Connect output port portOut
202 for (
203 PlatformIntType port = 0;
204 port < static_cast<PlatformIntType>(this->getNum_portOut_OutputPorts());
205 port++
206 ) {
207 this->m_portOut_OutputPort[port].init();
208
209#if FW_OBJECT_NAMES == 1
210 char portName[120];
211 (void) snprintf(
212 portName,
213 sizeof(portName),
214 "%s_portOut_OutputPort[%" PRI_PlatformIntType "]",
215 this->m_objName,
216 port
217 );
218 this->m_portOut_OutputPort[port].setObjName(portName);
219#endif
220 }
221 }
222
223 // ----------------------------------------------------------------------
224 // Getters for typed input ports
225 // ----------------------------------------------------------------------
226
227 Fw::InputBufferSendPort* BufferRepeaterComponentBase ::
228 get_portIn_InputPort(NATIVE_INT_TYPE portNum)
229 {
230 FW_ASSERT(
231 portNum < this->getNum_portIn_InputPorts(),
232 static_cast<FwAssertArgType>(portNum)
233 );
234
235 return &this->m_portIn_InputPort[portNum];
236 }
237
238 // ----------------------------------------------------------------------
239 // Connect special input ports to special output ports
240 // ----------------------------------------------------------------------
241
242 void BufferRepeaterComponentBase ::
243 set_Log_OutputPort(
244 NATIVE_INT_TYPE portNum,
245 Fw::InputLogPort* port
246 )
247 {
248 FW_ASSERT(
249 portNum < this->getNum_Log_OutputPorts(),
250 static_cast<FwAssertArgType>(portNum)
251 );
252
253 this->m_Log_OutputPort[portNum].addCallPort(port);
254 }
255
256#if FW_ENABLE_TEXT_LOGGING == 1
257
258 void BufferRepeaterComponentBase ::
259 set_LogText_OutputPort(
260 NATIVE_INT_TYPE portNum,
262 )
263 {
264 FW_ASSERT(
265 portNum < this->getNum_LogText_OutputPorts(),
266 static_cast<FwAssertArgType>(portNum)
267 );
268
269 this->m_LogText_OutputPort[portNum].addCallPort(port);
270 }
271
272#endif
273
274 void BufferRepeaterComponentBase ::
275 set_Time_OutputPort(
276 NATIVE_INT_TYPE portNum,
278 )
279 {
280 FW_ASSERT(
281 portNum < this->getNum_Time_OutputPorts(),
282 static_cast<FwAssertArgType>(portNum)
283 );
284
285 this->m_Time_OutputPort[portNum].addCallPort(port);
286 }
287
288 // ----------------------------------------------------------------------
289 // Connect typed input ports to typed output ports
290 // ----------------------------------------------------------------------
291
292 void BufferRepeaterComponentBase ::
293 set_allocate_OutputPort(
294 NATIVE_INT_TYPE portNum,
296 )
297 {
298 FW_ASSERT(
299 portNum < this->getNum_allocate_OutputPorts(),
300 static_cast<FwAssertArgType>(portNum)
301 );
302
303 this->m_allocate_OutputPort[portNum].addCallPort(port);
304 }
305
306 void BufferRepeaterComponentBase ::
307 set_deallocate_OutputPort(
308 NATIVE_INT_TYPE portNum,
310 )
311 {
312 FW_ASSERT(
313 portNum < this->getNum_deallocate_OutputPorts(),
314 static_cast<FwAssertArgType>(portNum)
315 );
316
317 this->m_deallocate_OutputPort[portNum].addCallPort(port);
318 }
319
320 void BufferRepeaterComponentBase ::
321 set_portOut_OutputPort(
322 NATIVE_INT_TYPE portNum,
324 )
325 {
326 FW_ASSERT(
327 portNum < this->getNum_portOut_OutputPorts(),
328 static_cast<FwAssertArgType>(portNum)
329 );
330
331 this->m_portOut_OutputPort[portNum].addCallPort(port);
332 }
333
334#if FW_PORT_SERIALIZATION
335
336 // ----------------------------------------------------------------------
337 // Connect serial input ports to special output ports
338 // ----------------------------------------------------------------------
339
340 void BufferRepeaterComponentBase ::
341 set_Log_OutputPort(
342 NATIVE_INT_TYPE portNum,
343 Fw::InputSerializePort* port
344 )
345 {
346 FW_ASSERT(
347 portNum < this->getNum_Log_OutputPorts(),
348 static_cast<FwAssertArgType>(portNum)
349 );
350
351 this->m_Log_OutputPort[portNum].registerSerialPort(port);
352 }
353
354#if FW_ENABLE_TEXT_LOGGING == 1
355
356 void BufferRepeaterComponentBase ::
357 set_LogText_OutputPort(
358 NATIVE_INT_TYPE portNum,
359 Fw::InputSerializePort* port
360 )
361 {
362 FW_ASSERT(
363 portNum < this->getNum_LogText_OutputPorts(),
364 static_cast<FwAssertArgType>(portNum)
365 );
366
367 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
368 }
369
370#endif
371
372 void BufferRepeaterComponentBase ::
373 set_Time_OutputPort(
374 NATIVE_INT_TYPE portNum,
375 Fw::InputSerializePort* port
376 )
377 {
378 FW_ASSERT(
379 portNum < this->getNum_Time_OutputPorts(),
380 static_cast<FwAssertArgType>(portNum)
381 );
382
383 this->m_Time_OutputPort[portNum].registerSerialPort(port);
384 }
385
386#endif
387
388#if FW_PORT_SERIALIZATION
389
390 // ----------------------------------------------------------------------
391 // Connect serial input ports to typed output ports
392 // ----------------------------------------------------------------------
393
394 void BufferRepeaterComponentBase ::
395 set_deallocate_OutputPort(
396 NATIVE_INT_TYPE portNum,
397 Fw::InputSerializePort* port
398 )
399 {
400 FW_ASSERT(
401 portNum < this->getNum_deallocate_OutputPorts(),
402 static_cast<FwAssertArgType>(portNum)
403 );
404
405 this->m_deallocate_OutputPort[portNum].registerSerialPort(port);
406 }
407
408 void BufferRepeaterComponentBase ::
409 set_portOut_OutputPort(
410 NATIVE_INT_TYPE portNum,
411 Fw::InputSerializePort* port
412 )
413 {
414 FW_ASSERT(
415 portNum < this->getNum_portOut_OutputPorts(),
416 static_cast<FwAssertArgType>(portNum)
417 );
418
419 this->m_portOut_OutputPort[portNum].registerSerialPort(port);
420 }
421
422#endif
423
424 // ----------------------------------------------------------------------
425 // Component construction and destruction
426 // ----------------------------------------------------------------------
427
428 BufferRepeaterComponentBase ::
429 BufferRepeaterComponentBase(const char* compName) :
430 Fw::PassiveComponentBase(compName)
431 {
432
433 }
434
435 BufferRepeaterComponentBase ::
436 ~BufferRepeaterComponentBase()
437 {
438
439 }
440
441 // ----------------------------------------------------------------------
442 // Getters for numbers of typed input ports
443 // ----------------------------------------------------------------------
444
445 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
446 getNum_portIn_InputPorts()
447 {
448 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_portIn_InputPort));
449 }
450
451 // ----------------------------------------------------------------------
452 // Getters for numbers of special output ports
453 // ----------------------------------------------------------------------
454
455 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
456 getNum_Log_OutputPorts()
457 {
458 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
459 }
460
461#if FW_ENABLE_TEXT_LOGGING == 1
462
463 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
464 getNum_LogText_OutputPorts()
465 {
466 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
467 }
468
469#endif
470
471 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
472 getNum_Time_OutputPorts()
473 {
474 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
475 }
476
477 // ----------------------------------------------------------------------
478 // Getters for numbers of typed output ports
479 // ----------------------------------------------------------------------
480
481 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
482 getNum_allocate_OutputPorts()
483 {
484 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_allocate_OutputPort));
485 }
486
487 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
488 getNum_deallocate_OutputPorts()
489 {
490 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_deallocate_OutputPort));
491 }
492
493 NATIVE_INT_TYPE BufferRepeaterComponentBase ::
494 getNum_portOut_OutputPorts()
495 {
496 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_portOut_OutputPort));
497 }
498
499 // ----------------------------------------------------------------------
500 // Connection status queries for special output ports
501 // ----------------------------------------------------------------------
502
503 bool BufferRepeaterComponentBase ::
504 isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
505 {
506 FW_ASSERT(
507 portNum < this->getNum_Log_OutputPorts(),
508 static_cast<FwAssertArgType>(portNum)
509 );
510
511 return this->m_Log_OutputPort[portNum].isConnected();
512 }
513
514#if FW_ENABLE_TEXT_LOGGING == 1
515
516 bool BufferRepeaterComponentBase ::
517 isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
518 {
519 FW_ASSERT(
520 portNum < this->getNum_LogText_OutputPorts(),
521 static_cast<FwAssertArgType>(portNum)
522 );
523
524 return this->m_LogText_OutputPort[portNum].isConnected();
525 }
526
527#endif
528
529 bool BufferRepeaterComponentBase ::
530 isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
531 {
532 FW_ASSERT(
533 portNum < this->getNum_Time_OutputPorts(),
534 static_cast<FwAssertArgType>(portNum)
535 );
536
537 return this->m_Time_OutputPort[portNum].isConnected();
538 }
539
540 // ----------------------------------------------------------------------
541 // Connection status queries for typed output ports
542 // ----------------------------------------------------------------------
543
544 bool BufferRepeaterComponentBase ::
545 isConnected_allocate_OutputPort(NATIVE_INT_TYPE portNum)
546 {
547 FW_ASSERT(
548 portNum < this->getNum_allocate_OutputPorts(),
549 static_cast<FwAssertArgType>(portNum)
550 );
551
552 return this->m_allocate_OutputPort[portNum].isConnected();
553 }
554
555 bool BufferRepeaterComponentBase ::
556 isConnected_deallocate_OutputPort(NATIVE_INT_TYPE portNum)
557 {
558 FW_ASSERT(
559 portNum < this->getNum_deallocate_OutputPorts(),
560 static_cast<FwAssertArgType>(portNum)
561 );
562
563 return this->m_deallocate_OutputPort[portNum].isConnected();
564 }
565
566 bool BufferRepeaterComponentBase ::
567 isConnected_portOut_OutputPort(NATIVE_INT_TYPE portNum)
568 {
569 FW_ASSERT(
570 portNum < this->getNum_portOut_OutputPorts(),
571 static_cast<FwAssertArgType>(portNum)
572 );
573
574 return this->m_portOut_OutputPort[portNum].isConnected();
575 }
576
577 // ----------------------------------------------------------------------
578 // Port handler base-class functions for typed input ports
579 //
580 // Call these functions directly to bypass the corresponding ports
581 // ----------------------------------------------------------------------
582
583 void BufferRepeaterComponentBase ::
584 portIn_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_portIn_InputPorts(),
592 static_cast<FwAssertArgType>(portNum)
593 );
594
595 // Down call to pure virtual handler method implemented in Impl class
596 this->portIn_handler(
597 portNum,
598 fwBuffer
599 );
600 }
601
602 // ----------------------------------------------------------------------
603 // Invocation functions for typed output ports
604 // ----------------------------------------------------------------------
605
606 Fw::Buffer BufferRepeaterComponentBase ::
607 allocate_out(
608 NATIVE_INT_TYPE portNum,
609 U32 size
610 )
611 {
612 FW_ASSERT(
613 portNum < this->getNum_allocate_OutputPorts(),
614 static_cast<FwAssertArgType>(portNum)
615 );
616 return this->m_allocate_OutputPort[portNum].invoke(
617 size
618 );
619 }
620
621 void BufferRepeaterComponentBase ::
622 deallocate_out(
623 NATIVE_INT_TYPE portNum,
624 Fw::Buffer& fwBuffer
625 )
626 {
627 FW_ASSERT(
628 portNum < this->getNum_deallocate_OutputPorts(),
629 static_cast<FwAssertArgType>(portNum)
630 );
631 this->m_deallocate_OutputPort[portNum].invoke(
632 fwBuffer
633 );
634 }
635
636 void BufferRepeaterComponentBase ::
637 portOut_out(
638 NATIVE_INT_TYPE portNum,
639 Fw::Buffer& fwBuffer
640 )
641 {
642 FW_ASSERT(
643 portNum < this->getNum_portOut_OutputPorts(),
644 static_cast<FwAssertArgType>(portNum)
645 );
646 this->m_portOut_OutputPort[portNum].invoke(
647 fwBuffer
648 );
649 }
650
651 // ----------------------------------------------------------------------
652 // Event logging functions
653 // ----------------------------------------------------------------------
654
655 void BufferRepeaterComponentBase ::
656 log_WARNING_HI_AllocationSoftFailure(
657 I32 port,
658 U32 size
659 )
660 {
661 // Get the time
662 Fw::Time _logTime;
663 if (this->m_Time_OutputPort[0].isConnected()) {
664 this->m_Time_OutputPort[0].invoke(_logTime);
665 }
666
667 FwEventIdType _id = static_cast<FwEventIdType>(0);
668
669 _id = this->getIdBase() + EVENTID_ALLOCATIONSOFTFAILURE;
670
671 // Emit the event on the log port
672 if (this->m_Log_OutputPort[0].isConnected()) {
673 Fw::LogBuffer _logBuff;
675
676#if FW_AMPCS_COMPATIBLE
677 // Serialize the number of arguments
678 _status = _logBuff.serialize(static_cast<U8>(2));
679 FW_ASSERT(
680 _status == Fw::FW_SERIALIZE_OK,
681 static_cast<FwAssertArgType>(_status)
682 );
683#endif
684
685#if FW_AMPCS_COMPATIBLE
686 // Serialize the argument size
687 _status = _logBuff.serialize(
688 static_cast<U8>(sizeof(I32))
689 );
690 FW_ASSERT(
691 _status == Fw::FW_SERIALIZE_OK,
692 static_cast<FwAssertArgType>(_status)
693 );
694#endif
695 _status = _logBuff.serialize(port);
696 FW_ASSERT(
697 _status == Fw::FW_SERIALIZE_OK,
698 static_cast<FwAssertArgType>(_status)
699 );
700
701#if FW_AMPCS_COMPATIBLE
702 // Serialize the argument size
703 _status = _logBuff.serialize(
704 static_cast<U8>(sizeof(U32))
705 );
706 FW_ASSERT(
707 _status == Fw::FW_SERIALIZE_OK,
708 static_cast<FwAssertArgType>(_status)
709 );
710#endif
711 _status = _logBuff.serialize(size);
712 FW_ASSERT(
713 _status == Fw::FW_SERIALIZE_OK,
714 static_cast<FwAssertArgType>(_status)
715 );
716
717 this->m_Log_OutputPort[0].invoke(
718 _id,
719 _logTime,
721 _logBuff
722 );
723 }
724
725 // Emit the event on the text log port
726#if FW_ENABLE_TEXT_LOGGING
727 if (this->m_LogText_OutputPort[0].isConnected()) {
728#if FW_OBJECT_NAMES == 1
729 const char* _formatString =
730 "(%s) %s: Failed to allocate %" PRIi32 " byte buffer for port %" PRIu32 "";
731#else
732 const char* _formatString =
733 "%s: Failed to allocate %" PRIi32 " byte buffer for port %" PRIu32 "";
734#endif
735
736 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
737
738 (void) snprintf(
739 _textBuffer,
741 _formatString,
742#if FW_OBJECT_NAMES == 1
743 this->m_objName,
744#endif
745 "AllocationSoftFailure ",
746 port,
747 size
748 );
749
750 // Null terminate
751 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
752 Fw::TextLogString _logString = _textBuffer;
753 this->m_LogText_OutputPort[0].invoke(
754 _id,
755 _logTime,
757 _logString
758 );
759 }
760#endif
761 }
762
763 void BufferRepeaterComponentBase ::
764 log_FATAL_AllocationHardFailure(
765 I32 port,
766 U32 size
767 )
768 {
769 // Get the time
770 Fw::Time _logTime;
771 if (this->m_Time_OutputPort[0].isConnected()) {
772 this->m_Time_OutputPort[0].invoke(_logTime);
773 }
774
775 FwEventIdType _id = static_cast<FwEventIdType>(0);
776
777 _id = this->getIdBase() + EVENTID_ALLOCATIONHARDFAILURE;
778
779 // Emit the event on the log port
780 if (this->m_Log_OutputPort[0].isConnected()) {
781 Fw::LogBuffer _logBuff;
783
784#if FW_AMPCS_COMPATIBLE
785 // Serialize the number of arguments
786 _status = _logBuff.serialize(static_cast<U8>(2 + 1));
787 FW_ASSERT(
788 _status == Fw::FW_SERIALIZE_OK,
789 static_cast<FwAssertArgType>(_status)
790 );
791
792 // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
793 _status = _logBuff.serialize(static_cast<U8>(4));
794 FW_ASSERT(
795 _status == Fw::FW_SERIALIZE_OK,
796 static_cast<FwAssertArgType>(_status)
797 );
798
799 _status = _logBuff.serialize(static_cast<U32>(0));
800 FW_ASSERT(
801 _status == Fw::FW_SERIALIZE_OK,
802 static_cast<FwAssertArgType>(_status)
803 );
804#endif
805
806#if FW_AMPCS_COMPATIBLE
807 // Serialize the argument size
808 _status = _logBuff.serialize(
809 static_cast<U8>(sizeof(I32))
810 );
811 FW_ASSERT(
812 _status == Fw::FW_SERIALIZE_OK,
813 static_cast<FwAssertArgType>(_status)
814 );
815#endif
816 _status = _logBuff.serialize(port);
817 FW_ASSERT(
818 _status == Fw::FW_SERIALIZE_OK,
819 static_cast<FwAssertArgType>(_status)
820 );
821
822#if FW_AMPCS_COMPATIBLE
823 // Serialize the argument size
824 _status = _logBuff.serialize(
825 static_cast<U8>(sizeof(U32))
826 );
827 FW_ASSERT(
828 _status == Fw::FW_SERIALIZE_OK,
829 static_cast<FwAssertArgType>(_status)
830 );
831#endif
832 _status = _logBuff.serialize(size);
833 FW_ASSERT(
834 _status == Fw::FW_SERIALIZE_OK,
835 static_cast<FwAssertArgType>(_status)
836 );
837
838 this->m_Log_OutputPort[0].invoke(
839 _id,
840 _logTime,
842 _logBuff
843 );
844 }
845
846 // Emit the event on the text log port
847#if FW_ENABLE_TEXT_LOGGING
848 if (this->m_LogText_OutputPort[0].isConnected()) {
849#if FW_OBJECT_NAMES == 1
850 const char* _formatString =
851 "(%s) %s: Failed to allocate %" PRIi32 " byte buffer for port %" PRIu32 "";
852#else
853 const char* _formatString =
854 "%s: Failed to allocate %" PRIi32 " byte buffer for port %" PRIu32 "";
855#endif
856
857 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
858
859 (void) snprintf(
860 _textBuffer,
862 _formatString,
863#if FW_OBJECT_NAMES == 1
864 this->m_objName,
865#endif
866 "AllocationHardFailure ",
867 port,
868 size
869 );
870
871 // Null terminate
872 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
873 Fw::TextLogString _logString = _textBuffer;
874 this->m_LogText_OutputPort[0].invoke(
875 _id,
876 _logTime,
878 _logString
879 );
880 }
881#endif
882 }
883
884 // ----------------------------------------------------------------------
885 // Time
886 // ----------------------------------------------------------------------
887
888 Fw::Time BufferRepeaterComponentBase ::
889 getTime()
890 {
891 if (this->m_Time_OutputPort[0].isConnected()) {
892 Fw::Time _time;
893 this->m_Time_OutputPort[0].invoke(_time);
894 return _time;
895 }
896 else {
897 return Fw::Time(TB_NONE, 0, 0);
898 }
899 }
900
901 // ----------------------------------------------------------------------
902 // Calls for messages received on typed input ports
903 // ----------------------------------------------------------------------
904
905 void BufferRepeaterComponentBase ::
906 m_p_portIn_in(
907 Fw::PassiveComponentBase* callComp,
908 NATIVE_INT_TYPE portNum,
909 Fw::Buffer& fwBuffer
910 )
911 {
912 FW_ASSERT(callComp);
913 BufferRepeaterComponentBase* compPtr = static_cast<BufferRepeaterComponentBase*>(callComp);
914 compPtr->portIn_handlerBase(
915 portNum,
916 fwBuffer
917 );
918 }
919
920}
#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 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.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ WARNING_HI
A serious but recoverable event.
@ FATAL
A fatal non-recoverable event.
void init()
Object initializer.
Definition ObjBase.cpp:27
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Auto-generated base for BufferRepeater component.
void portIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port portIn.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.