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