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