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