F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StreamCrossoverComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title StreamCrossoverComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for StreamCrossover 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 Drv {
16
17 // ----------------------------------------------------------------------
18 // Component initialization
19 // ----------------------------------------------------------------------
20
21 void StreamCrossoverComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port streamIn
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_streamIn_InputPorts());
31 port++
32 ) {
33 this->m_streamIn_InputPort[port].init();
34 this->m_streamIn_InputPort[port].addCallComp(
35 this,
36 m_p_streamIn_in
37 );
38 this->m_streamIn_InputPort[port].setPortNum(port);
39
40#if FW_OBJECT_NAMES == 1
41 char portName[120];
42 (void) snprintf(
43 portName,
44 sizeof(portName),
45 "%s_streamIn_InputPort[%" PRI_PlatformIntType "]",
46 this->m_objName,
47 port
48 );
49 this->m_streamIn_InputPort[port].setObjName(portName);
50#endif
51 }
52
53 // Connect output port logOut
54 for (
55 PlatformIntType port = 0;
56 port < static_cast<PlatformIntType>(this->getNum_logOut_OutputPorts());
57 port++
58 ) {
59 this->m_logOut_OutputPort[port].init();
60
61#if FW_OBJECT_NAMES == 1
62 char portName[120];
63 (void) snprintf(
64 portName,
65 sizeof(portName),
66 "%s_logOut_OutputPort[%" PRI_PlatformIntType "]",
67 this->m_objName,
68 port
69 );
70 this->m_logOut_OutputPort[port].setObjName(portName);
71#endif
72 }
73
74#if FW_ENABLE_TEXT_LOGGING == 1
75 // Connect output port logTextOut
76 for (
77 PlatformIntType port = 0;
78 port < static_cast<PlatformIntType>(this->getNum_logTextOut_OutputPorts());
79 port++
80 ) {
81 this->m_logTextOut_OutputPort[port].init();
82
83#if FW_OBJECT_NAMES == 1
84 char portName[120];
85 (void) snprintf(
86 portName,
87 sizeof(portName),
88 "%s_logTextOut_OutputPort[%" PRI_PlatformIntType "]",
89 this->m_objName,
90 port
91 );
92 this->m_logTextOut_OutputPort[port].setObjName(portName);
93#endif
94 }
95#endif
96
97 // Connect output port timeCaller
98 for (
99 PlatformIntType port = 0;
100 port < static_cast<PlatformIntType>(this->getNum_timeCaller_OutputPorts());
101 port++
102 ) {
103 this->m_timeCaller_OutputPort[port].init();
104
105#if FW_OBJECT_NAMES == 1
106 char portName[120];
107 (void) snprintf(
108 portName,
109 sizeof(portName),
110 "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
111 this->m_objName,
112 port
113 );
114 this->m_timeCaller_OutputPort[port].setObjName(portName);
115#endif
116 }
117
118 // Connect output port errorDeallocate
119 for (
120 PlatformIntType port = 0;
121 port < static_cast<PlatformIntType>(this->getNum_errorDeallocate_OutputPorts());
122 port++
123 ) {
124 this->m_errorDeallocate_OutputPort[port].init();
125
126#if FW_OBJECT_NAMES == 1
127 char portName[120];
128 (void) snprintf(
129 portName,
130 sizeof(portName),
131 "%s_errorDeallocate_OutputPort[%" PRI_PlatformIntType "]",
132 this->m_objName,
133 port
134 );
135 this->m_errorDeallocate_OutputPort[port].setObjName(portName);
136#endif
137 }
138
139 // Connect output port streamOut
140 for (
141 PlatformIntType port = 0;
142 port < static_cast<PlatformIntType>(this->getNum_streamOut_OutputPorts());
143 port++
144 ) {
145 this->m_streamOut_OutputPort[port].init();
146
147#if FW_OBJECT_NAMES == 1
148 char portName[120];
149 (void) snprintf(
150 portName,
151 sizeof(portName),
152 "%s_streamOut_OutputPort[%" PRI_PlatformIntType "]",
153 this->m_objName,
154 port
155 );
156 this->m_streamOut_OutputPort[port].setObjName(portName);
157#endif
158 }
159 }
160
161 // ----------------------------------------------------------------------
162 // Getters for typed input ports
163 // ----------------------------------------------------------------------
164
165 Drv::InputByteStreamRecvPort* StreamCrossoverComponentBase ::
166 get_streamIn_InputPort(NATIVE_INT_TYPE portNum)
167 {
168 FW_ASSERT(
169 portNum < this->getNum_streamIn_InputPorts(),
170 static_cast<FwAssertArgType>(portNum)
171 );
172
173 return &this->m_streamIn_InputPort[portNum];
174 }
175
176 // ----------------------------------------------------------------------
177 // Connect input ports to special output ports
178 // ----------------------------------------------------------------------
179
180 void StreamCrossoverComponentBase ::
181 set_logOut_OutputPort(
182 NATIVE_INT_TYPE portNum,
183 Fw::InputLogPort* port
184 )
185 {
186 FW_ASSERT(
187 portNum < this->getNum_logOut_OutputPorts(),
188 static_cast<FwAssertArgType>(portNum)
189 );
190
191 this->m_logOut_OutputPort[portNum].addCallPort(port);
192 }
193
194#if FW_ENABLE_TEXT_LOGGING == 1
195
196 void StreamCrossoverComponentBase ::
197 set_logTextOut_OutputPort(
198 NATIVE_INT_TYPE portNum,
200 )
201 {
202 FW_ASSERT(
203 portNum < this->getNum_logTextOut_OutputPorts(),
204 static_cast<FwAssertArgType>(portNum)
205 );
206
207 this->m_logTextOut_OutputPort[portNum].addCallPort(port);
208 }
209
210#endif
211
212 void StreamCrossoverComponentBase ::
213 set_timeCaller_OutputPort(
214 NATIVE_INT_TYPE portNum,
216 )
217 {
218 FW_ASSERT(
219 portNum < this->getNum_timeCaller_OutputPorts(),
220 static_cast<FwAssertArgType>(portNum)
221 );
222
223 this->m_timeCaller_OutputPort[portNum].addCallPort(port);
224 }
225
226 // ----------------------------------------------------------------------
227 // Connect typed input ports to typed output ports
228 // ----------------------------------------------------------------------
229
230 void StreamCrossoverComponentBase ::
231 set_errorDeallocate_OutputPort(
232 NATIVE_INT_TYPE portNum,
234 )
235 {
236 FW_ASSERT(
237 portNum < this->getNum_errorDeallocate_OutputPorts(),
238 static_cast<FwAssertArgType>(portNum)
239 );
240
241 this->m_errorDeallocate_OutputPort[portNum].addCallPort(port);
242 }
243
244 void StreamCrossoverComponentBase ::
245 set_streamOut_OutputPort(
246 NATIVE_INT_TYPE portNum,
248 )
249 {
250 FW_ASSERT(
251 portNum < this->getNum_streamOut_OutputPorts(),
252 static_cast<FwAssertArgType>(portNum)
253 );
254
255 this->m_streamOut_OutputPort[portNum].addCallPort(port);
256 }
257
258#if FW_PORT_SERIALIZATION
259
260 // ----------------------------------------------------------------------
261 // Connect serial input ports to special output ports
262 // ----------------------------------------------------------------------
263
264 void StreamCrossoverComponentBase ::
265 set_logOut_OutputPort(
266 NATIVE_INT_TYPE portNum,
267 Fw::InputSerializePort* port
268 )
269 {
270 FW_ASSERT(
271 portNum < this->getNum_logOut_OutputPorts(),
272 static_cast<FwAssertArgType>(portNum)
273 );
274
275 this->m_logOut_OutputPort[portNum].registerSerialPort(port);
276 }
277
278#if FW_ENABLE_TEXT_LOGGING == 1
279
280 void StreamCrossoverComponentBase ::
281 set_logTextOut_OutputPort(
282 NATIVE_INT_TYPE portNum,
283 Fw::InputSerializePort* port
284 )
285 {
286 FW_ASSERT(
287 portNum < this->getNum_logTextOut_OutputPorts(),
288 static_cast<FwAssertArgType>(portNum)
289 );
290
291 this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
292 }
293
294#endif
295
296 void StreamCrossoverComponentBase ::
297 set_timeCaller_OutputPort(
298 NATIVE_INT_TYPE portNum,
299 Fw::InputSerializePort* port
300 )
301 {
302 FW_ASSERT(
303 portNum < this->getNum_timeCaller_OutputPorts(),
304 static_cast<FwAssertArgType>(portNum)
305 );
306
307 this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
308 }
309
310#endif
311
312#if FW_PORT_SERIALIZATION
313
314 // ----------------------------------------------------------------------
315 // Connect serial input ports to typed output ports
316 // ----------------------------------------------------------------------
317
318 void StreamCrossoverComponentBase ::
319 set_errorDeallocate_OutputPort(
320 NATIVE_INT_TYPE portNum,
321 Fw::InputSerializePort* port
322 )
323 {
324 FW_ASSERT(
325 portNum < this->getNum_errorDeallocate_OutputPorts(),
326 static_cast<FwAssertArgType>(portNum)
327 );
328
329 this->m_errorDeallocate_OutputPort[portNum].registerSerialPort(port);
330 }
331
332#endif
333
334 // ----------------------------------------------------------------------
335 // Component construction and destruction
336 // ----------------------------------------------------------------------
337
338 StreamCrossoverComponentBase ::
339 StreamCrossoverComponentBase(const char* compName) :
340 Fw::PassiveComponentBase(compName)
341 {
342
343 }
344
345 StreamCrossoverComponentBase ::
346 ~StreamCrossoverComponentBase()
347 {
348
349 }
350
351 // ----------------------------------------------------------------------
352 // Getters for numbers of typed input ports
353 // ----------------------------------------------------------------------
354
355 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
356 getNum_streamIn_InputPorts() const
357 {
358 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_streamIn_InputPort));
359 }
360
361 // ----------------------------------------------------------------------
362 // Getters for numbers of special output ports
363 // ----------------------------------------------------------------------
364
365 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
366 getNum_logOut_OutputPorts() const
367 {
368 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_logOut_OutputPort));
369 }
370
371#if FW_ENABLE_TEXT_LOGGING == 1
372
373 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
374 getNum_logTextOut_OutputPorts() const
375 {
376 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_logTextOut_OutputPort));
377 }
378
379#endif
380
381 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
382 getNum_timeCaller_OutputPorts() const
383 {
384 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
385 }
386
387 // ----------------------------------------------------------------------
388 // Getters for numbers of typed output ports
389 // ----------------------------------------------------------------------
390
391 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
392 getNum_errorDeallocate_OutputPorts() const
393 {
394 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_errorDeallocate_OutputPort));
395 }
396
397 NATIVE_INT_TYPE StreamCrossoverComponentBase ::
398 getNum_streamOut_OutputPorts() const
399 {
400 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_streamOut_OutputPort));
401 }
402
403 // ----------------------------------------------------------------------
404 // Connection status queries for special output ports
405 // ----------------------------------------------------------------------
406
407 bool StreamCrossoverComponentBase ::
408 isConnected_logOut_OutputPort(NATIVE_INT_TYPE portNum)
409 {
410 FW_ASSERT(
411 portNum < this->getNum_logOut_OutputPorts(),
412 static_cast<FwAssertArgType>(portNum)
413 );
414
415 return this->m_logOut_OutputPort[portNum].isConnected();
416 }
417
418#if FW_ENABLE_TEXT_LOGGING == 1
419
420 bool StreamCrossoverComponentBase ::
421 isConnected_logTextOut_OutputPort(NATIVE_INT_TYPE portNum)
422 {
423 FW_ASSERT(
424 portNum < this->getNum_logTextOut_OutputPorts(),
425 static_cast<FwAssertArgType>(portNum)
426 );
427
428 return this->m_logTextOut_OutputPort[portNum].isConnected();
429 }
430
431#endif
432
433 bool StreamCrossoverComponentBase ::
434 isConnected_timeCaller_OutputPort(NATIVE_INT_TYPE portNum)
435 {
436 FW_ASSERT(
437 portNum < this->getNum_timeCaller_OutputPorts(),
438 static_cast<FwAssertArgType>(portNum)
439 );
440
441 return this->m_timeCaller_OutputPort[portNum].isConnected();
442 }
443
444 // ----------------------------------------------------------------------
445 // Connection status queries for typed output ports
446 // ----------------------------------------------------------------------
447
448 bool StreamCrossoverComponentBase ::
449 isConnected_errorDeallocate_OutputPort(NATIVE_INT_TYPE portNum)
450 {
451 FW_ASSERT(
452 portNum < this->getNum_errorDeallocate_OutputPorts(),
453 static_cast<FwAssertArgType>(portNum)
454 );
455
456 return this->m_errorDeallocate_OutputPort[portNum].isConnected();
457 }
458
459 bool StreamCrossoverComponentBase ::
460 isConnected_streamOut_OutputPort(NATIVE_INT_TYPE portNum)
461 {
462 FW_ASSERT(
463 portNum < this->getNum_streamOut_OutputPorts(),
464 static_cast<FwAssertArgType>(portNum)
465 );
466
467 return this->m_streamOut_OutputPort[portNum].isConnected();
468 }
469
470 // ----------------------------------------------------------------------
471 // Port handler base-class functions for typed input ports
472 //
473 // Call these functions directly to bypass the corresponding ports
474 // ----------------------------------------------------------------------
475
476 void StreamCrossoverComponentBase ::
477 streamIn_handlerBase(
478 NATIVE_INT_TYPE portNum,
479 Fw::Buffer& recvBuffer,
480 const Drv::RecvStatus& recvStatus
481 )
482 {
483 // Make sure port number is valid
484 FW_ASSERT(
485 portNum < this->getNum_streamIn_InputPorts(),
486 static_cast<FwAssertArgType>(portNum)
487 );
488
489 // Down call to pure virtual handler method implemented in Impl class
490 this->streamIn_handler(
491 portNum,
492 recvBuffer,
493 recvStatus
494 );
495 }
496
497 // ----------------------------------------------------------------------
498 // Invocation functions for typed output ports
499 // ----------------------------------------------------------------------
500
501 void StreamCrossoverComponentBase ::
502 errorDeallocate_out(
503 NATIVE_INT_TYPE portNum,
504 Fw::Buffer& fwBuffer
505 )
506 {
507 FW_ASSERT(
508 portNum < this->getNum_errorDeallocate_OutputPorts(),
509 static_cast<FwAssertArgType>(portNum)
510 );
511 this->m_errorDeallocate_OutputPort[portNum].invoke(
512 fwBuffer
513 );
514 }
515
516 Drv::SendStatus StreamCrossoverComponentBase ::
517 streamOut_out(
518 NATIVE_INT_TYPE portNum,
519 Fw::Buffer& sendBuffer
520 )
521 {
522 FW_ASSERT(
523 portNum < this->getNum_streamOut_OutputPorts(),
524 static_cast<FwAssertArgType>(portNum)
525 );
526 return this->m_streamOut_OutputPort[portNum].invoke(
527 sendBuffer
528 );
529 }
530
531 // ----------------------------------------------------------------------
532 // Event logging functions
533 // ----------------------------------------------------------------------
534
535 void StreamCrossoverComponentBase ::
536 log_WARNING_HI_StreamOutError(Drv::SendStatus sendStatus)
537 {
538 // Get the time
539 Fw::Time _logTime;
540 if (this->m_timeCaller_OutputPort[0].isConnected()) {
541 this->m_timeCaller_OutputPort[0].invoke(_logTime);
542 }
543
544 FwEventIdType _id = static_cast<FwEventIdType>(0);
545
546 _id = this->getIdBase() + EVENTID_STREAMOUTERROR;
547
548 // Emit the event on the log port
549 if (this->m_logOut_OutputPort[0].isConnected()) {
550 Fw::LogBuffer _logBuff;
552
553#if FW_AMPCS_COMPATIBLE
554 // Serialize the number of arguments
555 _status = _logBuff.serialize(static_cast<U8>(1));
556 FW_ASSERT(
557 _status == Fw::FW_SERIALIZE_OK,
558 static_cast<FwAssertArgType>(_status)
559 );
560#endif
561
562#if FW_AMPCS_COMPATIBLE
563 // Serialize the argument size
564 _status = _logBuff.serialize(
566 );
567 FW_ASSERT(
568 _status == Fw::FW_SERIALIZE_OK,
569 static_cast<FwAssertArgType>(_status)
570 );
571#endif
572 _status = _logBuff.serialize(sendStatus);
573 FW_ASSERT(
574 _status == Fw::FW_SERIALIZE_OK,
575 static_cast<FwAssertArgType>(_status)
576 );
577
578 this->m_logOut_OutputPort[0].invoke(
579 _id,
580 _logTime,
582 _logBuff
583 );
584 }
585
586 // Emit the event on the text log port
587#if FW_ENABLE_TEXT_LOGGING
588 if (this->m_logTextOut_OutputPort[0].isConnected()) {
589#if FW_OBJECT_NAMES == 1
590 const char* _formatString =
591 "(%s) %s: StreamCrossover StreamOut Error: %s";
592#else
593 const char* _formatString =
594 "%s: StreamCrossover StreamOut Error: %s";
595#endif
596
597 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
598
599 Fw::String sendStatusStr;
600 sendStatus.toString(sendStatusStr);
601
602 (void) snprintf(
603 _textBuffer,
605 _formatString,
606#if FW_OBJECT_NAMES == 1
607 this->m_objName,
608#endif
609 "StreamOutError ",
610 sendStatusStr.toChar()
611 );
612
613 // Null terminate
614 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
615 Fw::TextLogString _logString = _textBuffer;
616 this->m_logTextOut_OutputPort[0].invoke(
617 _id,
618 _logTime,
620 _logString
621 );
622 }
623#endif
624 }
625
626 // ----------------------------------------------------------------------
627 // Time
628 // ----------------------------------------------------------------------
629
630 Fw::Time StreamCrossoverComponentBase ::
631 getTime()
632 {
633 if (this->m_timeCaller_OutputPort[0].isConnected()) {
634 Fw::Time _time;
635 this->m_timeCaller_OutputPort[0].invoke(_time);
636 return _time;
637 }
638 else {
639 return Fw::Time(TB_NONE, 0, 0);
640 }
641 }
642
643 // ----------------------------------------------------------------------
644 // Calls for messages received on typed input ports
645 // ----------------------------------------------------------------------
646
647 void StreamCrossoverComponentBase ::
648 m_p_streamIn_in(
649 Fw::PassiveComponentBase* callComp,
650 NATIVE_INT_TYPE portNum,
651 Fw::Buffer& recvBuffer,
652 const Drv::RecvStatus& recvStatus
653 )
654 {
655 FW_ASSERT(callComp);
656 StreamCrossoverComponentBase* compPtr = static_cast<StreamCrossoverComponentBase*>(callComp);
657 compPtr->streamIn_handlerBase(
658 portNum,
659 recvBuffer,
660 recvStatus
661 );
662 }
663
664}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
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
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwEventIdType
Definition FpConfig.h:62
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition FpConfig.h:291
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition FpConfig.h:82
Status associated with the received data.
Status returned by the send call.
@ SERIALIZED_SIZE
The size of the serial representation.
Auto-generated base for StreamCrossover component.
void streamIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::Buffer &recvBuffer, const Drv::RecvStatus &recvStatus)
Handler base-class function for input port streamIn.
Input BufferSend port.
@ WARNING_HI
A serious but recoverable event.
void init()
Object initializer.
Definition ObjBase.cpp:27
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
gets char buffer
Definition String.cpp:48
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.