F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Svc {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
22  {
23  // Initialize base class
25 
26  // Connect input port CmdBuff
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_CmdBuff_InputPorts());
30  port++
31  ) {
32  this->m_CmdBuff_InputPort[port].init();
33  this->m_CmdBuff_InputPort[port].addCallComp(
34  this,
35  m_p_CmdBuff_in
36  );
37  this->m_CmdBuff_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_CmdBuff_InputPort[%" PRI_PlatformIntType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_CmdBuff_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect input port seqCmdStatus
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_seqCmdStatus_InputPorts());
54  port++
55  ) {
56  this->m_seqCmdStatus_InputPort[port].init();
57  this->m_seqCmdStatus_InputPort[port].addCallComp(
58  this,
59  m_p_seqCmdStatus_in
60  );
61  this->m_seqCmdStatus_InputPort[port].setPortNum(port);
62 
63 #if FW_OBJECT_NAMES == 1
64  Fw::ObjectName portName;
65  portName.format(
66  "%s_seqCmdStatus_InputPort[%" PRI_PlatformIntType "]",
67  this->m_objName.toChar(),
68  port
69  );
70  this->m_seqCmdStatus_InputPort[port].setObjName(portName.toChar());
71 #endif
72  }
73 
74  // Connect output port LocalCmd
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_LocalCmd_OutputPorts());
78  port++
79  ) {
80  this->m_LocalCmd_OutputPort[port].init();
81 
82 #if FW_OBJECT_NAMES == 1
83  Fw::ObjectName portName;
84  portName.format(
85  "%s_LocalCmd_OutputPort[%" PRI_PlatformIntType "]",
86  this->m_objName.toChar(),
87  port
88  );
89  this->m_LocalCmd_OutputPort[port].setObjName(portName.toChar());
90 #endif
91  }
92 
93  // Connect output port RemoteCmd
94  for (
95  FwIndexType port = 0;
96  port < static_cast<FwIndexType>(this->getNum_RemoteCmd_OutputPorts());
97  port++
98  ) {
99  this->m_RemoteCmd_OutputPort[port].init();
100 
101 #if FW_OBJECT_NAMES == 1
102  Fw::ObjectName portName;
103  portName.format(
104  "%s_RemoteCmd_OutputPort[%" PRI_PlatformIntType "]",
105  this->m_objName.toChar(),
106  port
107  );
108  this->m_RemoteCmd_OutputPort[port].setObjName(portName.toChar());
109 #endif
110  }
111 
112  // Connect output port forwardSeqCmdStatus
113  for (
114  FwIndexType port = 0;
115  port < static_cast<FwIndexType>(this->getNum_forwardSeqCmdStatus_OutputPorts());
116  port++
117  ) {
118  this->m_forwardSeqCmdStatus_OutputPort[port].init();
119 
120 #if FW_OBJECT_NAMES == 1
121  Fw::ObjectName portName;
122  portName.format(
123  "%s_forwardSeqCmdStatus_OutputPort[%" PRI_PlatformIntType "]",
124  this->m_objName.toChar(),
125  port
126  );
127  this->m_forwardSeqCmdStatus_OutputPort[port].setObjName(portName.toChar());
128 #endif
129  }
130  }
131 
132  // ----------------------------------------------------------------------
133  // Getters for typed input ports
134  // ----------------------------------------------------------------------
135 
138  {
139  FW_ASSERT(
140  portNum < this->getNum_CmdBuff_InputPorts(),
141  static_cast<FwAssertArgType>(portNum)
142  );
143 
144  return &this->m_CmdBuff_InputPort[portNum];
145  }
146 
149  {
150  FW_ASSERT(
151  portNum < this->getNum_seqCmdStatus_InputPorts(),
152  static_cast<FwAssertArgType>(portNum)
153  );
154 
155  return &this->m_seqCmdStatus_InputPort[portNum];
156  }
157 
158  // ----------------------------------------------------------------------
159  // Connect typed input ports to typed output ports
160  // ----------------------------------------------------------------------
161 
164  FwIndexType portNum,
165  Fw::InputComPort* port
166  )
167  {
168  FW_ASSERT(
169  portNum < this->getNum_LocalCmd_OutputPorts(),
170  static_cast<FwAssertArgType>(portNum)
171  );
172 
173  this->m_LocalCmd_OutputPort[portNum].addCallPort(port);
174  }
175 
178  FwIndexType portNum,
179  Fw::InputComPort* port
180  )
181  {
182  FW_ASSERT(
183  portNum < this->getNum_RemoteCmd_OutputPorts(),
184  static_cast<FwAssertArgType>(portNum)
185  );
186 
187  this->m_RemoteCmd_OutputPort[portNum].addCallPort(port);
188  }
189 
192  FwIndexType portNum,
194  )
195  {
196  FW_ASSERT(
197  portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
198  static_cast<FwAssertArgType>(portNum)
199  );
200 
201  this->m_forwardSeqCmdStatus_OutputPort[portNum].addCallPort(port);
202  }
203 
204 #if FW_PORT_SERIALIZATION
205 
206  // ----------------------------------------------------------------------
207  // Connect serial input ports to typed output ports
208  // ----------------------------------------------------------------------
209 
212  FwIndexType portNum,
213  Fw::InputSerializePort* port
214  )
215  {
216  FW_ASSERT(
217  portNum < this->getNum_LocalCmd_OutputPorts(),
218  static_cast<FwAssertArgType>(portNum)
219  );
220 
221  this->m_LocalCmd_OutputPort[portNum].registerSerialPort(port);
222  }
223 
226  FwIndexType portNum,
227  Fw::InputSerializePort* port
228  )
229  {
230  FW_ASSERT(
231  portNum < this->getNum_RemoteCmd_OutputPorts(),
232  static_cast<FwAssertArgType>(portNum)
233  );
234 
235  this->m_RemoteCmd_OutputPort[portNum].registerSerialPort(port);
236  }
237 
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  )
243  {
244  FW_ASSERT(
245  portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
246  static_cast<FwAssertArgType>(portNum)
247  );
248 
249  this->m_forwardSeqCmdStatus_OutputPort[portNum].registerSerialPort(port);
250  }
251 
252 #endif
253 
254  // ----------------------------------------------------------------------
255  // Component construction and destruction
256  // ----------------------------------------------------------------------
257 
259  CmdSplitterComponentBase(const char* compName) :
260  Fw::PassiveComponentBase(compName)
261  {
262 
263  }
264 
267  {
268 
269  }
270 
271  // ----------------------------------------------------------------------
272  // Getters for numbers of typed input ports
273  // ----------------------------------------------------------------------
274 
277  {
278  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdBuff_InputPort));
279  }
280 
283  {
284  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_seqCmdStatus_InputPort));
285  }
286 
287  // ----------------------------------------------------------------------
288  // Getters for numbers of typed output ports
289  // ----------------------------------------------------------------------
290 
293  {
294  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LocalCmd_OutputPort));
295  }
296 
299  {
300  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_RemoteCmd_OutputPort));
301  }
302 
305  {
306  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_forwardSeqCmdStatus_OutputPort));
307  }
308 
309  // ----------------------------------------------------------------------
310  // Connection status queries for typed output ports
311  // ----------------------------------------------------------------------
312 
315  {
316  FW_ASSERT(
317  portNum < this->getNum_LocalCmd_OutputPorts(),
318  static_cast<FwAssertArgType>(portNum)
319  );
320 
321  return this->m_LocalCmd_OutputPort[portNum].isConnected();
322  }
323 
326  {
327  FW_ASSERT(
328  portNum < this->getNum_RemoteCmd_OutputPorts(),
329  static_cast<FwAssertArgType>(portNum)
330  );
331 
332  return this->m_RemoteCmd_OutputPort[portNum].isConnected();
333  }
334 
337  {
338  FW_ASSERT(
339  portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
340  static_cast<FwAssertArgType>(portNum)
341  );
342 
343  return this->m_forwardSeqCmdStatus_OutputPort[portNum].isConnected();
344  }
345 
346  // ----------------------------------------------------------------------
347  // Port handler base-class functions for typed input ports
348  //
349  // Call these functions directly to bypass the corresponding ports
350  // ----------------------------------------------------------------------
351 
354  FwIndexType portNum,
355  Fw::ComBuffer& data,
356  U32 context
357  )
358  {
359  // Make sure port number is valid
360  FW_ASSERT(
361  portNum < this->getNum_CmdBuff_InputPorts(),
362  static_cast<FwAssertArgType>(portNum)
363  );
364 
365  // Call handler function
366  this->CmdBuff_handler(
367  portNum,
368  data,
369  context
370  );
371  }
372 
375  FwIndexType portNum,
376  FwOpcodeType opCode,
377  U32 cmdSeq,
378  const Fw::CmdResponse& response
379  )
380  {
381  // Make sure port number is valid
382  FW_ASSERT(
383  portNum < this->getNum_seqCmdStatus_InputPorts(),
384  static_cast<FwAssertArgType>(portNum)
385  );
386 
387  // Call handler function
388  this->seqCmdStatus_handler(
389  portNum,
390  opCode,
391  cmdSeq,
392  response
393  );
394  }
395 
396  // ----------------------------------------------------------------------
397  // Invocation functions for typed output ports
398  // ----------------------------------------------------------------------
399 
402  FwIndexType portNum,
403  Fw::ComBuffer& data,
404  U32 context
405  )
406  {
407  FW_ASSERT(
408  portNum < this->getNum_LocalCmd_OutputPorts(),
409  static_cast<FwAssertArgType>(portNum)
410  );
411 
412  FW_ASSERT(
413  this->m_LocalCmd_OutputPort[portNum].isConnected(),
414  static_cast<FwAssertArgType>(portNum)
415  );
416  this->m_LocalCmd_OutputPort[portNum].invoke(
417  data,
418  context
419  );
420  }
421 
424  FwIndexType portNum,
425  Fw::ComBuffer& data,
426  U32 context
427  )
428  {
429  FW_ASSERT(
430  portNum < this->getNum_RemoteCmd_OutputPorts(),
431  static_cast<FwAssertArgType>(portNum)
432  );
433 
434  FW_ASSERT(
435  this->m_RemoteCmd_OutputPort[portNum].isConnected(),
436  static_cast<FwAssertArgType>(portNum)
437  );
438  this->m_RemoteCmd_OutputPort[portNum].invoke(
439  data,
440  context
441  );
442  }
443 
446  FwIndexType portNum,
447  FwOpcodeType opCode,
448  U32 cmdSeq,
449  const Fw::CmdResponse& response
450  )
451  {
452  FW_ASSERT(
453  portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
454  static_cast<FwAssertArgType>(portNum)
455  );
456 
457  FW_ASSERT(
458  this->m_forwardSeqCmdStatus_OutputPort[portNum].isConnected(),
459  static_cast<FwAssertArgType>(portNum)
460  );
461  this->m_forwardSeqCmdStatus_OutputPort[portNum].invoke(
462  opCode,
463  cmdSeq,
464  response
465  );
466  }
467 
468  // ----------------------------------------------------------------------
469  // Calls for messages received on typed input ports
470  // ----------------------------------------------------------------------
471 
472  void CmdSplitterComponentBase ::
473  m_p_CmdBuff_in(
474  Fw::PassiveComponentBase* callComp,
475  FwIndexType portNum,
476  Fw::ComBuffer& data,
477  U32 context
478  )
479  {
480  FW_ASSERT(callComp);
481  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
482  compPtr->CmdBuff_handlerBase(
483  portNum,
484  data,
485  context
486  );
487  }
488 
489  void CmdSplitterComponentBase ::
490  m_p_seqCmdStatus_in(
491  Fw::PassiveComponentBase* callComp,
492  FwIndexType portNum,
493  FwOpcodeType opCode,
494  U32 cmdSeq,
495  const Fw::CmdResponse& response
496  )
497  {
498  FW_ASSERT(callComp);
499  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
500  compPtr->seqCmdStatus_handlerBase(
501  portNum,
502  opCode,
503  cmdSeq,
504  response
505  );
506  }
507 
508 }
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port interface.
Definition: ComPortAc.cpp:156
void init()
Initialization function.
Definition: ComPortAc.cpp:137
void LocalCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port LocalCmd.
bool isConnected_forwardSeqCmdStatus_OutputPort(FwIndexType portNum)
I32 FwEnumStoreType
Definition: FpConfig.h:64
Fw::InputCmdResponsePort * get_seqCmdStatus_InputPort(FwIndexType portNum)
CmdSplitterComponentBase(const char *compName="")
Construct CmdSplitterComponentBase object.
Enum representing a command response.
bool isConnected_LocalCmd_OutputPort(FwIndexType portNum)
virtual ~CmdSplitterComponentBase()
Destroy CmdSplitterComponentBase object.
virtual void CmdBuff_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port CmdBuff.
void forwardSeqCmdStatus_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port forwardSeqCmdStatus.
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
FwIndexType getNum_RemoteCmd_OutputPorts() const
void init()
Object initializer.
Definition: ObjBase.cpp:26
void set_LocalCmd_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to LocalCmd[portNum].
void init()
Initialization function.
Definition: ComPortAc.cpp:56
FwIndexType getNum_LocalCmd_OutputPorts() const
FwIndexType getNum_seqCmdStatus_InputPorts() const
void set_RemoteCmd_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to RemoteCmd[portNum].
Auto-generated base for CmdSplitter component.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
U32 FwOpcodeType
Definition: FpConfig.h:91
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
const char * toChar() const
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
bool isConnected_RemoteCmd_OutputPort(FwIndexType portNum)
void CmdBuff_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port CmdBuff.
bool isConnected() const
Definition: PortBase.cpp:42
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
Fw::InputComPort * get_CmdBuff_InputPort(FwIndexType portNum)
void setPortNum(FwIndexType portNum)
FwIndexType getNum_forwardSeqCmdStatus_OutputPorts() const
void init()
Initialization function.
void set_forwardSeqCmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to forwardSeqCmdStatus[portNum].
void RemoteCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port RemoteCmd.
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:85
void init()
Initialization function.
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:143
virtual void seqCmdStatus_handler(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)=0
Handler for input port seqCmdStatus.
void seqCmdStatus_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Handler base-class function for input port seqCmdStatus.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.