F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
FramerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title FramerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for Framer 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 FramerComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port bufferIn
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_bufferIn_InputPorts());
31 port++
32 ) {
33 this->m_bufferIn_InputPort[port].init();
34 this->m_bufferIn_InputPort[port].addCallComp(
35 this,
36 m_p_bufferIn_in
37 );
38 this->m_bufferIn_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_bufferIn_InputPort[%" PRI_PlatformIntType "]",
52 this->m_objName,
53 port
54 );
55 this->m_bufferIn_InputPort[port].setObjName(portName);
56#endif
57 }
58
59 // Connect input port comIn
60 for (
61 PlatformIntType port = 0;
62 port < static_cast<PlatformIntType>(this->getNum_comIn_InputPorts());
63 port++
64 ) {
65 this->m_comIn_InputPort[port].init();
66 this->m_comIn_InputPort[port].addCallComp(
67 this,
68 m_p_comIn_in
69 );
70 this->m_comIn_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_comIn_InputPort[%" PRI_PlatformIntType "]",
84 this->m_objName,
85 port
86 );
87 this->m_comIn_InputPort[port].setObjName(portName);
88#endif
89 }
90
91 // Connect input port comStatusIn
92 for (
93 PlatformIntType port = 0;
94 port < static_cast<PlatformIntType>(this->getNum_comStatusIn_InputPorts());
95 port++
96 ) {
97 this->m_comStatusIn_InputPort[port].init();
98 this->m_comStatusIn_InputPort[port].addCallComp(
99 this,
100 m_p_comStatusIn_in
101 );
102 this->m_comStatusIn_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_comStatusIn_InputPort[%" PRI_PlatformIntType "]",
116 this->m_objName,
117 port
118 );
119 this->m_comStatusIn_InputPort[port].setObjName(portName);
120#endif
121 }
122
123 // Connect output port bufferDeallocate
124 for (
125 PlatformIntType port = 0;
126 port < static_cast<PlatformIntType>(this->getNum_bufferDeallocate_OutputPorts());
127 port++
128 ) {
129 this->m_bufferDeallocate_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_bufferDeallocate_OutputPort[%" PRI_PlatformIntType "]",
143 this->m_objName,
144 port
145 );
146 this->m_bufferDeallocate_OutputPort[port].setObjName(portName);
147#endif
148 }
149
150 // Connect output port comStatusOut
151 for (
152 PlatformIntType port = 0;
153 port < static_cast<PlatformIntType>(this->getNum_comStatusOut_OutputPorts());
154 port++
155 ) {
156 this->m_comStatusOut_OutputPort[port].init();
157
158#if FW_OBJECT_NAMES == 1
159 // The port name consists of this->m_objName and some extra info.
160 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
161 // However, the compiler may assume that this->m_objName fills
162 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
163 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
164 // bytes to cover the extra info.
165 char portName[2*FW_OBJ_NAME_MAX_SIZE];
166 (void) snprintf(
167 portName,
168 sizeof(portName),
169 "%s_comStatusOut_OutputPort[%" PRI_PlatformIntType "]",
170 this->m_objName,
171 port
172 );
173 this->m_comStatusOut_OutputPort[port].setObjName(portName);
174#endif
175 }
176
177 // Connect output port framedAllocate
178 for (
179 PlatformIntType port = 0;
180 port < static_cast<PlatformIntType>(this->getNum_framedAllocate_OutputPorts());
181 port++
182 ) {
183 this->m_framedAllocate_OutputPort[port].init();
184
185#if FW_OBJECT_NAMES == 1
186 // The port name consists of this->m_objName and some extra info.
187 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
188 // However, the compiler may assume that this->m_objName fills
189 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
190 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
191 // bytes to cover the extra info.
192 char portName[2*FW_OBJ_NAME_MAX_SIZE];
193 (void) snprintf(
194 portName,
195 sizeof(portName),
196 "%s_framedAllocate_OutputPort[%" PRI_PlatformIntType "]",
197 this->m_objName,
198 port
199 );
200 this->m_framedAllocate_OutputPort[port].setObjName(portName);
201#endif
202 }
203
204 // Connect output port framedOut
205 for (
206 PlatformIntType port = 0;
207 port < static_cast<PlatformIntType>(this->getNum_framedOut_OutputPorts());
208 port++
209 ) {
210 this->m_framedOut_OutputPort[port].init();
211
212#if FW_OBJECT_NAMES == 1
213 // The port name consists of this->m_objName and some extra info.
214 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
215 // However, the compiler may assume that this->m_objName fills
216 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
217 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
218 // bytes to cover the extra info.
219 char portName[2*FW_OBJ_NAME_MAX_SIZE];
220 (void) snprintf(
221 portName,
222 sizeof(portName),
223 "%s_framedOut_OutputPort[%" PRI_PlatformIntType "]",
224 this->m_objName,
225 port
226 );
227 this->m_framedOut_OutputPort[port].setObjName(portName);
228#endif
229 }
230 }
231
232 // ----------------------------------------------------------------------
233 // Getters for typed input ports
234 // ----------------------------------------------------------------------
235
236 Fw::InputBufferSendPort* FramerComponentBase ::
237 get_bufferIn_InputPort(NATIVE_INT_TYPE portNum)
238 {
239 FW_ASSERT(
240 portNum < this->getNum_bufferIn_InputPorts(),
241 static_cast<FwAssertArgType>(portNum)
242 );
243
244 return &this->m_bufferIn_InputPort[portNum];
245 }
246
247 Fw::InputComPort* FramerComponentBase ::
248 get_comIn_InputPort(NATIVE_INT_TYPE portNum)
249 {
250 FW_ASSERT(
251 portNum < this->getNum_comIn_InputPorts(),
252 static_cast<FwAssertArgType>(portNum)
253 );
254
255 return &this->m_comIn_InputPort[portNum];
256 }
257
258 Fw::InputSuccessConditionPort* FramerComponentBase ::
259 get_comStatusIn_InputPort(NATIVE_INT_TYPE portNum)
260 {
261 FW_ASSERT(
262 portNum < this->getNum_comStatusIn_InputPorts(),
263 static_cast<FwAssertArgType>(portNum)
264 );
265
266 return &this->m_comStatusIn_InputPort[portNum];
267 }
268
269 // ----------------------------------------------------------------------
270 // Connect typed input ports to typed output ports
271 // ----------------------------------------------------------------------
272
273 void FramerComponentBase ::
274 set_bufferDeallocate_OutputPort(
275 NATIVE_INT_TYPE portNum,
277 )
278 {
279 FW_ASSERT(
280 portNum < this->getNum_bufferDeallocate_OutputPorts(),
281 static_cast<FwAssertArgType>(portNum)
282 );
283
284 this->m_bufferDeallocate_OutputPort[portNum].addCallPort(port);
285 }
286
287 void FramerComponentBase ::
288 set_comStatusOut_OutputPort(
289 NATIVE_INT_TYPE portNum,
291 )
292 {
293 FW_ASSERT(
294 portNum < this->getNum_comStatusOut_OutputPorts(),
295 static_cast<FwAssertArgType>(portNum)
296 );
297
298 this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
299 }
300
301 void FramerComponentBase ::
302 set_framedAllocate_OutputPort(
303 NATIVE_INT_TYPE portNum,
305 )
306 {
307 FW_ASSERT(
308 portNum < this->getNum_framedAllocate_OutputPorts(),
309 static_cast<FwAssertArgType>(portNum)
310 );
311
312 this->m_framedAllocate_OutputPort[portNum].addCallPort(port);
313 }
314
315 void FramerComponentBase ::
316 set_framedOut_OutputPort(
317 NATIVE_INT_TYPE portNum,
319 )
320 {
321 FW_ASSERT(
322 portNum < this->getNum_framedOut_OutputPorts(),
323 static_cast<FwAssertArgType>(portNum)
324 );
325
326 this->m_framedOut_OutputPort[portNum].addCallPort(port);
327 }
328
329#if FW_PORT_SERIALIZATION
330
331 // ----------------------------------------------------------------------
332 // Connect serial input ports to typed output ports
333 // ----------------------------------------------------------------------
334
335 void FramerComponentBase ::
336 set_bufferDeallocate_OutputPort(
337 NATIVE_INT_TYPE portNum,
338 Fw::InputSerializePort* port
339 )
340 {
341 FW_ASSERT(
342 portNum < this->getNum_bufferDeallocate_OutputPorts(),
343 static_cast<FwAssertArgType>(portNum)
344 );
345
346 this->m_bufferDeallocate_OutputPort[portNum].registerSerialPort(port);
347 }
348
349 void FramerComponentBase ::
350 set_comStatusOut_OutputPort(
351 NATIVE_INT_TYPE portNum,
352 Fw::InputSerializePort* port
353 )
354 {
355 FW_ASSERT(
356 portNum < this->getNum_comStatusOut_OutputPorts(),
357 static_cast<FwAssertArgType>(portNum)
358 );
359
360 this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
361 }
362
363#endif
364
365 // ----------------------------------------------------------------------
366 // Component construction and destruction
367 // ----------------------------------------------------------------------
368
369 FramerComponentBase ::
370 FramerComponentBase(const char* compName) :
371 Fw::PassiveComponentBase(compName)
372 {
373
374 }
375
376 FramerComponentBase ::
377 ~FramerComponentBase()
378 {
379
380 }
381
382 // ----------------------------------------------------------------------
383 // Getters for numbers of typed input ports
384 // ----------------------------------------------------------------------
385
386 NATIVE_INT_TYPE FramerComponentBase ::
387 getNum_bufferIn_InputPorts() const
388 {
389 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferIn_InputPort));
390 }
391
392 NATIVE_INT_TYPE FramerComponentBase ::
393 getNum_comIn_InputPorts() const
394 {
395 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
396 }
397
398 NATIVE_INT_TYPE FramerComponentBase ::
399 getNum_comStatusIn_InputPorts() const
400 {
401 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusIn_InputPort));
402 }
403
404 // ----------------------------------------------------------------------
405 // Getters for numbers of typed output ports
406 // ----------------------------------------------------------------------
407
408 NATIVE_INT_TYPE FramerComponentBase ::
409 getNum_bufferDeallocate_OutputPorts() const
410 {
411 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferDeallocate_OutputPort));
412 }
413
414 NATIVE_INT_TYPE FramerComponentBase ::
415 getNum_comStatusOut_OutputPorts() const
416 {
417 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusOut_OutputPort));
418 }
419
420 NATIVE_INT_TYPE FramerComponentBase ::
421 getNum_framedAllocate_OutputPorts() const
422 {
423 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_framedAllocate_OutputPort));
424 }
425
426 NATIVE_INT_TYPE FramerComponentBase ::
427 getNum_framedOut_OutputPorts() const
428 {
429 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_framedOut_OutputPort));
430 }
431
432 // ----------------------------------------------------------------------
433 // Connection status queries for typed output ports
434 // ----------------------------------------------------------------------
435
436 bool FramerComponentBase ::
437 isConnected_bufferDeallocate_OutputPort(NATIVE_INT_TYPE portNum)
438 {
439 FW_ASSERT(
440 portNum < this->getNum_bufferDeallocate_OutputPorts(),
441 static_cast<FwAssertArgType>(portNum)
442 );
443
444 return this->m_bufferDeallocate_OutputPort[portNum].isConnected();
445 }
446
447 bool FramerComponentBase ::
448 isConnected_comStatusOut_OutputPort(NATIVE_INT_TYPE portNum)
449 {
450 FW_ASSERT(
451 portNum < this->getNum_comStatusOut_OutputPorts(),
452 static_cast<FwAssertArgType>(portNum)
453 );
454
455 return this->m_comStatusOut_OutputPort[portNum].isConnected();
456 }
457
458 bool FramerComponentBase ::
459 isConnected_framedAllocate_OutputPort(NATIVE_INT_TYPE portNum)
460 {
461 FW_ASSERT(
462 portNum < this->getNum_framedAllocate_OutputPorts(),
463 static_cast<FwAssertArgType>(portNum)
464 );
465
466 return this->m_framedAllocate_OutputPort[portNum].isConnected();
467 }
468
469 bool FramerComponentBase ::
470 isConnected_framedOut_OutputPort(NATIVE_INT_TYPE portNum)
471 {
472 FW_ASSERT(
473 portNum < this->getNum_framedOut_OutputPorts(),
474 static_cast<FwAssertArgType>(portNum)
475 );
476
477 return this->m_framedOut_OutputPort[portNum].isConnected();
478 }
479
480 // ----------------------------------------------------------------------
481 // Port handler base-class functions for typed input ports
482 //
483 // Call these functions directly to bypass the corresponding ports
484 // ----------------------------------------------------------------------
485
486 void FramerComponentBase ::
487 bufferIn_handlerBase(
488 NATIVE_INT_TYPE portNum,
489 Fw::Buffer& fwBuffer
490 )
491 {
492 // Make sure port number is valid
493 FW_ASSERT(
494 portNum < this->getNum_bufferIn_InputPorts(),
495 static_cast<FwAssertArgType>(portNum)
496 );
497
498 // Lock guard mutex before calling
499 this->lock();
500
501 // Call handler function
502 this->bufferIn_handler(
503 portNum,
504 fwBuffer
505 );
506
507 // Unlock guard mutex
508 this->unLock();
509 }
510
511 void FramerComponentBase ::
512 comIn_handlerBase(
513 NATIVE_INT_TYPE portNum,
514 Fw::ComBuffer& data,
515 U32 context
516 )
517 {
518 // Make sure port number is valid
519 FW_ASSERT(
520 portNum < this->getNum_comIn_InputPorts(),
521 static_cast<FwAssertArgType>(portNum)
522 );
523
524 // Lock guard mutex before calling
525 this->lock();
526
527 // Call handler function
528 this->comIn_handler(
529 portNum,
530 data,
531 context
532 );
533
534 // Unlock guard mutex
535 this->unLock();
536 }
537
538 void FramerComponentBase ::
539 comStatusIn_handlerBase(
540 NATIVE_INT_TYPE portNum,
541 Fw::Success& condition
542 )
543 {
544 // Make sure port number is valid
545 FW_ASSERT(
546 portNum < this->getNum_comStatusIn_InputPorts(),
547 static_cast<FwAssertArgType>(portNum)
548 );
549
550 // Call handler function
551 this->comStatusIn_handler(
552 portNum,
553 condition
554 );
555 }
556
557 // ----------------------------------------------------------------------
558 // Invocation functions for typed output ports
559 // ----------------------------------------------------------------------
560
561 void FramerComponentBase ::
562 bufferDeallocate_out(
563 NATIVE_INT_TYPE portNum,
564 Fw::Buffer& fwBuffer
565 )
566 {
567 FW_ASSERT(
568 portNum < this->getNum_bufferDeallocate_OutputPorts(),
569 static_cast<FwAssertArgType>(portNum)
570 );
571 this->m_bufferDeallocate_OutputPort[portNum].invoke(
572 fwBuffer
573 );
574 }
575
576 void FramerComponentBase ::
577 comStatusOut_out(
578 NATIVE_INT_TYPE portNum,
579 Fw::Success& condition
580 )
581 {
582 FW_ASSERT(
583 portNum < this->getNum_comStatusOut_OutputPorts(),
584 static_cast<FwAssertArgType>(portNum)
585 );
586 this->m_comStatusOut_OutputPort[portNum].invoke(
587 condition
588 );
589 }
590
591 Fw::Buffer FramerComponentBase ::
592 framedAllocate_out(
593 NATIVE_INT_TYPE portNum,
594 U32 size
595 )
596 {
597 FW_ASSERT(
598 portNum < this->getNum_framedAllocate_OutputPorts(),
599 static_cast<FwAssertArgType>(portNum)
600 );
601 return this->m_framedAllocate_OutputPort[portNum].invoke(
602 size
603 );
604 }
605
606 Drv::SendStatus FramerComponentBase ::
607 framedOut_out(
608 NATIVE_INT_TYPE portNum,
609 Fw::Buffer& sendBuffer
610 )
611 {
612 FW_ASSERT(
613 portNum < this->getNum_framedOut_OutputPorts(),
614 static_cast<FwAssertArgType>(portNum)
615 );
616 return this->m_framedOut_OutputPort[portNum].invoke(
617 sendBuffer
618 );
619 }
620
621 // ----------------------------------------------------------------------
622 // Mutex operations for guarded ports
623 //
624 // You can override these operations to provide more sophisticated
625 // synchronization
626 // ----------------------------------------------------------------------
627
628 void FramerComponentBase ::
629 lock()
630 {
631 this->m_guardedPortMutex.lock();
632 }
633
634 void FramerComponentBase ::
635 unLock()
636 {
637 this->m_guardedPortMutex.unLock();
638 }
639
640 // ----------------------------------------------------------------------
641 // Calls for messages received on typed input ports
642 // ----------------------------------------------------------------------
643
644 void FramerComponentBase ::
645 m_p_bufferIn_in(
646 Fw::PassiveComponentBase* callComp,
647 NATIVE_INT_TYPE portNum,
648 Fw::Buffer& fwBuffer
649 )
650 {
651 FW_ASSERT(callComp);
652 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
653 compPtr->bufferIn_handlerBase(
654 portNum,
655 fwBuffer
656 );
657 }
658
659 void FramerComponentBase ::
660 m_p_comIn_in(
661 Fw::PassiveComponentBase* callComp,
662 NATIVE_INT_TYPE portNum,
663 Fw::ComBuffer& data,
664 U32 context
665 )
666 {
667 FW_ASSERT(callComp);
668 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
669 compPtr->comIn_handlerBase(
670 portNum,
671 data,
672 context
673 );
674 }
675
676 void FramerComponentBase ::
677 m_p_comStatusIn_in(
678 Fw::PassiveComponentBase* callComp,
679 NATIVE_INT_TYPE portNum,
680 Fw::Success& condition
681 )
682 {
683 FW_ASSERT(callComp);
684 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
685 compPtr->comStatusIn_handlerBase(
686 portNum,
687 condition
688 );
689 }
690
691}
#define FW_ASSERT(...)
Definition Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
#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
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
Status returned by the send call.
void init()
Object initializer.
Definition ObjBase.cpp:27
Success/Failure.
Auto-generated base for Framer component.
void comIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
void bufferIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferIn.