F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PassThroughRouterComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PassThroughRouterComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for PassThroughRouter component base class
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
22  {
23  // Initialize base class
25 
26  // Connect input port allPacketsReturnIn
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_allPacketsReturnIn_InputPorts());
30  port++
31  ) {
32  this->m_allPacketsReturnIn_InputPort[port].init();
33  this->m_allPacketsReturnIn_InputPort[port].addCallComp(
34  this,
35  m_p_allPacketsReturnIn_in
36  );
37  this->m_allPacketsReturnIn_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_allPacketsReturnIn_InputPort[%" PRI_FwIndexType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_allPacketsReturnIn_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect input port dataIn
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
54  port++
55  ) {
56  this->m_dataIn_InputPort[port].init();
57  this->m_dataIn_InputPort[port].addCallComp(
58  this,
59  m_p_dataIn_in
60  );
61  this->m_dataIn_InputPort[port].setPortNum(port);
62 
63 #if FW_OBJECT_NAMES == 1
64  Fw::ObjectName portName;
65  portName.format(
66  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
67  this->m_objName.toChar(),
68  port
69  );
70  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
71 #endif
72  }
73 
74  // Connect output port logOut
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
78  port++
79  ) {
80  this->m_logOut_OutputPort[port].init();
81 
82 #if FW_OBJECT_NAMES == 1
83  Fw::ObjectName portName;
84  portName.format(
85  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
86  this->m_objName.toChar(),
87  port
88  );
89  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
90 #endif
91  }
92 
93 #if FW_ENABLE_TEXT_LOGGING == 1
94  // Connect output port logTextOut
95  for (
96  FwIndexType port = 0;
97  port < static_cast<FwIndexType>(this->getNum_logTextOut_OutputPorts());
98  port++
99  ) {
100  this->m_logTextOut_OutputPort[port].init();
101 
102 #if FW_OBJECT_NAMES == 1
103  Fw::ObjectName portName;
104  portName.format(
105  "%s_logTextOut_OutputPort[%" PRI_FwIndexType "]",
106  this->m_objName.toChar(),
107  port
108  );
109  this->m_logTextOut_OutputPort[port].setObjName(portName.toChar());
110 #endif
111  }
112 #endif
113 
114  // Connect output port timeCaller
115  for (
116  FwIndexType port = 0;
117  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
118  port++
119  ) {
120  this->m_timeCaller_OutputPort[port].init();
121 
122 #if FW_OBJECT_NAMES == 1
123  Fw::ObjectName portName;
124  portName.format(
125  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
126  this->m_objName.toChar(),
127  port
128  );
129  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
130 #endif
131  }
132 
133  // Connect output port allPacketsOut
134  for (
135  FwIndexType port = 0;
136  port < static_cast<FwIndexType>(this->getNum_allPacketsOut_OutputPorts());
137  port++
138  ) {
139  this->m_allPacketsOut_OutputPort[port].init();
140 
141 #if FW_OBJECT_NAMES == 1
142  Fw::ObjectName portName;
143  portName.format(
144  "%s_allPacketsOut_OutputPort[%" PRI_FwIndexType "]",
145  this->m_objName.toChar(),
146  port
147  );
148  this->m_allPacketsOut_OutputPort[port].setObjName(portName.toChar());
149 #endif
150  }
151 
152  // Connect output port dataReturnOut
153  for (
154  FwIndexType port = 0;
155  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
156  port++
157  ) {
158  this->m_dataReturnOut_OutputPort[port].init();
159 
160 #if FW_OBJECT_NAMES == 1
161  Fw::ObjectName portName;
162  portName.format(
163  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
164  this->m_objName.toChar(),
165  port
166  );
167  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
168 #endif
169  }
170  }
171 
172  // ----------------------------------------------------------------------
173  // Getters for typed input ports
174  // ----------------------------------------------------------------------
175 
178  {
179  FW_ASSERT(
180  (0 <= portNum) && (portNum < this->getNum_allPacketsReturnIn_InputPorts()),
181  static_cast<FwAssertArgType>(portNum)
182  );
183 
184  return &this->m_allPacketsReturnIn_InputPort[portNum];
185  }
186 
189  {
190  FW_ASSERT(
191  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
192  static_cast<FwAssertArgType>(portNum)
193  );
194 
195  return &this->m_dataIn_InputPort[portNum];
196  }
197 
198  // ----------------------------------------------------------------------
199  // Connect input ports to special output ports
200  // ----------------------------------------------------------------------
201 
204  FwIndexType portNum,
205  Fw::InputLogPort* port
206  )
207  {
208  FW_ASSERT(
209  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
210  static_cast<FwAssertArgType>(portNum)
211  );
212 
213  this->m_logOut_OutputPort[portNum].addCallPort(port);
214  }
215 
216 #if FW_ENABLE_TEXT_LOGGING == 1
217 
218  void PassThroughRouterComponentBase ::
219  set_logTextOut_OutputPort(
220  FwIndexType portNum,
222  )
223  {
224  FW_ASSERT(
225  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
226  static_cast<FwAssertArgType>(portNum)
227  );
228 
229  this->m_logTextOut_OutputPort[portNum].addCallPort(port);
230  }
231 
232 #endif
233 
236  FwIndexType portNum,
237  Fw::InputTimePort* port
238  )
239  {
240  FW_ASSERT(
241  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
242  static_cast<FwAssertArgType>(portNum)
243  );
244 
245  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
246  }
247 
248  // ----------------------------------------------------------------------
249  // Connect typed input ports to typed output ports
250  // ----------------------------------------------------------------------
251 
254  FwIndexType portNum,
256  )
257  {
258  FW_ASSERT(
259  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
260  static_cast<FwAssertArgType>(portNum)
261  );
262 
263  this->m_allPacketsOut_OutputPort[portNum].addCallPort(port);
264  }
265 
268  FwIndexType portNum,
270  )
271  {
272  FW_ASSERT(
273  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
274  static_cast<FwAssertArgType>(portNum)
275  );
276 
277  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
278  }
279 
280 #if FW_PORT_SERIALIZATION
281 
282  // ----------------------------------------------------------------------
283  // Connect serial input ports to special output ports
284  // ----------------------------------------------------------------------
285 
288  FwIndexType portNum,
289  Fw::InputSerializePort* port
290  )
291  {
292  FW_ASSERT(
293  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
294  static_cast<FwAssertArgType>(portNum)
295  );
296 
297  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
298  }
299 
300 #if FW_ENABLE_TEXT_LOGGING == 1
301 
302  void PassThroughRouterComponentBase ::
303  set_logTextOut_OutputPort(
304  FwIndexType portNum,
305  Fw::InputSerializePort* port
306  )
307  {
308  FW_ASSERT(
309  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
310  static_cast<FwAssertArgType>(portNum)
311  );
312 
313  this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
314  }
315 
316 #endif
317 
320  FwIndexType portNum,
321  Fw::InputSerializePort* port
322  )
323  {
324  FW_ASSERT(
325  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
326  static_cast<FwAssertArgType>(portNum)
327  );
328 
329  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
330  }
331 
332 #endif
333 
334 #if FW_PORT_SERIALIZATION
335 
336  // ----------------------------------------------------------------------
337  // Connect serial input ports to typed output ports
338  // ----------------------------------------------------------------------
339 
342  FwIndexType portNum,
343  Fw::InputSerializePort* port
344  )
345  {
346  FW_ASSERT(
347  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
348  static_cast<FwAssertArgType>(portNum)
349  );
350 
351  this->m_allPacketsOut_OutputPort[portNum].registerSerialPort(port);
352  }
353 
356  FwIndexType portNum,
357  Fw::InputSerializePort* port
358  )
359  {
360  FW_ASSERT(
361  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
362  static_cast<FwAssertArgType>(portNum)
363  );
364 
365  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
366  }
367 
368 #endif
369 
370  // ----------------------------------------------------------------------
371  // Component construction and destruction
372  // ----------------------------------------------------------------------
373 
375  PassThroughRouterComponentBase(const char* compName) :
376  Fw::PassiveComponentBase(compName)
377  {
378 
379  }
380 
383  {
384 
385  }
386 
387  // ----------------------------------------------------------------------
388  // Connection status queries for special output ports
389  // ----------------------------------------------------------------------
390 
393  {
394  FW_ASSERT(
395  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
396  static_cast<FwAssertArgType>(portNum)
397  );
398 
399  return this->m_logOut_OutputPort[portNum].isConnected();
400  }
401 
402 #if FW_ENABLE_TEXT_LOGGING == 1
403 
404  bool PassThroughRouterComponentBase ::
405  isConnected_logTextOut_OutputPort(FwIndexType portNum)
406  {
407  FW_ASSERT(
408  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
409  static_cast<FwAssertArgType>(portNum)
410  );
411 
412  return this->m_logTextOut_OutputPort[portNum].isConnected();
413  }
414 
415 #endif
416 
419  {
420  FW_ASSERT(
421  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
422  static_cast<FwAssertArgType>(portNum)
423  );
424 
425  return this->m_timeCaller_OutputPort[portNum].isConnected();
426  }
427 
428  // ----------------------------------------------------------------------
429  // Connection status queries for typed output ports
430  // ----------------------------------------------------------------------
431 
434  {
435  FW_ASSERT(
436  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
437  static_cast<FwAssertArgType>(portNum)
438  );
439 
440  return this->m_allPacketsOut_OutputPort[portNum].isConnected();
441  }
442 
445  {
446  FW_ASSERT(
447  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
448  static_cast<FwAssertArgType>(portNum)
449  );
450 
451  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
452  }
453 
454  // ----------------------------------------------------------------------
455  // Port handler base-class functions for typed input ports
456  //
457  // Call these functions directly to bypass the corresponding ports
458  // ----------------------------------------------------------------------
459 
462  FwIndexType portNum,
463  Fw::Buffer& fwBuffer
464  )
465  {
466  // Make sure port number is valid
467  FW_ASSERT(
468  (0 <= portNum) && (portNum < this->getNum_allPacketsReturnIn_InputPorts()),
469  static_cast<FwAssertArgType>(portNum)
470  );
471 
472  // Call handler function
474  portNum,
475  fwBuffer
476  );
477  }
478 
481  FwIndexType portNum,
482  Fw::Buffer& data,
483  const ComCfg::FrameContext& context
484  )
485  {
486  // Make sure port number is valid
487  FW_ASSERT(
488  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
489  static_cast<FwAssertArgType>(portNum)
490  );
491 
492  // Call handler function
493  this->dataIn_handler(
494  portNum,
495  data,
496  context
497  );
498  }
499 
500  // ----------------------------------------------------------------------
501  // Invocation functions for typed output ports
502  // ----------------------------------------------------------------------
503 
506  FwIndexType portNum,
507  Fw::Buffer& fwBuffer
508  )
509  {
510  FW_ASSERT(
511  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
512  static_cast<FwAssertArgType>(portNum)
513  );
514 
515  FW_ASSERT(
516  this->m_allPacketsOut_OutputPort[portNum].isConnected(),
517  static_cast<FwAssertArgType>(portNum)
518  );
519  this->m_allPacketsOut_OutputPort[portNum].invoke(
520  fwBuffer
521  );
522  }
523 
526  FwIndexType portNum,
527  Fw::Buffer& data,
528  const ComCfg::FrameContext& context
529  )
530  {
531  FW_ASSERT(
532  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
533  static_cast<FwAssertArgType>(portNum)
534  );
535 
536  FW_ASSERT(
537  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
538  static_cast<FwAssertArgType>(portNum)
539  );
540  this->m_dataReturnOut_OutputPort[portNum].invoke(
541  data,
542  context
543  );
544  }
545 
546  // ----------------------------------------------------------------------
547  // Time
548  // ----------------------------------------------------------------------
549 
551  getTime() const
552  {
553  if (this->m_timeCaller_OutputPort[0].isConnected()) {
554  Fw::Time _time;
555  this->m_timeCaller_OutputPort[0].invoke(_time);
556  return _time;
557  }
558  else {
559  return Fw::Time(TimeBase::TB_NONE, 0, 0);
560  }
561  }
562 
563  // ----------------------------------------------------------------------
564  // Calls for messages received on typed input ports
565  // ----------------------------------------------------------------------
566 
567  void PassThroughRouterComponentBase ::
568  m_p_allPacketsReturnIn_in(
569  Fw::PassiveComponentBase* callComp,
570  FwIndexType portNum,
571  Fw::Buffer& fwBuffer
572  )
573  {
574  FW_ASSERT(callComp);
575  PassThroughRouterComponentBase* compPtr = static_cast<PassThroughRouterComponentBase*>(callComp);
577  portNum,
578  fwBuffer
579  );
580  }
581 
582  void PassThroughRouterComponentBase ::
583  m_p_dataIn_in(
584  Fw::PassiveComponentBase* callComp,
585  FwIndexType portNum,
586  Fw::Buffer& data,
587  const ComCfg::FrameContext& context
588  )
589  {
590  FW_ASSERT(callComp);
591  PassThroughRouterComponentBase* compPtr = static_cast<PassThroughRouterComponentBase*>(callComp);
592  compPtr->dataIn_handlerBase(
593  portNum,
594  data,
595  context
596  );
597  }
598 
599 }
static constexpr FwIndexType getNum_dataReturnOut_OutputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
I32 FwEnumStoreType
bool isConnected_allPacketsOut_OutputPort(FwIndexType portNum)
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Svc::InputComDataWithContextPort * get_dataIn_InputPort(FwIndexType portNum)
void dataIn_handlerBase(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Handler base-class function for input port dataIn.
No time base has been established (Required)
void addCallPort(InputComDataWithContextPort *callPort)
Register an input port.
static constexpr FwIndexType getNum_allPacketsReturnIn_InputPorts()
void init()
Object initializer.
Definition: ObjBase.cpp:24
static constexpr FwIndexType getNum_allPacketsOut_OutputPorts()
void allPacketsOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port allPacketsOut.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
void set_dataReturnOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataReturnOut[portNum].
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Fw::InputBufferSendPort * get_allPacketsReturnIn_InputPort(FwIndexType portNum)
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
bool isConnected_dataReturnOut_OutputPort(FwIndexType portNum)
void invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port interface.
void init()
Initialization function.
void set_allPacketsOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to allPacketsOut[portNum].
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataReturnOut.
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
void setPortNum(FwIndexType portNum)
void init()
Initialization function.
void init()
Initialization function.
virtual void allPacketsReturnIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port allPacketsReturnIn.
virtual void dataIn_handler(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)=0
Handler for input port dataIn.
PassThroughRouterComponentBase(const char *compName="")
Construct PassThroughRouterComponentBase object.
PlatformIndexType FwIndexType
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.
virtual ~PassThroughRouterComponentBase()
Destroy PassThroughRouterComponentBase object.
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
Auto-generated base for PassThroughRouter component.
Implementation of malloc based allocator.
void allPacketsReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port allPacketsReturnIn.
static constexpr FwIndexType getNum_dataIn_InputPorts()
static constexpr FwIndexType getNum_logOut_OutputPorts()
#define FW_ASSERT(...)
Definition: Assert.hpp:14