F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComAggregatorComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComAggregatorComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComAggregator 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  namespace {
17 
18  // Constant definitions for the state machine signal buffer
19  namespace SmSignalBuffer {
20 
21  // Union for computing the max size of a signal type
22  union SignalTypeUnion {
23  BYTE size_of_Fw_Success[Fw::Success::SERIALIZED_SIZE];
24  BYTE size_of_Svc_ComDataContextPair[Svc::ComDataContextPair::SERIALIZED_SIZE];
25  };
26 
27  // The serialized size
28  static constexpr FwSizeType SERIALIZED_SIZE =
29  2 * sizeof(FwEnumStoreType) +
30  sizeof(SignalTypeUnion);
31 
32  }
33 
34  enum MsgTypeEnum {
35  COMAGGREGATOR_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
36  INTERNAL_STATE_MACHINE_SIGNAL,
37  };
38 
39  // Get the max size by constructing a union of the async input, command, and
40  // internal port serialization sizes
41  union BuffUnion {
42  // Size of buffer for internal state machine signals
43  // The internal SmSignalBuffer stores the state machine id, the
44  // signal id, and the signal data
45  BYTE internalSmBufferSize[SmSignalBuffer::SERIALIZED_SIZE];
46  };
47 
48  // Define a message buffer class large enough to handle all the
49  // asynchronous inputs to the component
50  class ComponentIpcSerializableBuffer :
52  {
53 
54  public:
55 
56  enum {
57  // Offset into data in buffer: Size of message ID and port number
58  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
59  // Max data size
60  MAX_DATA_SIZE = sizeof(BuffUnion),
61  // Max message size: Size of message id + size of port + max data size
62  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
63  };
64 
65  Fw::Serializable::SizeType getCapacity() const {
66  return sizeof(m_buff);
67  }
68 
69  U8* getBuffAddr() {
70  return m_buff;
71  }
72 
73  const U8* getBuffAddr() const {
74  return m_buff;
75  }
76 
77  private:
78  // Should be the max of all the input ports serialized sizes...
79  U8 m_buff[SERIALIZATION_SIZE];
80 
81  };
82  }
83 
84  // ----------------------------------------------------------------------
85  // Types for internal state machines
86  // ----------------------------------------------------------------------
87 
90  m_component(component)
91  {
92 
93  }
94 
97  {
98  this->initBase(static_cast<FwEnumStoreType>(smId));
99  }
100 
102  getId() const
103  {
104  return static_cast<ComAggregatorComponentBase::SmId>(this->m_id);
105  }
106 
107  void ComAggregatorComponentBase::Svc_AggregationMachine ::
108  action_doClear(Signal signal)
109  {
110  this->m_component.Svc_AggregationMachine_action_doClear(this->getId(), signal);
111  }
112 
113  void ComAggregatorComponentBase::Svc_AggregationMachine ::
114  action_doFill(
115  Signal signal,
116  const Svc::ComDataContextPair& value
117  )
118  {
119  this->m_component.Svc_AggregationMachine_action_doFill(this->getId(), signal, value);
120  }
121 
122  void ComAggregatorComponentBase::Svc_AggregationMachine ::
123  action_doSend(Signal signal)
124  {
125  this->m_component.Svc_AggregationMachine_action_doSend(this->getId(), signal);
126  }
127 
128  void ComAggregatorComponentBase::Svc_AggregationMachine ::
129  action_doHold(
130  Signal signal,
131  const Svc::ComDataContextPair& value
132  )
133  {
134  this->m_component.Svc_AggregationMachine_action_doHold(this->getId(), signal, value);
135  }
136 
137  void ComAggregatorComponentBase::Svc_AggregationMachine ::
138  action_assertNoStatus(Signal signal)
139  {
140  this->m_component.Svc_AggregationMachine_action_assertNoStatus(this->getId(), signal);
141  }
142 
143  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
144  guard_isFull(
145  Signal signal,
146  const Svc::ComDataContextPair& value
147  ) const
148  {
149  return this->m_component.Svc_AggregationMachine_guard_isFull(this->getId(), signal, value);
150  }
151 
152  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
153  guard_willFill(
154  Signal signal,
155  const Svc::ComDataContextPair& value
156  ) const
157  {
158  return this->m_component.Svc_AggregationMachine_guard_willFill(this->getId(), signal, value);
159  }
160 
161  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
162  guard_isNotEmpty(Signal signal) const
163  {
164  return this->m_component.Svc_AggregationMachine_guard_isNotEmpty(this->getId(), signal);
165  }
166 
167  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
168  guard_isGood(
169  Signal signal,
170  const Fw::Success& value
171  ) const
172  {
173  return this->m_component.Svc_AggregationMachine_guard_isGood(this->getId(), signal, value);
174  }
175 
176  // ----------------------------------------------------------------------
177  // Component initialization
178  // ----------------------------------------------------------------------
179 
182  FwSizeType queueDepth,
183  FwEnumStoreType instance
184  )
185  {
186  // Initialize base class
188 
189  // Initialize state machine instances
190  this->m_stateMachine_aggregationMachine.init(SmId::aggregationMachine);
191 
192  // Connect input port comStatusIn
193  for (
194  FwIndexType port = 0;
195  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
196  port++
197  ) {
198  this->m_comStatusIn_InputPort[port].init();
199  this->m_comStatusIn_InputPort[port].addCallComp(
200  this,
201  m_p_comStatusIn_in
202  );
203  this->m_comStatusIn_InputPort[port].setPortNum(port);
204 
205 #if FW_OBJECT_NAMES == 1
206  Fw::ObjectName portName;
207  portName.format(
208  "%s_comStatusIn_InputPort[%" PRI_FwIndexType "]",
209  this->m_objName.toChar(),
210  port
211  );
212  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
213 #endif
214  }
215 
216  // Connect input port dataIn
217  for (
218  FwIndexType port = 0;
219  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
220  port++
221  ) {
222  this->m_dataIn_InputPort[port].init();
223  this->m_dataIn_InputPort[port].addCallComp(
224  this,
225  m_p_dataIn_in
226  );
227  this->m_dataIn_InputPort[port].setPortNum(port);
228 
229 #if FW_OBJECT_NAMES == 1
230  Fw::ObjectName portName;
231  portName.format(
232  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
233  this->m_objName.toChar(),
234  port
235  );
236  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
237 #endif
238  }
239 
240  // Connect input port dataReturnIn
241  for (
242  FwIndexType port = 0;
243  port < static_cast<FwIndexType>(this->getNum_dataReturnIn_InputPorts());
244  port++
245  ) {
246  this->m_dataReturnIn_InputPort[port].init();
247  this->m_dataReturnIn_InputPort[port].addCallComp(
248  this,
249  m_p_dataReturnIn_in
250  );
251  this->m_dataReturnIn_InputPort[port].setPortNum(port);
252 
253 #if FW_OBJECT_NAMES == 1
254  Fw::ObjectName portName;
255  portName.format(
256  "%s_dataReturnIn_InputPort[%" PRI_FwIndexType "]",
257  this->m_objName.toChar(),
258  port
259  );
260  this->m_dataReturnIn_InputPort[port].setObjName(portName.toChar());
261 #endif
262  }
263 
264  // Connect input port timeout
265  for (
266  FwIndexType port = 0;
267  port < static_cast<FwIndexType>(this->getNum_timeout_InputPorts());
268  port++
269  ) {
270  this->m_timeout_InputPort[port].init();
271  this->m_timeout_InputPort[port].addCallComp(
272  this,
273  m_p_timeout_in
274  );
275  this->m_timeout_InputPort[port].setPortNum(port);
276 
277 #if FW_OBJECT_NAMES == 1
278  Fw::ObjectName portName;
279  portName.format(
280  "%s_timeout_InputPort[%" PRI_FwIndexType "]",
281  this->m_objName.toChar(),
282  port
283  );
284  this->m_timeout_InputPort[port].setObjName(portName.toChar());
285 #endif
286  }
287 
288  // Connect output port comStatusOut
289  for (
290  FwIndexType port = 0;
291  port < static_cast<FwIndexType>(this->getNum_comStatusOut_OutputPorts());
292  port++
293  ) {
294  this->m_comStatusOut_OutputPort[port].init();
295 
296 #if FW_OBJECT_NAMES == 1
297  Fw::ObjectName portName;
298  portName.format(
299  "%s_comStatusOut_OutputPort[%" PRI_FwIndexType "]",
300  this->m_objName.toChar(),
301  port
302  );
303  this->m_comStatusOut_OutputPort[port].setObjName(portName.toChar());
304 #endif
305  }
306 
307  // Connect output port dataOut
308  for (
309  FwIndexType port = 0;
310  port < static_cast<FwIndexType>(this->getNum_dataOut_OutputPorts());
311  port++
312  ) {
313  this->m_dataOut_OutputPort[port].init();
314 
315 #if FW_OBJECT_NAMES == 1
316  Fw::ObjectName portName;
317  portName.format(
318  "%s_dataOut_OutputPort[%" PRI_FwIndexType "]",
319  this->m_objName.toChar(),
320  port
321  );
322  this->m_dataOut_OutputPort[port].setObjName(portName.toChar());
323 #endif
324  }
325 
326  // Connect output port dataReturnOut
327  for (
328  FwIndexType port = 0;
329  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
330  port++
331  ) {
332  this->m_dataReturnOut_OutputPort[port].init();
333 
334 #if FW_OBJECT_NAMES == 1
335  Fw::ObjectName portName;
336  portName.format(
337  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
338  this->m_objName.toChar(),
339  port
340  );
341  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
342 #endif
343  }
344 
345  // Create the queue
346  Os::Queue::Status qStat = this->createQueue(
347  queueDepth,
348  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
349  );
350  FW_ASSERT(
351  Os::Queue::Status::OP_OK == qStat,
352  static_cast<FwAssertArgType>(qStat)
353  );
354  }
355 
356  // ----------------------------------------------------------------------
357  // Getters for typed input ports
358  // ----------------------------------------------------------------------
359 
362  {
363  FW_ASSERT(
364  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
365  static_cast<FwAssertArgType>(portNum)
366  );
367 
368  return &this->m_comStatusIn_InputPort[portNum];
369  }
370 
373  {
374  FW_ASSERT(
375  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
376  static_cast<FwAssertArgType>(portNum)
377  );
378 
379  return &this->m_dataIn_InputPort[portNum];
380  }
381 
384  {
385  FW_ASSERT(
386  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
387  static_cast<FwAssertArgType>(portNum)
388  );
389 
390  return &this->m_dataReturnIn_InputPort[portNum];
391  }
392 
395  {
396  FW_ASSERT(
397  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
398  static_cast<FwAssertArgType>(portNum)
399  );
400 
401  return &this->m_timeout_InputPort[portNum];
402  }
403 
404  // ----------------------------------------------------------------------
405  // Connect typed input ports to typed output ports
406  // ----------------------------------------------------------------------
407 
410  FwIndexType portNum,
412  )
413  {
414  FW_ASSERT(
415  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
416  static_cast<FwAssertArgType>(portNum)
417  );
418 
419  this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
420  }
421 
424  FwIndexType portNum,
426  )
427  {
428  FW_ASSERT(
429  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
430  static_cast<FwAssertArgType>(portNum)
431  );
432 
433  this->m_dataOut_OutputPort[portNum].addCallPort(port);
434  }
435 
438  FwIndexType portNum,
440  )
441  {
442  FW_ASSERT(
443  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
444  static_cast<FwAssertArgType>(portNum)
445  );
446 
447  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
448  }
449 
450 #if FW_PORT_SERIALIZATION
451 
452  // ----------------------------------------------------------------------
453  // Connect serial input ports to typed output ports
454  // ----------------------------------------------------------------------
455 
458  FwIndexType portNum,
459  Fw::InputSerializePort* port
460  )
461  {
462  FW_ASSERT(
463  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
468  }
469 
472  FwIndexType portNum,
473  Fw::InputSerializePort* port
474  )
475  {
476  FW_ASSERT(
477  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
478  static_cast<FwAssertArgType>(portNum)
479  );
480 
481  this->m_dataOut_OutputPort[portNum].registerSerialPort(port);
482  }
483 
486  FwIndexType portNum,
487  Fw::InputSerializePort* port
488  )
489  {
490  FW_ASSERT(
491  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
492  static_cast<FwAssertArgType>(portNum)
493  );
494 
495  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
496  }
497 
498 #endif
499 
500  // ----------------------------------------------------------------------
501  // Component construction and destruction
502  // ----------------------------------------------------------------------
503 
505  ComAggregatorComponentBase(const char* compName) :
506  Fw::ActiveComponentBase(compName),
507  m_stateMachine_aggregationMachine(*this)
508  {
509 
510  }
511 
514  {
515 
516  }
517 
518  // ----------------------------------------------------------------------
519  // Connection status queries for typed output ports
520  // ----------------------------------------------------------------------
521 
524  {
525  FW_ASSERT(
526  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
527  static_cast<FwAssertArgType>(portNum)
528  );
529 
530  return this->m_comStatusOut_OutputPort[portNum].isConnected();
531  }
532 
535  {
536  FW_ASSERT(
537  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
538  static_cast<FwAssertArgType>(portNum)
539  );
540 
541  return this->m_dataOut_OutputPort[portNum].isConnected();
542  }
543 
546  {
547  FW_ASSERT(
548  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
549  static_cast<FwAssertArgType>(portNum)
550  );
551 
552  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
553  }
554 
555  // ----------------------------------------------------------------------
556  // Port handler base-class functions for typed input ports
557  //
558  // Call these functions directly to bypass the corresponding ports
559  // ----------------------------------------------------------------------
560 
563  FwIndexType portNum,
564  Fw::Success& condition
565  )
566  {
567  // Make sure port number is valid
568  FW_ASSERT(
569  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
570  static_cast<FwAssertArgType>(portNum)
571  );
572 
573  // Call handler function
574  this->comStatusIn_handler(
575  portNum,
576  condition
577  );
578  }
579 
582  FwIndexType portNum,
583  Fw::Buffer& data,
584  const ComCfg::FrameContext& context
585  )
586  {
587  // Make sure port number is valid
588  FW_ASSERT(
589  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
590  static_cast<FwAssertArgType>(portNum)
591  );
592 
593  // Call handler function
594  this->dataIn_handler(
595  portNum,
596  data,
597  context
598  );
599  }
600 
603  FwIndexType portNum,
604  Fw::Buffer& data,
605  const ComCfg::FrameContext& context
606  )
607  {
608  // Make sure port number is valid
609  FW_ASSERT(
610  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
611  static_cast<FwAssertArgType>(portNum)
612  );
613 
614  // Call handler function
615  this->dataReturnIn_handler(
616  portNum,
617  data,
618  context
619  );
620  }
621 
624  FwIndexType portNum,
625  U32 context
626  )
627  {
628  // Make sure port number is valid
629  FW_ASSERT(
630  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
631  static_cast<FwAssertArgType>(portNum)
632  );
633 
634  // Call handler function
635  this->timeout_handler(
636  portNum,
637  context
638  );
639  }
640 
641  // ----------------------------------------------------------------------
642  // Invocation functions for typed output ports
643  // ----------------------------------------------------------------------
644 
647  FwIndexType portNum,
648  Fw::Success& condition
649  )
650  {
651  FW_ASSERT(
652  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
653  static_cast<FwAssertArgType>(portNum)
654  );
655 
656  FW_ASSERT(
657  this->m_comStatusOut_OutputPort[portNum].isConnected(),
658  static_cast<FwAssertArgType>(portNum)
659  );
660  this->m_comStatusOut_OutputPort[portNum].invoke(
661  condition
662  );
663  }
664 
667  FwIndexType portNum,
668  Fw::Buffer& data,
669  const ComCfg::FrameContext& context
670  )
671  {
672  FW_ASSERT(
673  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
674  static_cast<FwAssertArgType>(portNum)
675  );
676 
677  FW_ASSERT(
678  this->m_dataOut_OutputPort[portNum].isConnected(),
679  static_cast<FwAssertArgType>(portNum)
680  );
681  this->m_dataOut_OutputPort[portNum].invoke(
682  data,
683  context
684  );
685  }
686 
689  FwIndexType portNum,
690  Fw::Buffer& data,
691  const ComCfg::FrameContext& context
692  )
693  {
694  FW_ASSERT(
695  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
696  static_cast<FwAssertArgType>(portNum)
697  );
698 
699  FW_ASSERT(
700  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
701  static_cast<FwAssertArgType>(portNum)
702  );
703  this->m_dataReturnOut_OutputPort[portNum].invoke(
704  data,
705  context
706  );
707  }
708 
709  // ----------------------------------------------------------------------
710  // State getter functions
711  // ----------------------------------------------------------------------
712 
715  {
716  return this->m_stateMachine_aggregationMachine.getState();
717  }
718 
719  // ----------------------------------------------------------------------
720  // Signal send functions
721  // ----------------------------------------------------------------------
722 
725  {
726  ComponentIpcSerializableBuffer buffer;
727  // Serialize the message type, port number, state ID, and signal
728  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::timeout), buffer);
729  // Send the message and handle overflow
730  this->aggregationMachine_sendSignalFinish(buffer);
731  }
732 
735  {
736  ComponentIpcSerializableBuffer buffer;
737  // Serialize the message type, port number, state ID, and signal
738  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::fill), buffer);
739  // Serialize the signal data
740  const Fw::SerializeStatus status = buffer.serializeFrom(value);
741  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
742  // Send the message and handle overflow
743  this->aggregationMachine_sendSignalFinish(buffer);
744  }
745 
748  {
749  ComponentIpcSerializableBuffer buffer;
750  // Serialize the message type, port number, state ID, and signal
751  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::status), buffer);
752  // Serialize the signal data
753  const Fw::SerializeStatus status = buffer.serializeFrom(value);
754  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
755  // Send the message and handle overflow
756  this->aggregationMachine_sendSignalFinish(buffer);
757  }
758 
759  // ----------------------------------------------------------------------
760  // Message dispatch functions
761  // ----------------------------------------------------------------------
762 
763  Fw::QueuedComponentBase::MsgDispatchStatus ComAggregatorComponentBase ::
764  doDispatch()
765  {
766  ComponentIpcSerializableBuffer _msg;
767  FwQueuePriorityType _priority = 0;
768 
769  Os::Queue::Status _msgStatus = this->m_queue.receive(
770  _msg,
772  _priority
773  );
774  FW_ASSERT(
775  _msgStatus == Os::Queue::OP_OK,
776  static_cast<FwAssertArgType>(_msgStatus)
777  );
778 
779  // Reset to beginning of buffer
780  _msg.resetDeser();
781 
782  FwEnumStoreType _desMsg = 0;
783  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
784  FW_ASSERT(
785  _deserStatus == Fw::FW_SERIALIZE_OK,
786  static_cast<FwAssertArgType>(_deserStatus)
787  );
788 
789  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
790 
791  if (_msgType == COMAGGREGATOR_COMPONENT_EXIT) {
792  return MSG_DISPATCH_EXIT;
793  }
794 
795  FwIndexType portNum = 0;
796  _deserStatus = _msg.deserializeTo(portNum);
797  FW_ASSERT(
798  _deserStatus == Fw::FW_SERIALIZE_OK,
799  static_cast<FwAssertArgType>(_deserStatus)
800  );
801 
802  switch (_msgType) {
803 
804  // Handle signals to internal state machines
805  case INTERNAL_STATE_MACHINE_SIGNAL:
806  this->smDispatch(_msg);
807  break;
808 
809  default:
810  return MSG_DISPATCH_ERROR;
811  }
812 
813  return MSG_DISPATCH_OK;
814  }
815 
816  // ----------------------------------------------------------------------
817  // Calls for messages received on typed input ports
818  // ----------------------------------------------------------------------
819 
820  void ComAggregatorComponentBase ::
821  m_p_comStatusIn_in(
822  Fw::PassiveComponentBase* callComp,
823  FwIndexType portNum,
824  Fw::Success& condition
825  )
826  {
827  FW_ASSERT(callComp);
828  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
829  compPtr->comStatusIn_handlerBase(
830  portNum,
831  condition
832  );
833  }
834 
835  void ComAggregatorComponentBase ::
836  m_p_dataIn_in(
837  Fw::PassiveComponentBase* callComp,
838  FwIndexType portNum,
839  Fw::Buffer& data,
840  const ComCfg::FrameContext& context
841  )
842  {
843  FW_ASSERT(callComp);
844  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
845  compPtr->dataIn_handlerBase(
846  portNum,
847  data,
848  context
849  );
850  }
851 
852  void ComAggregatorComponentBase ::
853  m_p_dataReturnIn_in(
854  Fw::PassiveComponentBase* callComp,
855  FwIndexType portNum,
856  Fw::Buffer& data,
857  const ComCfg::FrameContext& context
858  )
859  {
860  FW_ASSERT(callComp);
861  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
862  compPtr->dataReturnIn_handlerBase(
863  portNum,
864  data,
865  context
866  );
867  }
868 
869  void ComAggregatorComponentBase ::
870  m_p_timeout_in(
871  Fw::PassiveComponentBase* callComp,
872  FwIndexType portNum,
873  U32 context
874  )
875  {
876  FW_ASSERT(callComp);
877  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
878  compPtr->timeout_handlerBase(
879  portNum,
880  context
881  );
882  }
883 
884  // ----------------------------------------------------------------------
885  // Send signal helper functions
886  // ----------------------------------------------------------------------
887 
888  void ComAggregatorComponentBase ::
889  sendSignalStart(
890  SmId smId,
891  FwEnumStoreType signal,
892  Fw::SerialBufferBase& buffer
893  )
894  {
896 
897  // Serialize the message type
898  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(INTERNAL_STATE_MACHINE_SIGNAL));
899  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
900 
901  // Serialize the port number
902  status = buffer.serializeFrom(static_cast<FwIndexType>(0));
903  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
904 
905  // Serialize the state machine ID
906  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(smId));
907  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
908 
909  // Serialize the signal
910  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(signal));
911  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
912  }
913 
914  void ComAggregatorComponentBase ::
915  aggregationMachine_sendSignalFinish(Fw::LinearBufferBase& buffer)
916  {
917  // Send message
919  Os::Queue::Status qStatus = this->m_queue.send(buffer, 0, _block);
920 
921  FW_ASSERT(
922  qStatus == Os::Queue::OP_OK,
923  static_cast<FwAssertArgType>(qStatus)
924  );
925  }
926 
927  // ----------------------------------------------------------------------
928  // Helper functions for state machine dispatch
929  // ----------------------------------------------------------------------
930 
931  void ComAggregatorComponentBase ::
932  smDispatch(Fw::SerialBufferBase& buffer)
933  {
934  // Deserialize the state machine ID and signal
935  FwEnumStoreType storedSmId;
936  FwEnumStoreType storedSignal;
937  ComAggregatorComponentBase::deserializeSmIdAndSignal(buffer, storedSmId, storedSignal);
938 
939  // Select the target state machine instance
940  const SmId smId = static_cast<SmId>(storedSmId);
941  switch (smId) {
943  const Svc_AggregationMachine::Signal signal = static_cast<Svc_AggregationMachine::Signal>(storedSignal);
944  this->Svc_AggregationMachine_smDispatch(buffer, this->m_stateMachine_aggregationMachine, signal);
945  break;
946  }
947  default:
948  FW_ASSERT(0, static_cast<FwAssertArgType>(smId));
949  break;
950  }
951  }
952 
953  void ComAggregatorComponentBase ::
954  deserializeSmIdAndSignal(
955  Fw::SerialBufferBase& buffer,
956  FwEnumStoreType& smId,
957  FwEnumStoreType& signal
958  )
959  {
960  // Move deserialization beyond the message type and port number
961  Fw::SerializeStatus status =
962  buffer.moveDeserToOffset(ComponentIpcSerializableBuffer::DATA_OFFSET);
963  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
964 
965  // Deserialize the state machine ID
966  status = buffer.deserializeTo(smId);
967  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
968 
969  // Deserialize the signal
970  status = buffer.deserializeTo(signal);
971  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
972  }
973 
974  void ComAggregatorComponentBase ::
975  Svc_AggregationMachine_smDispatch(
976  Fw::SerialBufferBase& buffer,
977  Svc_AggregationMachine& sm,
979  )
980  {
981  switch (signal) {
983  // Assert no data left in buffer
984  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
985  // Call the sendSignal function for sm and timeout
986  sm.sendSignal_timeout();
987  break;
988  }
990  // Deserialize the data
992  const Fw::SerializeStatus status = buffer.deserializeTo(value);
993  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
994  // Assert no data left in buffer
995  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
996  // Call the sendSignal function for sm and fill
997  sm.sendSignal_fill(value);
998  break;
999  }
1001  // Deserialize the data
1002  Fw::Success value;
1003  const Fw::SerializeStatus status = buffer.deserializeTo(value);
1004  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1005  // Assert no data left in buffer
1006  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1007  // Call the sendSignal function for sm and status
1008  sm.sendSignal_status(value);
1009  break;
1010  }
1011  default:
1012  FW_ASSERT(0, static_cast<FwAssertArgType>(signal));
1013  break;
1014  }
1015  }
1016 
1017 }
Serialization/Deserialization operation was successful.
bool isConnected_dataOut_OutputPort(FwIndexType portNum)
void comStatusOut_out(FwIndexType portNum, Fw::Success &condition)
Invoke output port comStatusOut.
static constexpr FwIndexType getNum_comStatusOut_OutputPorts()
Operation succeeded.
Definition: Os.hpp:26
static constexpr FwIndexType getNum_dataOut_OutputPorts()
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_dataIn_InputPorts()
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
void set_dataReturnOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataReturnOut[portNum].
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataReturnOut.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init(ComAggregatorComponentBase::SmId smId)
Initialize the state machine.
void aggregationMachine_sendSignal_status(const Fw::Success &value)
Send signal status to state machine aggregationMachine.
static constexpr FwIndexType getNum_timeout_InputPorts()
void timeout_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port timeout.
static constexpr FwIndexType getNum_comStatusIn_InputPorts()
AggregationMachineStateMachineBase::State getState() const
Get the state.
Fw::InputSuccessConditionPort * get_comStatusIn_InputPort(FwIndexType portNum)
virtual ~ComAggregatorComponentBase()
Destroy ComAggregatorComponentBase object.
Svc_AggregationMachine::State aggregationMachine_getState() const
Get the state of state machine instance aggregationMachine.
void addCallPort(InputSuccessConditionPort *callPort)
Register an input port.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
Os::Queue m_queue
queue object for active component
static constexpr FwIndexType getNum_dataReturnIn_InputPorts()
void addCallPort(InputComDataWithContextPort *callPort)
Register an input port.
void dataIn_handlerBase(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Handler base-class function for input port dataIn.
void set_comStatusOut_OutputPort(FwIndexType portNum, Fw::InputSuccessConditionPort *port)
Connect port to comStatusOut[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
Message will block until space is available.
Definition: Queue.hpp:47
void dataReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Handler base-class function for input port dataReturnIn.
The size of the serial representation.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
Svc_AggregationMachine(ComAggregatorComponentBase &component)
Constructor.
virtual void dataIn_handler(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)=0
Handler for input port dataIn.
ActiveComponentBase(const char *name)
Constructor.
void comStatusIn_handlerBase(FwIndexType portNum, Fw::Success &condition)
Handler base-class function for input port comStatusIn.
message to exit active component task
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
Svc::InputComDataWithContextPort * get_dataReturnIn_InputPort(FwIndexType portNum)
FwSizeType SizeType
void invoke(Fw::Success &condition) const
Invoke a port interface.
void invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port interface.
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
ComAggregatorComponentBase::SmId getId() const
Get the state machine id.
virtual void timeout_handler(FwIndexType portNum, U32 context)=0
Handler for input port timeout.
ComAggregatorComponentBase(const char *compName="")
Construct ComAggregatorComponentBase object.
bool isConnected_comStatusOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
virtual Serializable::SizeType getDeserializeSizeLeft() const =0
Get remaining deserialization buffer size.
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
Auto-generated base for ComAggregator component.
void aggregationMachine_sendSignal_timeout()
Send signal timeout to state machine aggregationMachine.
void init()
Initialization function.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
A message was sent requesting an exit of the loop.
static constexpr FwIndexType getNum_dataReturnOut_OutputPorts()
PlatformIndexType FwIndexType
virtual void comStatusIn_handler(FwIndexType portNum, Fw::Success &condition)=0
Handler for input port comStatusIn.
Svc::InputComDataWithContextPort * get_dataIn_InputPort(FwIndexType portNum)
Type used to pass context info between components during framing/deframing.
Svc::InputSchedPort * get_timeout_InputPort(FwIndexType portNum)
RateGroupDivider component implementation.
bool isConnected_dataReturnOut_OutputPort(FwIndexType portNum)
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:56
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
void init()
Initialization function.
virtual SerializeStatus moveDeserToOffset(FwSizeType offset)=0
Move deserialization pointer to specified offset.
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void aggregationMachine_sendSignal_fill(const Svc::ComDataContextPair &value)
Send signal fill to state machine aggregationMachine.
Success/Failure.
void set_dataOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataOut[portNum].
void dataOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Invoke output port dataOut.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
virtual void dataReturnIn_handler(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)=0
Handler for input port dataReturnIn.
void init()
Initialization function.