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