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 #if !FW_DIRECT_PORT_CALLS
193  // Connect input port comStatusIn
194  for (
195  FwIndexType port = 0;
196  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
197  port++
198  ) {
199  this->m_comStatusIn_InputPort[port].init();
200  this->m_comStatusIn_InputPort[port].addCallComp(
201  this,
202  m_p_comStatusIn_in
203  );
204  this->m_comStatusIn_InputPort[port].setPortNum(port);
205 
206 #if FW_OBJECT_NAMES == 1
207  Fw::ObjectName portName;
208  portName.format(
209  "%s_comStatusIn_InputPort[%" PRI_FwIndexType "]",
210  this->m_objName.toChar(),
211  port
212  );
213  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
214 #endif
215  }
216 #endif
217 
218 #if !FW_DIRECT_PORT_CALLS
219  // Connect input port dataIn
220  for (
221  FwIndexType port = 0;
222  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
223  port++
224  ) {
225  this->m_dataIn_InputPort[port].init();
226  this->m_dataIn_InputPort[port].addCallComp(
227  this,
228  m_p_dataIn_in
229  );
230  this->m_dataIn_InputPort[port].setPortNum(port);
231 
232 #if FW_OBJECT_NAMES == 1
233  Fw::ObjectName portName;
234  portName.format(
235  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
236  this->m_objName.toChar(),
237  port
238  );
239  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
240 #endif
241  }
242 #endif
243 
244 #if !FW_DIRECT_PORT_CALLS
245  // Connect input port dataReturnIn
246  for (
247  FwIndexType port = 0;
248  port < static_cast<FwIndexType>(this->getNum_dataReturnIn_InputPorts());
249  port++
250  ) {
251  this->m_dataReturnIn_InputPort[port].init();
252  this->m_dataReturnIn_InputPort[port].addCallComp(
253  this,
254  m_p_dataReturnIn_in
255  );
256  this->m_dataReturnIn_InputPort[port].setPortNum(port);
257 
258 #if FW_OBJECT_NAMES == 1
259  Fw::ObjectName portName;
260  portName.format(
261  "%s_dataReturnIn_InputPort[%" PRI_FwIndexType "]",
262  this->m_objName.toChar(),
263  port
264  );
265  this->m_dataReturnIn_InputPort[port].setObjName(portName.toChar());
266 #endif
267  }
268 #endif
269 
270 #if !FW_DIRECT_PORT_CALLS
271  // Connect input port timeout
272  for (
273  FwIndexType port = 0;
274  port < static_cast<FwIndexType>(this->getNum_timeout_InputPorts());
275  port++
276  ) {
277  this->m_timeout_InputPort[port].init();
278  this->m_timeout_InputPort[port].addCallComp(
279  this,
280  m_p_timeout_in
281  );
282  this->m_timeout_InputPort[port].setPortNum(port);
283 
284 #if FW_OBJECT_NAMES == 1
285  Fw::ObjectName portName;
286  portName.format(
287  "%s_timeout_InputPort[%" PRI_FwIndexType "]",
288  this->m_objName.toChar(),
289  port
290  );
291  this->m_timeout_InputPort[port].setObjName(portName.toChar());
292 #endif
293  }
294 #endif
295 
296 #if !FW_DIRECT_PORT_CALLS
297  // Connect output port comStatusOut
298  for (
299  FwIndexType port = 0;
300  port < static_cast<FwIndexType>(this->getNum_comStatusOut_OutputPorts());
301  port++
302  ) {
303  this->m_comStatusOut_OutputPort[port].init();
304 
305 #if FW_OBJECT_NAMES == 1
306  Fw::ObjectName portName;
307  portName.format(
308  "%s_comStatusOut_OutputPort[%" PRI_FwIndexType "]",
309  this->m_objName.toChar(),
310  port
311  );
312  this->m_comStatusOut_OutputPort[port].setObjName(portName.toChar());
313 #endif
314  }
315 #endif
316 
317 #if !FW_DIRECT_PORT_CALLS
318  // Connect output port dataOut
319  for (
320  FwIndexType port = 0;
321  port < static_cast<FwIndexType>(this->getNum_dataOut_OutputPorts());
322  port++
323  ) {
324  this->m_dataOut_OutputPort[port].init();
325 
326 #if FW_OBJECT_NAMES == 1
327  Fw::ObjectName portName;
328  portName.format(
329  "%s_dataOut_OutputPort[%" PRI_FwIndexType "]",
330  this->m_objName.toChar(),
331  port
332  );
333  this->m_dataOut_OutputPort[port].setObjName(portName.toChar());
334 #endif
335  }
336 #endif
337 
338 #if !FW_DIRECT_PORT_CALLS
339  // Connect output port dataReturnOut
340  for (
341  FwIndexType port = 0;
342  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
343  port++
344  ) {
345  this->m_dataReturnOut_OutputPort[port].init();
346 
347 #if FW_OBJECT_NAMES == 1
348  Fw::ObjectName portName;
349  portName.format(
350  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
351  this->m_objName.toChar(),
352  port
353  );
354  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
355 #endif
356  }
357 #endif
358 
359  // Create the queue
360  Os::Queue::Status qStat = this->createQueue(
361  queueDepth,
362  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
363  );
364  FW_ASSERT(
365  Os::Queue::Status::OP_OK == qStat,
366  static_cast<FwAssertArgType>(qStat)
367  );
368  }
369 
370 #if !FW_DIRECT_PORT_CALLS
371 
372  // ----------------------------------------------------------------------
373  // Getters for typed input ports
374  // ----------------------------------------------------------------------
375 
378  {
379  FW_ASSERT(
380  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
381  static_cast<FwAssertArgType>(portNum)
382  );
383 
384  return &this->m_comStatusIn_InputPort[portNum];
385  }
386 
389  {
390  FW_ASSERT(
391  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
392  static_cast<FwAssertArgType>(portNum)
393  );
394 
395  return &this->m_dataIn_InputPort[portNum];
396  }
397 
400  {
401  FW_ASSERT(
402  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
403  static_cast<FwAssertArgType>(portNum)
404  );
405 
406  return &this->m_dataReturnIn_InputPort[portNum];
407  }
408 
411  {
412  FW_ASSERT(
413  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
414  static_cast<FwAssertArgType>(portNum)
415  );
416 
417  return &this->m_timeout_InputPort[portNum];
418  }
419 
420 #endif
421 
422 #if !FW_DIRECT_PORT_CALLS
423 
424  // ----------------------------------------------------------------------
425  // Connect typed input ports to typed output ports
426  // ----------------------------------------------------------------------
427 
430  FwIndexType portNum,
432  )
433  {
434  FW_ASSERT(
435  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
436  static_cast<FwAssertArgType>(portNum)
437  );
438 
439  this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
440  }
441 
444  FwIndexType portNum,
446  )
447  {
448  FW_ASSERT(
449  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
450  static_cast<FwAssertArgType>(portNum)
451  );
452 
453  this->m_dataOut_OutputPort[portNum].addCallPort(port);
454  }
455 
458  FwIndexType portNum,
460  )
461  {
462  FW_ASSERT(
463  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
468  }
469 
470 #endif
471 
472 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
473 
474  // ----------------------------------------------------------------------
475  // Connect serial input ports to typed output ports
476  // ----------------------------------------------------------------------
477 
480  FwIndexType portNum,
481  Fw::InputSerializePort* port
482  )
483  {
484  FW_ASSERT(
485  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
486  static_cast<FwAssertArgType>(portNum)
487  );
488 
489  this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
490  }
491 
494  FwIndexType portNum,
495  Fw::InputSerializePort* port
496  )
497  {
498  FW_ASSERT(
499  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
500  static_cast<FwAssertArgType>(portNum)
501  );
502 
503  this->m_dataOut_OutputPort[portNum].registerSerialPort(port);
504  }
505 
508  FwIndexType portNum,
509  Fw::InputSerializePort* port
510  )
511  {
512  FW_ASSERT(
513  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
514  static_cast<FwAssertArgType>(portNum)
515  );
516 
517  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
518  }
519 
520 #endif
521 
522  // ----------------------------------------------------------------------
523  // Component construction and destruction
524  // ----------------------------------------------------------------------
525 
527  ComAggregatorComponentBase(const char* compName) :
528  Fw::ActiveComponentBase(compName),
529  m_stateMachine_aggregationMachine(*this)
530  {
531 
532  }
533 
536  {
537 
538  }
539 
540 #if !FW_DIRECT_PORT_CALLS
541 
542  // ----------------------------------------------------------------------
543  // Connection status queries for typed output ports
544  // ----------------------------------------------------------------------
545 
548  {
549  FW_ASSERT(
550  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
551  static_cast<FwAssertArgType>(portNum)
552  );
553 
554  return this->m_comStatusOut_OutputPort[portNum].isConnected();
555  }
556 
559  {
560  FW_ASSERT(
561  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
562  static_cast<FwAssertArgType>(portNum)
563  );
564 
565  return this->m_dataOut_OutputPort[portNum].isConnected();
566  }
567 
570  {
571  FW_ASSERT(
572  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
573  static_cast<FwAssertArgType>(portNum)
574  );
575 
576  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
577  }
578 
579 #endif
580 
581  // ----------------------------------------------------------------------
582  // Port handler base-class functions for typed input ports
583  //
584  // Call these functions directly to bypass the corresponding ports
585  // ----------------------------------------------------------------------
586 
589  FwIndexType portNum,
590  Fw::Success& condition
591  )
592  {
593  // Make sure port number is valid
594  FW_ASSERT(
595  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
596  static_cast<FwAssertArgType>(portNum)
597  );
598 
599  // Call handler function
600  this->comStatusIn_handler(
601  portNum,
602  condition
603  );
604  }
605 
608  FwIndexType portNum,
609  Fw::Buffer& data,
610  const ComCfg::FrameContext& context
611  )
612  {
613  // Make sure port number is valid
614  FW_ASSERT(
615  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
616  static_cast<FwAssertArgType>(portNum)
617  );
618 
619  // Call handler function
620  this->dataIn_handler(
621  portNum,
622  data,
623  context
624  );
625  }
626 
629  FwIndexType portNum,
630  Fw::Buffer& data,
631  const ComCfg::FrameContext& context
632  )
633  {
634  // Make sure port number is valid
635  FW_ASSERT(
636  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
637  static_cast<FwAssertArgType>(portNum)
638  );
639 
640  // Call handler function
641  this->dataReturnIn_handler(
642  portNum,
643  data,
644  context
645  );
646  }
647 
650  FwIndexType portNum,
651  U32 context
652  )
653  {
654  // Make sure port number is valid
655  FW_ASSERT(
656  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
657  static_cast<FwAssertArgType>(portNum)
658  );
659 
660  // Call handler function
661  this->timeout_handler(
662  portNum,
663  context
664  );
665  }
666 
667 #if !FW_DIRECT_PORT_CALLS
668 
669  // ----------------------------------------------------------------------
670  // Invocation functions for typed output ports
671  // ----------------------------------------------------------------------
672 
675  FwIndexType portNum,
676  Fw::Success& condition
677  ) const
678  {
679  FW_ASSERT(
680  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
681  static_cast<FwAssertArgType>(portNum)
682  );
683 
684  FW_ASSERT(
685  this->m_comStatusOut_OutputPort[portNum].isConnected(),
686  static_cast<FwAssertArgType>(portNum)
687  );
688  this->m_comStatusOut_OutputPort[portNum].invoke(
689  condition
690  );
691  }
692 
695  FwIndexType portNum,
696  Fw::Buffer& data,
697  const ComCfg::FrameContext& context
698  ) const
699  {
700  FW_ASSERT(
701  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
702  static_cast<FwAssertArgType>(portNum)
703  );
704 
705  FW_ASSERT(
706  this->m_dataOut_OutputPort[portNum].isConnected(),
707  static_cast<FwAssertArgType>(portNum)
708  );
709  this->m_dataOut_OutputPort[portNum].invoke(
710  data,
711  context
712  );
713  }
714 
717  FwIndexType portNum,
718  Fw::Buffer& data,
719  const ComCfg::FrameContext& context
720  ) const
721  {
722  FW_ASSERT(
723  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
724  static_cast<FwAssertArgType>(portNum)
725  );
726 
727  FW_ASSERT(
728  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
729  static_cast<FwAssertArgType>(portNum)
730  );
731  this->m_dataReturnOut_OutputPort[portNum].invoke(
732  data,
733  context
734  );
735  }
736 
737 #endif
738 
739  // ----------------------------------------------------------------------
740  // State getter functions
741  // ----------------------------------------------------------------------
742 
745  {
746  return this->m_stateMachine_aggregationMachine.getState();
747  }
748 
749  // ----------------------------------------------------------------------
750  // Signal send functions
751  // ----------------------------------------------------------------------
752 
755  {
756  ComponentIpcSerializableBuffer buffer;
757  // Serialize the message type, port number, state ID, and signal
758  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::timeout), buffer);
759  // Send the message and handle overflow
760  this->aggregationMachine_sendSignalFinish(buffer);
761  }
762 
765  {
766  ComponentIpcSerializableBuffer buffer;
767  // Serialize the message type, port number, state ID, and signal
768  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::fill), buffer);
769  // Serialize the signal data
770  const Fw::SerializeStatus status = buffer.serializeFrom(value);
771  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
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::status), 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 
789  // ----------------------------------------------------------------------
790  // Message dispatch functions
791  // ----------------------------------------------------------------------
792 
793  Fw::QueuedComponentBase::MsgDispatchStatus ComAggregatorComponentBase ::
794  doDispatch()
795  {
796  ComponentIpcSerializableBuffer _msg;
797  FwQueuePriorityType _priority = 0;
798 
799  Os::Queue::Status _msgStatus = this->m_queue.receive(
800  _msg,
802  _priority
803  );
804  FW_ASSERT(
805  _msgStatus == Os::Queue::OP_OK,
806  static_cast<FwAssertArgType>(_msgStatus)
807  );
808 
809  // Reset to beginning of buffer
810  _msg.resetDeser();
811 
812  FwEnumStoreType _desMsg = 0;
813  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
814  FW_ASSERT(
815  _deserStatus == Fw::FW_SERIALIZE_OK,
816  static_cast<FwAssertArgType>(_deserStatus)
817  );
818 
819  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
820 
821  if (_msgType == COMAGGREGATOR_COMPONENT_EXIT) {
822  return MSG_DISPATCH_EXIT;
823  }
824 
825  FwIndexType portNum = 0;
826  _deserStatus = _msg.deserializeTo(portNum);
827  FW_ASSERT(
828  _deserStatus == Fw::FW_SERIALIZE_OK,
829  static_cast<FwAssertArgType>(_deserStatus)
830  );
831 
832  switch (_msgType) {
833 
834  // Handle signals to internal state machines
835  case INTERNAL_STATE_MACHINE_SIGNAL:
836  this->smDispatch(_msg);
837  break;
838 
839  default:
840  return MSG_DISPATCH_ERROR;
841  }
842 
843  return MSG_DISPATCH_OK;
844  }
845 
846  // ----------------------------------------------------------------------
847  // Calls for messages received on typed input ports
848  // ----------------------------------------------------------------------
849 
850  void ComAggregatorComponentBase ::
851  m_p_comStatusIn_in(
852  Fw::PassiveComponentBase* callComp,
853  FwIndexType portNum,
854  Fw::Success& condition
855  )
856  {
857  FW_ASSERT(callComp);
858  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
859  compPtr->comStatusIn_handlerBase(
860  portNum,
861  condition
862  );
863  }
864 
865  void ComAggregatorComponentBase ::
866  m_p_dataIn_in(
867  Fw::PassiveComponentBase* callComp,
868  FwIndexType portNum,
869  Fw::Buffer& data,
870  const ComCfg::FrameContext& context
871  )
872  {
873  FW_ASSERT(callComp);
874  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
875  compPtr->dataIn_handlerBase(
876  portNum,
877  data,
878  context
879  );
880  }
881 
882  void ComAggregatorComponentBase ::
883  m_p_dataReturnIn_in(
884  Fw::PassiveComponentBase* callComp,
885  FwIndexType portNum,
886  Fw::Buffer& data,
887  const ComCfg::FrameContext& context
888  )
889  {
890  FW_ASSERT(callComp);
891  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
892  compPtr->dataReturnIn_handlerBase(
893  portNum,
894  data,
895  context
896  );
897  }
898 
899  void ComAggregatorComponentBase ::
900  m_p_timeout_in(
901  Fw::PassiveComponentBase* callComp,
902  FwIndexType portNum,
903  U32 context
904  )
905  {
906  FW_ASSERT(callComp);
907  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
908  compPtr->timeout_handlerBase(
909  portNum,
910  context
911  );
912  }
913 
914  // ----------------------------------------------------------------------
915  // Send signal helper functions
916  // ----------------------------------------------------------------------
917 
918  void ComAggregatorComponentBase ::
919  sendSignalStart(
920  SmId smId,
921  FwEnumStoreType signal,
922  Fw::SerialBufferBase& buffer
923  )
924  {
926 
927  // Serialize the message type
928  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(INTERNAL_STATE_MACHINE_SIGNAL));
929  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
930 
931  // Serialize the port number
932  status = buffer.serializeFrom(static_cast<FwIndexType>(0));
933  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
934 
935  // Serialize the state machine ID
936  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(smId));
937  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
938 
939  // Serialize the signal
940  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(signal));
941  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
942  }
943 
944  void ComAggregatorComponentBase ::
945  aggregationMachine_sendSignalFinish(Fw::LinearBufferBase& buffer)
946  {
947  // Send message
949  Os::Queue::Status qStatus = this->m_queue.send(buffer, 0, _block);
950 
951  FW_ASSERT(
952  qStatus == Os::Queue::OP_OK,
953  static_cast<FwAssertArgType>(qStatus)
954  );
955  }
956 
957  // ----------------------------------------------------------------------
958  // Helper functions for state machine dispatch
959  // ----------------------------------------------------------------------
960 
961  void ComAggregatorComponentBase ::
962  smDispatch(Fw::SerialBufferBase& buffer)
963  {
964  // Deserialize the state machine ID and signal
965  FwEnumStoreType storedSmId;
966  FwEnumStoreType storedSignal;
967  ComAggregatorComponentBase::deserializeSmIdAndSignal(buffer, storedSmId, storedSignal);
968 
969  // Select the target state machine instance
970  const SmId smId = static_cast<SmId>(storedSmId);
971  switch (smId) {
973  const Svc_AggregationMachine::Signal signal = static_cast<Svc_AggregationMachine::Signal>(storedSignal);
974  this->Svc_AggregationMachine_smDispatch(buffer, this->m_stateMachine_aggregationMachine, signal);
975  break;
976  }
977  default:
978  FW_ASSERT(0, static_cast<FwAssertArgType>(smId));
979  break;
980  }
981  }
982 
983  void ComAggregatorComponentBase ::
984  deserializeSmIdAndSignal(
985  Fw::SerialBufferBase& buffer,
986  FwEnumStoreType& smId,
987  FwEnumStoreType& signal
988  )
989  {
990  // Move deserialization beyond the message type and port number
991  Fw::SerializeStatus status =
992  buffer.moveDeserToOffset(ComponentIpcSerializableBuffer::DATA_OFFSET);
993  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
994 
995  // Deserialize the state machine ID
996  status = buffer.deserializeTo(smId);
997  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
998 
999  // Deserialize the signal
1000  status = buffer.deserializeTo(signal);
1001  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1002  }
1003 
1004  void ComAggregatorComponentBase ::
1005  Svc_AggregationMachine_smDispatch(
1006  Fw::SerialBufferBase& buffer,
1007  Svc_AggregationMachine& sm,
1009  )
1010  {
1011  switch (signal) {
1013  // Assert no data left in buffer
1014  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1015  // Call the sendSignal function for sm and timeout
1016  sm.sendSignal_timeout();
1017  break;
1018  }
1020  // Deserialize the data
1022  const Fw::SerializeStatus status = buffer.deserializeTo(value);
1023  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1024  // Assert no data left in buffer
1025  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1026  // Call the sendSignal function for sm and fill
1027  sm.sendSignal_fill(value);
1028  break;
1029  }
1031  // Deserialize the data
1032  Fw::Success value;
1033  const Fw::SerializeStatus status = buffer.deserializeTo(value);
1034  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
1035  // Assert no data left in buffer
1036  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
1037  // Call the sendSignal function for sm and status
1038  sm.sendSignal_status(value);
1039  break;
1040  }
1041  default:
1042  FW_ASSERT(0, static_cast<FwAssertArgType>(signal));
1043  break;
1044  }
1045  }
1046 
1047 }
Serialization/Deserialization operation was successful.
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
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.
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 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.
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
The size of the serial representation.
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:79
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:56
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.
message to exit active component task
void init()
Initialization function.