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 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Drv {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
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 
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 
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 
201  FwIndexType portNum,
202  Fw::InputTimePort* port
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 
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 
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 
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 
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 
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 
326  StreamCrossoverComponentBase(const char* compName) :
327  Fw::PassiveComponentBase(compName)
328  {
329 
330  }
331 
334  {
335 
336  }
337 
338  // ----------------------------------------------------------------------
339  // Getters for numbers of typed input ports
340  // ----------------------------------------------------------------------
341 
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 
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 
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 
380  {
381  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_errorDeallocate_OutputPort));
382  }
383 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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)
Definition: FpConfig.h:148
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void init()
Initialization function.
Drv::SendStatus invoke(Fw::Buffer &sendBuffer)
Invoke a port interface.
void addCallPort(InputByteStreamSendPort *callPort)
Register an input port.
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 set_streamOut_OutputPort(FwIndexType portNum, Drv::InputByteStreamSendPort *port)
Connect port to streamOut[portNum].
void set_errorDeallocate_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to errorDeallocate[portNum].
void log_WARNING_HI_StreamOutError(Drv::SendStatus sendStatus)
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
@ EVENTID_STREAMOUTERROR
Indicates buffer failed to send to streamOut.
bool isConnected_logOut_OutputPort(FwIndexType portNum)
void errorDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port errorDeallocate.
bool isConnected_errorDeallocate_OutputPort(FwIndexType portNum)
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
virtual ~StreamCrossoverComponentBase()
Destroy StreamCrossoverComponentBase object.
Drv::InputByteStreamRecvPort * get_streamIn_InputPort(FwIndexType portNum)
Drv::SendStatus streamOut_out(FwIndexType portNum, Fw::Buffer &sendBuffer)
Invoke output port streamOut.
StreamCrossoverComponentBase(const char *compName="")
Construct StreamCrossoverComponentBase object.
void streamIn_handlerBase(FwIndexType portNum, Fw::Buffer &recvBuffer, const Drv::RecvStatus &recvStatus)
Handler base-class function for input port streamIn.
virtual void streamIn_handler(FwIndexType portNum, Fw::Buffer &recvBuffer, const Drv::RecvStatus &recvStatus)=0
Handler for input port streamIn.
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
bool isConnected_streamOut_OutputPort(FwIndexType portNum)
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Buffer &fwBuffer)
Invoke a port interface.
void init()
Initialization function.
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
bool isConnected()
Definition: PortBase.cpp:41
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
const char * toChar() const
Definition: String.hpp:50
Definition: Time.hpp:9
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.