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  ComponentIpcSerializableBuffer() : Fw::LinearBufferBase(m_buff, sizeof(m_buff)) {
66 
67  }
68 
69  private:
70  // Should be the max of all the input ports serialized sizes...
71  U8 m_buff[SERIALIZATION_SIZE];
72 
73  };
74  }
75 
76  // ----------------------------------------------------------------------
77  // Types for internal state machines
78  // ----------------------------------------------------------------------
79 
82  m_component(component)
83  {
84 
85  }
86 
89  {
90  this->initBase(static_cast<FwEnumStoreType>(smId));
91  }
92 
94  getId() const
95  {
96  return static_cast<ComAggregatorComponentBase::SmId>(this->m_id);
97  }
98 
99  void ComAggregatorComponentBase::Svc_AggregationMachine ::
100  action_doClear(Signal signal)
101  {
102  this->m_component.Svc_AggregationMachine_action_doClear(this->getId(), signal);
103  }
104 
105  void ComAggregatorComponentBase::Svc_AggregationMachine ::
106  action_doFill(
107  Signal signal,
108  const Svc::ComDataContextPair& value
109  )
110  {
111  this->m_component.Svc_AggregationMachine_action_doFill(this->getId(), signal, value);
112  }
113 
114  void ComAggregatorComponentBase::Svc_AggregationMachine ::
115  action_doSend(Signal signal)
116  {
117  this->m_component.Svc_AggregationMachine_action_doSend(this->getId(), signal);
118  }
119 
120  void ComAggregatorComponentBase::Svc_AggregationMachine ::
121  action_doHold(
122  Signal signal,
123  const Svc::ComDataContextPair& value
124  )
125  {
126  this->m_component.Svc_AggregationMachine_action_doHold(this->getId(), signal, value);
127  }
128 
129  void ComAggregatorComponentBase::Svc_AggregationMachine ::
130  action_doSplitHold(
131  Signal signal,
132  const Svc::ComDataContextPair& value
133  )
134  {
135  this->m_component.Svc_AggregationMachine_action_doSplitHold(this->getId(), signal, value);
136  }
137 
138  void ComAggregatorComponentBase::Svc_AggregationMachine ::
139  action_doNoteFailure(Signal signal)
140  {
141  this->m_component.Svc_AggregationMachine_action_doNoteFailure(this->getId(), signal);
142  }
143 
144  void ComAggregatorComponentBase::Svc_AggregationMachine ::
145  action_assertNoStatus(Signal signal)
146  {
147  this->m_component.Svc_AggregationMachine_action_assertNoStatus(this->getId(), signal);
148  }
149 
150  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
151  guard_isFull(
152  Signal signal,
153  const Svc::ComDataContextPair& value
154  ) const
155  {
156  return this->m_component.Svc_AggregationMachine_guard_isFull(this->getId(), signal, value);
157  }
158 
159  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
160  guard_willFill(
161  Signal signal,
162  const Svc::ComDataContextPair& value
163  ) const
164  {
165  return this->m_component.Svc_AggregationMachine_guard_willFill(this->getId(), signal, value);
166  }
167 
168  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
169  guard_isNotEmpty(Signal signal) const
170  {
171  return this->m_component.Svc_AggregationMachine_guard_isNotEmpty(this->getId(), signal);
172  }
173 
174  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
175  guard_isGood(
176  Signal signal,
177  const Fw::Success& value
178  ) const
179  {
180  return this->m_component.Svc_AggregationMachine_guard_isGood(this->getId(), signal, value);
181  }
182 
183  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
184  guard_isSpanFull(Signal signal) const
185  {
186  return this->m_component.Svc_AggregationMachine_guard_isSpanFull(this->getId(), signal);
187  }
188 
189  // ----------------------------------------------------------------------
190  // Component initialization
191  // ----------------------------------------------------------------------
192 
195  FwSizeType queueDepth,
196  FwEnumStoreType instance
197  )
198  {
199  // Initialize base class
201 
202  // Initialize state machine instances
203  this->m_stateMachine_aggregationMachine.init(SmId::aggregationMachine);
204 
205 #if !FW_DIRECT_PORT_CALLS
206  // Connect input port comStatusIn
207  for (
208  FwIndexType port = 0;
209  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
210  port++
211  ) {
212  this->m_comStatusIn_InputPort[port].init();
213  this->m_comStatusIn_InputPort[port].addCallComp(
214  this,
215  m_p_comStatusIn_in
216  );
217  this->m_comStatusIn_InputPort[port].setPortNum(port);
218 
219 #if FW_OBJECT_NAMES == 1
220  Fw::ObjectName portName;
221  portName.format(
222  "%s_comStatusIn_InputPort[%" PRI_FwIndexType "]",
223  this->m_objName.toChar(),
224  port
225  );
226  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
227 #endif
228  }
229 #endif
230 
231 #if !FW_DIRECT_PORT_CALLS
232  // Connect input port dataIn
233  for (
234  FwIndexType port = 0;
235  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
236  port++
237  ) {
238  this->m_dataIn_InputPort[port].init();
239  this->m_dataIn_InputPort[port].addCallComp(
240  this,
241  m_p_dataIn_in
242  );
243  this->m_dataIn_InputPort[port].setPortNum(port);
244 
245 #if FW_OBJECT_NAMES == 1
246  Fw::ObjectName portName;
247  portName.format(
248  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
249  this->m_objName.toChar(),
250  port
251  );
252  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
253 #endif
254  }
255 #endif
256 
257 #if !FW_DIRECT_PORT_CALLS
258  // Connect input port dataReturnIn
259  for (
260  FwIndexType port = 0;
261  port < static_cast<FwIndexType>(this->getNum_dataReturnIn_InputPorts());
262  port++
263  ) {
264  this->m_dataReturnIn_InputPort[port].init();
265  this->m_dataReturnIn_InputPort[port].addCallComp(
266  this,
267  m_p_dataReturnIn_in
268  );
269  this->m_dataReturnIn_InputPort[port].setPortNum(port);
270 
271 #if FW_OBJECT_NAMES == 1
272  Fw::ObjectName portName;
273  portName.format(
274  "%s_dataReturnIn_InputPort[%" PRI_FwIndexType "]",
275  this->m_objName.toChar(),
276  port
277  );
278  this->m_dataReturnIn_InputPort[port].setObjName(portName.toChar());
279 #endif
280  }
281 #endif
282 
283 #if !FW_DIRECT_PORT_CALLS
284  // Connect input port timeout
285  for (
286  FwIndexType port = 0;
287  port < static_cast<FwIndexType>(this->getNum_timeout_InputPorts());
288  port++
289  ) {
290  this->m_timeout_InputPort[port].init();
291  this->m_timeout_InputPort[port].addCallComp(
292  this,
293  m_p_timeout_in
294  );
295  this->m_timeout_InputPort[port].setPortNum(port);
296 
297 #if FW_OBJECT_NAMES == 1
298  Fw::ObjectName portName;
299  portName.format(
300  "%s_timeout_InputPort[%" PRI_FwIndexType "]",
301  this->m_objName.toChar(),
302  port
303  );
304  this->m_timeout_InputPort[port].setObjName(portName.toChar());
305 #endif
306  }
307 #endif
308 
309 #if !FW_DIRECT_PORT_CALLS
310  // Connect output port comStatusOut
311  for (
312  FwIndexType port = 0;
313  port < static_cast<FwIndexType>(this->getNum_comStatusOut_OutputPorts());
314  port++
315  ) {
316  this->m_comStatusOut_OutputPort[port].init();
317 
318 #if FW_OBJECT_NAMES == 1
319  Fw::ObjectName portName;
320  portName.format(
321  "%s_comStatusOut_OutputPort[%" PRI_FwIndexType "]",
322  this->m_objName.toChar(),
323  port
324  );
325  this->m_comStatusOut_OutputPort[port].setObjName(portName.toChar());
326 #endif
327  }
328 #endif
329 
330 #if !FW_DIRECT_PORT_CALLS
331  // Connect output port dataOut
332  for (
333  FwIndexType port = 0;
334  port < static_cast<FwIndexType>(this->getNum_dataOut_OutputPorts());
335  port++
336  ) {
337  this->m_dataOut_OutputPort[port].init();
338 
339 #if FW_OBJECT_NAMES == 1
340  Fw::ObjectName portName;
341  portName.format(
342  "%s_dataOut_OutputPort[%" PRI_FwIndexType "]",
343  this->m_objName.toChar(),
344  port
345  );
346  this->m_dataOut_OutputPort[port].setObjName(portName.toChar());
347 #endif
348  }
349 #endif
350 
351 #if !FW_DIRECT_PORT_CALLS
352  // Connect output port dataReturnOut
353  for (
354  FwIndexType port = 0;
355  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
356  port++
357  ) {
358  this->m_dataReturnOut_OutputPort[port].init();
359 
360 #if FW_OBJECT_NAMES == 1
361  Fw::ObjectName portName;
362  portName.format(
363  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
364  this->m_objName.toChar(),
365  port
366  );
367  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
368 #endif
369  }
370 #endif
371 
372  // Create the queue
373  Os::Queue::Status qStat = this->createQueue(
374  queueDepth,
375  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
376  );
377  FW_ASSERT(
378  Os::Queue::Status::OP_OK == qStat,
379  static_cast<FwAssertArgType>(qStat)
380  );
381  }
382 
383 #if !FW_DIRECT_PORT_CALLS
384 
385  // ----------------------------------------------------------------------
386  // Getters for typed input ports
387  // ----------------------------------------------------------------------
388 
391  {
392  FW_ASSERT(
393  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
394  static_cast<FwAssertArgType>(portNum)
395  );
396 
397  return &this->m_comStatusIn_InputPort[portNum];
398  }
399 
402  {
403  FW_ASSERT(
404  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
405  static_cast<FwAssertArgType>(portNum)
406  );
407 
408  return &this->m_dataIn_InputPort[portNum];
409  }
410 
413  {
414  FW_ASSERT(
415  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
416  static_cast<FwAssertArgType>(portNum)
417  );
418 
419  return &this->m_dataReturnIn_InputPort[portNum];
420  }
421 
424  {
425  FW_ASSERT(
426  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
427  static_cast<FwAssertArgType>(portNum)
428  );
429 
430  return &this->m_timeout_InputPort[portNum];
431  }
432 
433 #endif
434 
435 #if !FW_DIRECT_PORT_CALLS
436 
437  // ----------------------------------------------------------------------
438  // Connect typed input ports to typed output ports
439  // ----------------------------------------------------------------------
440 
443  FwIndexType portNum,
445  )
446  {
447  FW_ASSERT(
448  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
449  static_cast<FwAssertArgType>(portNum)
450  );
451 
452  this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
453  }
454 
457  FwIndexType portNum,
459  )
460  {
461  FW_ASSERT(
462  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
463  static_cast<FwAssertArgType>(portNum)
464  );
465 
466  this->m_dataOut_OutputPort[portNum].addCallPort(port);
467  }
468 
471  FwIndexType portNum,
473  )
474  {
475  FW_ASSERT(
476  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
477  static_cast<FwAssertArgType>(portNum)
478  );
479 
480  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
481  }
482 
483 #endif
484 
485 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
486 
487  // ----------------------------------------------------------------------
488  // Connect serial input ports to typed output ports
489  // ----------------------------------------------------------------------
490 
493  FwIndexType portNum,
494  Fw::InputSerializePort* port
495  )
496  {
497  FW_ASSERT(
498  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
499  static_cast<FwAssertArgType>(portNum)
500  );
501 
502  this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
503  }
504 
507  FwIndexType portNum,
508  Fw::InputSerializePort* port
509  )
510  {
511  FW_ASSERT(
512  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
513  static_cast<FwAssertArgType>(portNum)
514  );
515 
516  this->m_dataOut_OutputPort[portNum].registerSerialPort(port);
517  }
518 
521  FwIndexType portNum,
522  Fw::InputSerializePort* port
523  )
524  {
525  FW_ASSERT(
526  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
527  static_cast<FwAssertArgType>(portNum)
528  );
529 
530  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
531  }
532 
533 #endif
534 
535  // ----------------------------------------------------------------------
536  // Component construction and destruction
537  // ----------------------------------------------------------------------
538 
540  ComAggregatorComponentBase(const char* compName) :
541  Fw::ActiveComponentBase(compName),
542  m_stateMachine_aggregationMachine(*this)
543  {
544 
545  }
546 
549  {
550 
551  }
552 
553 #if !FW_DIRECT_PORT_CALLS
554 
555  // ----------------------------------------------------------------------
556  // Connection status queries for typed output ports
557  // ----------------------------------------------------------------------
558 
561  {
562  FW_ASSERT(
563  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
564  static_cast<FwAssertArgType>(portNum)
565  );
566 
567  return this->m_comStatusOut_OutputPort[portNum].isConnected();
568  }
569 
572  {
573  FW_ASSERT(
574  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
575  static_cast<FwAssertArgType>(portNum)
576  );
577 
578  return this->m_dataOut_OutputPort[portNum].isConnected();
579  }
580 
583  {
584  FW_ASSERT(
585  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
586  static_cast<FwAssertArgType>(portNum)
587  );
588 
589  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
590  }
591 
592 #endif
593 
594  // ----------------------------------------------------------------------
595  // Port handler base-class functions for typed input ports
596  //
597  // Call these functions directly to bypass the corresponding ports
598  // ----------------------------------------------------------------------
599 
602  FwIndexType portNum,
603  Fw::Success& condition
604  )
605  {
606  // Make sure port number is valid
607  FW_ASSERT(
608  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
609  static_cast<FwAssertArgType>(portNum)
610  );
611 
612  // Call handler function
613  this->comStatusIn_handler(
614  portNum,
615  condition
616  );
617  }
618 
621  FwIndexType portNum,
622  Fw::Buffer& data,
623  const ComCfg::FrameContext& context
624  )
625  {
626  // Make sure port number is valid
627  FW_ASSERT(
628  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
629  static_cast<FwAssertArgType>(portNum)
630  );
631 
632  // Call handler function
633  this->dataIn_handler(
634  portNum,
635  data,
636  context
637  );
638  }
639 
642  FwIndexType portNum,
643  Fw::Buffer& data,
644  const ComCfg::FrameContext& context
645  )
646  {
647  // Make sure port number is valid
648  FW_ASSERT(
649  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
650  static_cast<FwAssertArgType>(portNum)
651  );
652 
653  // Call handler function
654  this->dataReturnIn_handler(
655  portNum,
656  data,
657  context
658  );
659  }
660 
663  FwIndexType portNum,
664  U32 context
665  )
666  {
667  // Make sure port number is valid
668  FW_ASSERT(
669  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
670  static_cast<FwAssertArgType>(portNum)
671  );
672 
673  // Call handler function
674  this->timeout_handler(
675  portNum,
676  context
677  );
678  }
679 
680 #if !FW_DIRECT_PORT_CALLS
681 
682  // ----------------------------------------------------------------------
683  // Invocation functions for typed output ports
684  // ----------------------------------------------------------------------
685 
688  FwIndexType portNum,
689  Fw::Success& condition
690  ) const
691  {
692  FW_ASSERT(
693  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
694  static_cast<FwAssertArgType>(portNum)
695  );
696 
697  FW_ASSERT(
698  this->m_comStatusOut_OutputPort[portNum].isConnected(),
699  static_cast<FwAssertArgType>(portNum)
700  );
701  this->m_comStatusOut_OutputPort[portNum].invoke(
702  condition
703  );
704  }
705 
708  FwIndexType portNum,
709  Fw::Buffer& data,
710  const ComCfg::FrameContext& context
711  ) const
712  {
713  FW_ASSERT(
714  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
715  static_cast<FwAssertArgType>(portNum)
716  );
717 
718  FW_ASSERT(
719  this->m_dataOut_OutputPort[portNum].isConnected(),
720  static_cast<FwAssertArgType>(portNum)
721  );
722  this->m_dataOut_OutputPort[portNum].invoke(
723  data,
724  context
725  );
726  }
727 
730  FwIndexType portNum,
731  Fw::Buffer& data,
732  const ComCfg::FrameContext& context
733  ) const
734  {
735  FW_ASSERT(
736  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
737  static_cast<FwAssertArgType>(portNum)
738  );
739 
740  FW_ASSERT(
741  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
742  static_cast<FwAssertArgType>(portNum)
743  );
744  this->m_dataReturnOut_OutputPort[portNum].invoke(
745  data,
746  context
747  );
748  }
749 
750 #endif
751 
752  // ----------------------------------------------------------------------
753  // State getter functions
754  // ----------------------------------------------------------------------
755 
758  {
759  return this->m_stateMachine_aggregationMachine.getState();
760  }
761 
762  // ----------------------------------------------------------------------
763  // Signal send functions
764  // ----------------------------------------------------------------------
765 
768  {
769  ComponentIpcSerializableBuffer buffer;
770  // Serialize the message type, port number, state ID, and signal
771  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::timeout), buffer);
772  // Send the message and handle overflow
773  this->aggregationMachine_sendSignalFinish(buffer);
774  }
775 
778  {
779  ComponentIpcSerializableBuffer buffer;
780  // Serialize the message type, port number, state ID, and signal
781  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::fill), buffer);
782  // Serialize the signal data
783  const Fw::SerializeStatus status = buffer.serializeFrom(value);
784  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
785  // Send the message and handle overflow
786  this->aggregationMachine_sendSignalFinish(buffer);
787  }
788 
791  {
792  ComponentIpcSerializableBuffer buffer;
793  // Serialize the message type, port number, state ID, and signal
794  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::status), buffer);
795  // Serialize the signal data
796  const Fw::SerializeStatus status = buffer.serializeFrom(value);
797  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
798  // Send the message and handle overflow
799  this->aggregationMachine_sendSignalFinish(buffer);
800  }
801 
802  // ----------------------------------------------------------------------
803  // Message dispatch functions
804  // ----------------------------------------------------------------------
805 
806  Fw::QueuedComponentBase::MsgDispatchStatus ComAggregatorComponentBase ::
807  doDispatch()
808  {
809  ComponentIpcSerializableBuffer _msg;
810  FwQueuePriorityType _priority = 0;
811 
812  Os::Queue::Status _msgStatus = this->m_queue.receive(
813  _msg,
815  _priority
816  );
817  FW_ASSERT(
818  _msgStatus == Os::Queue::OP_OK,
819  static_cast<FwAssertArgType>(_msgStatus)
820  );
821 
822  // Reset to beginning of buffer
823  _msg.resetDeser();
824 
825  FwEnumStoreType _desMsg = 0;
826  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
827  FW_ASSERT(
828  _deserStatus == Fw::FW_SERIALIZE_OK,
829  static_cast<FwAssertArgType>(_deserStatus)
830  );
831 
832  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
833 
834  if (_msgType == COMAGGREGATOR_COMPONENT_EXIT) {
835  return MSG_DISPATCH_EXIT;
836  }
837 
838  FwIndexType portNum = 0;
839  _deserStatus = _msg.deserializeTo(portNum);
840  FW_ASSERT(
841  _deserStatus == Fw::FW_SERIALIZE_OK,
842  static_cast<FwAssertArgType>(_deserStatus)
843  );
844 
845  switch (_msgType) {
846 
847  // Handle signals to internal state machines
848  case INTERNAL_STATE_MACHINE_SIGNAL:
849  this->smDispatch(_msg);
850  break;
851 
852  default:
853  return MSG_DISPATCH_ERROR;
854  }
855 
856  return MSG_DISPATCH_OK;
857  }
858 
859  // ----------------------------------------------------------------------
860  // Calls for messages received on typed input ports
861  // ----------------------------------------------------------------------
862 
863  void ComAggregatorComponentBase ::
864  m_p_comStatusIn_in(
865  Fw::PassiveComponentBase* callComp,
866  FwIndexType portNum,
867  Fw::Success& condition
868  )
869  {
870  FW_ASSERT(callComp != nullptr);
871  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
872  compPtr->comStatusIn_handlerBase(
873  portNum,
874  condition
875  );
876  }
877 
878  void ComAggregatorComponentBase ::
879  m_p_dataIn_in(
880  Fw::PassiveComponentBase* callComp,
881  FwIndexType portNum,
882  Fw::Buffer& data,
883  const ComCfg::FrameContext& context
884  )
885  {
886  FW_ASSERT(callComp != nullptr);
887  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
888  compPtr->dataIn_handlerBase(
889  portNum,
890  data,
891  context
892  );
893  }
894 
895  void ComAggregatorComponentBase ::
896  m_p_dataReturnIn_in(
897  Fw::PassiveComponentBase* callComp,
898  FwIndexType portNum,
899  Fw::Buffer& data,
900  const ComCfg::FrameContext& context
901  )
902  {
903  FW_ASSERT(callComp != nullptr);
904  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
905  compPtr->dataReturnIn_handlerBase(
906  portNum,
907  data,
908  context
909  );
910  }
911 
912  void ComAggregatorComponentBase ::
913  m_p_timeout_in(
914  Fw::PassiveComponentBase* callComp,
915  FwIndexType portNum,
916  U32 context
917  )
918  {
919  FW_ASSERT(callComp != nullptr);
920  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
921  compPtr->timeout_handlerBase(
922  portNum,
923  context
924  );
925  }
926 
927  // ----------------------------------------------------------------------
928  // Send signal helper functions
929  // ----------------------------------------------------------------------
930 
931  void ComAggregatorComponentBase ::
932  sendSignalStart(
933  SmId smId,
934  FwEnumStoreType signal,
935  Fw::SerialBufferBase& buffer
936  )
937  {
939 
940  // Serialize the message type
941  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(INTERNAL_STATE_MACHINE_SIGNAL));
942  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
943 
944  // Serialize the port number
945  status = buffer.serializeFrom(static_cast<FwIndexType>(0));
946  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
947 
948  // Serialize the state machine ID
949  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(smId));
950  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
951 
952  // Serialize the signal
953  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(signal));
954  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
955  }
956 
957  void ComAggregatorComponentBase ::
958  aggregationMachine_sendSignalFinish(Fw::LinearBufferBase& buffer)
959  {
960  // Send message
962  Os::Queue::Status qStatus = this->m_queue.send(buffer, 0, _block);
963 
964  FW_ASSERT(
965  qStatus == Os::Queue::OP_OK,
966  static_cast<FwAssertArgType>(qStatus)
967  );
968  }
969 
970  // ----------------------------------------------------------------------
971  // Helper functions for state machine dispatch
972  // ----------------------------------------------------------------------
973 
974  void ComAggregatorComponentBase ::
975  smDispatch(Fw::SerialBufferBase& buffer)
976  {
977  // Deserialize the state machine ID and signal
978  FwEnumStoreType storedSmId;
979  FwEnumStoreType storedSignal;
980  ComAggregatorComponentBase::deserializeSmIdAndSignal(buffer, storedSmId, storedSignal);
981 
982  // Select the target state machine instance
983  const SmId smId = static_cast<SmId>(storedSmId);
984  switch (smId) {
986  const Svc_AggregationMachine::Signal signal = static_cast<Svc_AggregationMachine::Signal>(storedSignal);
987  this->Svc_AggregationMachine_smDispatch(buffer, this->m_stateMachine_aggregationMachine, signal);
988  break;
989  }
990  default:
991  FW_ASSERT(false, static_cast<FwAssertArgType>(smId));
992  break;
993  }
994  }
995 
996  void ComAggregatorComponentBase ::
997  deserializeSmIdAndSignal(
998  Fw::SerialBufferBase& buffer,
999  FwEnumStoreType& smId,
1000  FwEnumStoreType& signal
1001  )
1002  {
1003  // Move deserialization beyond the message type and port number
1004  Fw::SerializeStatus status =
1005  buffer.moveDeserToOffset(ComponentIpcSerializableBuffer::DATA_OFFSET);
1006  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1007 
1008  // Deserialize the state machine ID
1009  status = buffer.deserializeTo(smId);
1010  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1011 
1012  // Deserialize the signal
1013  status = buffer.deserializeTo(signal);
1014  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1015  }
1016 
1017  void ComAggregatorComponentBase ::
1018  Svc_AggregationMachine_smDispatch(
1019  Fw::SerialBufferBase& buffer,
1020  Svc_AggregationMachine& sm,
1022  )
1023  {
1024  switch (signal) {
1026  // Assert no data left in buffer
1027  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1028  // Call the sendSignal function for sm and timeout
1029  sm.sendSignal_timeout();
1030  break;
1031  }
1033  // Deserialize the data
1035  const Fw::SerializeStatus status = buffer.deserializeTo(value);
1036  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1037  // Assert no data left in buffer
1038  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1039  // Call the sendSignal function for sm and fill
1040  sm.sendSignal_fill(value);
1041  break;
1042  }
1044  // Deserialize the data
1045  Fw::Success value;
1046  const Fw::SerializeStatus status = buffer.deserializeTo(value);
1047  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1048  // Assert no data left in buffer
1049  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1050  // Call the sendSignal function for sm and status
1051  sm.sendSignal_status(value);
1052  break;
1053  }
1054  default:
1055  FW_ASSERT(false, static_cast<FwAssertArgType>(signal));
1056  break;
1057  }
1058  }
1059 
1060 }
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_comStatusOut_OutputPorts()
Operation succeeded.
Definition: Os.hpp:27
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
bool isConnected_comStatusOut_OutputPort(FwIndexType portNum) const
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:73
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init(ComAggregatorComponentBase::SmId smId)
Initialize the state machine.
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke output port dataReturnOut.
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.
bool isConnected_dataOut_OutputPort(FwIndexType portNum) const
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.
Svc::InputComDataWithContextPort * get_dataReturnIn_InputPort(FwIndexType portNum)
void invoke(Fw::Success &condition) const
Invoke a port connection.
void invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port connection.
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.
bool isConnected_dataReturnOut_OutputPort(FwIndexType portNum) const
ComAggregatorComponentBase(const char *compName="")
Construct ComAggregatorComponentBase object.
void init()
Initialization function.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
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:54
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:79
message to exit active component task
The size of the serial representation.
A message was sent requesting an exit of the loop.
static constexpr FwIndexType getNum_dataReturnOut_OutputPorts()
PlatformIndexType FwIndexType
void comStatusOut_out(FwIndexType portNum, Fw::Success &condition) const
Invoke output port comStatusOut.
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.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:57
LinearBufferTemplate< FW_SM_SIGNAL_BUFFER_MAX_SIZE > SmSignalBuffer
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
void dataOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke output port dataOut.
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].
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.