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
CmdSplitterComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title CmdSplitterComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for CmdSplitter 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 {
22 };
23
24 // Define a message buffer class large enough to handle all the
25 // asynchronous inputs to the component
26 class ComponentIpcSerializableBuffer :
28 {
29
30 public:
31
32 enum {
33 // Max. message size = size of data + message id + port
34 SERIALIZATION_SIZE =
35 sizeof(BuffUnion) +
36 sizeof(NATIVE_INT_TYPE) +
37 sizeof(NATIVE_INT_TYPE)
38 };
39
40 NATIVE_UINT_TYPE getBuffCapacity() const {
41 return sizeof(m_buff);
42 }
43
44 U8* getBuffAddr() {
45 return m_buff;
46 }
47
48 const U8* getBuffAddr() const {
49 return m_buff;
50 }
51
52 private:
53 // Should be the max of all the input ports serialized sizes...
54 U8 m_buff[SERIALIZATION_SIZE];
55
56 };
57 }
58
59 // ----------------------------------------------------------------------
60 // Component initialization
61 // ----------------------------------------------------------------------
62
63 void CmdSplitterComponentBase ::
64 init(NATIVE_INT_TYPE instance)
65 {
66 // Initialize base class
68
69 // Connect input port CmdBuff
70 for (
71 PlatformIntType port = 0;
72 port < static_cast<PlatformIntType>(this->getNum_CmdBuff_InputPorts());
73 port++
74 ) {
75 this->m_CmdBuff_InputPort[port].init();
76 this->m_CmdBuff_InputPort[port].addCallComp(
77 this,
78 m_p_CmdBuff_in
79 );
80 this->m_CmdBuff_InputPort[port].setPortNum(port);
81
82#if FW_OBJECT_NAMES == 1
83 char portName[120];
84 (void) snprintf(
85 portName,
86 sizeof(portName),
87 "%s_CmdBuff_InputPort[%" PRI_PlatformIntType "]",
88 this->m_objName,
89 port
90 );
91 this->m_CmdBuff_InputPort[port].setObjName(portName);
92#endif
93 }
94
95 // Connect input port seqCmdStatus
96 for (
97 PlatformIntType port = 0;
98 port < static_cast<PlatformIntType>(this->getNum_seqCmdStatus_InputPorts());
99 port++
100 ) {
101 this->m_seqCmdStatus_InputPort[port].init();
102 this->m_seqCmdStatus_InputPort[port].addCallComp(
103 this,
104 m_p_seqCmdStatus_in
105 );
106 this->m_seqCmdStatus_InputPort[port].setPortNum(port);
107
108#if FW_OBJECT_NAMES == 1
109 char portName[120];
110 (void) snprintf(
111 portName,
112 sizeof(portName),
113 "%s_seqCmdStatus_InputPort[%" PRI_PlatformIntType "]",
114 this->m_objName,
115 port
116 );
117 this->m_seqCmdStatus_InputPort[port].setObjName(portName);
118#endif
119 }
120
121 // Connect output port LocalCmd
122 for (
123 PlatformIntType port = 0;
124 port < static_cast<PlatformIntType>(this->getNum_LocalCmd_OutputPorts());
125 port++
126 ) {
127 this->m_LocalCmd_OutputPort[port].init();
128
129#if FW_OBJECT_NAMES == 1
130 char portName[120];
131 (void) snprintf(
132 portName,
133 sizeof(portName),
134 "%s_LocalCmd_OutputPort[%" PRI_PlatformIntType "]",
135 this->m_objName,
136 port
137 );
138 this->m_LocalCmd_OutputPort[port].setObjName(portName);
139#endif
140 }
141
142 // Connect output port RemoteCmd
143 for (
144 PlatformIntType port = 0;
145 port < static_cast<PlatformIntType>(this->getNum_RemoteCmd_OutputPorts());
146 port++
147 ) {
148 this->m_RemoteCmd_OutputPort[port].init();
149
150#if FW_OBJECT_NAMES == 1
151 char portName[120];
152 (void) snprintf(
153 portName,
154 sizeof(portName),
155 "%s_RemoteCmd_OutputPort[%" PRI_PlatformIntType "]",
156 this->m_objName,
157 port
158 );
159 this->m_RemoteCmd_OutputPort[port].setObjName(portName);
160#endif
161 }
162
163 // Connect output port forwardSeqCmdStatus
164 for (
165 PlatformIntType port = 0;
166 port < static_cast<PlatformIntType>(this->getNum_forwardSeqCmdStatus_OutputPorts());
167 port++
168 ) {
169 this->m_forwardSeqCmdStatus_OutputPort[port].init();
170
171#if FW_OBJECT_NAMES == 1
172 char portName[120];
173 (void) snprintf(
174 portName,
175 sizeof(portName),
176 "%s_forwardSeqCmdStatus_OutputPort[%" PRI_PlatformIntType "]",
177 this->m_objName,
178 port
179 );
180 this->m_forwardSeqCmdStatus_OutputPort[port].setObjName(portName);
181#endif
182 }
183 }
184
185 // ----------------------------------------------------------------------
186 // Getters for typed input ports
187 // ----------------------------------------------------------------------
188
189 Fw::InputComPort* CmdSplitterComponentBase ::
190 get_CmdBuff_InputPort(NATIVE_INT_TYPE portNum)
191 {
192 FW_ASSERT(
193 portNum < this->getNum_CmdBuff_InputPorts(),
194 static_cast<FwAssertArgType>(portNum)
195 );
196
197 return &this->m_CmdBuff_InputPort[portNum];
198 }
199
200 Fw::InputCmdResponsePort* CmdSplitterComponentBase ::
201 get_seqCmdStatus_InputPort(NATIVE_INT_TYPE portNum)
202 {
203 FW_ASSERT(
204 portNum < this->getNum_seqCmdStatus_InputPorts(),
205 static_cast<FwAssertArgType>(portNum)
206 );
207
208 return &this->m_seqCmdStatus_InputPort[portNum];
209 }
210
211 // ----------------------------------------------------------------------
212 // Connect typed input ports to typed output ports
213 // ----------------------------------------------------------------------
214
215 void CmdSplitterComponentBase ::
216 set_LocalCmd_OutputPort(
217 NATIVE_INT_TYPE portNum,
218 Fw::InputComPort* port
219 )
220 {
221 FW_ASSERT(
222 portNum < this->getNum_LocalCmd_OutputPorts(),
223 static_cast<FwAssertArgType>(portNum)
224 );
225
226 this->m_LocalCmd_OutputPort[portNum].addCallPort(port);
227 }
228
229 void CmdSplitterComponentBase ::
230 set_RemoteCmd_OutputPort(
231 NATIVE_INT_TYPE portNum,
232 Fw::InputComPort* port
233 )
234 {
235 FW_ASSERT(
236 portNum < this->getNum_RemoteCmd_OutputPorts(),
237 static_cast<FwAssertArgType>(portNum)
238 );
239
240 this->m_RemoteCmd_OutputPort[portNum].addCallPort(port);
241 }
242
243 void CmdSplitterComponentBase ::
244 set_forwardSeqCmdStatus_OutputPort(
245 NATIVE_INT_TYPE portNum,
247 )
248 {
249 FW_ASSERT(
250 portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
251 static_cast<FwAssertArgType>(portNum)
252 );
253
254 this->m_forwardSeqCmdStatus_OutputPort[portNum].addCallPort(port);
255 }
256
257#if FW_PORT_SERIALIZATION
258
259 // ----------------------------------------------------------------------
260 // Connect serial input ports to typed output ports
261 // ----------------------------------------------------------------------
262
263 void CmdSplitterComponentBase ::
264 set_LocalCmd_OutputPort(
265 NATIVE_INT_TYPE portNum,
266 Fw::InputSerializePort* port
267 )
268 {
269 FW_ASSERT(
270 portNum < this->getNum_LocalCmd_OutputPorts(),
271 static_cast<FwAssertArgType>(portNum)
272 );
273
274 this->m_LocalCmd_OutputPort[portNum].registerSerialPort(port);
275 }
276
277 void CmdSplitterComponentBase ::
278 set_RemoteCmd_OutputPort(
279 NATIVE_INT_TYPE portNum,
280 Fw::InputSerializePort* port
281 )
282 {
283 FW_ASSERT(
284 portNum < this->getNum_RemoteCmd_OutputPorts(),
285 static_cast<FwAssertArgType>(portNum)
286 );
287
288 this->m_RemoteCmd_OutputPort[portNum].registerSerialPort(port);
289 }
290
291 void CmdSplitterComponentBase ::
292 set_forwardSeqCmdStatus_OutputPort(
293 NATIVE_INT_TYPE portNum,
294 Fw::InputSerializePort* port
295 )
296 {
297 FW_ASSERT(
298 portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
299 static_cast<FwAssertArgType>(portNum)
300 );
301
302 this->m_forwardSeqCmdStatus_OutputPort[portNum].registerSerialPort(port);
303 }
304
305#endif
306
307 // ----------------------------------------------------------------------
308 // Component construction and destruction
309 // ----------------------------------------------------------------------
310
311 CmdSplitterComponentBase ::
312 CmdSplitterComponentBase(const char* compName) :
313 Fw::PassiveComponentBase(compName)
314 {
315
316 }
317
318 CmdSplitterComponentBase ::
319 ~CmdSplitterComponentBase()
320 {
321
322 }
323
324 // ----------------------------------------------------------------------
325 // Getters for numbers of typed input ports
326 // ----------------------------------------------------------------------
327
328 NATIVE_INT_TYPE CmdSplitterComponentBase ::
329 getNum_CmdBuff_InputPorts()
330 {
331 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdBuff_InputPort));
332 }
333
334 NATIVE_INT_TYPE CmdSplitterComponentBase ::
335 getNum_seqCmdStatus_InputPorts()
336 {
337 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_seqCmdStatus_InputPort));
338 }
339
340 // ----------------------------------------------------------------------
341 // Getters for numbers of typed output ports
342 // ----------------------------------------------------------------------
343
344 NATIVE_INT_TYPE CmdSplitterComponentBase ::
345 getNum_LocalCmd_OutputPorts()
346 {
347 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LocalCmd_OutputPort));
348 }
349
350 NATIVE_INT_TYPE CmdSplitterComponentBase ::
351 getNum_RemoteCmd_OutputPorts()
352 {
353 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_RemoteCmd_OutputPort));
354 }
355
356 NATIVE_INT_TYPE CmdSplitterComponentBase ::
357 getNum_forwardSeqCmdStatus_OutputPorts()
358 {
359 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_forwardSeqCmdStatus_OutputPort));
360 }
361
362 // ----------------------------------------------------------------------
363 // Connection status queries for typed output ports
364 // ----------------------------------------------------------------------
365
366 bool CmdSplitterComponentBase ::
367 isConnected_LocalCmd_OutputPort(NATIVE_INT_TYPE portNum)
368 {
369 FW_ASSERT(
370 portNum < this->getNum_LocalCmd_OutputPorts(),
371 static_cast<FwAssertArgType>(portNum)
372 );
373
374 return this->m_LocalCmd_OutputPort[portNum].isConnected();
375 }
376
377 bool CmdSplitterComponentBase ::
378 isConnected_RemoteCmd_OutputPort(NATIVE_INT_TYPE portNum)
379 {
380 FW_ASSERT(
381 portNum < this->getNum_RemoteCmd_OutputPorts(),
382 static_cast<FwAssertArgType>(portNum)
383 );
384
385 return this->m_RemoteCmd_OutputPort[portNum].isConnected();
386 }
387
388 bool CmdSplitterComponentBase ::
389 isConnected_forwardSeqCmdStatus_OutputPort(NATIVE_INT_TYPE portNum)
390 {
391 FW_ASSERT(
392 portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
393 static_cast<FwAssertArgType>(portNum)
394 );
395
396 return this->m_forwardSeqCmdStatus_OutputPort[portNum].isConnected();
397 }
398
399 // ----------------------------------------------------------------------
400 // Port handler base-class functions for typed input ports
401 //
402 // Call these functions directly to bypass the corresponding ports
403 // ----------------------------------------------------------------------
404
405 void CmdSplitterComponentBase ::
406 CmdBuff_handlerBase(
407 NATIVE_INT_TYPE portNum,
408 Fw::ComBuffer& data,
409 U32 context
410 )
411 {
412 // Make sure port number is valid
413 FW_ASSERT(
414 portNum < this->getNum_CmdBuff_InputPorts(),
415 static_cast<FwAssertArgType>(portNum)
416 );
417
418 // Down call to pure virtual handler method implemented in Impl class
419 this->CmdBuff_handler(
420 portNum,
421 data,
422 context
423 );
424 }
425
426 void CmdSplitterComponentBase ::
427 seqCmdStatus_handlerBase(
428 NATIVE_INT_TYPE portNum,
429 FwOpcodeType opCode,
430 U32 cmdSeq,
431 const Fw::CmdResponse& response
432 )
433 {
434 // Make sure port number is valid
435 FW_ASSERT(
436 portNum < this->getNum_seqCmdStatus_InputPorts(),
437 static_cast<FwAssertArgType>(portNum)
438 );
439
440 // Down call to pure virtual handler method implemented in Impl class
441 this->seqCmdStatus_handler(
442 portNum,
443 opCode,
444 cmdSeq,
445 response
446 );
447 }
448
449 // ----------------------------------------------------------------------
450 // Invocation functions for typed output ports
451 // ----------------------------------------------------------------------
452
453 void CmdSplitterComponentBase ::
454 LocalCmd_out(
455 NATIVE_INT_TYPE portNum,
456 Fw::ComBuffer& data,
457 U32 context
458 )
459 {
460 FW_ASSERT(
461 portNum < this->getNum_LocalCmd_OutputPorts(),
462 static_cast<FwAssertArgType>(portNum)
463 );
464 this->m_LocalCmd_OutputPort[portNum].invoke(
465 data,
466 context
467 );
468 }
469
470 void CmdSplitterComponentBase ::
471 RemoteCmd_out(
472 NATIVE_INT_TYPE portNum,
473 Fw::ComBuffer& data,
474 U32 context
475 )
476 {
477 FW_ASSERT(
478 portNum < this->getNum_RemoteCmd_OutputPorts(),
479 static_cast<FwAssertArgType>(portNum)
480 );
481 this->m_RemoteCmd_OutputPort[portNum].invoke(
482 data,
483 context
484 );
485 }
486
487 void CmdSplitterComponentBase ::
488 forwardSeqCmdStatus_out(
489 NATIVE_INT_TYPE portNum,
490 FwOpcodeType opCode,
491 U32 cmdSeq,
492 const Fw::CmdResponse& response
493 )
494 {
495 FW_ASSERT(
496 portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
497 static_cast<FwAssertArgType>(portNum)
498 );
499 this->m_forwardSeqCmdStatus_OutputPort[portNum].invoke(
500 opCode,
501 cmdSeq,
502 response
503 );
504 }
505
506 // ----------------------------------------------------------------------
507 // Calls for messages received on typed input ports
508 // ----------------------------------------------------------------------
509
510 void CmdSplitterComponentBase ::
511 m_p_CmdBuff_in(
512 Fw::PassiveComponentBase* callComp,
513 NATIVE_INT_TYPE portNum,
514 Fw::ComBuffer& data,
515 U32 context
516 )
517 {
518 FW_ASSERT(callComp);
519 CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
520 compPtr->CmdBuff_handlerBase(
521 portNum,
522 data,
523 context
524 );
525 }
526
527 void CmdSplitterComponentBase ::
528 m_p_seqCmdStatus_in(
529 Fw::PassiveComponentBase* callComp,
530 NATIVE_INT_TYPE portNum,
531 FwOpcodeType opCode,
532 U32 cmdSeq,
533 const Fw::CmdResponse& response
534 )
535 {
536 FW_ASSERT(callComp);
537 CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
539 portNum,
540 opCode,
541 cmdSeq,
542 response
543 );
544 }
545
546}
#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
U32 FwOpcodeType
Definition FpConfig.h:56
Enum representing a command response.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition ComPortAc.hpp:37
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for CmdSplitter component.
void seqCmdStatus_handlerBase(NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Handler base-class function for input port seqCmdStatus.
void CmdBuff_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port CmdBuff.