F´ Flight Software - C/C++ Documentation  devel
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 
21  init(FwEnumStoreType instance)
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  this->m_LocalCmd_OutputPort[portNum].invoke(
412  data,
413  context
414  );
415  }
416 
419  FwIndexType portNum,
420  Fw::ComBuffer& data,
421  U32 context
422  )
423  {
424  FW_ASSERT(
425  portNum < this->getNum_RemoteCmd_OutputPorts(),
426  static_cast<FwAssertArgType>(portNum)
427  );
428  this->m_RemoteCmd_OutputPort[portNum].invoke(
429  data,
430  context
431  );
432  }
433 
436  FwIndexType portNum,
437  FwOpcodeType opCode,
438  U32 cmdSeq,
439  const Fw::CmdResponse& response
440  )
441  {
442  FW_ASSERT(
443  portNum < this->getNum_forwardSeqCmdStatus_OutputPorts(),
444  static_cast<FwAssertArgType>(portNum)
445  );
446  this->m_forwardSeqCmdStatus_OutputPort[portNum].invoke(
447  opCode,
448  cmdSeq,
449  response
450  );
451  }
452 
453  // ----------------------------------------------------------------------
454  // Calls for messages received on typed input ports
455  // ----------------------------------------------------------------------
456 
457  void CmdSplitterComponentBase ::
458  m_p_CmdBuff_in(
459  Fw::PassiveComponentBase* callComp,
460  FwIndexType portNum,
461  Fw::ComBuffer& data,
462  U32 context
463  )
464  {
465  FW_ASSERT(callComp);
466  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
467  compPtr->CmdBuff_handlerBase(
468  portNum,
469  data,
470  context
471  );
472  }
473 
474  void CmdSplitterComponentBase ::
475  m_p_seqCmdStatus_in(
476  Fw::PassiveComponentBase* callComp,
477  FwIndexType portNum,
478  FwOpcodeType opCode,
479  U32 cmdSeq,
480  const Fw::CmdResponse& response
481  )
482  {
483  FW_ASSERT(callComp);
484  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
485  compPtr->seqCmdStatus_handlerBase(
486  portNum,
487  opCode,
488  cmdSeq,
489  response
490  );
491  }
492 
493 }
#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
U32 FwOpcodeType
Definition: FpConfig.h:91
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
Enum representing a command response.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
void init()
Initialization function.
Definition: ComPortAc.cpp:56
void setPortNum(NATIVE_INT_TYPE portNum)
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void init()
Initialization function.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke a port interface.
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:143
void init()
Initialization function.
Definition: ComPortAc.cpp:137
void invoke(Fw::ComBuffer &data, U32 context)
Invoke a port interface.
Definition: ComPortAc.cpp:156
bool isConnected()
Definition: PortBase.cpp:41
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
Auto-generated base for CmdSplitter component.
FwIndexType getNum_LocalCmd_OutputPorts() const
FwIndexType getNum_RemoteCmd_OutputPorts() const
void RemoteCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port RemoteCmd.
bool isConnected_RemoteCmd_OutputPort(FwIndexType portNum)
CmdSplitterComponentBase(const char *compName="")
Construct CmdSplitterComponentBase object.
void CmdBuff_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port CmdBuff.
void set_forwardSeqCmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to forwardSeqCmdStatus[portNum].
void set_LocalCmd_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to LocalCmd[portNum].
void seqCmdStatus_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Handler base-class function for input port seqCmdStatus.
virtual void CmdBuff_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port CmdBuff.
virtual ~CmdSplitterComponentBase()
Destroy CmdSplitterComponentBase object.
bool isConnected_forwardSeqCmdStatus_OutputPort(FwIndexType portNum)
void forwardSeqCmdStatus_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port forwardSeqCmdStatus.
FwIndexType getNum_seqCmdStatus_InputPorts() const
FwIndexType getNum_forwardSeqCmdStatus_OutputPorts() const
bool isConnected_LocalCmd_OutputPort(FwIndexType portNum)
void set_RemoteCmd_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to RemoteCmd[portNum].
virtual void seqCmdStatus_handler(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)=0
Handler for input port seqCmdStatus.
Fw::InputComPort * get_CmdBuff_InputPort(FwIndexType portNum)
Fw::InputCmdResponsePort * get_seqCmdStatus_InputPort(FwIndexType portNum)
void LocalCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port LocalCmd.