F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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 <cstdio>
8
10#include "Fw/Types/Assert.hpp"
11#if FW_ENABLE_TEXT_LOGGING
12#include "Fw/Types/String.hpp"
13#endif
14
15namespace Svc {
16
17 namespace {
18 // Get the max size by doing a union of the input and internal port serialization sizes
19 union BuffUnion {
21 };
22
23 // Define a message buffer class large enough to handle all the
24 // asynchronous inputs to the component
25 class ComponentIpcSerializableBuffer :
27 {
28
29 public:
30
31 enum {
32 // Max. message size = size of data + message id + port
33 SERIALIZATION_SIZE =
34 sizeof(BuffUnion) +
35 sizeof(NATIVE_INT_TYPE) +
36 sizeof(NATIVE_INT_TYPE)
37 };
38
39 NATIVE_UINT_TYPE getBuffCapacity() const {
40 return sizeof(m_buff);
41 }
42
43 U8* getBuffAddr() {
44 return m_buff;
45 }
46
47 const U8* getBuffAddr() const {
48 return m_buff;
49 }
50
51 private:
52 // Should be the max of all the input ports serialized sizes...
53 U8 m_buff[SERIALIZATION_SIZE];
54
55 };
56 }
57
58 // ----------------------------------------------------------------------
59 // Component initialization
60 // ----------------------------------------------------------------------
61
62 void ComSplitterComponentBase ::
63 init(NATIVE_INT_TYPE instance)
64 {
65 // Initialize base class
67
68 // Connect input port comIn
69 for (
70 PlatformIntType port = 0;
71 port < static_cast<PlatformIntType>(this->getNum_comIn_InputPorts());
72 port++
73 ) {
74 this->m_comIn_InputPort[port].init();
75 this->m_comIn_InputPort[port].addCallComp(
76 this,
77 m_p_comIn_in
78 );
79 this->m_comIn_InputPort[port].setPortNum(port);
80
81#if FW_OBJECT_NAMES == 1
82 char portName[120];
83 (void) snprintf(
84 portName,
85 sizeof(portName),
86 "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
87 this->m_objName,
88 port
89 );
90 this->m_comIn_InputPort[port].setObjName(portName);
91#endif
92 }
93
94 // Connect output port comOut
95 for (
96 PlatformIntType port = 0;
97 port < static_cast<PlatformIntType>(this->getNum_comOut_OutputPorts());
98 port++
99 ) {
100 this->m_comOut_OutputPort[port].init();
101
102#if FW_OBJECT_NAMES == 1
103 char portName[120];
104 (void) snprintf(
105 portName,
106 sizeof(portName),
107 "%s_comOut_OutputPort[%" PRI_PlatformIntType "]",
108 this->m_objName,
109 port
110 );
111 this->m_comOut_OutputPort[port].setObjName(portName);
112#endif
113 }
114 }
115
116 // ----------------------------------------------------------------------
117 // Getters for typed input ports
118 // ----------------------------------------------------------------------
119
120 Fw::InputComPort* ComSplitterComponentBase ::
121 get_comIn_InputPort(NATIVE_INT_TYPE portNum)
122 {
123 FW_ASSERT(
124 portNum < this->getNum_comIn_InputPorts(),
125 static_cast<FwAssertArgType>(portNum)
126 );
127
128 return &this->m_comIn_InputPort[portNum];
129 }
130
131 // ----------------------------------------------------------------------
132 // Connect typed input ports to typed output ports
133 // ----------------------------------------------------------------------
134
135 void ComSplitterComponentBase ::
136 set_comOut_OutputPort(
137 NATIVE_INT_TYPE portNum,
138 Fw::InputComPort* port
139 )
140 {
141 FW_ASSERT(
142 portNum < this->getNum_comOut_OutputPorts(),
143 static_cast<FwAssertArgType>(portNum)
144 );
145
146 this->m_comOut_OutputPort[portNum].addCallPort(port);
147 }
148
149#if FW_PORT_SERIALIZATION
150
151 // ----------------------------------------------------------------------
152 // Connect serial input ports to typed output ports
153 // ----------------------------------------------------------------------
154
155 void ComSplitterComponentBase ::
156 set_comOut_OutputPort(
157 NATIVE_INT_TYPE portNum,
158 Fw::InputSerializePort* port
159 )
160 {
161 FW_ASSERT(
162 portNum < this->getNum_comOut_OutputPorts(),
163 static_cast<FwAssertArgType>(portNum)
164 );
165
166 this->m_comOut_OutputPort[portNum].registerSerialPort(port);
167 }
168
169#endif
170
171 // ----------------------------------------------------------------------
172 // Component construction and destruction
173 // ----------------------------------------------------------------------
174
175 ComSplitterComponentBase ::
176 ComSplitterComponentBase(const char* compName) :
177 Fw::PassiveComponentBase(compName)
178 {
179
180 }
181
182 ComSplitterComponentBase ::
183 ~ComSplitterComponentBase()
184 {
185
186 }
187
188 // ----------------------------------------------------------------------
189 // Getters for numbers of typed input ports
190 // ----------------------------------------------------------------------
191
192 NATIVE_INT_TYPE ComSplitterComponentBase ::
193 getNum_comIn_InputPorts()
194 {
195 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
196 }
197
198 // ----------------------------------------------------------------------
199 // Getters for numbers of typed output ports
200 // ----------------------------------------------------------------------
201
202 NATIVE_INT_TYPE ComSplitterComponentBase ::
203 getNum_comOut_OutputPorts()
204 {
205 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comOut_OutputPort));
206 }
207
208 // ----------------------------------------------------------------------
209 // Connection status queries for typed output ports
210 // ----------------------------------------------------------------------
211
212 bool ComSplitterComponentBase ::
213 isConnected_comOut_OutputPort(NATIVE_INT_TYPE portNum)
214 {
215 FW_ASSERT(
216 portNum < this->getNum_comOut_OutputPorts(),
217 static_cast<FwAssertArgType>(portNum)
218 );
219
220 return this->m_comOut_OutputPort[portNum].isConnected();
221 }
222
223 // ----------------------------------------------------------------------
224 // Port handler base-class functions for typed input ports
225 //
226 // Call these functions directly to bypass the corresponding ports
227 // ----------------------------------------------------------------------
228
229 void ComSplitterComponentBase ::
230 comIn_handlerBase(
231 NATIVE_INT_TYPE portNum,
232 Fw::ComBuffer& data,
233 U32 context
234 )
235 {
236 // Make sure port number is valid
237 FW_ASSERT(
238 portNum < this->getNum_comIn_InputPorts(),
239 static_cast<FwAssertArgType>(portNum)
240 );
241
242 // Down call to pure virtual handler method implemented in Impl class
243 this->comIn_handler(
244 portNum,
245 data,
246 context
247 );
248 }
249
250 // ----------------------------------------------------------------------
251 // Invocation functions for typed output ports
252 // ----------------------------------------------------------------------
253
254 void ComSplitterComponentBase ::
255 comOut_out(
256 NATIVE_INT_TYPE portNum,
257 Fw::ComBuffer& data,
258 U32 context
259 )
260 {
261 FW_ASSERT(
262 portNum < this->getNum_comOut_OutputPorts(),
263 static_cast<FwAssertArgType>(portNum)
264 );
265 this->m_comOut_OutputPort[portNum].invoke(
266 data,
267 context
268 );
269 }
270
271 // ----------------------------------------------------------------------
272 // Calls for messages received on typed input ports
273 // ----------------------------------------------------------------------
274
275 void ComSplitterComponentBase ::
276 m_p_comIn_in(
277 Fw::PassiveComponentBase* callComp,
278 NATIVE_INT_TYPE portNum,
279 Fw::ComBuffer& data,
280 U32 context
281 )
282 {
283 FW_ASSERT(callComp);
284 ComSplitterComponentBase* compPtr = static_cast<ComSplitterComponentBase*>(callComp);
285 compPtr->comIn_handlerBase(
286 portNum,
287 data,
288 context
289 );
290 }
291
292}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition ComPortAc.hpp:37
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for ComSplitter component.
void comIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.