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  // Connect input port comIn
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
30  port++
31  ) {
32  this->m_comIn_InputPort[port].init();
33  this->m_comIn_InputPort[port].addCallComp(
34  this,
35  m_p_comIn_in
36  );
37  this->m_comIn_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_comIn_InputPort[%" PRI_FwIndexType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_comIn_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect output port comOut
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_comOut_OutputPorts());
54  port++
55  ) {
56  this->m_comOut_OutputPort[port].init();
57 
58 #if FW_OBJECT_NAMES == 1
59  Fw::ObjectName portName;
60  portName.format(
61  "%s_comOut_OutputPort[%" PRI_FwIndexType "]",
62  this->m_objName.toChar(),
63  port
64  );
65  this->m_comOut_OutputPort[port].setObjName(portName.toChar());
66 #endif
67  }
68  }
69 
70  // ----------------------------------------------------------------------
71  // Getters for typed input ports
72  // ----------------------------------------------------------------------
73 
76  {
77  FW_ASSERT(
78  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
79  static_cast<FwAssertArgType>(portNum)
80  );
81 
82  return &this->m_comIn_InputPort[portNum];
83  }
84 
85  // ----------------------------------------------------------------------
86  // Connect typed input ports to typed output ports
87  // ----------------------------------------------------------------------
88 
91  FwIndexType portNum,
92  Fw::InputComPort* port
93  )
94  {
95  FW_ASSERT(
96  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
97  static_cast<FwAssertArgType>(portNum)
98  );
99 
100  this->m_comOut_OutputPort[portNum].addCallPort(port);
101  }
102 
103 #if FW_PORT_SERIALIZATION
104 
105  // ----------------------------------------------------------------------
106  // Connect serial input ports to typed output ports
107  // ----------------------------------------------------------------------
108 
111  FwIndexType portNum,
112  Fw::InputSerializePort* port
113  )
114  {
115  FW_ASSERT(
116  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
117  static_cast<FwAssertArgType>(portNum)
118  );
119 
120  this->m_comOut_OutputPort[portNum].registerSerialPort(port);
121  }
122 
123 #endif
124 
125  // ----------------------------------------------------------------------
126  // Component construction and destruction
127  // ----------------------------------------------------------------------
128 
130  ComSplitterComponentBase(const char* compName) :
131  Fw::PassiveComponentBase(compName)
132  {
133 
134  }
135 
138  {
139 
140  }
141 
142  // ----------------------------------------------------------------------
143  // Connection status queries for typed output ports
144  // ----------------------------------------------------------------------
145 
148  {
149  FW_ASSERT(
150  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
151  static_cast<FwAssertArgType>(portNum)
152  );
153 
154  return this->m_comOut_OutputPort[portNum].isConnected();
155  }
156 
157  // ----------------------------------------------------------------------
158  // Port handler base-class functions for typed input ports
159  //
160  // Call these functions directly to bypass the corresponding ports
161  // ----------------------------------------------------------------------
162 
165  FwIndexType portNum,
166  Fw::ComBuffer& data,
167  U32 context
168  )
169  {
170  // Make sure port number is valid
171  FW_ASSERT(
172  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
173  static_cast<FwAssertArgType>(portNum)
174  );
175 
176  // Call handler function
177  this->comIn_handler(
178  portNum,
179  data,
180  context
181  );
182  }
183 
184  // ----------------------------------------------------------------------
185  // Invocation functions for typed output ports
186  // ----------------------------------------------------------------------
187 
190  FwIndexType portNum,
191  Fw::ComBuffer& data,
192  U32 context
193  )
194  {
195  FW_ASSERT(
196  (0 <= portNum) && (portNum < this->getNum_comOut_OutputPorts()),
197  static_cast<FwAssertArgType>(portNum)
198  );
199 
200  FW_ASSERT(
201  this->m_comOut_OutputPort[portNum].isConnected(),
202  static_cast<FwAssertArgType>(portNum)
203  );
204  this->m_comOut_OutputPort[portNum].invoke(
205  data,
206  context
207  );
208  }
209 
210  // ----------------------------------------------------------------------
211  // Calls for messages received on typed input ports
212  // ----------------------------------------------------------------------
213 
214  void ComSplitterComponentBase ::
215  m_p_comIn_in(
216  Fw::PassiveComponentBase* callComp,
217  FwIndexType portNum,
218  Fw::ComBuffer& data,
219  U32 context
220  )
221  {
222  FW_ASSERT(callComp);
223  ComSplitterComponentBase* compPtr = static_cast<ComSplitterComponentBase*>(callComp);
224  compPtr->comIn_handlerBase(
225  portNum,
226  data,
227  context
228  );
229  }
230 
231 }
bool isConnected_comOut_OutputPort(FwIndexType portNum)
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port interface.
Definition: ComPortAc.cpp:156
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: ComPortAc.cpp:137
I32 FwEnumStoreType
virtual ~ComSplitterComponentBase()
Destroy ComSplitterComponentBase object.
void init()
Object initializer.
Definition: ObjBase.cpp:24
void init()
Initialization function.
Definition: ComPortAc.cpp:56
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:62
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
void comOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comOut.
RateGroupDivider component implementation.
static constexpr FwIndexType getNum_comOut_OutputPorts()
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:143
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.