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
ComStubComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title ComStubComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for ComStub 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 ComStubComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port comDataIn
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_comDataIn_InputPorts());
31 port++
32 ) {
33 this->m_comDataIn_InputPort[port].init();
34 this->m_comDataIn_InputPort[port].addCallComp(
35 this,
36 m_p_comDataIn_in
37 );
38 this->m_comDataIn_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_comDataIn_InputPort[%" PRI_PlatformIntType "]",
52 this->m_objName,
53 port
54 );
55 this->m_comDataIn_InputPort[port].setObjName(portName);
56#endif
57 }
58
59 // Connect input port drvConnected
60 for (
61 PlatformIntType port = 0;
62 port < static_cast<PlatformIntType>(this->getNum_drvConnected_InputPorts());
63 port++
64 ) {
65 this->m_drvConnected_InputPort[port].init();
66 this->m_drvConnected_InputPort[port].addCallComp(
67 this,
68 m_p_drvConnected_in
69 );
70 this->m_drvConnected_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_drvConnected_InputPort[%" PRI_PlatformIntType "]",
84 this->m_objName,
85 port
86 );
87 this->m_drvConnected_InputPort[port].setObjName(portName);
88#endif
89 }
90
91 // Connect input port drvDataIn
92 for (
93 PlatformIntType port = 0;
94 port < static_cast<PlatformIntType>(this->getNum_drvDataIn_InputPorts());
95 port++
96 ) {
97 this->m_drvDataIn_InputPort[port].init();
98 this->m_drvDataIn_InputPort[port].addCallComp(
99 this,
100 m_p_drvDataIn_in
101 );
102 this->m_drvDataIn_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_drvDataIn_InputPort[%" PRI_PlatformIntType "]",
116 this->m_objName,
117 port
118 );
119 this->m_drvDataIn_InputPort[port].setObjName(portName);
120#endif
121 }
122
123 // Connect output port comDataOut
124 for (
125 PlatformIntType port = 0;
126 port < static_cast<PlatformIntType>(this->getNum_comDataOut_OutputPorts());
127 port++
128 ) {
129 this->m_comDataOut_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_comDataOut_OutputPort[%" PRI_PlatformIntType "]",
143 this->m_objName,
144 port
145 );
146 this->m_comDataOut_OutputPort[port].setObjName(portName);
147#endif
148 }
149
150 // Connect output port comStatus
151 for (
152 PlatformIntType port = 0;
153 port < static_cast<PlatformIntType>(this->getNum_comStatus_OutputPorts());
154 port++
155 ) {
156 this->m_comStatus_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_comStatus_OutputPort[%" PRI_PlatformIntType "]",
170 this->m_objName,
171 port
172 );
173 this->m_comStatus_OutputPort[port].setObjName(portName);
174#endif
175 }
176
177 // Connect output port drvDataOut
178 for (
179 PlatformIntType port = 0;
180 port < static_cast<PlatformIntType>(this->getNum_drvDataOut_OutputPorts());
181 port++
182 ) {
183 this->m_drvDataOut_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_drvDataOut_OutputPort[%" PRI_PlatformIntType "]",
197 this->m_objName,
198 port
199 );
200 this->m_drvDataOut_OutputPort[port].setObjName(portName);
201#endif
202 }
203 }
204
205 // ----------------------------------------------------------------------
206 // Getters for typed input ports
207 // ----------------------------------------------------------------------
208
209 Drv::InputByteStreamSendPort* ComStubComponentBase ::
210 get_comDataIn_InputPort(NATIVE_INT_TYPE portNum)
211 {
212 FW_ASSERT(
213 portNum < this->getNum_comDataIn_InputPorts(),
214 static_cast<FwAssertArgType>(portNum)
215 );
216
217 return &this->m_comDataIn_InputPort[portNum];
218 }
219
220 Drv::InputByteStreamReadyPort* ComStubComponentBase ::
221 get_drvConnected_InputPort(NATIVE_INT_TYPE portNum)
222 {
223 FW_ASSERT(
224 portNum < this->getNum_drvConnected_InputPorts(),
225 static_cast<FwAssertArgType>(portNum)
226 );
227
228 return &this->m_drvConnected_InputPort[portNum];
229 }
230
231 Drv::InputByteStreamRecvPort* ComStubComponentBase ::
232 get_drvDataIn_InputPort(NATIVE_INT_TYPE portNum)
233 {
234 FW_ASSERT(
235 portNum < this->getNum_drvDataIn_InputPorts(),
236 static_cast<FwAssertArgType>(portNum)
237 );
238
239 return &this->m_drvDataIn_InputPort[portNum];
240 }
241
242 // ----------------------------------------------------------------------
243 // Connect typed input ports to typed output ports
244 // ----------------------------------------------------------------------
245
246 void ComStubComponentBase ::
247 set_comDataOut_OutputPort(
248 NATIVE_INT_TYPE portNum,
250 )
251 {
252 FW_ASSERT(
253 portNum < this->getNum_comDataOut_OutputPorts(),
254 static_cast<FwAssertArgType>(portNum)
255 );
256
257 this->m_comDataOut_OutputPort[portNum].addCallPort(port);
258 }
259
260 void ComStubComponentBase ::
261 set_comStatus_OutputPort(
262 NATIVE_INT_TYPE portNum,
264 )
265 {
266 FW_ASSERT(
267 portNum < this->getNum_comStatus_OutputPorts(),
268 static_cast<FwAssertArgType>(portNum)
269 );
270
271 this->m_comStatus_OutputPort[portNum].addCallPort(port);
272 }
273
274 void ComStubComponentBase ::
275 set_drvDataOut_OutputPort(
276 NATIVE_INT_TYPE portNum,
278 )
279 {
280 FW_ASSERT(
281 portNum < this->getNum_drvDataOut_OutputPorts(),
282 static_cast<FwAssertArgType>(portNum)
283 );
284
285 this->m_drvDataOut_OutputPort[portNum].addCallPort(port);
286 }
287
288#if FW_PORT_SERIALIZATION
289
290 // ----------------------------------------------------------------------
291 // Connect serial input ports to typed output ports
292 // ----------------------------------------------------------------------
293
294 void ComStubComponentBase ::
295 set_comDataOut_OutputPort(
296 NATIVE_INT_TYPE portNum,
297 Fw::InputSerializePort* port
298 )
299 {
300 FW_ASSERT(
301 portNum < this->getNum_comDataOut_OutputPorts(),
302 static_cast<FwAssertArgType>(portNum)
303 );
304
305 this->m_comDataOut_OutputPort[portNum].registerSerialPort(port);
306 }
307
308 void ComStubComponentBase ::
309 set_comStatus_OutputPort(
310 NATIVE_INT_TYPE portNum,
311 Fw::InputSerializePort* port
312 )
313 {
314 FW_ASSERT(
315 portNum < this->getNum_comStatus_OutputPorts(),
316 static_cast<FwAssertArgType>(portNum)
317 );
318
319 this->m_comStatus_OutputPort[portNum].registerSerialPort(port);
320 }
321
322#endif
323
324 // ----------------------------------------------------------------------
325 // Component construction and destruction
326 // ----------------------------------------------------------------------
327
328 ComStubComponentBase ::
329 ComStubComponentBase(const char* compName) :
330 Fw::PassiveComponentBase(compName)
331 {
332
333 }
334
335 ComStubComponentBase ::
336 ~ComStubComponentBase()
337 {
338
339 }
340
341 // ----------------------------------------------------------------------
342 // Getters for numbers of typed input ports
343 // ----------------------------------------------------------------------
344
345 NATIVE_INT_TYPE ComStubComponentBase ::
346 getNum_comDataIn_InputPorts() const
347 {
348 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comDataIn_InputPort));
349 }
350
351 NATIVE_INT_TYPE ComStubComponentBase ::
352 getNum_drvConnected_InputPorts() const
353 {
354 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvConnected_InputPort));
355 }
356
357 NATIVE_INT_TYPE ComStubComponentBase ::
358 getNum_drvDataIn_InputPorts() const
359 {
360 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvDataIn_InputPort));
361 }
362
363 // ----------------------------------------------------------------------
364 // Getters for numbers of typed output ports
365 // ----------------------------------------------------------------------
366
367 NATIVE_INT_TYPE ComStubComponentBase ::
368 getNum_comDataOut_OutputPorts() const
369 {
370 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comDataOut_OutputPort));
371 }
372
373 NATIVE_INT_TYPE ComStubComponentBase ::
374 getNum_comStatus_OutputPorts() const
375 {
376 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatus_OutputPort));
377 }
378
379 NATIVE_INT_TYPE ComStubComponentBase ::
380 getNum_drvDataOut_OutputPorts() const
381 {
382 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvDataOut_OutputPort));
383 }
384
385 // ----------------------------------------------------------------------
386 // Connection status queries for typed output ports
387 // ----------------------------------------------------------------------
388
389 bool ComStubComponentBase ::
390 isConnected_comDataOut_OutputPort(NATIVE_INT_TYPE portNum)
391 {
392 FW_ASSERT(
393 portNum < this->getNum_comDataOut_OutputPorts(),
394 static_cast<FwAssertArgType>(portNum)
395 );
396
397 return this->m_comDataOut_OutputPort[portNum].isConnected();
398 }
399
400 bool ComStubComponentBase ::
401 isConnected_comStatus_OutputPort(NATIVE_INT_TYPE portNum)
402 {
403 FW_ASSERT(
404 portNum < this->getNum_comStatus_OutputPorts(),
405 static_cast<FwAssertArgType>(portNum)
406 );
407
408 return this->m_comStatus_OutputPort[portNum].isConnected();
409 }
410
411 bool ComStubComponentBase ::
412 isConnected_drvDataOut_OutputPort(NATIVE_INT_TYPE portNum)
413 {
414 FW_ASSERT(
415 portNum < this->getNum_drvDataOut_OutputPorts(),
416 static_cast<FwAssertArgType>(portNum)
417 );
418
419 return this->m_drvDataOut_OutputPort[portNum].isConnected();
420 }
421
422 // ----------------------------------------------------------------------
423 // Port handler base-class functions for typed input ports
424 //
425 // Call these functions directly to bypass the corresponding ports
426 // ----------------------------------------------------------------------
427
428 Drv::SendStatus ComStubComponentBase ::
429 comDataIn_handlerBase(
430 NATIVE_INT_TYPE portNum,
431 Fw::Buffer& sendBuffer
432 )
433 {
434 // Make sure port number is valid
435 FW_ASSERT(
436 portNum < this->getNum_comDataIn_InputPorts(),
437 static_cast<FwAssertArgType>(portNum)
438 );
439
440 Drv::SendStatus retVal;
441
442 // Call handler function
443 retVal = this->comDataIn_handler(
444 portNum,
445 sendBuffer
446 );
447
448 return retVal;
449 }
450
451 void ComStubComponentBase ::
452 drvConnected_handlerBase(NATIVE_INT_TYPE portNum)
453 {
454 // Make sure port number is valid
455 FW_ASSERT(
456 portNum < this->getNum_drvConnected_InputPorts(),
457 static_cast<FwAssertArgType>(portNum)
458 );
459
460 // Call handler function
461 this->drvConnected_handler(portNum);
462 }
463
464 void ComStubComponentBase ::
465 drvDataIn_handlerBase(
466 NATIVE_INT_TYPE portNum,
467 Fw::Buffer& recvBuffer,
468 const Drv::RecvStatus& recvStatus
469 )
470 {
471 // Make sure port number is valid
472 FW_ASSERT(
473 portNum < this->getNum_drvDataIn_InputPorts(),
474 static_cast<FwAssertArgType>(portNum)
475 );
476
477 // Call handler function
478 this->drvDataIn_handler(
479 portNum,
480 recvBuffer,
481 recvStatus
482 );
483 }
484
485 // ----------------------------------------------------------------------
486 // Invocation functions for typed output ports
487 // ----------------------------------------------------------------------
488
489 void ComStubComponentBase ::
490 comDataOut_out(
491 NATIVE_INT_TYPE portNum,
492 Fw::Buffer& recvBuffer,
493 const Drv::RecvStatus& recvStatus
494 )
495 {
496 FW_ASSERT(
497 portNum < this->getNum_comDataOut_OutputPorts(),
498 static_cast<FwAssertArgType>(portNum)
499 );
500 this->m_comDataOut_OutputPort[portNum].invoke(
501 recvBuffer,
502 recvStatus
503 );
504 }
505
506 void ComStubComponentBase ::
507 comStatus_out(
508 NATIVE_INT_TYPE portNum,
509 Fw::Success& condition
510 )
511 {
512 FW_ASSERT(
513 portNum < this->getNum_comStatus_OutputPorts(),
514 static_cast<FwAssertArgType>(portNum)
515 );
516 this->m_comStatus_OutputPort[portNum].invoke(
517 condition
518 );
519 }
520
521 Drv::SendStatus ComStubComponentBase ::
522 drvDataOut_out(
523 NATIVE_INT_TYPE portNum,
524 Fw::Buffer& sendBuffer
525 )
526 {
527 FW_ASSERT(
528 portNum < this->getNum_drvDataOut_OutputPorts(),
529 static_cast<FwAssertArgType>(portNum)
530 );
531 return this->m_drvDataOut_OutputPort[portNum].invoke(
532 sendBuffer
533 );
534 }
535
536 // ----------------------------------------------------------------------
537 // Calls for messages received on typed input ports
538 // ----------------------------------------------------------------------
539
540 Drv::SendStatus ComStubComponentBase ::
541 m_p_comDataIn_in(
542 Fw::PassiveComponentBase* callComp,
543 NATIVE_INT_TYPE portNum,
544 Fw::Buffer& sendBuffer
545 )
546 {
547 FW_ASSERT(callComp);
548 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
549 return compPtr->comDataIn_handlerBase(
550 portNum,
551 sendBuffer
552 );
553 }
554
555 void ComStubComponentBase ::
556 m_p_drvConnected_in(
557 Fw::PassiveComponentBase* callComp,
558 NATIVE_INT_TYPE portNum
559 )
560 {
561 FW_ASSERT(callComp);
562 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
563 compPtr->drvConnected_handlerBase(portNum);
564 }
565
566 void ComStubComponentBase ::
567 m_p_drvDataIn_in(
568 Fw::PassiveComponentBase* callComp,
569 NATIVE_INT_TYPE portNum,
570 Fw::Buffer& recvBuffer,
571 const Drv::RecvStatus& recvStatus
572 )
573 {
574 FW_ASSERT(callComp);
575 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
576 compPtr->drvDataIn_handlerBase(
577 portNum,
578 recvBuffer,
579 recvStatus
580 );
581 }
582
583}
#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 associated with the received data.
Status returned by the send call.
void init()
Object initializer.
Definition ObjBase.cpp:27
Success/Failure.
Auto-generated base for ComStub component.
Drv::SendStatus comDataIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &sendBuffer)
Handler base-class function for input port comDataIn.
void drvConnected_handlerBase(NATIVE_INT_TYPE portNum)
Handler base-class function for input port drvConnected.