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 #if !FW_DIRECT_PORT_CALLS
27  // Connect input port allPacketsReturnIn
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(this->getNum_allPacketsReturnIn_InputPorts());
31  port++
32  ) {
33  this->m_allPacketsReturnIn_InputPort[port].init();
34  this->m_allPacketsReturnIn_InputPort[port].addCallComp(
35  this,
36  m_p_allPacketsReturnIn_in
37  );
38  this->m_allPacketsReturnIn_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  Fw::ObjectName portName;
42  portName.format(
43  "%s_allPacketsReturnIn_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_allPacketsReturnIn_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect input port dataIn
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
57  port++
58  ) {
59  this->m_dataIn_InputPort[port].init();
60  this->m_dataIn_InputPort[port].addCallComp(
61  this,
62  m_p_dataIn_in
63  );
64  this->m_dataIn_InputPort[port].setPortNum(port);
65 
66 #if FW_OBJECT_NAMES == 1
67  Fw::ObjectName portName;
68  portName.format(
69  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
70  this->m_objName.toChar(),
71  port
72  );
73  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
74 #endif
75  }
76 #endif
77 
78 #if !FW_DIRECT_PORT_CALLS
79  // Connect output port logOut
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
83  port++
84  ) {
85  this->m_logOut_OutputPort[port].init();
86 
87 #if FW_OBJECT_NAMES == 1
88  Fw::ObjectName portName;
89  portName.format(
90  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
91  this->m_objName.toChar(),
92  port
93  );
94  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
95 #endif
96  }
97 #endif
98 
99 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
100  // Connect output port logTextOut
101  for (
102  FwIndexType port = 0;
103  port < static_cast<FwIndexType>(this->getNum_logTextOut_OutputPorts());
104  port++
105  ) {
106  this->m_logTextOut_OutputPort[port].init();
107 
108 #if FW_OBJECT_NAMES == 1
109  Fw::ObjectName portName;
110  portName.format(
111  "%s_logTextOut_OutputPort[%" PRI_FwIndexType "]",
112  this->m_objName.toChar(),
113  port
114  );
115  this->m_logTextOut_OutputPort[port].setObjName(portName.toChar());
116 #endif
117  }
118 #endif
119 
120 #if !FW_DIRECT_PORT_CALLS
121  // Connect output port timeCaller
122  for (
123  FwIndexType port = 0;
124  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
125  port++
126  ) {
127  this->m_timeCaller_OutputPort[port].init();
128 
129 #if FW_OBJECT_NAMES == 1
130  Fw::ObjectName portName;
131  portName.format(
132  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
133  this->m_objName.toChar(),
134  port
135  );
136  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
137 #endif
138  }
139 #endif
140 
141 #if !FW_DIRECT_PORT_CALLS
142  // Connect output port allPacketsOut
143  for (
144  FwIndexType port = 0;
145  port < static_cast<FwIndexType>(this->getNum_allPacketsOut_OutputPorts());
146  port++
147  ) {
148  this->m_allPacketsOut_OutputPort[port].init();
149 
150 #if FW_OBJECT_NAMES == 1
151  Fw::ObjectName portName;
152  portName.format(
153  "%s_allPacketsOut_OutputPort[%" PRI_FwIndexType "]",
154  this->m_objName.toChar(),
155  port
156  );
157  this->m_allPacketsOut_OutputPort[port].setObjName(portName.toChar());
158 #endif
159  }
160 #endif
161 
162 #if !FW_DIRECT_PORT_CALLS
163  // Connect output port dataReturnOut
164  for (
165  FwIndexType port = 0;
166  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
167  port++
168  ) {
169  this->m_dataReturnOut_OutputPort[port].init();
170 
171 #if FW_OBJECT_NAMES == 1
172  Fw::ObjectName portName;
173  portName.format(
174  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
175  this->m_objName.toChar(),
176  port
177  );
178  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
179 #endif
180  }
181 #endif
182  }
183 
184 #if !FW_DIRECT_PORT_CALLS
185 
186  // ----------------------------------------------------------------------
187  // Getters for typed input ports
188  // ----------------------------------------------------------------------
189 
192  {
193  FW_ASSERT(
194  (0 <= portNum) && (portNum < this->getNum_allPacketsReturnIn_InputPorts()),
195  static_cast<FwAssertArgType>(portNum)
196  );
197 
198  return &this->m_allPacketsReturnIn_InputPort[portNum];
199  }
200 
203  {
204  FW_ASSERT(
205  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
206  static_cast<FwAssertArgType>(portNum)
207  );
208 
209  return &this->m_dataIn_InputPort[portNum];
210  }
211 
212 #endif
213 
214 #if !FW_DIRECT_PORT_CALLS
215 
216  // ----------------------------------------------------------------------
217  // Connect input ports to special output ports
218  // ----------------------------------------------------------------------
219 
222  FwIndexType portNum,
223  Fw::InputLogPort* port
224  )
225  {
226  FW_ASSERT(
227  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
228  static_cast<FwAssertArgType>(portNum)
229  );
230 
231  this->m_logOut_OutputPort[portNum].addCallPort(port);
232  }
233 
234 #if FW_ENABLE_TEXT_LOGGING == 1
235 
236  void PassThroughRouterComponentBase ::
237  set_logTextOut_OutputPort(
238  FwIndexType portNum,
240  )
241  {
242  FW_ASSERT(
243  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
244  static_cast<FwAssertArgType>(portNum)
245  );
246 
247  this->m_logTextOut_OutputPort[portNum].addCallPort(port);
248  }
249 
250 #endif
251 
254  FwIndexType portNum,
255  Fw::InputTimePort* port
256  )
257  {
258  FW_ASSERT(
259  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
260  static_cast<FwAssertArgType>(portNum)
261  );
262 
263  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
264  }
265 
266 #endif
267 
268 #if !FW_DIRECT_PORT_CALLS
269 
270  // ----------------------------------------------------------------------
271  // Connect typed input ports to typed output ports
272  // ----------------------------------------------------------------------
273 
276  FwIndexType portNum,
278  )
279  {
280  FW_ASSERT(
281  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
282  static_cast<FwAssertArgType>(portNum)
283  );
284 
285  this->m_allPacketsOut_OutputPort[portNum].addCallPort(port);
286  }
287 
290  FwIndexType portNum,
292  )
293  {
294  FW_ASSERT(
295  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
296  static_cast<FwAssertArgType>(portNum)
297  );
298 
299  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
300  }
301 
302 #endif
303 
304 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
305 
306  // ----------------------------------------------------------------------
307  // Connect serial input ports to special output ports
308  // ----------------------------------------------------------------------
309 
312  FwIndexType portNum,
313  Fw::InputSerializePort* port
314  )
315  {
316  FW_ASSERT(
317  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
318  static_cast<FwAssertArgType>(portNum)
319  );
320 
321  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
322  }
323 
324 #if FW_ENABLE_TEXT_LOGGING == 1
325 
326  void PassThroughRouterComponentBase ::
327  set_logTextOut_OutputPort(
328  FwIndexType portNum,
329  Fw::InputSerializePort* port
330  )
331  {
332  FW_ASSERT(
333  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
334  static_cast<FwAssertArgType>(portNum)
335  );
336 
337  this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
338  }
339 
340 #endif
341 
344  FwIndexType portNum,
345  Fw::InputSerializePort* port
346  )
347  {
348  FW_ASSERT(
349  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
350  static_cast<FwAssertArgType>(portNum)
351  );
352 
353  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
354  }
355 
356 #endif
357 
358 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
359 
360  // ----------------------------------------------------------------------
361  // Connect serial input ports to typed output ports
362  // ----------------------------------------------------------------------
363 
366  FwIndexType portNum,
367  Fw::InputSerializePort* port
368  )
369  {
370  FW_ASSERT(
371  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
372  static_cast<FwAssertArgType>(portNum)
373  );
374 
375  this->m_allPacketsOut_OutputPort[portNum].registerSerialPort(port);
376  }
377 
380  FwIndexType portNum,
381  Fw::InputSerializePort* port
382  )
383  {
384  FW_ASSERT(
385  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
386  static_cast<FwAssertArgType>(portNum)
387  );
388 
389  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
390  }
391 
392 #endif
393 
394  // ----------------------------------------------------------------------
395  // Component construction and destruction
396  // ----------------------------------------------------------------------
397 
399  PassThroughRouterComponentBase(const char* compName) :
400  Fw::PassiveComponentBase(compName)
401  {
402 
403  }
404 
407  {
408 
409  }
410 
411 #if !FW_DIRECT_PORT_CALLS
412 
413  // ----------------------------------------------------------------------
414  // Connection status queries for special output ports
415  // ----------------------------------------------------------------------
416 
419  {
420  FW_ASSERT(
421  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
422  static_cast<FwAssertArgType>(portNum)
423  );
424 
425  return this->m_logOut_OutputPort[portNum].isConnected();
426  }
427 
428 #if FW_ENABLE_TEXT_LOGGING == 1
429 
430  bool PassThroughRouterComponentBase ::
431  isConnected_logTextOut_OutputPort(FwIndexType portNum) const
432  {
433  FW_ASSERT(
434  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
435  static_cast<FwAssertArgType>(portNum)
436  );
437 
438  return this->m_logTextOut_OutputPort[portNum].isConnected();
439  }
440 
441 #endif
442 
445  {
446  FW_ASSERT(
447  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
448  static_cast<FwAssertArgType>(portNum)
449  );
450 
451  return this->m_timeCaller_OutputPort[portNum].isConnected();
452  }
453 
454 #endif
455 
456 #if !FW_DIRECT_PORT_CALLS
457 
458  // ----------------------------------------------------------------------
459  // Connection status queries for typed output ports
460  // ----------------------------------------------------------------------
461 
464  {
465  FW_ASSERT(
466  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
467  static_cast<FwAssertArgType>(portNum)
468  );
469 
470  return this->m_allPacketsOut_OutputPort[portNum].isConnected();
471  }
472 
475  {
476  FW_ASSERT(
477  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
478  static_cast<FwAssertArgType>(portNum)
479  );
480 
481  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
482  }
483 
484 #endif
485 
486  // ----------------------------------------------------------------------
487  // Port handler base-class functions for typed input ports
488  //
489  // Call these functions directly to bypass the corresponding ports
490  // ----------------------------------------------------------------------
491 
494  FwIndexType portNum,
495  Fw::Buffer& fwBuffer
496  )
497  {
498  // Make sure port number is valid
499  FW_ASSERT(
500  (0 <= portNum) && (portNum < this->getNum_allPacketsReturnIn_InputPorts()),
501  static_cast<FwAssertArgType>(portNum)
502  );
503 
504  // Call handler function
506  portNum,
507  fwBuffer
508  );
509  }
510 
513  FwIndexType portNum,
514  Fw::Buffer& data,
515  const ComCfg::FrameContext& context
516  )
517  {
518  // Make sure port number is valid
519  FW_ASSERT(
520  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
521  static_cast<FwAssertArgType>(portNum)
522  );
523 
524  // Call handler function
525  this->dataIn_handler(
526  portNum,
527  data,
528  context
529  );
530  }
531 
532 #if !FW_DIRECT_PORT_CALLS
533 
534  // ----------------------------------------------------------------------
535  // Invocation functions for typed output ports
536  // ----------------------------------------------------------------------
537 
540  FwIndexType portNum,
541  Fw::Buffer& fwBuffer
542  ) const
543  {
544  FW_ASSERT(
545  (0 <= portNum) && (portNum < this->getNum_allPacketsOut_OutputPorts()),
546  static_cast<FwAssertArgType>(portNum)
547  );
548 
549  FW_ASSERT(
550  this->m_allPacketsOut_OutputPort[portNum].isConnected(),
551  static_cast<FwAssertArgType>(portNum)
552  );
553  this->m_allPacketsOut_OutputPort[portNum].invoke(
554  fwBuffer
555  );
556  }
557 
560  FwIndexType portNum,
561  Fw::Buffer& data,
562  const ComCfg::FrameContext& context
563  ) const
564  {
565  FW_ASSERT(
566  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
567  static_cast<FwAssertArgType>(portNum)
568  );
569 
570  FW_ASSERT(
571  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
572  static_cast<FwAssertArgType>(portNum)
573  );
574  this->m_dataReturnOut_OutputPort[portNum].invoke(
575  data,
576  context
577  );
578  }
579 
580 #endif
581 
582  // ----------------------------------------------------------------------
583  // Time
584  // ----------------------------------------------------------------------
585 
587  getTime() const
588  {
589  if (this->isConnected_timeCaller_OutputPort(0)) {
590  Fw::Time _time;
591  this->timeCaller_out(0, _time);
592  return _time;
593  }
594  else {
595  return Fw::Time(TimeBase::TB_NONE, 0, 0);
596  }
597  }
598 
599  // ----------------------------------------------------------------------
600  // Calls for messages received on typed input ports
601  // ----------------------------------------------------------------------
602 
603  void PassThroughRouterComponentBase ::
604  m_p_allPacketsReturnIn_in(
605  Fw::PassiveComponentBase* callComp,
606  FwIndexType portNum,
607  Fw::Buffer& fwBuffer
608  )
609  {
610  FW_ASSERT(callComp);
611  PassThroughRouterComponentBase* compPtr = static_cast<PassThroughRouterComponentBase*>(callComp);
613  portNum,
614  fwBuffer
615  );
616  }
617 
618  void PassThroughRouterComponentBase ::
619  m_p_dataIn_in(
620  Fw::PassiveComponentBase* callComp,
621  FwIndexType portNum,
622  Fw::Buffer& data,
623  const ComCfg::FrameContext& context
624  )
625  {
626  FW_ASSERT(callComp);
627  PassThroughRouterComponentBase* compPtr = static_cast<PassThroughRouterComponentBase*>(callComp);
628  compPtr->dataIn_handlerBase(
629  portNum,
630  data,
631  context
632  );
633  }
634 
635 #if !FW_DIRECT_PORT_CALLS
636 
637  // ----------------------------------------------------------------------
638  // Invocation functions for special output ports
639  // ----------------------------------------------------------------------
640 
641  void PassThroughRouterComponentBase ::
642  timeCaller_out(
643  FwIndexType portNum,
644  Fw::Time& time
645  ) const
646  {
647  FW_ASSERT(
648  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
649  static_cast<FwAssertArgType>(portNum)
650  );
651 
652  FW_ASSERT(
653  this->m_timeCaller_OutputPort[portNum].isConnected(),
654  static_cast<FwAssertArgType>(portNum)
655  );
656  this->m_timeCaller_OutputPort[portNum].invoke(
657  time
658  );
659  }
660 
661 #endif
662 
663 }
static constexpr FwIndexType getNum_dataReturnOut_OutputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
I32 FwEnumStoreType
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
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 set_dataReturnOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataReturnOut[portNum].
void init()
Initialization function.
Definition: TimePortAc.cpp:151
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 connection.
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
bool isConnected_allPacketsOut_OutputPort(FwIndexType portNum) const
void invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port connection.
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke output port dataReturnOut.
void init()
Initialization function.
void set_allPacketsOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to allPacketsOut[portNum].
bool isConnected() const
Definition: PortBase.cpp:38
void allPacketsOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port allPacketsOut.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:180
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:186
Type used to pass context info between components during framing/deframing.
bool isConnected_dataReturnOut_OutputPort(FwIndexType portNum) const
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
bool isConnected_logOut_OutputPort(FwIndexType portNum) const