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