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