F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
FramerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FramerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Framer 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 Svc {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
21  init(FwEnumStoreType instance)
22  {
23  // Initialize base class
25 
26  // Connect input port bufferIn
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_bufferIn_InputPorts());
30  port++
31  ) {
32  this->m_bufferIn_InputPort[port].init();
33  this->m_bufferIn_InputPort[port].addCallComp(
34  this,
35  m_p_bufferIn_in
36  );
37  this->m_bufferIn_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_bufferIn_InputPort[%" PRI_PlatformIntType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_bufferIn_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect input port comIn
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
54  port++
55  ) {
56  this->m_comIn_InputPort[port].init();
57  this->m_comIn_InputPort[port].addCallComp(
58  this,
59  m_p_comIn_in
60  );
61  this->m_comIn_InputPort[port].setPortNum(port);
62 
63 #if FW_OBJECT_NAMES == 1
64  Fw::ObjectName portName;
65  portName.format(
66  "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
67  this->m_objName.toChar(),
68  port
69  );
70  this->m_comIn_InputPort[port].setObjName(portName.toChar());
71 #endif
72  }
73 
74  // Connect input port comStatusIn
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
78  port++
79  ) {
80  this->m_comStatusIn_InputPort[port].init();
81  this->m_comStatusIn_InputPort[port].addCallComp(
82  this,
83  m_p_comStatusIn_in
84  );
85  this->m_comStatusIn_InputPort[port].setPortNum(port);
86 
87 #if FW_OBJECT_NAMES == 1
88  Fw::ObjectName portName;
89  portName.format(
90  "%s_comStatusIn_InputPort[%" PRI_PlatformIntType "]",
91  this->m_objName.toChar(),
92  port
93  );
94  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
95 #endif
96  }
97 
98  // Connect output port bufferDeallocate
99  for (
100  FwIndexType port = 0;
101  port < static_cast<FwIndexType>(this->getNum_bufferDeallocate_OutputPorts());
102  port++
103  ) {
104  this->m_bufferDeallocate_OutputPort[port].init();
105 
106 #if FW_OBJECT_NAMES == 1
107  Fw::ObjectName portName;
108  portName.format(
109  "%s_bufferDeallocate_OutputPort[%" PRI_PlatformIntType "]",
110  this->m_objName.toChar(),
111  port
112  );
113  this->m_bufferDeallocate_OutputPort[port].setObjName(portName.toChar());
114 #endif
115  }
116 
117  // Connect output port comStatusOut
118  for (
119  FwIndexType port = 0;
120  port < static_cast<FwIndexType>(this->getNum_comStatusOut_OutputPorts());
121  port++
122  ) {
123  this->m_comStatusOut_OutputPort[port].init();
124 
125 #if FW_OBJECT_NAMES == 1
126  Fw::ObjectName portName;
127  portName.format(
128  "%s_comStatusOut_OutputPort[%" PRI_PlatformIntType "]",
129  this->m_objName.toChar(),
130  port
131  );
132  this->m_comStatusOut_OutputPort[port].setObjName(portName.toChar());
133 #endif
134  }
135 
136  // Connect output port framedAllocate
137  for (
138  FwIndexType port = 0;
139  port < static_cast<FwIndexType>(this->getNum_framedAllocate_OutputPorts());
140  port++
141  ) {
142  this->m_framedAllocate_OutputPort[port].init();
143 
144 #if FW_OBJECT_NAMES == 1
145  Fw::ObjectName portName;
146  portName.format(
147  "%s_framedAllocate_OutputPort[%" PRI_PlatformIntType "]",
148  this->m_objName.toChar(),
149  port
150  );
151  this->m_framedAllocate_OutputPort[port].setObjName(portName.toChar());
152 #endif
153  }
154 
155  // Connect output port framedOut
156  for (
157  FwIndexType port = 0;
158  port < static_cast<FwIndexType>(this->getNum_framedOut_OutputPorts());
159  port++
160  ) {
161  this->m_framedOut_OutputPort[port].init();
162 
163 #if FW_OBJECT_NAMES == 1
164  Fw::ObjectName portName;
165  portName.format(
166  "%s_framedOut_OutputPort[%" PRI_PlatformIntType "]",
167  this->m_objName.toChar(),
168  port
169  );
170  this->m_framedOut_OutputPort[port].setObjName(portName.toChar());
171 #endif
172  }
173  }
174 
175  // ----------------------------------------------------------------------
176  // Getters for typed input ports
177  // ----------------------------------------------------------------------
178 
181  {
182  FW_ASSERT(
183  portNum < this->getNum_bufferIn_InputPorts(),
184  static_cast<FwAssertArgType>(portNum)
185  );
186 
187  return &this->m_bufferIn_InputPort[portNum];
188  }
189 
192  {
193  FW_ASSERT(
194  portNum < this->getNum_comIn_InputPorts(),
195  static_cast<FwAssertArgType>(portNum)
196  );
197 
198  return &this->m_comIn_InputPort[portNum];
199  }
200 
203  {
204  FW_ASSERT(
205  portNum < this->getNum_comStatusIn_InputPorts(),
206  static_cast<FwAssertArgType>(portNum)
207  );
208 
209  return &this->m_comStatusIn_InputPort[portNum];
210  }
211 
212  // ----------------------------------------------------------------------
213  // Connect typed input ports to typed output ports
214  // ----------------------------------------------------------------------
215 
218  FwIndexType portNum,
220  )
221  {
222  FW_ASSERT(
223  portNum < this->getNum_bufferDeallocate_OutputPorts(),
224  static_cast<FwAssertArgType>(portNum)
225  );
226 
227  this->m_bufferDeallocate_OutputPort[portNum].addCallPort(port);
228  }
229 
232  FwIndexType portNum,
234  )
235  {
236  FW_ASSERT(
237  portNum < this->getNum_comStatusOut_OutputPorts(),
238  static_cast<FwAssertArgType>(portNum)
239  );
240 
241  this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
242  }
243 
246  FwIndexType portNum,
248  )
249  {
250  FW_ASSERT(
251  portNum < this->getNum_framedAllocate_OutputPorts(),
252  static_cast<FwAssertArgType>(portNum)
253  );
254 
255  this->m_framedAllocate_OutputPort[portNum].addCallPort(port);
256  }
257 
260  FwIndexType portNum,
262  )
263  {
264  FW_ASSERT(
265  portNum < this->getNum_framedOut_OutputPorts(),
266  static_cast<FwAssertArgType>(portNum)
267  );
268 
269  this->m_framedOut_OutputPort[portNum].addCallPort(port);
270  }
271 
272 #if FW_PORT_SERIALIZATION
273 
274  // ----------------------------------------------------------------------
275  // Connect serial input ports to typed output ports
276  // ----------------------------------------------------------------------
277 
280  FwIndexType portNum,
281  Fw::InputSerializePort* port
282  )
283  {
284  FW_ASSERT(
285  portNum < this->getNum_bufferDeallocate_OutputPorts(),
286  static_cast<FwAssertArgType>(portNum)
287  );
288 
289  this->m_bufferDeallocate_OutputPort[portNum].registerSerialPort(port);
290  }
291 
294  FwIndexType portNum,
295  Fw::InputSerializePort* port
296  )
297  {
298  FW_ASSERT(
299  portNum < this->getNum_comStatusOut_OutputPorts(),
300  static_cast<FwAssertArgType>(portNum)
301  );
302 
303  this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
304  }
305 
306 #endif
307 
308  // ----------------------------------------------------------------------
309  // Component construction and destruction
310  // ----------------------------------------------------------------------
311 
313  FramerComponentBase(const char* compName) :
314  Fw::PassiveComponentBase(compName)
315  {
316 
317  }
318 
321  {
322 
323  }
324 
325  // ----------------------------------------------------------------------
326  // Getters for numbers of typed input ports
327  // ----------------------------------------------------------------------
328 
331  {
332  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferIn_InputPort));
333  }
334 
337  {
338  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
339  }
340 
343  {
344  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusIn_InputPort));
345  }
346 
347  // ----------------------------------------------------------------------
348  // Getters for numbers of typed output ports
349  // ----------------------------------------------------------------------
350 
353  {
354  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferDeallocate_OutputPort));
355  }
356 
359  {
360  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_comStatusOut_OutputPort));
361  }
362 
365  {
366  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_framedAllocate_OutputPort));
367  }
368 
371  {
372  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_framedOut_OutputPort));
373  }
374 
375  // ----------------------------------------------------------------------
376  // Connection status queries for typed output ports
377  // ----------------------------------------------------------------------
378 
381  {
382  FW_ASSERT(
383  portNum < this->getNum_bufferDeallocate_OutputPorts(),
384  static_cast<FwAssertArgType>(portNum)
385  );
386 
387  return this->m_bufferDeallocate_OutputPort[portNum].isConnected();
388  }
389 
392  {
393  FW_ASSERT(
394  portNum < this->getNum_comStatusOut_OutputPorts(),
395  static_cast<FwAssertArgType>(portNum)
396  );
397 
398  return this->m_comStatusOut_OutputPort[portNum].isConnected();
399  }
400 
403  {
404  FW_ASSERT(
405  portNum < this->getNum_framedAllocate_OutputPorts(),
406  static_cast<FwAssertArgType>(portNum)
407  );
408 
409  return this->m_framedAllocate_OutputPort[portNum].isConnected();
410  }
411 
414  {
415  FW_ASSERT(
416  portNum < this->getNum_framedOut_OutputPorts(),
417  static_cast<FwAssertArgType>(portNum)
418  );
419 
420  return this->m_framedOut_OutputPort[portNum].isConnected();
421  }
422 
423  // ----------------------------------------------------------------------
424  // Port handler base-class functions for typed input ports
425  //
426  // Call these functions directly to bypass the corresponding ports
427  // ----------------------------------------------------------------------
428 
431  FwIndexType portNum,
432  Fw::Buffer& fwBuffer
433  )
434  {
435  // Make sure port number is valid
436  FW_ASSERT(
437  portNum < this->getNum_bufferIn_InputPorts(),
438  static_cast<FwAssertArgType>(portNum)
439  );
440 
441  // Lock guard mutex before calling
442  this->lock();
443 
444  // Call handler function
445  this->bufferIn_handler(
446  portNum,
447  fwBuffer
448  );
449 
450  // Unlock guard mutex
451  this->unLock();
452  }
453 
456  FwIndexType portNum,
457  Fw::ComBuffer& data,
458  U32 context
459  )
460  {
461  // Make sure port number is valid
462  FW_ASSERT(
463  portNum < this->getNum_comIn_InputPorts(),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  // Lock guard mutex before calling
468  this->lock();
469 
470  // Call handler function
471  this->comIn_handler(
472  portNum,
473  data,
474  context
475  );
476 
477  // Unlock guard mutex
478  this->unLock();
479  }
480 
483  FwIndexType portNum,
484  Fw::Success& condition
485  )
486  {
487  // Make sure port number is valid
488  FW_ASSERT(
489  portNum < this->getNum_comStatusIn_InputPorts(),
490  static_cast<FwAssertArgType>(portNum)
491  );
492 
493  // Call handler function
494  this->comStatusIn_handler(
495  portNum,
496  condition
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  portNum < this->getNum_bufferDeallocate_OutputPorts(),
512  static_cast<FwAssertArgType>(portNum)
513  );
514  this->m_bufferDeallocate_OutputPort[portNum].invoke(
515  fwBuffer
516  );
517  }
518 
521  FwIndexType portNum,
522  Fw::Success& condition
523  )
524  {
525  FW_ASSERT(
526  portNum < this->getNum_comStatusOut_OutputPorts(),
527  static_cast<FwAssertArgType>(portNum)
528  );
529  this->m_comStatusOut_OutputPort[portNum].invoke(
530  condition
531  );
532  }
533 
536  FwIndexType portNum,
537  U32 size
538  )
539  {
540  FW_ASSERT(
541  portNum < this->getNum_framedAllocate_OutputPorts(),
542  static_cast<FwAssertArgType>(portNum)
543  );
544  return this->m_framedAllocate_OutputPort[portNum].invoke(
545  size
546  );
547  }
548 
551  FwIndexType portNum,
552  Fw::Buffer& sendBuffer
553  )
554  {
555  FW_ASSERT(
556  portNum < this->getNum_framedOut_OutputPorts(),
557  static_cast<FwAssertArgType>(portNum)
558  );
559  return this->m_framedOut_OutputPort[portNum].invoke(
560  sendBuffer
561  );
562  }
563 
564  // ----------------------------------------------------------------------
565  // Mutex operations for guarded ports
566  //
567  // You can override these operations to provide more sophisticated
568  // synchronization
569  // ----------------------------------------------------------------------
570 
572  lock()
573  {
574  this->m_guardedPortMutex.lock();
575  }
576 
578  unLock()
579  {
580  this->m_guardedPortMutex.unLock();
581  }
582 
583  // ----------------------------------------------------------------------
584  // Calls for messages received on typed input ports
585  // ----------------------------------------------------------------------
586 
587  void FramerComponentBase ::
588  m_p_bufferIn_in(
589  Fw::PassiveComponentBase* callComp,
590  FwIndexType portNum,
591  Fw::Buffer& fwBuffer
592  )
593  {
594  FW_ASSERT(callComp);
595  FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
596  compPtr->bufferIn_handlerBase(
597  portNum,
598  fwBuffer
599  );
600  }
601 
602  void FramerComponentBase ::
603  m_p_comIn_in(
604  Fw::PassiveComponentBase* callComp,
605  FwIndexType portNum,
606  Fw::ComBuffer& data,
607  U32 context
608  )
609  {
610  FW_ASSERT(callComp);
611  FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
612  compPtr->comIn_handlerBase(
613  portNum,
614  data,
615  context
616  );
617  }
618 
619  void FramerComponentBase ::
620  m_p_comStatusIn_in(
621  Fw::PassiveComponentBase* callComp,
622  FwIndexType portNum,
623  Fw::Success& condition
624  )
625  {
626  FW_ASSERT(callComp);
627  FramerComponentBase* compPtr = static_cast<FramerComponentBase*>(callComp);
628  compPtr->comStatusIn_handlerBase(
629  portNum,
630  condition
631  );
632  }
633 
634 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:70
#define PRI_PlatformIntType
I32 FwEnumStoreType
Definition: FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
void init()
Initialization function.
Drv::SendStatus invoke(Fw::Buffer &sendBuffer)
Invoke a port interface.
void addCallPort(InputByteStreamSendPort *callPort)
Register an input port.
Status returned by the send call.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
void init()
Initialization function.
Definition: ComPortAc.cpp:56
void setPortNum(NATIVE_INT_TYPE portNum)
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void init()
Initialization function.
void addCallPort(InputBufferGetPort *callPort)
Register an input port.
Fw::Buffer invoke(U32 size)
Invoke a port interface.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Buffer &fwBuffer)
Invoke a port interface.
void init()
Initialization function.
void invoke(Fw::Success &condition)
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputSuccessConditionPort *callPort)
Register an input port.
bool isConnected()
Definition: PortBase.cpp:41
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
Success/Failure.
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:40
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34
Auto-generated base for Framer component.
bool isConnected_bufferDeallocate_OutputPort(FwIndexType portNum)
Fw::InputBufferSendPort * get_bufferIn_InputPort(FwIndexType portNum)
virtual void comStatusIn_handler(FwIndexType portNum, Fw::Success &condition)=0
Handler for input port comStatusIn.
void bufferIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferIn.
virtual void unLock()
Unlock the guarded mutex.
FwIndexType getNum_framedOut_OutputPorts() const
virtual void comIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
virtual ~FramerComponentBase()
Destroy FramerComponentBase object.
void comIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
void set_framedOut_OutputPort(FwIndexType portNum, Drv::InputByteStreamSendPort *port)
Connect port to framedOut[portNum].
void bufferDeallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferDeallocate.
FwIndexType getNum_framedAllocate_OutputPorts() const
FwIndexType getNum_comStatusOut_OutputPorts() const
void comStatusOut_out(FwIndexType portNum, Fw::Success &condition)
Invoke output port comStatusOut.
Fw::InputSuccessConditionPort * get_comStatusIn_InputPort(FwIndexType portNum)
bool isConnected_framedOut_OutputPort(FwIndexType portNum)
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
void comStatusIn_handlerBase(FwIndexType portNum, Fw::Success &condition)
Handler base-class function for input port comStatusIn.
FwIndexType getNum_comStatusIn_InputPorts() const
FramerComponentBase(const char *compName="")
Construct FramerComponentBase object.
FwIndexType getNum_bufferIn_InputPorts() const
Drv::SendStatus framedOut_out(FwIndexType portNum, Fw::Buffer &sendBuffer)
Invoke output port framedOut.
FwIndexType getNum_comIn_InputPorts() const
void set_framedAllocate_OutputPort(FwIndexType portNum, Fw::InputBufferGetPort *port)
Connect port to framedAllocate[portNum].
Fw::Buffer framedAllocate_out(FwIndexType portNum, U32 size)
Invoke output port framedAllocate.
FwIndexType getNum_bufferDeallocate_OutputPorts() const
void set_bufferDeallocate_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferDeallocate[portNum].
virtual void bufferIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferIn.
bool isConnected_comStatusOut_OutputPort(FwIndexType portNum)
bool isConnected_framedAllocate_OutputPort(FwIndexType portNum)
void set_comStatusOut_OutputPort(FwIndexType portNum, Fw::InputSuccessConditionPort *port)
Connect port to comStatusOut[portNum].
virtual void lock()
Lock the guarded mutex.