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  // 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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  // Connection status queries for typed output ports
273  // ----------------------------------------------------------------------
274 
277  {
278  FW_ASSERT(
279  (0 <= portNum) && (portNum < this->getNum_LocalCmd_OutputPorts()),
280  static_cast<FwAssertArgType>(portNum)
281  );
282 
283  return this->m_LocalCmd_OutputPort[portNum].isConnected();
284  }
285 
288  {
289  FW_ASSERT(
290  (0 <= portNum) && (portNum < this->getNum_RemoteCmd_OutputPorts()),
291  static_cast<FwAssertArgType>(portNum)
292  );
293 
294  return this->m_RemoteCmd_OutputPort[portNum].isConnected();
295  }
296 
299  {
300  FW_ASSERT(
301  (0 <= portNum) && (portNum < this->getNum_forwardSeqCmdStatus_OutputPorts()),
302  static_cast<FwAssertArgType>(portNum)
303  );
304 
305  return this->m_forwardSeqCmdStatus_OutputPort[portNum].isConnected();
306  }
307 
308  // ----------------------------------------------------------------------
309  // Port handler base-class functions for typed input ports
310  //
311  // Call these functions directly to bypass the corresponding ports
312  // ----------------------------------------------------------------------
313 
316  FwIndexType portNum,
317  Fw::ComBuffer& data,
318  U32 context
319  )
320  {
321  // Make sure port number is valid
322  FW_ASSERT(
323  (0 <= portNum) && (portNum < this->getNum_CmdBuff_InputPorts()),
324  static_cast<FwAssertArgType>(portNum)
325  );
326 
327  // Call handler function
328  this->CmdBuff_handler(
329  portNum,
330  data,
331  context
332  );
333  }
334 
337  FwIndexType portNum,
338  FwOpcodeType opCode,
339  U32 cmdSeq,
340  const Fw::CmdResponse& response
341  )
342  {
343  // Make sure port number is valid
344  FW_ASSERT(
345  (0 <= portNum) && (portNum < this->getNum_seqCmdStatus_InputPorts()),
346  static_cast<FwAssertArgType>(portNum)
347  );
348 
349  // Call handler function
350  this->seqCmdStatus_handler(
351  portNum,
352  opCode,
353  cmdSeq,
354  response
355  );
356  }
357 
358  // ----------------------------------------------------------------------
359  // Invocation functions for typed output ports
360  // ----------------------------------------------------------------------
361 
364  FwIndexType portNum,
365  Fw::ComBuffer& data,
366  U32 context
367  )
368  {
369  FW_ASSERT(
370  (0 <= portNum) && (portNum < this->getNum_LocalCmd_OutputPorts()),
371  static_cast<FwAssertArgType>(portNum)
372  );
373 
374  FW_ASSERT(
375  this->m_LocalCmd_OutputPort[portNum].isConnected(),
376  static_cast<FwAssertArgType>(portNum)
377  );
378  this->m_LocalCmd_OutputPort[portNum].invoke(
379  data,
380  context
381  );
382  }
383 
386  FwIndexType portNum,
387  Fw::ComBuffer& data,
388  U32 context
389  )
390  {
391  FW_ASSERT(
392  (0 <= portNum) && (portNum < this->getNum_RemoteCmd_OutputPorts()),
393  static_cast<FwAssertArgType>(portNum)
394  );
395 
396  FW_ASSERT(
397  this->m_RemoteCmd_OutputPort[portNum].isConnected(),
398  static_cast<FwAssertArgType>(portNum)
399  );
400  this->m_RemoteCmd_OutputPort[portNum].invoke(
401  data,
402  context
403  );
404  }
405 
408  FwIndexType portNum,
409  FwOpcodeType opCode,
410  U32 cmdSeq,
411  const Fw::CmdResponse& response
412  )
413  {
414  FW_ASSERT(
415  (0 <= portNum) && (portNum < this->getNum_forwardSeqCmdStatus_OutputPorts()),
416  static_cast<FwAssertArgType>(portNum)
417  );
418 
419  FW_ASSERT(
420  this->m_forwardSeqCmdStatus_OutputPort[portNum].isConnected(),
421  static_cast<FwAssertArgType>(portNum)
422  );
423  this->m_forwardSeqCmdStatus_OutputPort[portNum].invoke(
424  opCode,
425  cmdSeq,
426  response
427  );
428  }
429 
430  // ----------------------------------------------------------------------
431  // Calls for messages received on typed input ports
432  // ----------------------------------------------------------------------
433 
434  void CmdSplitterComponentBase ::
435  m_p_CmdBuff_in(
436  Fw::PassiveComponentBase* callComp,
437  FwIndexType portNum,
438  Fw::ComBuffer& data,
439  U32 context
440  )
441  {
442  FW_ASSERT(callComp);
443  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
444  compPtr->CmdBuff_handlerBase(
445  portNum,
446  data,
447  context
448  );
449  }
450 
451  void CmdSplitterComponentBase ::
452  m_p_seqCmdStatus_in(
453  Fw::PassiveComponentBase* callComp,
454  FwIndexType portNum,
455  FwOpcodeType opCode,
456  U32 cmdSeq,
457  const Fw::CmdResponse& response
458  )
459  {
460  FW_ASSERT(callComp);
461  CmdSplitterComponentBase* compPtr = static_cast<CmdSplitterComponentBase*>(callComp);
462  compPtr->seqCmdStatus_handlerBase(
463  portNum,
464  opCode,
465  cmdSeq,
466  response
467  );
468  }
469 
470 }
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port interface.
Definition: ComPortAc.cpp:156
void init()
Initialization function.
Definition: ComPortAc.cpp:137
FwIdType FwOpcodeType
The type of a command opcode.
I32 FwEnumStoreType
void LocalCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port LocalCmd.
bool isConnected_forwardSeqCmdStatus_OutputPort(FwIndexType portNum)
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.
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.
void forwardSeqCmdStatus_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
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:56
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
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.
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:55
Fw::InputComPort * get_CmdBuff_InputPort(FwIndexType portNum)
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].
PlatformIndexType FwIndexType
void RemoteCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port RemoteCmd.
void init()
Initialization function.
RateGroupDivider component implementation.
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:143
Implementation of malloc based allocator.
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.