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
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 namespace {
18 // Get the max size by doing a union of the input and internal port serialization sizes
19 union BuffUnion {
23 };
24
25 // Define a message buffer class large enough to handle all the
26 // asynchronous inputs to the component
27 class ComponentIpcSerializableBuffer :
29 {
30
31 public:
32
33 enum {
34 // Max. message size = size of data + message id + port
35 SERIALIZATION_SIZE =
36 sizeof(BuffUnion) +
37 sizeof(NATIVE_INT_TYPE) +
38 sizeof(NATIVE_INT_TYPE)
39 };
40
41 NATIVE_UINT_TYPE getBuffCapacity() const {
42 return sizeof(m_buff);
43 }
44
45 U8* getBuffAddr() {
46 return m_buff;
47 }
48
49 const U8* getBuffAddr() const {
50 return m_buff;
51 }
52
53 private:
54 // Should be the max of all the input ports serialized sizes...
55 U8 m_buff[SERIALIZATION_SIZE];
56
57 };
58 }
59
60 // ----------------------------------------------------------------------
61 // Component initialization
62 // ----------------------------------------------------------------------
63
64 void FramerComponentBase ::
65 init(NATIVE_INT_TYPE instance)
66 {
67 // Initialize base class
69
70 // Connect input port bufferIn
71 for (
72 PlatformIntType port = 0;
73 port < static_cast<PlatformIntType>(this->getNum_bufferIn_InputPorts());
74 port++
75 ) {
76 this->m_bufferIn_InputPort[port].init();
77 this->m_bufferIn_InputPort[port].addCallComp(
78 this,
79 m_p_bufferIn_in
80 );
81 this->m_bufferIn_InputPort[port].setPortNum(port);
82
83#if FW_OBJECT_NAMES == 1
84 char portName[120];
85 (void) snprintf(
86 portName,
87 sizeof(portName),
88 "%s_bufferIn_InputPort[%" PRI_PlatformIntType "]",
89 this->m_objName,
90 port
91 );
92 this->m_bufferIn_InputPort[port].setObjName(portName);
93#endif
94 }
95
96 // Connect input port comIn
97 for (
98 PlatformIntType port = 0;
99 port < static_cast<PlatformIntType>(this->getNum_comIn_InputPorts());
100 port++
101 ) {
102 this->m_comIn_InputPort[port].init();
103 this->m_comIn_InputPort[port].addCallComp(
104 this,
105 m_p_comIn_in
106 );
107 this->m_comIn_InputPort[port].setPortNum(port);
108
109#if FW_OBJECT_NAMES == 1
110 char portName[120];
111 (void) snprintf(
112 portName,
113 sizeof(portName),
114 "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
115 this->m_objName,
116 port
117 );
118 this->m_comIn_InputPort[port].setObjName(portName);
119#endif
120 }
121
122 // Connect input port comStatusIn
123 for (
124 PlatformIntType port = 0;
125 port < static_cast<PlatformIntType>(this->getNum_comStatusIn_InputPorts());
126 port++
127 ) {
128 this->m_comStatusIn_InputPort[port].init();
129 this->m_comStatusIn_InputPort[port].addCallComp(
130 this,
131 m_p_comStatusIn_in
132 );
133 this->m_comStatusIn_InputPort[port].setPortNum(port);
134
135#if FW_OBJECT_NAMES == 1
136 char portName[120];
137 (void) snprintf(
138 portName,
139 sizeof(portName),
140 "%s_comStatusIn_InputPort[%" PRI_PlatformIntType "]",
141 this->m_objName,
142 port
143 );
144 this->m_comStatusIn_InputPort[port].setObjName(portName);
145#endif
146 }
147
148 // Connect output port bufferDeallocate
149 for (
150 PlatformIntType port = 0;
151 port < static_cast<PlatformIntType>(this->getNum_bufferDeallocate_OutputPorts());
152 port++
153 ) {
154 this->m_bufferDeallocate_OutputPort[port].init();
155
156#if FW_OBJECT_NAMES == 1
157 char portName[120];
158 (void) snprintf(
159 portName,
160 sizeof(portName),
161 "%s_bufferDeallocate_OutputPort[%" PRI_PlatformIntType "]",
162 this->m_objName,
163 port
164 );
165 this->m_bufferDeallocate_OutputPort[port].setObjName(portName);
166#endif
167 }
168
169 // Connect output port comStatusOut
170 for (
171 PlatformIntType port = 0;
172 port < static_cast<PlatformIntType>(this->getNum_comStatusOut_OutputPorts());
173 port++
174 ) {
175 this->m_comStatusOut_OutputPort[port].init();
176
177#if FW_OBJECT_NAMES == 1
178 char portName[120];
179 (void) snprintf(
180 portName,
181 sizeof(portName),
182 "%s_comStatusOut_OutputPort[%" PRI_PlatformIntType "]",
183 this->m_objName,
184 port
185 );
186 this->m_comStatusOut_OutputPort[port].setObjName(portName);
187#endif
188 }
189
190 // Connect output port framedAllocate
191 for (
192 PlatformIntType port = 0;
193 port < static_cast<PlatformIntType>(this->getNum_framedAllocate_OutputPorts());
194 port++
195 ) {
196 this->m_framedAllocate_OutputPort[port].init();
197
198#if FW_OBJECT_NAMES == 1
199 char portName[120];
200 (void) snprintf(
201 portName,
202 sizeof(portName),
203 "%s_framedAllocate_OutputPort[%" PRI_PlatformIntType "]",
204 this->m_objName,
205 port
206 );
207 this->m_framedAllocate_OutputPort[port].setObjName(portName);
208#endif
209 }
210
211 // Connect output port framedOut
212 for (
213 PlatformIntType port = 0;
214 port < static_cast<PlatformIntType>(this->getNum_framedOut_OutputPorts());
215 port++
216 ) {
217 this->m_framedOut_OutputPort[port].init();
218
219#if FW_OBJECT_NAMES == 1
220 char portName[120];
221 (void) snprintf(
222 portName,
223 sizeof(portName),
224 "%s_framedOut_OutputPort[%" PRI_PlatformIntType "]",
225 this->m_objName,
226 port
227 );
228 this->m_framedOut_OutputPort[port].setObjName(portName);
229#endif
230 }
231 }
232
233 // ----------------------------------------------------------------------
234 // Getters for typed input ports
235 // ----------------------------------------------------------------------
236
237 Fw::InputBufferSendPort* FramerComponentBase ::
238 get_bufferIn_InputPort(NATIVE_INT_TYPE portNum)
239 {
240 FW_ASSERT(
241 portNum < this->getNum_bufferIn_InputPorts(),
242 static_cast<FwAssertArgType>(portNum)
243 );
244
245 return &this->m_bufferIn_InputPort[portNum];
246 }
247
248 Fw::InputComPort* FramerComponentBase ::
249 get_comIn_InputPort(NATIVE_INT_TYPE portNum)
250 {
251 FW_ASSERT(
252 portNum < this->getNum_comIn_InputPorts(),
253 static_cast<FwAssertArgType>(portNum)
254 );
255
256 return &this->m_comIn_InputPort[portNum];
257 }
258
259 Fw::InputSuccessConditionPort* FramerComponentBase ::
260 get_comStatusIn_InputPort(NATIVE_INT_TYPE portNum)
261 {
262 FW_ASSERT(
263 portNum < this->getNum_comStatusIn_InputPorts(),
264 static_cast<FwAssertArgType>(portNum)
265 );
266
267 return &this->m_comStatusIn_InputPort[portNum];
268 }
269
270 // ----------------------------------------------------------------------
271 // Connect typed input ports to typed output ports
272 // ----------------------------------------------------------------------
273
274 void FramerComponentBase ::
275 set_bufferDeallocate_OutputPort(
276 NATIVE_INT_TYPE portNum,
278 )
279 {
280 FW_ASSERT(
281 portNum < this->getNum_bufferDeallocate_OutputPorts(),
282 static_cast<FwAssertArgType>(portNum)
283 );
284
285 this->m_bufferDeallocate_OutputPort[portNum].addCallPort(port);
286 }
287
288 void FramerComponentBase ::
289 set_comStatusOut_OutputPort(
290 NATIVE_INT_TYPE portNum,
292 )
293 {
294 FW_ASSERT(
295 portNum < this->getNum_comStatusOut_OutputPorts(),
296 static_cast<FwAssertArgType>(portNum)
297 );
298
299 this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
300 }
301
302 void FramerComponentBase ::
303 set_framedAllocate_OutputPort(
304 NATIVE_INT_TYPE portNum,
306 )
307 {
308 FW_ASSERT(
309 portNum < this->getNum_framedAllocate_OutputPorts(),
310 static_cast<FwAssertArgType>(portNum)
311 );
312
313 this->m_framedAllocate_OutputPort[portNum].addCallPort(port);
314 }
315
316 void FramerComponentBase ::
317 set_framedOut_OutputPort(
318 NATIVE_INT_TYPE portNum,
320 )
321 {
322 FW_ASSERT(
323 portNum < this->getNum_framedOut_OutputPorts(),
324 static_cast<FwAssertArgType>(portNum)
325 );
326
327 this->m_framedOut_OutputPort[portNum].addCallPort(port);
328 }
329
330#if FW_PORT_SERIALIZATION
331
332 // ----------------------------------------------------------------------
333 // Connect serial input ports to typed output ports
334 // ----------------------------------------------------------------------
335
336 void FramerComponentBase ::
337 set_bufferDeallocate_OutputPort(
338 NATIVE_INT_TYPE portNum,
339 Fw::InputSerializePort* port
340 )
341 {
342 FW_ASSERT(
343 portNum < this->getNum_bufferDeallocate_OutputPorts(),
344 static_cast<FwAssertArgType>(portNum)
345 );
346
347 this->m_bufferDeallocate_OutputPort[portNum].registerSerialPort(port);
348 }
349
350 void FramerComponentBase ::
351 set_comStatusOut_OutputPort(
352 NATIVE_INT_TYPE portNum,
353 Fw::InputSerializePort* port
354 )
355 {
356 FW_ASSERT(
357 portNum < this->getNum_comStatusOut_OutputPorts(),
358 static_cast<FwAssertArgType>(portNum)
359 );
360
361 this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
362 }
363
364#endif
365
366 // ----------------------------------------------------------------------
367 // Component construction and destruction
368 // ----------------------------------------------------------------------
369
370 FramerComponentBase ::
371 FramerComponentBase(const char* compName) :
372 Fw::PassiveComponentBase(compName)
373 {
374
375 }
376
377 FramerComponentBase ::
378 ~FramerComponentBase()
379 {
380
381 }
382
383 // ----------------------------------------------------------------------
384 // Getters for numbers of typed input ports
385 // ----------------------------------------------------------------------
386
387 NATIVE_INT_TYPE FramerComponentBase ::
388 getNum_bufferIn_InputPorts()
389 {
390 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferIn_InputPort));
391 }
392
393 NATIVE_INT_TYPE FramerComponentBase ::
394 getNum_comIn_InputPorts()
395 {
396 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
397 }
398
399 NATIVE_INT_TYPE FramerComponentBase ::
400 getNum_comStatusIn_InputPorts()
401 {
402 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusIn_InputPort));
403 }
404
405 // ----------------------------------------------------------------------
406 // Getters for numbers of typed output ports
407 // ----------------------------------------------------------------------
408
409 NATIVE_INT_TYPE FramerComponentBase ::
410 getNum_bufferDeallocate_OutputPorts()
411 {
412 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferDeallocate_OutputPort));
413 }
414
415 NATIVE_INT_TYPE FramerComponentBase ::
416 getNum_comStatusOut_OutputPorts()
417 {
418 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusOut_OutputPort));
419 }
420
421 NATIVE_INT_TYPE FramerComponentBase ::
422 getNum_framedAllocate_OutputPorts()
423 {
424 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_framedAllocate_OutputPort));
425 }
426
427 NATIVE_INT_TYPE FramerComponentBase ::
428 getNum_framedOut_OutputPorts()
429 {
430 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_framedOut_OutputPort));
431 }
432
433 // ----------------------------------------------------------------------
434 // Connection status queries for typed output ports
435 // ----------------------------------------------------------------------
436
437 bool FramerComponentBase ::
438 isConnected_bufferDeallocate_OutputPort(NATIVE_INT_TYPE portNum)
439 {
440 FW_ASSERT(
441 portNum < this->getNum_bufferDeallocate_OutputPorts(),
442 static_cast<FwAssertArgType>(portNum)
443 );
444
445 return this->m_bufferDeallocate_OutputPort[portNum].isConnected();
446 }
447
448 bool FramerComponentBase ::
449 isConnected_comStatusOut_OutputPort(NATIVE_INT_TYPE portNum)
450 {
451 FW_ASSERT(
452 portNum < this->getNum_comStatusOut_OutputPorts(),
453 static_cast<FwAssertArgType>(portNum)
454 );
455
456 return this->m_comStatusOut_OutputPort[portNum].isConnected();
457 }
458
459 bool FramerComponentBase ::
460 isConnected_framedAllocate_OutputPort(NATIVE_INT_TYPE portNum)
461 {
462 FW_ASSERT(
463 portNum < this->getNum_framedAllocate_OutputPorts(),
464 static_cast<FwAssertArgType>(portNum)
465 );
466
467 return this->m_framedAllocate_OutputPort[portNum].isConnected();
468 }
469
470 bool FramerComponentBase ::
471 isConnected_framedOut_OutputPort(NATIVE_INT_TYPE portNum)
472 {
473 FW_ASSERT(
474 portNum < this->getNum_framedOut_OutputPorts(),
475 static_cast<FwAssertArgType>(portNum)
476 );
477
478 return this->m_framedOut_OutputPort[portNum].isConnected();
479 }
480
481 // ----------------------------------------------------------------------
482 // Port handler base-class functions for typed input ports
483 //
484 // Call these functions directly to bypass the corresponding ports
485 // ----------------------------------------------------------------------
486
487 void FramerComponentBase ::
488 bufferIn_handlerBase(
489 NATIVE_INT_TYPE portNum,
490 Fw::Buffer& fwBuffer
491 )
492 {
493 // Make sure port number is valid
494 FW_ASSERT(
495 portNum < this->getNum_bufferIn_InputPorts(),
496 static_cast<FwAssertArgType>(portNum)
497 );
498
499 // Lock guard mutex before calling
500 this->lock();
501
502 // Down call to pure virtual handler method implemented in Impl class
503 this->bufferIn_handler(
504 portNum,
505 fwBuffer
506 );
507
508 // Unlock guard mutex
509 this->unLock();
510 }
511
512 void FramerComponentBase ::
513 comIn_handlerBase(
514 NATIVE_INT_TYPE portNum,
515 Fw::ComBuffer& data,
516 U32 context
517 )
518 {
519 // Make sure port number is valid
520 FW_ASSERT(
521 portNum < this->getNum_comIn_InputPorts(),
522 static_cast<FwAssertArgType>(portNum)
523 );
524
525 // Lock guard mutex before calling
526 this->lock();
527
528 // Down call to pure virtual handler method implemented in Impl class
529 this->comIn_handler(
530 portNum,
531 data,
532 context
533 );
534
535 // Unlock guard mutex
536 this->unLock();
537 }
538
539 void FramerComponentBase ::
540 comStatusIn_handlerBase(
541 NATIVE_INT_TYPE portNum,
542 Fw::Success& condition
543 )
544 {
545 // Make sure port number is valid
546 FW_ASSERT(
547 portNum < this->getNum_comStatusIn_InputPorts(),
548 static_cast<FwAssertArgType>(portNum)
549 );
550
551 // Down call to pure virtual handler method implemented in Impl class
552 this->comStatusIn_handler(
553 portNum,
554 condition
555 );
556 }
557
558 // ----------------------------------------------------------------------
559 // Invocation functions for typed output ports
560 // ----------------------------------------------------------------------
561
562 void FramerComponentBase ::
563 bufferDeallocate_out(
564 NATIVE_INT_TYPE portNum,
565 Fw::Buffer& fwBuffer
566 )
567 {
568 FW_ASSERT(
569 portNum < this->getNum_bufferDeallocate_OutputPorts(),
570 static_cast<FwAssertArgType>(portNum)
571 );
572 this->m_bufferDeallocate_OutputPort[portNum].invoke(
573 fwBuffer
574 );
575 }
576
577 void FramerComponentBase ::
578 comStatusOut_out(
579 NATIVE_INT_TYPE portNum,
580 Fw::Success& condition
581 )
582 {
583 FW_ASSERT(
584 portNum < this->getNum_comStatusOut_OutputPorts(),
585 static_cast<FwAssertArgType>(portNum)
586 );
587 this->m_comStatusOut_OutputPort[portNum].invoke(
588 condition
589 );
590 }
591
592 Fw::Buffer FramerComponentBase ::
593 framedAllocate_out(
594 NATIVE_INT_TYPE portNum,
595 U32 size
596 )
597 {
598 FW_ASSERT(
599 portNum < this->getNum_framedAllocate_OutputPorts(),
600 static_cast<FwAssertArgType>(portNum)
601 );
602 return this->m_framedAllocate_OutputPort[portNum].invoke(
603 size
604 );
605 }
606
607 Drv::SendStatus FramerComponentBase ::
608 framedOut_out(
609 NATIVE_INT_TYPE portNum,
610 Fw::Buffer& sendBuffer
611 )
612 {
613 FW_ASSERT(
614 portNum < this->getNum_framedOut_OutputPorts(),
615 static_cast<FwAssertArgType>(portNum)
616 );
617 return this->m_framedOut_OutputPort[portNum].invoke(
618 sendBuffer
619 );
620 }
621
622 // ----------------------------------------------------------------------
623 // Mutex operations for guarded ports
624 //
625 // You can override these operations to provide more sophisticated
626 // synchronization
627 // ----------------------------------------------------------------------
628
629 void FramerComponentBase ::
630 lock()
631 {
632 this->m_guardedPortMutex.lock();
633 }
634
635 void FramerComponentBase ::
636 unLock()
637 {
638 this->m_guardedPortMutex.unLock();
639 }
640
641 // ----------------------------------------------------------------------
642 // Calls for messages received on typed input ports
643 // ----------------------------------------------------------------------
644
645 void FramerComponentBase ::
646 m_p_bufferIn_in(
647 Fw::PassiveComponentBase* callComp,
648 NATIVE_INT_TYPE portNum,
649 Fw::Buffer& fwBuffer
650 )
651 {
652 FW_ASSERT(callComp);
653 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
654 compPtr->bufferIn_handlerBase(
655 portNum,
656 fwBuffer
657 );
658 }
659
660 void FramerComponentBase ::
661 m_p_comIn_in(
662 Fw::PassiveComponentBase* callComp,
663 NATIVE_INT_TYPE portNum,
664 Fw::ComBuffer& data,
665 U32 context
666 )
667 {
668 FW_ASSERT(callComp);
669 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
670 compPtr->comIn_handlerBase(
671 portNum,
672 data,
673 context
674 );
675 }
676
677 void FramerComponentBase ::
678 m_p_comStatusIn_in(
679 Fw::PassiveComponentBase* callComp,
680 NATIVE_INT_TYPE portNum,
681 Fw::Success& condition
682 )
683 {
684 FW_ASSERT(callComp);
685 FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
686 compPtr->comStatusIn_handlerBase(
687 portNum,
688 condition
689 );
690 }
691
692}
#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
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
Input ByteStreamSend port.
Input BufferGet port.
Input BufferSend port.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition ComPortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
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.