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