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_isNotEmpty(Signal signal) const
154  {
155  return this->m_component.Svc_AggregationMachine_guard_isNotEmpty(this->getId(), signal);
156  }
157 
158  bool ComAggregatorComponentBase::Svc_AggregationMachine ::
159  guard_isGood(
160  Signal signal,
161  const Fw::Success& value
162  ) const
163  {
164  return this->m_component.Svc_AggregationMachine_guard_isGood(this->getId(), signal, value);
165  }
166 
167  // ----------------------------------------------------------------------
168  // Component initialization
169  // ----------------------------------------------------------------------
170 
173  FwSizeType queueDepth,
174  FwEnumStoreType instance
175  )
176  {
177  // Initialize base class
179 
180  // Initialize state machine instances
181  this->m_stateMachine_aggregationMachine.init(SmId::aggregationMachine);
182 
183  // Connect input port comStatusIn
184  for (
185  FwIndexType port = 0;
186  port < static_cast<FwIndexType>(this->getNum_comStatusIn_InputPorts());
187  port++
188  ) {
189  this->m_comStatusIn_InputPort[port].init();
190  this->m_comStatusIn_InputPort[port].addCallComp(
191  this,
192  m_p_comStatusIn_in
193  );
194  this->m_comStatusIn_InputPort[port].setPortNum(port);
195 
196 #if FW_OBJECT_NAMES == 1
197  Fw::ObjectName portName;
198  portName.format(
199  "%s_comStatusIn_InputPort[%" PRI_FwIndexType "]",
200  this->m_objName.toChar(),
201  port
202  );
203  this->m_comStatusIn_InputPort[port].setObjName(portName.toChar());
204 #endif
205  }
206 
207  // Connect input port dataIn
208  for (
209  FwIndexType port = 0;
210  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
211  port++
212  ) {
213  this->m_dataIn_InputPort[port].init();
214  this->m_dataIn_InputPort[port].addCallComp(
215  this,
216  m_p_dataIn_in
217  );
218  this->m_dataIn_InputPort[port].setPortNum(port);
219 
220 #if FW_OBJECT_NAMES == 1
221  Fw::ObjectName portName;
222  portName.format(
223  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
224  this->m_objName.toChar(),
225  port
226  );
227  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
228 #endif
229  }
230 
231  // Connect input port dataReturnIn
232  for (
233  FwIndexType port = 0;
234  port < static_cast<FwIndexType>(this->getNum_dataReturnIn_InputPorts());
235  port++
236  ) {
237  this->m_dataReturnIn_InputPort[port].init();
238  this->m_dataReturnIn_InputPort[port].addCallComp(
239  this,
240  m_p_dataReturnIn_in
241  );
242  this->m_dataReturnIn_InputPort[port].setPortNum(port);
243 
244 #if FW_OBJECT_NAMES == 1
245  Fw::ObjectName portName;
246  portName.format(
247  "%s_dataReturnIn_InputPort[%" PRI_FwIndexType "]",
248  this->m_objName.toChar(),
249  port
250  );
251  this->m_dataReturnIn_InputPort[port].setObjName(portName.toChar());
252 #endif
253  }
254 
255  // Connect input port timeout
256  for (
257  FwIndexType port = 0;
258  port < static_cast<FwIndexType>(this->getNum_timeout_InputPorts());
259  port++
260  ) {
261  this->m_timeout_InputPort[port].init();
262  this->m_timeout_InputPort[port].addCallComp(
263  this,
264  m_p_timeout_in
265  );
266  this->m_timeout_InputPort[port].setPortNum(port);
267 
268 #if FW_OBJECT_NAMES == 1
269  Fw::ObjectName portName;
270  portName.format(
271  "%s_timeout_InputPort[%" PRI_FwIndexType "]",
272  this->m_objName.toChar(),
273  port
274  );
275  this->m_timeout_InputPort[port].setObjName(portName.toChar());
276 #endif
277  }
278 
279  // Connect output port comStatusOut
280  for (
281  FwIndexType port = 0;
282  port < static_cast<FwIndexType>(this->getNum_comStatusOut_OutputPorts());
283  port++
284  ) {
285  this->m_comStatusOut_OutputPort[port].init();
286 
287 #if FW_OBJECT_NAMES == 1
288  Fw::ObjectName portName;
289  portName.format(
290  "%s_comStatusOut_OutputPort[%" PRI_FwIndexType "]",
291  this->m_objName.toChar(),
292  port
293  );
294  this->m_comStatusOut_OutputPort[port].setObjName(portName.toChar());
295 #endif
296  }
297 
298  // Connect output port dataOut
299  for (
300  FwIndexType port = 0;
301  port < static_cast<FwIndexType>(this->getNum_dataOut_OutputPorts());
302  port++
303  ) {
304  this->m_dataOut_OutputPort[port].init();
305 
306 #if FW_OBJECT_NAMES == 1
307  Fw::ObjectName portName;
308  portName.format(
309  "%s_dataOut_OutputPort[%" PRI_FwIndexType "]",
310  this->m_objName.toChar(),
311  port
312  );
313  this->m_dataOut_OutputPort[port].setObjName(portName.toChar());
314 #endif
315  }
316 
317  // Connect output port dataReturnOut
318  for (
319  FwIndexType port = 0;
320  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
321  port++
322  ) {
323  this->m_dataReturnOut_OutputPort[port].init();
324 
325 #if FW_OBJECT_NAMES == 1
326  Fw::ObjectName portName;
327  portName.format(
328  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
329  this->m_objName.toChar(),
330  port
331  );
332  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
333 #endif
334  }
335 
336  // Create the queue
337  Os::Queue::Status qStat = this->createQueue(
338  queueDepth,
339  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
340  );
341  FW_ASSERT(
342  Os::Queue::Status::OP_OK == qStat,
343  static_cast<FwAssertArgType>(qStat)
344  );
345  }
346 
347  // ----------------------------------------------------------------------
348  // Getters for typed input ports
349  // ----------------------------------------------------------------------
350 
353  {
354  FW_ASSERT(
355  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
356  static_cast<FwAssertArgType>(portNum)
357  );
358 
359  return &this->m_comStatusIn_InputPort[portNum];
360  }
361 
364  {
365  FW_ASSERT(
366  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
367  static_cast<FwAssertArgType>(portNum)
368  );
369 
370  return &this->m_dataIn_InputPort[portNum];
371  }
372 
375  {
376  FW_ASSERT(
377  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
378  static_cast<FwAssertArgType>(portNum)
379  );
380 
381  return &this->m_dataReturnIn_InputPort[portNum];
382  }
383 
386  {
387  FW_ASSERT(
388  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
389  static_cast<FwAssertArgType>(portNum)
390  );
391 
392  return &this->m_timeout_InputPort[portNum];
393  }
394 
395  // ----------------------------------------------------------------------
396  // Connect typed input ports to typed output ports
397  // ----------------------------------------------------------------------
398 
401  FwIndexType portNum,
403  )
404  {
405  FW_ASSERT(
406  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
407  static_cast<FwAssertArgType>(portNum)
408  );
409 
410  this->m_comStatusOut_OutputPort[portNum].addCallPort(port);
411  }
412 
415  FwIndexType portNum,
417  )
418  {
419  FW_ASSERT(
420  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
421  static_cast<FwAssertArgType>(portNum)
422  );
423 
424  this->m_dataOut_OutputPort[portNum].addCallPort(port);
425  }
426 
429  FwIndexType portNum,
431  )
432  {
433  FW_ASSERT(
434  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
435  static_cast<FwAssertArgType>(portNum)
436  );
437 
438  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
439  }
440 
441 #if FW_PORT_SERIALIZATION
442 
443  // ----------------------------------------------------------------------
444  // Connect serial input ports to typed output ports
445  // ----------------------------------------------------------------------
446 
449  FwIndexType portNum,
450  Fw::InputSerializePort* port
451  )
452  {
453  FW_ASSERT(
454  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
455  static_cast<FwAssertArgType>(portNum)
456  );
457 
458  this->m_comStatusOut_OutputPort[portNum].registerSerialPort(port);
459  }
460 
463  FwIndexType portNum,
464  Fw::InputSerializePort* port
465  )
466  {
467  FW_ASSERT(
468  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
469  static_cast<FwAssertArgType>(portNum)
470  );
471 
472  this->m_dataOut_OutputPort[portNum].registerSerialPort(port);
473  }
474 
477  FwIndexType portNum,
478  Fw::InputSerializePort* port
479  )
480  {
481  FW_ASSERT(
482  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
483  static_cast<FwAssertArgType>(portNum)
484  );
485 
486  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
487  }
488 
489 #endif
490 
491  // ----------------------------------------------------------------------
492  // Component construction and destruction
493  // ----------------------------------------------------------------------
494 
496  ComAggregatorComponentBase(const char* compName) :
497  Fw::ActiveComponentBase(compName),
498  m_stateMachine_aggregationMachine(*this)
499  {
500 
501  }
502 
505  {
506 
507  }
508 
509  // ----------------------------------------------------------------------
510  // Connection status queries for typed output ports
511  // ----------------------------------------------------------------------
512 
515  {
516  FW_ASSERT(
517  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
518  static_cast<FwAssertArgType>(portNum)
519  );
520 
521  return this->m_comStatusOut_OutputPort[portNum].isConnected();
522  }
523 
526  {
527  FW_ASSERT(
528  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
529  static_cast<FwAssertArgType>(portNum)
530  );
531 
532  return this->m_dataOut_OutputPort[portNum].isConnected();
533  }
534 
537  {
538  FW_ASSERT(
539  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
540  static_cast<FwAssertArgType>(portNum)
541  );
542 
543  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
544  }
545 
546  // ----------------------------------------------------------------------
547  // Port handler base-class functions for typed input ports
548  //
549  // Call these functions directly to bypass the corresponding ports
550  // ----------------------------------------------------------------------
551 
554  FwIndexType portNum,
555  Fw::Success& condition
556  )
557  {
558  // Make sure port number is valid
559  FW_ASSERT(
560  (0 <= portNum) && (portNum < this->getNum_comStatusIn_InputPorts()),
561  static_cast<FwAssertArgType>(portNum)
562  );
563 
564  // Call handler function
565  this->comStatusIn_handler(
566  portNum,
567  condition
568  );
569  }
570 
573  FwIndexType portNum,
574  Fw::Buffer& data,
575  const ComCfg::FrameContext& context
576  )
577  {
578  // Make sure port number is valid
579  FW_ASSERT(
580  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
581  static_cast<FwAssertArgType>(portNum)
582  );
583 
584  // Call handler function
585  this->dataIn_handler(
586  portNum,
587  data,
588  context
589  );
590  }
591 
594  FwIndexType portNum,
595  Fw::Buffer& data,
596  const ComCfg::FrameContext& context
597  )
598  {
599  // Make sure port number is valid
600  FW_ASSERT(
601  (0 <= portNum) && (portNum < this->getNum_dataReturnIn_InputPorts()),
602  static_cast<FwAssertArgType>(portNum)
603  );
604 
605  // Call handler function
606  this->dataReturnIn_handler(
607  portNum,
608  data,
609  context
610  );
611  }
612 
615  FwIndexType portNum,
616  U32 context
617  )
618  {
619  // Make sure port number is valid
620  FW_ASSERT(
621  (0 <= portNum) && (portNum < this->getNum_timeout_InputPorts()),
622  static_cast<FwAssertArgType>(portNum)
623  );
624 
625  // Call handler function
626  this->timeout_handler(
627  portNum,
628  context
629  );
630  }
631 
632  // ----------------------------------------------------------------------
633  // Invocation functions for typed output ports
634  // ----------------------------------------------------------------------
635 
638  FwIndexType portNum,
639  Fw::Success& condition
640  )
641  {
642  FW_ASSERT(
643  (0 <= portNum) && (portNum < this->getNum_comStatusOut_OutputPorts()),
644  static_cast<FwAssertArgType>(portNum)
645  );
646 
647  FW_ASSERT(
648  this->m_comStatusOut_OutputPort[portNum].isConnected(),
649  static_cast<FwAssertArgType>(portNum)
650  );
651  this->m_comStatusOut_OutputPort[portNum].invoke(
652  condition
653  );
654  }
655 
658  FwIndexType portNum,
659  Fw::Buffer& data,
660  const ComCfg::FrameContext& context
661  )
662  {
663  FW_ASSERT(
664  (0 <= portNum) && (portNum < this->getNum_dataOut_OutputPorts()),
665  static_cast<FwAssertArgType>(portNum)
666  );
667 
668  FW_ASSERT(
669  this->m_dataOut_OutputPort[portNum].isConnected(),
670  static_cast<FwAssertArgType>(portNum)
671  );
672  this->m_dataOut_OutputPort[portNum].invoke(
673  data,
674  context
675  );
676  }
677 
680  FwIndexType portNum,
681  Fw::Buffer& data,
682  const ComCfg::FrameContext& context
683  )
684  {
685  FW_ASSERT(
686  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
687  static_cast<FwAssertArgType>(portNum)
688  );
689 
690  FW_ASSERT(
691  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
692  static_cast<FwAssertArgType>(portNum)
693  );
694  this->m_dataReturnOut_OutputPort[portNum].invoke(
695  data,
696  context
697  );
698  }
699 
700  // ----------------------------------------------------------------------
701  // State getter functions
702  // ----------------------------------------------------------------------
703 
706  {
707  return this->m_stateMachine_aggregationMachine.getState();
708  }
709 
710  // ----------------------------------------------------------------------
711  // Signal send functions
712  // ----------------------------------------------------------------------
713 
716  {
717  ComponentIpcSerializableBuffer buffer;
718  // Serialize the message type, port number, state ID, and signal
719  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::timeout), buffer);
720  // Send the message and handle overflow
721  this->aggregationMachine_sendSignalFinish(buffer);
722  }
723 
726  {
727  ComponentIpcSerializableBuffer buffer;
728  // Serialize the message type, port number, state ID, and signal
729  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::fill), buffer);
730  // Serialize the signal data
731  const Fw::SerializeStatus status = buffer.serializeFrom(value);
732  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
733  // Send the message and handle overflow
734  this->aggregationMachine_sendSignalFinish(buffer);
735  }
736 
739  {
740  ComponentIpcSerializableBuffer buffer;
741  // Serialize the message type, port number, state ID, and signal
742  this->sendSignalStart(SmId::aggregationMachine, static_cast<FwEnumStoreType>(Svc_AggregationMachine::Signal::status), buffer);
743  // Serialize the signal data
744  const Fw::SerializeStatus status = buffer.serializeFrom(value);
745  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
746  // Send the message and handle overflow
747  this->aggregationMachine_sendSignalFinish(buffer);
748  }
749 
750  // ----------------------------------------------------------------------
751  // Message dispatch functions
752  // ----------------------------------------------------------------------
753 
754  Fw::QueuedComponentBase::MsgDispatchStatus ComAggregatorComponentBase ::
755  doDispatch()
756  {
757  ComponentIpcSerializableBuffer _msg;
758  FwQueuePriorityType _priority = 0;
759 
760  Os::Queue::Status _msgStatus = this->m_queue.receive(
761  _msg,
763  _priority
764  );
765  FW_ASSERT(
766  _msgStatus == Os::Queue::OP_OK,
767  static_cast<FwAssertArgType>(_msgStatus)
768  );
769 
770  // Reset to beginning of buffer
771  _msg.resetDeser();
772 
773  FwEnumStoreType _desMsg = 0;
774  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
775  FW_ASSERT(
776  _deserStatus == Fw::FW_SERIALIZE_OK,
777  static_cast<FwAssertArgType>(_deserStatus)
778  );
779 
780  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
781 
782  if (_msgType == COMAGGREGATOR_COMPONENT_EXIT) {
783  return MSG_DISPATCH_EXIT;
784  }
785 
786  FwIndexType portNum = 0;
787  _deserStatus = _msg.deserializeTo(portNum);
788  FW_ASSERT(
789  _deserStatus == Fw::FW_SERIALIZE_OK,
790  static_cast<FwAssertArgType>(_deserStatus)
791  );
792 
793  switch (_msgType) {
794 
795  // Handle signals to internal state machines
796  case INTERNAL_STATE_MACHINE_SIGNAL:
797  this->smDispatch(_msg);
798  break;
799 
800  default:
801  return MSG_DISPATCH_ERROR;
802  }
803 
804  return MSG_DISPATCH_OK;
805  }
806 
807  // ----------------------------------------------------------------------
808  // Calls for messages received on typed input ports
809  // ----------------------------------------------------------------------
810 
811  void ComAggregatorComponentBase ::
812  m_p_comStatusIn_in(
813  Fw::PassiveComponentBase* callComp,
814  FwIndexType portNum,
815  Fw::Success& condition
816  )
817  {
818  FW_ASSERT(callComp);
819  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
820  compPtr->comStatusIn_handlerBase(
821  portNum,
822  condition
823  );
824  }
825 
826  void ComAggregatorComponentBase ::
827  m_p_dataIn_in(
828  Fw::PassiveComponentBase* callComp,
829  FwIndexType portNum,
830  Fw::Buffer& data,
831  const ComCfg::FrameContext& context
832  )
833  {
834  FW_ASSERT(callComp);
835  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
836  compPtr->dataIn_handlerBase(
837  portNum,
838  data,
839  context
840  );
841  }
842 
843  void ComAggregatorComponentBase ::
844  m_p_dataReturnIn_in(
845  Fw::PassiveComponentBase* callComp,
846  FwIndexType portNum,
847  Fw::Buffer& data,
848  const ComCfg::FrameContext& context
849  )
850  {
851  FW_ASSERT(callComp);
852  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
853  compPtr->dataReturnIn_handlerBase(
854  portNum,
855  data,
856  context
857  );
858  }
859 
860  void ComAggregatorComponentBase ::
861  m_p_timeout_in(
862  Fw::PassiveComponentBase* callComp,
863  FwIndexType portNum,
864  U32 context
865  )
866  {
867  FW_ASSERT(callComp);
868  ComAggregatorComponentBase* compPtr = static_cast<ComAggregatorComponentBase*>(callComp);
869  compPtr->timeout_handlerBase(
870  portNum,
871  context
872  );
873  }
874 
875  // ----------------------------------------------------------------------
876  // Send signal helper functions
877  // ----------------------------------------------------------------------
878 
879  void ComAggregatorComponentBase ::
880  sendSignalStart(
881  SmId smId,
882  FwEnumStoreType signal,
883  Fw::SerialBufferBase& buffer
884  )
885  {
887 
888  // Serialize the message type
889  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(INTERNAL_STATE_MACHINE_SIGNAL));
890  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
891 
892  // Serialize the port number
893  status = buffer.serializeFrom(static_cast<FwIndexType>(0));
894  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
895 
896  // Serialize the state machine ID
897  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(smId));
898  FW_ASSERT (status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
899 
900  // Serialize the signal
901  status = buffer.serializeFrom(static_cast<FwEnumStoreType>(signal));
902  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
903  }
904 
905  void ComAggregatorComponentBase ::
906  aggregationMachine_sendSignalFinish(Fw::LinearBufferBase& buffer)
907  {
908  // Send message
910  Os::Queue::Status qStatus = this->m_queue.send(buffer, 0, _block);
911 
912  FW_ASSERT(
913  qStatus == Os::Queue::OP_OK,
914  static_cast<FwAssertArgType>(qStatus)
915  );
916  }
917 
918  // ----------------------------------------------------------------------
919  // Helper functions for state machine dispatch
920  // ----------------------------------------------------------------------
921 
922  void ComAggregatorComponentBase ::
923  smDispatch(Fw::SerialBufferBase& buffer)
924  {
925  // Deserialize the state machine ID and signal
926  FwEnumStoreType storedSmId;
927  FwEnumStoreType storedSignal;
928  ComAggregatorComponentBase::deserializeSmIdAndSignal(buffer, storedSmId, storedSignal);
929 
930  // Select the target state machine instance
931  const SmId smId = static_cast<SmId>(storedSmId);
932  switch (smId) {
934  const Svc_AggregationMachine::Signal signal = static_cast<Svc_AggregationMachine::Signal>(storedSignal);
935  this->Svc_AggregationMachine_smDispatch(buffer, this->m_stateMachine_aggregationMachine, signal);
936  break;
937  }
938  default:
939  FW_ASSERT(0, static_cast<FwAssertArgType>(smId));
940  break;
941  }
942  }
943 
944  void ComAggregatorComponentBase ::
945  deserializeSmIdAndSignal(
946  Fw::SerialBufferBase& buffer,
947  FwEnumStoreType& smId,
948  FwEnumStoreType& signal
949  )
950  {
951  // Move deserialization beyond the message type and port number
952  Fw::SerializeStatus status =
953  buffer.moveDeserToOffset(ComponentIpcSerializableBuffer::DATA_OFFSET);
954  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
955 
956  // Deserialize the state machine ID
957  status = buffer.deserializeTo(smId);
958  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
959 
960  // Deserialize the signal
961  status = buffer.deserializeTo(signal);
962  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
963  }
964 
965  void ComAggregatorComponentBase ::
966  Svc_AggregationMachine_smDispatch(
967  Fw::SerialBufferBase& buffer,
968  Svc_AggregationMachine& sm,
970  )
971  {
972  switch (signal) {
974  // Assert no data left in buffer
975  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
976  // Call the sendSignal function for sm and timeout
977  sm.sendSignal_timeout();
978  break;
979  }
981  // Deserialize the data
983  const Fw::SerializeStatus status = buffer.deserializeTo(value);
984  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
985  // Assert no data left in buffer
986  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
987  // Call the sendSignal function for sm and fill
988  sm.sendSignal_fill(value);
989  break;
990  }
992  // Deserialize the data
993  Fw::Success value;
994  const Fw::SerializeStatus status = buffer.deserializeTo(value);
995  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
996  // Assert no data left in buffer
997  FW_ASSERT(buffer.getDeserializeSizeLeft() == 0, static_cast<FwAssertArgType>(buffer.getDeserializeSizeLeft()));
998  // Call the sendSignal function for sm and status
999  sm.sendSignal_status(value);
1000  break;
1001  }
1002  default:
1003  FW_ASSERT(0, static_cast<FwAssertArgType>(signal));
1004  break;
1005  }
1006  }
1007 
1008 }
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:63
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
The size of the serial representation.
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.
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 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:46
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()
message to exit active component task
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.