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