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
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 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 ComStubComponentBase ::
65 init(NATIVE_INT_TYPE instance)
66 {
67 // Initialize base class
69
70 // Connect input port comDataIn
71 for (
72 PlatformIntType port = 0;
73 port < static_cast<PlatformIntType>(this->getNum_comDataIn_InputPorts());
74 port++
75 ) {
76 this->m_comDataIn_InputPort[port].init();
77 this->m_comDataIn_InputPort[port].addCallComp(
78 this,
79 m_p_comDataIn_in
80 );
81 this->m_comDataIn_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_comDataIn_InputPort[%" PRI_PlatformIntType "]",
89 this->m_objName,
90 port
91 );
92 this->m_comDataIn_InputPort[port].setObjName(portName);
93#endif
94 }
95
96 // Connect input port drvConnected
97 for (
98 PlatformIntType port = 0;
99 port < static_cast<PlatformIntType>(this->getNum_drvConnected_InputPorts());
100 port++
101 ) {
102 this->m_drvConnected_InputPort[port].init();
103 this->m_drvConnected_InputPort[port].addCallComp(
104 this,
105 m_p_drvConnected_in
106 );
107 this->m_drvConnected_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_drvConnected_InputPort[%" PRI_PlatformIntType "]",
115 this->m_objName,
116 port
117 );
118 this->m_drvConnected_InputPort[port].setObjName(portName);
119#endif
120 }
121
122 // Connect input port drvDataIn
123 for (
124 PlatformIntType port = 0;
125 port < static_cast<PlatformIntType>(this->getNum_drvDataIn_InputPorts());
126 port++
127 ) {
128 this->m_drvDataIn_InputPort[port].init();
129 this->m_drvDataIn_InputPort[port].addCallComp(
130 this,
131 m_p_drvDataIn_in
132 );
133 this->m_drvDataIn_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_drvDataIn_InputPort[%" PRI_PlatformIntType "]",
141 this->m_objName,
142 port
143 );
144 this->m_drvDataIn_InputPort[port].setObjName(portName);
145#endif
146 }
147
148 // Connect output port comDataOut
149 for (
150 PlatformIntType port = 0;
151 port < static_cast<PlatformIntType>(this->getNum_comDataOut_OutputPorts());
152 port++
153 ) {
154 this->m_comDataOut_OutputPort[port].init();
155
156#if FW_OBJECT_NAMES == 1
157 char portName[120];
158 (void) snprintf(
159 portName,
160 sizeof(portName),
161 "%s_comDataOut_OutputPort[%" PRI_PlatformIntType "]",
162 this->m_objName,
163 port
164 );
165 this->m_comDataOut_OutputPort[port].setObjName(portName);
166#endif
167 }
168
169 // Connect output port comStatus
170 for (
171 PlatformIntType port = 0;
172 port < static_cast<PlatformIntType>(this->getNum_comStatus_OutputPorts());
173 port++
174 ) {
175 this->m_comStatus_OutputPort[port].init();
176
177#if FW_OBJECT_NAMES == 1
178 char portName[120];
179 (void) snprintf(
180 portName,
181 sizeof(portName),
182 "%s_comStatus_OutputPort[%" PRI_PlatformIntType "]",
183 this->m_objName,
184 port
185 );
186 this->m_comStatus_OutputPort[port].setObjName(portName);
187#endif
188 }
189
190 // Connect output port drvDataOut
191 for (
192 PlatformIntType port = 0;
193 port < static_cast<PlatformIntType>(this->getNum_drvDataOut_OutputPorts());
194 port++
195 ) {
196 this->m_drvDataOut_OutputPort[port].init();
197
198#if FW_OBJECT_NAMES == 1
199 char portName[120];
200 (void) snprintf(
201 portName,
202 sizeof(portName),
203 "%s_drvDataOut_OutputPort[%" PRI_PlatformIntType "]",
204 this->m_objName,
205 port
206 );
207 this->m_drvDataOut_OutputPort[port].setObjName(portName);
208#endif
209 }
210 }
211
212 // ----------------------------------------------------------------------
213 // Getters for typed input ports
214 // ----------------------------------------------------------------------
215
216 Drv::InputByteStreamSendPort* ComStubComponentBase ::
217 get_comDataIn_InputPort(NATIVE_INT_TYPE portNum)
218 {
219 FW_ASSERT(
220 portNum < this->getNum_comDataIn_InputPorts(),
221 static_cast<FwAssertArgType>(portNum)
222 );
223
224 return &this->m_comDataIn_InputPort[portNum];
225 }
226
227 Drv::InputByteStreamReadyPort* ComStubComponentBase ::
228 get_drvConnected_InputPort(NATIVE_INT_TYPE portNum)
229 {
230 FW_ASSERT(
231 portNum < this->getNum_drvConnected_InputPorts(),
232 static_cast<FwAssertArgType>(portNum)
233 );
234
235 return &this->m_drvConnected_InputPort[portNum];
236 }
237
238 Drv::InputByteStreamRecvPort* ComStubComponentBase ::
239 get_drvDataIn_InputPort(NATIVE_INT_TYPE portNum)
240 {
241 FW_ASSERT(
242 portNum < this->getNum_drvDataIn_InputPorts(),
243 static_cast<FwAssertArgType>(portNum)
244 );
245
246 return &this->m_drvDataIn_InputPort[portNum];
247 }
248
249 // ----------------------------------------------------------------------
250 // Connect typed input ports to typed output ports
251 // ----------------------------------------------------------------------
252
253 void ComStubComponentBase ::
254 set_comDataOut_OutputPort(
255 NATIVE_INT_TYPE portNum,
257 )
258 {
259 FW_ASSERT(
260 portNum < this->getNum_comDataOut_OutputPorts(),
261 static_cast<FwAssertArgType>(portNum)
262 );
263
264 this->m_comDataOut_OutputPort[portNum].addCallPort(port);
265 }
266
267 void ComStubComponentBase ::
268 set_comStatus_OutputPort(
269 NATIVE_INT_TYPE portNum,
271 )
272 {
273 FW_ASSERT(
274 portNum < this->getNum_comStatus_OutputPorts(),
275 static_cast<FwAssertArgType>(portNum)
276 );
277
278 this->m_comStatus_OutputPort[portNum].addCallPort(port);
279 }
280
281 void ComStubComponentBase ::
282 set_drvDataOut_OutputPort(
283 NATIVE_INT_TYPE portNum,
285 )
286 {
287 FW_ASSERT(
288 portNum < this->getNum_drvDataOut_OutputPorts(),
289 static_cast<FwAssertArgType>(portNum)
290 );
291
292 this->m_drvDataOut_OutputPort[portNum].addCallPort(port);
293 }
294
295#if FW_PORT_SERIALIZATION
296
297 // ----------------------------------------------------------------------
298 // Connect serial input ports to typed output ports
299 // ----------------------------------------------------------------------
300
301 void ComStubComponentBase ::
302 set_comDataOut_OutputPort(
303 NATIVE_INT_TYPE portNum,
304 Fw::InputSerializePort* port
305 )
306 {
307 FW_ASSERT(
308 portNum < this->getNum_comDataOut_OutputPorts(),
309 static_cast<FwAssertArgType>(portNum)
310 );
311
312 this->m_comDataOut_OutputPort[portNum].registerSerialPort(port);
313 }
314
315 void ComStubComponentBase ::
316 set_comStatus_OutputPort(
317 NATIVE_INT_TYPE portNum,
318 Fw::InputSerializePort* port
319 )
320 {
321 FW_ASSERT(
322 portNum < this->getNum_comStatus_OutputPorts(),
323 static_cast<FwAssertArgType>(portNum)
324 );
325
326 this->m_comStatus_OutputPort[portNum].registerSerialPort(port);
327 }
328
329#endif
330
331 // ----------------------------------------------------------------------
332 // Component construction and destruction
333 // ----------------------------------------------------------------------
334
335 ComStubComponentBase ::
336 ComStubComponentBase(const char* compName) :
337 Fw::PassiveComponentBase(compName)
338 {
339
340 }
341
342 ComStubComponentBase ::
343 ~ComStubComponentBase()
344 {
345
346 }
347
348 // ----------------------------------------------------------------------
349 // Getters for numbers of typed input ports
350 // ----------------------------------------------------------------------
351
352 NATIVE_INT_TYPE ComStubComponentBase ::
353 getNum_comDataIn_InputPorts()
354 {
355 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comDataIn_InputPort));
356 }
357
358 NATIVE_INT_TYPE ComStubComponentBase ::
359 getNum_drvConnected_InputPorts()
360 {
361 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvConnected_InputPort));
362 }
363
364 NATIVE_INT_TYPE ComStubComponentBase ::
365 getNum_drvDataIn_InputPorts()
366 {
367 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvDataIn_InputPort));
368 }
369
370 // ----------------------------------------------------------------------
371 // Getters for numbers of typed output ports
372 // ----------------------------------------------------------------------
373
374 NATIVE_INT_TYPE ComStubComponentBase ::
375 getNum_comDataOut_OutputPorts()
376 {
377 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comDataOut_OutputPort));
378 }
379
380 NATIVE_INT_TYPE ComStubComponentBase ::
381 getNum_comStatus_OutputPorts()
382 {
383 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatus_OutputPort));
384 }
385
386 NATIVE_INT_TYPE ComStubComponentBase ::
387 getNum_drvDataOut_OutputPorts()
388 {
389 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_drvDataOut_OutputPort));
390 }
391
392 // ----------------------------------------------------------------------
393 // Connection status queries for typed output ports
394 // ----------------------------------------------------------------------
395
396 bool ComStubComponentBase ::
397 isConnected_comDataOut_OutputPort(NATIVE_INT_TYPE portNum)
398 {
399 FW_ASSERT(
400 portNum < this->getNum_comDataOut_OutputPorts(),
401 static_cast<FwAssertArgType>(portNum)
402 );
403
404 return this->m_comDataOut_OutputPort[portNum].isConnected();
405 }
406
407 bool ComStubComponentBase ::
408 isConnected_comStatus_OutputPort(NATIVE_INT_TYPE portNum)
409 {
410 FW_ASSERT(
411 portNum < this->getNum_comStatus_OutputPorts(),
412 static_cast<FwAssertArgType>(portNum)
413 );
414
415 return this->m_comStatus_OutputPort[portNum].isConnected();
416 }
417
418 bool ComStubComponentBase ::
419 isConnected_drvDataOut_OutputPort(NATIVE_INT_TYPE portNum)
420 {
421 FW_ASSERT(
422 portNum < this->getNum_drvDataOut_OutputPorts(),
423 static_cast<FwAssertArgType>(portNum)
424 );
425
426 return this->m_drvDataOut_OutputPort[portNum].isConnected();
427 }
428
429 // ----------------------------------------------------------------------
430 // Port handler base-class functions for typed input ports
431 //
432 // Call these functions directly to bypass the corresponding ports
433 // ----------------------------------------------------------------------
434
435 Drv::SendStatus ComStubComponentBase ::
436 comDataIn_handlerBase(
437 NATIVE_INT_TYPE portNum,
438 Fw::Buffer& sendBuffer
439 )
440 {
441 // Make sure port number is valid
442 FW_ASSERT(
443 portNum < this->getNum_comDataIn_InputPorts(),
444 static_cast<FwAssertArgType>(portNum)
445 );
446
447 Drv::SendStatus retVal;
448
449 // Down call to pure virtual handler method implemented in Impl class
450 retVal = this->comDataIn_handler(
451 portNum,
452 sendBuffer
453 );
454
455 return retVal;
456 }
457
458 void ComStubComponentBase ::
459 drvConnected_handlerBase(NATIVE_INT_TYPE portNum)
460 {
461 // Make sure port number is valid
462 FW_ASSERT(
463 portNum < this->getNum_drvConnected_InputPorts(),
464 static_cast<FwAssertArgType>(portNum)
465 );
466
467 // Down call to pure virtual handler method implemented in Impl class
468 this->drvConnected_handler(portNum);
469 }
470
471 void ComStubComponentBase ::
472 drvDataIn_handlerBase(
473 NATIVE_INT_TYPE portNum,
474 Fw::Buffer& recvBuffer,
475 const Drv::RecvStatus& recvStatus
476 )
477 {
478 // Make sure port number is valid
479 FW_ASSERT(
480 portNum < this->getNum_drvDataIn_InputPorts(),
481 static_cast<FwAssertArgType>(portNum)
482 );
483
484 // Down call to pure virtual handler method implemented in Impl class
485 this->drvDataIn_handler(
486 portNum,
487 recvBuffer,
488 recvStatus
489 );
490 }
491
492 // ----------------------------------------------------------------------
493 // Invocation functions for typed output ports
494 // ----------------------------------------------------------------------
495
496 void ComStubComponentBase ::
497 comDataOut_out(
498 NATIVE_INT_TYPE portNum,
499 Fw::Buffer& recvBuffer,
500 const Drv::RecvStatus& recvStatus
501 )
502 {
503 FW_ASSERT(
504 portNum < this->getNum_comDataOut_OutputPorts(),
505 static_cast<FwAssertArgType>(portNum)
506 );
507 this->m_comDataOut_OutputPort[portNum].invoke(
508 recvBuffer,
509 recvStatus
510 );
511 }
512
513 void ComStubComponentBase ::
514 comStatus_out(
515 NATIVE_INT_TYPE portNum,
516 Fw::Success& condition
517 )
518 {
519 FW_ASSERT(
520 portNum < this->getNum_comStatus_OutputPorts(),
521 static_cast<FwAssertArgType>(portNum)
522 );
523 this->m_comStatus_OutputPort[portNum].invoke(
524 condition
525 );
526 }
527
528 Drv::SendStatus ComStubComponentBase ::
529 drvDataOut_out(
530 NATIVE_INT_TYPE portNum,
531 Fw::Buffer& sendBuffer
532 )
533 {
534 FW_ASSERT(
535 portNum < this->getNum_drvDataOut_OutputPorts(),
536 static_cast<FwAssertArgType>(portNum)
537 );
538 return this->m_drvDataOut_OutputPort[portNum].invoke(
539 sendBuffer
540 );
541 }
542
543 // ----------------------------------------------------------------------
544 // Calls for messages received on typed input ports
545 // ----------------------------------------------------------------------
546
547 Drv::SendStatus ComStubComponentBase ::
548 m_p_comDataIn_in(
549 Fw::PassiveComponentBase* callComp,
550 NATIVE_INT_TYPE portNum,
551 Fw::Buffer& sendBuffer
552 )
553 {
554 FW_ASSERT(callComp);
555 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
556 return compPtr->comDataIn_handlerBase(
557 portNum,
558 sendBuffer
559 );
560 }
561
562 void ComStubComponentBase ::
563 m_p_drvConnected_in(
564 Fw::PassiveComponentBase* callComp,
565 NATIVE_INT_TYPE portNum
566 )
567 {
568 FW_ASSERT(callComp);
569 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
570 compPtr->drvConnected_handlerBase(portNum);
571 }
572
573 void ComStubComponentBase ::
574 m_p_drvDataIn_in(
575 Fw::PassiveComponentBase* callComp,
576 NATIVE_INT_TYPE portNum,
577 Fw::Buffer& recvBuffer,
578 const Drv::RecvStatus& recvStatus
579 )
580 {
581 FW_ASSERT(callComp);
582 ComStubComponentBase* compPtr = static_cast<ComStubComponentBase*>(callComp);
583 compPtr->drvDataIn_handlerBase(
584 portNum,
585 recvBuffer,
586 recvStatus
587 );
588 }
589
590}
#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 ByteStreamReady port.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Input ByteStreamRecv port.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Input ByteStreamSend port.
@ 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 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.