F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComSplitterComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComSplitterComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComSplitter 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 comIn
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
31  port++
32  ) {
33  this->m_comIn_InputPort[port].init();
34  this->m_comIn_InputPort[port].addCallComp(
35  this,
36  m_p_comIn_in
37  );
38  this->m_comIn_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  Fw::ObjectName portName;
42  portName.format(
43  "%s_comIn_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_comIn_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect output port comOut
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_comOut_OutputPorts());
57  port++
58  ) {
59  this->m_comOut_OutputPort[port].init();
60 
61 #if FW_OBJECT_NAMES == 1
62  Fw::ObjectName portName;
63  portName.format(
64  "%s_comOut_OutputPort[%" PRI_FwIndexType "]",
65  this->m_objName.toChar(),
66  port
67  );
68  this->m_comOut_OutputPort[port].setObjName(portName.toChar());
69 #endif
70  }
71 #endif
72  }
73 
74 #if !FW_DIRECT_PORT_CALLS
75 
76  // ----------------------------------------------------------------------
77  // Getters for typed input ports
78  // ----------------------------------------------------------------------
79 
82  {
83  FW_ASSERT(
84  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
85  static_cast<FwAssertArgType>(portNum)
86  );
87 
88  return &this->m_comIn_InputPort[portNum];
89  }
90 
91 #endif
92 
93 #if !FW_DIRECT_PORT_CALLS
94 
95  // ----------------------------------------------------------------------
96  // Connect typed input ports to typed output ports
97  // ----------------------------------------------------------------------
98 
101  FwIndexType portNum,
102  Fw::InputComPort* port
103  )
104  {
105  FW_ASSERT(
106  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
107  static_cast<FwAssertArgType>(portNum)
108  );
109 
110  this->m_comOut_OutputPort[portNum].addCallPort(port);
111  }
112 
113 #endif
114 
115 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
116 
117  // ----------------------------------------------------------------------
118  // Connect serial input ports to typed output ports
119  // ----------------------------------------------------------------------
120 
123  FwIndexType portNum,
124  Fw::InputSerializePort* port
125  )
126  {
127  FW_ASSERT(
128  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
129  static_cast<FwAssertArgType>(portNum)
130  );
131 
132  this->m_comOut_OutputPort[portNum].registerSerialPort(port);
133  }
134 
135 #endif
136 
137  // ----------------------------------------------------------------------
138  // Component construction and destruction
139  // ----------------------------------------------------------------------
140 
142  ComSplitterComponentBase(const char* compName) :
143  Fw::PassiveComponentBase(compName)
144  {
145 
146  }
147 
150  {
151 
152  }
153 
154 #if !FW_DIRECT_PORT_CALLS
155 
156  // ----------------------------------------------------------------------
157  // Connection status queries for typed output ports
158  // ----------------------------------------------------------------------
159 
162  {
163  FW_ASSERT(
164  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
165  static_cast<FwAssertArgType>(portNum)
166  );
167 
168  return this->m_comOut_OutputPort[portNum].isConnected();
169  }
170 
171 #endif
172 
173  // ----------------------------------------------------------------------
174  // Port handler base-class functions for typed input ports
175  //
176  // Call these functions directly to bypass the corresponding ports
177  // ----------------------------------------------------------------------
178 
181  FwIndexType portNum,
182  Fw::ComBuffer& data,
183  U32 context
184  )
185  {
186  // Make sure port number is valid
187  FW_ASSERT(
188  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
189  static_cast<FwAssertArgType>(portNum)
190  );
191 
192  // Call handler function
193  this->comIn_handler(
194  portNum,
195  data,
196  context
197  );
198  }
199 
200 #if !FW_DIRECT_PORT_CALLS
201 
202  // ----------------------------------------------------------------------
203  // Invocation functions for typed output ports
204  // ----------------------------------------------------------------------
205 
208  FwIndexType portNum,
209  Fw::ComBuffer& data,
210  U32 context
211  ) const
212  {
213  FW_ASSERT(
214  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
215  static_cast<FwAssertArgType>(portNum)
216  );
217 
218  FW_ASSERT(
219  this->m_comOut_OutputPort[portNum].isConnected(),
220  static_cast<FwAssertArgType>(portNum)
221  );
222  this->m_comOut_OutputPort[portNum].invoke(
223  data,
224  context
225  );
226  }
227 
228 #endif
229 
230  // ----------------------------------------------------------------------
231  // Calls for messages received on typed input ports
232  // ----------------------------------------------------------------------
233 
234  void ComSplitterComponentBase ::
235  m_p_comIn_in(
236  Fw::PassiveComponentBase* callComp,
237  FwIndexType portNum,
238  Fw::ComBuffer& data,
239  U32 context
240  )
241  {
242  FW_ASSERT(callComp);
243  ComSplitterComponentBase* compPtr = static_cast<ComSplitterComponentBase*>(callComp);
244  compPtr->comIn_handlerBase(
245  portNum,
246  data,
247  context
248  );
249  }
250 
251 }
void comOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port comOut.
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port connection.
Definition: ComPortAc.cpp:181
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: ComPortAc.cpp:162
I32 FwEnumStoreType
virtual ~ComSplitterComponentBase()
Destroy ComSplitterComponentBase object.
void init()
Object initializer.
Definition: ObjBase.cpp:24
void init()
Initialization function.
Definition: ComPortAc.cpp:81
void comIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:87
bool isConnected_comOut_OutputPort(FwIndexType portNum) const
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void setPortNum(FwIndexType portNum)
Auto-generated base for ComSplitter component.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
static constexpr FwIndexType getNum_comOut_OutputPorts()
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:168
static constexpr FwIndexType getNum_comIn_InputPorts()
void set_comOut_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to comOut[portNum].
Implementation of malloc based allocator.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual void comIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
ComSplitterComponentBase(const char *compName="")
Construct ComSplitterComponentBase object.