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