F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
TcpServerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title TcpServerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for TcpServer component base class
5// ======================================================================
6
8#include "Fw/Types/Assert.hpp"
10#if FW_ENABLE_TEXT_LOGGING
11#include "Fw/Types/String.hpp"
12#endif
13
14namespace Drv {
15
16 // ----------------------------------------------------------------------
17 // Component initialization
18 // ----------------------------------------------------------------------
19
20 void TcpServerComponentBase ::
21 init(FwEnumStoreType instance)
22 {
23 // Initialize base class
25
26 // Connect input port send
27 for (
28 FwIndexType port = 0;
29 port < static_cast<FwIndexType>(this->getNum_send_InputPorts());
30 port++
31 ) {
32 this->m_send_InputPort[port].init();
33 this->m_send_InputPort[port].addCallComp(
34 this,
35 m_p_send_in
36 );
37 this->m_send_InputPort[port].setPortNum(port);
38
39#if FW_OBJECT_NAMES == 1
40 Fw::ObjectName portName;
41 portName.format(
42 "%s_send_InputPort[%" PRI_PlatformIntType "]",
43 this->m_objName.toChar(),
44 port
45 );
46 this->m_send_InputPort[port].setObjName(portName.toChar());
47#endif
48 }
49
50 // Connect output port allocate
51 for (
52 FwIndexType port = 0;
53 port < static_cast<FwIndexType>(this->getNum_allocate_OutputPorts());
54 port++
55 ) {
56 this->m_allocate_OutputPort[port].init();
57
58#if FW_OBJECT_NAMES == 1
59 Fw::ObjectName portName;
60 portName.format(
61 "%s_allocate_OutputPort[%" PRI_PlatformIntType "]",
62 this->m_objName.toChar(),
63 port
64 );
65 this->m_allocate_OutputPort[port].setObjName(portName.toChar());
66#endif
67 }
68
69 // Connect output port deallocate
70 for (
71 FwIndexType port = 0;
72 port < static_cast<FwIndexType>(this->getNum_deallocate_OutputPorts());
73 port++
74 ) {
75 this->m_deallocate_OutputPort[port].init();
76
77#if FW_OBJECT_NAMES == 1
78 Fw::ObjectName portName;
79 portName.format(
80 "%s_deallocate_OutputPort[%" PRI_PlatformIntType "]",
81 this->m_objName.toChar(),
82 port
83 );
84 this->m_deallocate_OutputPort[port].setObjName(portName.toChar());
85#endif
86 }
87
88 // Connect output port ready
89 for (
90 FwIndexType port = 0;
91 port < static_cast<FwIndexType>(this->getNum_ready_OutputPorts());
92 port++
93 ) {
94 this->m_ready_OutputPort[port].init();
95
96#if FW_OBJECT_NAMES == 1
97 Fw::ObjectName portName;
98 portName.format(
99 "%s_ready_OutputPort[%" PRI_PlatformIntType "]",
100 this->m_objName.toChar(),
101 port
102 );
103 this->m_ready_OutputPort[port].setObjName(portName.toChar());
104#endif
105 }
106
107 // Connect output port recv
108 for (
109 FwIndexType port = 0;
110 port < static_cast<FwIndexType>(this->getNum_recv_OutputPorts());
111 port++
112 ) {
113 this->m_recv_OutputPort[port].init();
114
115#if FW_OBJECT_NAMES == 1
116 Fw::ObjectName portName;
117 portName.format(
118 "%s_recv_OutputPort[%" PRI_PlatformIntType "]",
119 this->m_objName.toChar(),
120 port
121 );
122 this->m_recv_OutputPort[port].setObjName(portName.toChar());
123#endif
124 }
125 }
126
127 // ----------------------------------------------------------------------
128 // Getters for typed input ports
129 // ----------------------------------------------------------------------
130
131 Drv::InputByteStreamSendPort* TcpServerComponentBase ::
132 get_send_InputPort(FwIndexType portNum)
133 {
134 FW_ASSERT(
135 portNum < this->getNum_send_InputPorts(),
136 static_cast<FwAssertArgType>(portNum)
137 );
138
139 return &this->m_send_InputPort[portNum];
140 }
141
142 // ----------------------------------------------------------------------
143 // Connect typed input ports to typed output ports
144 // ----------------------------------------------------------------------
145
146 void TcpServerComponentBase ::
147 set_allocate_OutputPort(
148 FwIndexType portNum,
150 )
151 {
152 FW_ASSERT(
153 portNum < this->getNum_allocate_OutputPorts(),
154 static_cast<FwAssertArgType>(portNum)
155 );
156
157 this->m_allocate_OutputPort[portNum].addCallPort(port);
158 }
159
160 void TcpServerComponentBase ::
161 set_deallocate_OutputPort(
162 FwIndexType portNum,
164 )
165 {
166 FW_ASSERT(
167 portNum < this->getNum_deallocate_OutputPorts(),
168 static_cast<FwAssertArgType>(portNum)
169 );
170
171 this->m_deallocate_OutputPort[portNum].addCallPort(port);
172 }
173
174 void TcpServerComponentBase ::
175 set_ready_OutputPort(
176 FwIndexType portNum,
178 )
179 {
180 FW_ASSERT(
181 portNum < this->getNum_ready_OutputPorts(),
182 static_cast<FwAssertArgType>(portNum)
183 );
184
185 this->m_ready_OutputPort[portNum].addCallPort(port);
186 }
187
188 void TcpServerComponentBase ::
189 set_recv_OutputPort(
190 FwIndexType portNum,
192 )
193 {
194 FW_ASSERT(
195 portNum < this->getNum_recv_OutputPorts(),
196 static_cast<FwAssertArgType>(portNum)
197 );
198
199 this->m_recv_OutputPort[portNum].addCallPort(port);
200 }
201
202#if FW_PORT_SERIALIZATION
203
204 // ----------------------------------------------------------------------
205 // Connect serial input ports to typed output ports
206 // ----------------------------------------------------------------------
207
208 void TcpServerComponentBase ::
209 set_deallocate_OutputPort(
210 FwIndexType portNum,
211 Fw::InputSerializePort* port
212 )
213 {
214 FW_ASSERT(
215 portNum < this->getNum_deallocate_OutputPorts(),
216 static_cast<FwAssertArgType>(portNum)
217 );
218
219 this->m_deallocate_OutputPort[portNum].registerSerialPort(port);
220 }
221
222 void TcpServerComponentBase ::
223 set_ready_OutputPort(
224 FwIndexType portNum,
225 Fw::InputSerializePort* port
226 )
227 {
228 FW_ASSERT(
229 portNum < this->getNum_ready_OutputPorts(),
230 static_cast<FwAssertArgType>(portNum)
231 );
232
233 this->m_ready_OutputPort[portNum].registerSerialPort(port);
234 }
235
236 void TcpServerComponentBase ::
237 set_recv_OutputPort(
238 FwIndexType portNum,
239 Fw::InputSerializePort* port
240 )
241 {
242 FW_ASSERT(
243 portNum < this->getNum_recv_OutputPorts(),
244 static_cast<FwAssertArgType>(portNum)
245 );
246
247 this->m_recv_OutputPort[portNum].registerSerialPort(port);
248 }
249
250#endif
251
252 // ----------------------------------------------------------------------
253 // Component construction and destruction
254 // ----------------------------------------------------------------------
255
256 TcpServerComponentBase ::
257 TcpServerComponentBase(const char* compName) :
258 Fw::PassiveComponentBase(compName)
259 {
260
261 }
262
263 TcpServerComponentBase ::
264 ~TcpServerComponentBase()
265 {
266
267 }
268
269 // ----------------------------------------------------------------------
270 // Getters for numbers of typed input ports
271 // ----------------------------------------------------------------------
272
273 FwIndexType TcpServerComponentBase ::
274 getNum_send_InputPorts() const
275 {
276 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_send_InputPort));
277 }
278
279 // ----------------------------------------------------------------------
280 // Getters for numbers of typed output ports
281 // ----------------------------------------------------------------------
282
283 FwIndexType TcpServerComponentBase ::
284 getNum_allocate_OutputPorts() const
285 {
286 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_allocate_OutputPort));
287 }
288
289 FwIndexType TcpServerComponentBase ::
290 getNum_deallocate_OutputPorts() const
291 {
292 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_deallocate_OutputPort));
293 }
294
295 FwIndexType TcpServerComponentBase ::
296 getNum_ready_OutputPorts() const
297 {
298 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_ready_OutputPort));
299 }
300
301 FwIndexType TcpServerComponentBase ::
302 getNum_recv_OutputPorts() const
303 {
304 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_recv_OutputPort));
305 }
306
307 // ----------------------------------------------------------------------
308 // Connection status queries for typed output ports
309 // ----------------------------------------------------------------------
310
311 bool TcpServerComponentBase ::
312 isConnected_allocate_OutputPort(FwIndexType portNum)
313 {
314 FW_ASSERT(
315 portNum < this->getNum_allocate_OutputPorts(),
316 static_cast<FwAssertArgType>(portNum)
317 );
318
319 return this->m_allocate_OutputPort[portNum].isConnected();
320 }
321
322 bool TcpServerComponentBase ::
323 isConnected_deallocate_OutputPort(FwIndexType portNum)
324 {
325 FW_ASSERT(
326 portNum < this->getNum_deallocate_OutputPorts(),
327 static_cast<FwAssertArgType>(portNum)
328 );
329
330 return this->m_deallocate_OutputPort[portNum].isConnected();
331 }
332
333 bool TcpServerComponentBase ::
334 isConnected_ready_OutputPort(FwIndexType portNum)
335 {
336 FW_ASSERT(
337 portNum < this->getNum_ready_OutputPorts(),
338 static_cast<FwAssertArgType>(portNum)
339 );
340
341 return this->m_ready_OutputPort[portNum].isConnected();
342 }
343
344 bool TcpServerComponentBase ::
345 isConnected_recv_OutputPort(FwIndexType portNum)
346 {
347 FW_ASSERT(
348 portNum < this->getNum_recv_OutputPorts(),
349 static_cast<FwAssertArgType>(portNum)
350 );
351
352 return this->m_recv_OutputPort[portNum].isConnected();
353 }
354
355 // ----------------------------------------------------------------------
356 // Port handler base-class functions for typed input ports
357 //
358 // Call these functions directly to bypass the corresponding ports
359 // ----------------------------------------------------------------------
360
361 Drv::SendStatus TcpServerComponentBase ::
362 send_handlerBase(
363 FwIndexType portNum,
364 Fw::Buffer& sendBuffer
365 )
366 {
367 // Make sure port number is valid
368 FW_ASSERT(
369 portNum < this->getNum_send_InputPorts(),
370 static_cast<FwAssertArgType>(portNum)
371 );
372
373 Drv::SendStatus retVal;
374
375 // Lock guard mutex before calling
376 this->lock();
377
378 // Call handler function
379 retVal = this->send_handler(
380 portNum,
381 sendBuffer
382 );
383
384 // Unlock guard mutex
385 this->unLock();
386
387 return retVal;
388 }
389
390 // ----------------------------------------------------------------------
391 // Invocation functions for typed output ports
392 // ----------------------------------------------------------------------
393
394 Fw::Buffer TcpServerComponentBase ::
395 allocate_out(
396 FwIndexType portNum,
397 U32 size
398 )
399 {
400 FW_ASSERT(
401 portNum < this->getNum_allocate_OutputPorts(),
402 static_cast<FwAssertArgType>(portNum)
403 );
404 return this->m_allocate_OutputPort[portNum].invoke(
405 size
406 );
407 }
408
409 void TcpServerComponentBase ::
410 deallocate_out(
411 FwIndexType portNum,
412 Fw::Buffer& fwBuffer
413 )
414 {
415 FW_ASSERT(
416 portNum < this->getNum_deallocate_OutputPorts(),
417 static_cast<FwAssertArgType>(portNum)
418 );
419 this->m_deallocate_OutputPort[portNum].invoke(
420 fwBuffer
421 );
422 }
423
424 void TcpServerComponentBase ::
425 ready_out(FwIndexType portNum)
426 {
427 FW_ASSERT(
428 portNum < this->getNum_ready_OutputPorts(),
429 static_cast<FwAssertArgType>(portNum)
430 );
431 this->m_ready_OutputPort[portNum].invoke();
432 }
433
434 void TcpServerComponentBase ::
435 recv_out(
436 FwIndexType portNum,
437 Fw::Buffer& recvBuffer,
438 const Drv::RecvStatus& recvStatus
439 )
440 {
441 FW_ASSERT(
442 portNum < this->getNum_recv_OutputPorts(),
443 static_cast<FwAssertArgType>(portNum)
444 );
445 this->m_recv_OutputPort[portNum].invoke(
446 recvBuffer,
447 recvStatus
448 );
449 }
450
451 // ----------------------------------------------------------------------
452 // Mutex operations for guarded ports
453 //
454 // You can override these operations to provide more sophisticated
455 // synchronization
456 // ----------------------------------------------------------------------
457
458 void TcpServerComponentBase ::
459 lock()
460 {
461 this->m_guardedPortMutex.lock();
462 }
463
464 void TcpServerComponentBase ::
465 unLock()
466 {
467 this->m_guardedPortMutex.unLock();
468 }
469
470 // ----------------------------------------------------------------------
471 // Calls for messages received on typed input ports
472 // ----------------------------------------------------------------------
473
474 Drv::SendStatus TcpServerComponentBase ::
475 m_p_send_in(
476 Fw::PassiveComponentBase* callComp,
477 FwIndexType portNum,
478 Fw::Buffer& sendBuffer
479 )
480 {
481 FW_ASSERT(callComp);
482 TcpServerComponentBase* compPtr = static_cast<TcpServerComponentBase*>(callComp);
483 return compPtr->send_handlerBase(
484 portNum,
485 sendBuffer
486 );
487 }
488
489}
#define FW_ASSERT(...)
Definition Assert.hpp:14
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:70
#define PRI_PlatformIntType
I32 FwEnumStoreType
Definition FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:39
PlatformIndexType FwIndexType
Definition FpConfig.h:25
Status associated with the received data.
Status returned by the send call.
Auto-generated base for TcpServer component.
Drv::SendStatus send_handlerBase(FwIndexType portNum, Fw::Buffer &sendBuffer)
Handler base-class function for input port send.
void init()
Object initializer.
Definition ObjBase.cpp:27
const char * toChar() const
void format(const CHAR *formatString,...)
write formatted string to buffer