F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ActivePhaserComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ActivePhaserComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ActivePhaser 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  enum MsgTypeEnum {
18  ACTIVEPHASER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  CYCLEIN_CYCLE,
20  INT_IF_TICK,
21  };
22 
23  // Get the max size by constructing a union of the async input, command, and
24  // internal port serialization sizes
25  union BuffUnion {
26  BYTE CycleInPortSize[Svc::CyclePortBuffer::CAPACITY];
27  };
28 
29  // Define a message buffer class large enough to handle all the
30  // asynchronous inputs to the component
31  class ComponentIpcSerializableBuffer :
33  {
34 
35  public:
36 
37  enum {
38  // Offset into data in buffer: Size of message ID and port number
39  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
40  // Max data size
41  MAX_DATA_SIZE = sizeof(BuffUnion),
42  // Max message size: Size of message id + size of port + max data size
43  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
44  };
45 
46  Fw::Serializable::SizeType getCapacity() const {
47  return sizeof(m_buff);
48  }
49 
50  U8* getBuffAddr() {
51  return m_buff;
52  }
53 
54  const U8* getBuffAddr() const {
55  return m_buff;
56  }
57 
58  private:
59  // Should be the max of all the input ports serialized sizes...
60  U8 m_buff[SERIALIZATION_SIZE];
61 
62  };
63  }
64 
65  // ----------------------------------------------------------------------
66  // Component initialization
67  // ----------------------------------------------------------------------
68 
71  FwSizeType queueDepth,
72  FwEnumStoreType instance
73  )
74  {
75  // Initialize base class
77 
78 #if !FW_DIRECT_PORT_CALLS
79  // Connect input port CycleIn
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
83  port++
84  ) {
85  this->m_CycleIn_InputPort[port].init();
86  this->m_CycleIn_InputPort[port].addCallComp(
87  this,
88  m_p_CycleIn_in
89  );
90  this->m_CycleIn_InputPort[port].setPortNum(port);
91 
92 #if FW_OBJECT_NAMES == 1
93  Fw::ObjectName portName;
94  portName.format(
95  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
96  this->m_objName.toChar(),
97  port
98  );
99  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
100 #endif
101  }
102 #endif
103 
104 #if !FW_DIRECT_PORT_CALLS
105  // Connect output port logOut
106  for (
107  FwIndexType port = 0;
108  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
109  port++
110  ) {
111  this->m_logOut_OutputPort[port].init();
112 
113 #if FW_OBJECT_NAMES == 1
114  Fw::ObjectName portName;
115  portName.format(
116  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
117  this->m_objName.toChar(),
118  port
119  );
120  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
121 #endif
122  }
123 #endif
124 
125 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
126  // Connect output port logTextOut
127  for (
128  FwIndexType port = 0;
129  port < static_cast<FwIndexType>(this->getNum_logTextOut_OutputPorts());
130  port++
131  ) {
132  this->m_logTextOut_OutputPort[port].init();
133 
134 #if FW_OBJECT_NAMES == 1
135  Fw::ObjectName portName;
136  portName.format(
137  "%s_logTextOut_OutputPort[%" PRI_FwIndexType "]",
138  this->m_objName.toChar(),
139  port
140  );
141  this->m_logTextOut_OutputPort[port].setObjName(portName.toChar());
142 #endif
143  }
144 #endif
145 
146 #if !FW_DIRECT_PORT_CALLS
147  // Connect output port timeCaller
148  for (
149  FwIndexType port = 0;
150  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
151  port++
152  ) {
153  this->m_timeCaller_OutputPort[port].init();
154 
155 #if FW_OBJECT_NAMES == 1
156  Fw::ObjectName portName;
157  portName.format(
158  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
159  this->m_objName.toChar(),
160  port
161  );
162  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
163 #endif
164  }
165 #endif
166 
167 #if !FW_DIRECT_PORT_CALLS
168  // Connect output port tlmOut
169  for (
170  FwIndexType port = 0;
171  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
172  port++
173  ) {
174  this->m_tlmOut_OutputPort[port].init();
175 
176 #if FW_OBJECT_NAMES == 1
177  Fw::ObjectName portName;
178  portName.format(
179  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
180  this->m_objName.toChar(),
181  port
182  );
183  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
184 #endif
185  }
186 #endif
187 
188 #if !FW_DIRECT_PORT_CALLS
189  // Connect output port PhaserMemberOut
190  for (
191  FwIndexType port = 0;
192  port < static_cast<FwIndexType>(this->getNum_PhaserMemberOut_OutputPorts());
193  port++
194  ) {
195  this->m_PhaserMemberOut_OutputPort[port].init();
196 
197 #if FW_OBJECT_NAMES == 1
198  Fw::ObjectName portName;
199  portName.format(
200  "%s_PhaserMemberOut_OutputPort[%" PRI_FwIndexType "]",
201  this->m_objName.toChar(),
202  port
203  );
204  this->m_PhaserMemberOut_OutputPort[port].setObjName(portName.toChar());
205 #endif
206  }
207 #endif
208 
209  // Create the queue
210  Os::Queue::Status qStat = this->createQueue(
211  queueDepth,
212  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
213  );
214  FW_ASSERT(
215  Os::Queue::Status::OP_OK == qStat,
216  static_cast<FwAssertArgType>(qStat)
217  );
218  }
219 
220 #if !FW_DIRECT_PORT_CALLS
221 
222  // ----------------------------------------------------------------------
223  // Getters for typed input ports
224  // ----------------------------------------------------------------------
225 
228  {
229  FW_ASSERT(
230  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
231  static_cast<FwAssertArgType>(portNum)
232  );
233 
234  return &this->m_CycleIn_InputPort[portNum];
235  }
236 
237 #endif
238 
239 #if !FW_DIRECT_PORT_CALLS
240 
241  // ----------------------------------------------------------------------
242  // Connect input ports to special output ports
243  // ----------------------------------------------------------------------
244 
247  FwIndexType portNum,
248  Fw::InputLogPort* port
249  )
250  {
251  FW_ASSERT(
252  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
253  static_cast<FwAssertArgType>(portNum)
254  );
255 
256  this->m_logOut_OutputPort[portNum].addCallPort(port);
257  }
258 
259 #if FW_ENABLE_TEXT_LOGGING == 1
260 
261  void ActivePhaserComponentBase ::
262  set_logTextOut_OutputPort(
263  FwIndexType portNum,
265  )
266  {
267  FW_ASSERT(
268  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
269  static_cast<FwAssertArgType>(portNum)
270  );
271 
272  this->m_logTextOut_OutputPort[portNum].addCallPort(port);
273  }
274 
275 #endif
276 
279  FwIndexType portNum,
280  Fw::InputTimePort* port
281  )
282  {
283  FW_ASSERT(
284  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
285  static_cast<FwAssertArgType>(portNum)
286  );
287 
288  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
289  }
290 
293  FwIndexType portNum,
294  Fw::InputTlmPort* port
295  )
296  {
297  FW_ASSERT(
298  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
299  static_cast<FwAssertArgType>(portNum)
300  );
301 
302  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
303  }
304 
305 #endif
306 
307 #if !FW_DIRECT_PORT_CALLS
308 
309  // ----------------------------------------------------------------------
310  // Connect typed input ports to typed output ports
311  // ----------------------------------------------------------------------
312 
315  FwIndexType portNum,
316  Svc::InputSchedPort* port
317  )
318  {
319  FW_ASSERT(
320  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
321  static_cast<FwAssertArgType>(portNum)
322  );
323 
324  this->m_PhaserMemberOut_OutputPort[portNum].addCallPort(port);
325  }
326 
327 #endif
328 
329 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
330 
331  // ----------------------------------------------------------------------
332  // Connect serial input ports to special output ports
333  // ----------------------------------------------------------------------
334 
337  FwIndexType portNum,
338  Fw::InputSerializePort* port
339  )
340  {
341  FW_ASSERT(
342  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
343  static_cast<FwAssertArgType>(portNum)
344  );
345 
346  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
347  }
348 
349 #if FW_ENABLE_TEXT_LOGGING == 1
350 
351  void ActivePhaserComponentBase ::
352  set_logTextOut_OutputPort(
353  FwIndexType portNum,
354  Fw::InputSerializePort* port
355  )
356  {
357  FW_ASSERT(
358  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
359  static_cast<FwAssertArgType>(portNum)
360  );
361 
362  this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
363  }
364 
365 #endif
366 
369  FwIndexType portNum,
370  Fw::InputSerializePort* port
371  )
372  {
373  FW_ASSERT(
374  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
375  static_cast<FwAssertArgType>(portNum)
376  );
377 
378  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
379  }
380 
383  FwIndexType portNum,
384  Fw::InputSerializePort* port
385  )
386  {
387  FW_ASSERT(
388  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
389  static_cast<FwAssertArgType>(portNum)
390  );
391 
392  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
393  }
394 
395 #endif
396 
397 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
398 
399  // ----------------------------------------------------------------------
400  // Connect serial input ports to typed output ports
401  // ----------------------------------------------------------------------
402 
405  FwIndexType portNum,
406  Fw::InputSerializePort* port
407  )
408  {
409  FW_ASSERT(
410  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
411  static_cast<FwAssertArgType>(portNum)
412  );
413 
414  this->m_PhaserMemberOut_OutputPort[portNum].registerSerialPort(port);
415  }
416 
417 #endif
418 
419  // ----------------------------------------------------------------------
420  // Component construction and destruction
421  // ----------------------------------------------------------------------
422 
424  ActivePhaserComponentBase(const char* compName) :
425  Fw::ActiveComponentBase(compName)
426  {
427  this->m_MissedDeadlineThrottle = 0;
428  }
429 
432  {
433 
434  }
435 
436 #if !FW_DIRECT_PORT_CALLS
437 
438  // ----------------------------------------------------------------------
439  // Connection status queries for special output ports
440  // ----------------------------------------------------------------------
441 
444  {
445  FW_ASSERT(
446  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
447  static_cast<FwAssertArgType>(portNum)
448  );
449 
450  return this->m_logOut_OutputPort[portNum].isConnected();
451  }
452 
453 #if FW_ENABLE_TEXT_LOGGING == 1
454 
455  bool ActivePhaserComponentBase ::
456  isConnected_logTextOut_OutputPort(FwIndexType portNum) const
457  {
458  FW_ASSERT(
459  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
460  static_cast<FwAssertArgType>(portNum)
461  );
462 
463  return this->m_logTextOut_OutputPort[portNum].isConnected();
464  }
465 
466 #endif
467 
470  {
471  FW_ASSERT(
472  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
473  static_cast<FwAssertArgType>(portNum)
474  );
475 
476  return this->m_timeCaller_OutputPort[portNum].isConnected();
477  }
478 
481  {
482  FW_ASSERT(
483  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
484  static_cast<FwAssertArgType>(portNum)
485  );
486 
487  return this->m_tlmOut_OutputPort[portNum].isConnected();
488  }
489 
490 #endif
491 
492 #if !FW_DIRECT_PORT_CALLS
493 
494  // ----------------------------------------------------------------------
495  // Connection status queries for typed output ports
496  // ----------------------------------------------------------------------
497 
500  {
501  FW_ASSERT(
502  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
503  static_cast<FwAssertArgType>(portNum)
504  );
505 
506  return this->m_PhaserMemberOut_OutputPort[portNum].isConnected();
507  }
508 
509 #endif
510 
511  // ----------------------------------------------------------------------
512  // Port handler base-class functions for typed input ports
513  //
514  // Call these functions directly to bypass the corresponding ports
515  // ----------------------------------------------------------------------
516 
519  FwIndexType portNum,
520  Os::RawTime& cycleStart
521  )
522  {
523  // Make sure port number is valid
524  FW_ASSERT(
525  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
526  static_cast<FwAssertArgType>(portNum)
527  );
528 
529  // Call pre-message hook
531  portNum,
532  cycleStart
533  );
534  ComponentIpcSerializableBuffer msg;
536 
537  // Serialize message ID
538  _status = msg.serializeFrom(
539  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
540  );
541  FW_ASSERT(
542  _status == Fw::FW_SERIALIZE_OK,
543  static_cast<FwAssertArgType>(_status)
544  );
545 
546  // Serialize port number
547  _status = msg.serializeFrom(portNum);
548  FW_ASSERT(
549  _status == Fw::FW_SERIALIZE_OK,
550  static_cast<FwAssertArgType>(_status)
551  );
552 
553  // Serialize argument cycleStart
554  _status = msg.serializeFrom(cycleStart);
555  FW_ASSERT(
556  _status == Fw::FW_SERIALIZE_OK,
557  static_cast<FwAssertArgType>(_status)
558  );
559 
560  // Send message
562  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
563 
564  if (qStatus == Os::Queue::Status::FULL) {
565  this->incNumMsgDropped();
566  return;
567  }
568 
569  FW_ASSERT(
570  qStatus == Os::Queue::OP_OK,
571  static_cast<FwAssertArgType>(qStatus)
572  );
573  }
574 
575  // ----------------------------------------------------------------------
576  // Pre-message hooks for typed async input ports
577  //
578  // Each of these functions is invoked just before processing a message
579  // on the corresponding port. By default, they do nothing. You can
580  // override them to provide specific pre-message behavior.
581  // ----------------------------------------------------------------------
582 
585  FwIndexType portNum,
586  Os::RawTime& cycleStart
587  )
588  {
589  // Default: no-op
590  }
591 
592 #if !FW_DIRECT_PORT_CALLS
593 
594  // ----------------------------------------------------------------------
595  // Invocation functions for typed output ports
596  // ----------------------------------------------------------------------
597 
600  FwIndexType portNum,
601  U32 context
602  ) const
603  {
604  FW_ASSERT(
605  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
606  static_cast<FwAssertArgType>(portNum)
607  );
608 
609  FW_ASSERT(
610  this->m_PhaserMemberOut_OutputPort[portNum].isConnected(),
611  static_cast<FwAssertArgType>(portNum)
612  );
613  this->m_PhaserMemberOut_OutputPort[portNum].invoke(
614  context
615  );
616  }
617 
618 #endif
619 
620  // ----------------------------------------------------------------------
621  // Internal interface base-class functions
622  // ----------------------------------------------------------------------
623 
626  {
627  ComponentIpcSerializableBuffer msg;
629 
630  // Serialize the message ID
631  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(INT_IF_TICK));
632  FW_ASSERT (
633  _status == Fw::FW_SERIALIZE_OK,
634  static_cast<FwAssertArgType>(_status)
635  );
636 
637  // Fake port number to make message dequeue work
638  _status = msg.serializeFrom(static_cast<FwIndexType>(0));
639  FW_ASSERT (
640  _status == Fw::FW_SERIALIZE_OK,
641  static_cast<FwAssertArgType>(_status)
642  );
643 
644  // Send message
646  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
647 
648  if (qStatus == Os::Queue::Status::FULL) {
649  this->incNumMsgDropped();
650  return;
651  }
652 
653  FW_ASSERT(
654  qStatus == Os::Queue::OP_OK,
655  static_cast<FwAssertArgType>(qStatus)
656  );
657  }
658 
659  // ----------------------------------------------------------------------
660  // Event logging functions
661  // ----------------------------------------------------------------------
662 
665  FwIndexType p,
666  U32 start,
667  U32 length,
668  U32 ticks
669  )
670  {
671  // Check throttle value
672  if (this->m_MissedDeadlineThrottle >= EVENTID_MISSEDDEADLINE_THROTTLE) {
673  return;
674  }
675  else {
676  this->m_MissedDeadlineThrottle++;
677  }
678 
679  // Get the time
680  Fw::Time _logTime;
681  if (this->isConnected_timeCaller_OutputPort(0)) {
682  this->timeCaller_out(0, _logTime);
683  }
684 
685  const FwEventIdType _id = this->getIdBase() + EVENTID_MISSEDDEADLINE;
686 
687  // Emit the event on the log port
688  if (this->isConnected_logOut_OutputPort(0)) {
689  Fw::LogBuffer _logBuff;
691 
692 #if FW_AMPCS_COMPATIBLE
693  // Serialize the number of arguments
694  _status = _logBuff.serializeFrom(static_cast<U8>(4));
695  FW_ASSERT(
696  _status == Fw::FW_SERIALIZE_OK,
697  static_cast<FwAssertArgType>(_status)
698  );
699 #endif
700 
701 #if FW_AMPCS_COMPATIBLE
702  // Serialize the argument size
703  _status = _logBuff.serializeFrom(
704  static_cast<U8>(sizeof(FwIndexType))
705  );
706  FW_ASSERT(
707  _status == Fw::FW_SERIALIZE_OK,
708  static_cast<FwAssertArgType>(_status)
709  );
710 #endif
711  _status = _logBuff.serializeFrom(p);
712  FW_ASSERT(
713  _status == Fw::FW_SERIALIZE_OK,
714  static_cast<FwAssertArgType>(_status)
715  );
716 
717 #if FW_AMPCS_COMPATIBLE
718  // Serialize the argument size
719  _status = _logBuff.serializeFrom(
720  static_cast<U8>(sizeof(U32))
721  );
722  FW_ASSERT(
723  _status == Fw::FW_SERIALIZE_OK,
724  static_cast<FwAssertArgType>(_status)
725  );
726 #endif
727  _status = _logBuff.serializeFrom(start);
728  FW_ASSERT(
729  _status == Fw::FW_SERIALIZE_OK,
730  static_cast<FwAssertArgType>(_status)
731  );
732 
733 #if FW_AMPCS_COMPATIBLE
734  // Serialize the argument size
735  _status = _logBuff.serializeFrom(
736  static_cast<U8>(sizeof(U32))
737  );
738  FW_ASSERT(
739  _status == Fw::FW_SERIALIZE_OK,
740  static_cast<FwAssertArgType>(_status)
741  );
742 #endif
743  _status = _logBuff.serializeFrom(length);
744  FW_ASSERT(
745  _status == Fw::FW_SERIALIZE_OK,
746  static_cast<FwAssertArgType>(_status)
747  );
748 
749 #if FW_AMPCS_COMPATIBLE
750  // Serialize the argument size
751  _status = _logBuff.serializeFrom(
752  static_cast<U8>(sizeof(U32))
753  );
754  FW_ASSERT(
755  _status == Fw::FW_SERIALIZE_OK,
756  static_cast<FwAssertArgType>(_status)
757  );
758 #endif
759  _status = _logBuff.serializeFrom(ticks);
760  FW_ASSERT(
761  _status == Fw::FW_SERIALIZE_OK,
762  static_cast<FwAssertArgType>(_status)
763  );
764 
765  this->logOut_out(
766  0,
767  _id,
768  _logTime,
770  _logBuff
771  );
772  }
773 
774  // Emit the event on the text log port
775 #if FW_ENABLE_TEXT_LOGGING
776  if (this->isConnected_logTextOut_OutputPort(0)) {
777 #if FW_OBJECT_NAMES == 1
778  const char* _formatString =
779  "(%s) %s: Port %" PRIi16 " schedule at %" PRIu32 " for %" PRIu32 " ticks was long by %" PRIu32 " ticks";
780 #else
781  const char* _formatString =
782  "%s: Port %" PRIi16 " schedule at %" PRIu32 " for %" PRIu32 " ticks was long by %" PRIu32 " ticks";
783 #endif
784 
785  Fw::TextLogString _logString;
786  _logString.format(
787  _formatString,
788 #if FW_OBJECT_NAMES == 1
789  this->m_objName.toChar(),
790 #endif
791  "MissedDeadline ",
792  p,
793  start,
794  length,
795  ticks
796  );
797 
798  this->logTextOut_out(
799  0,
800  _id,
801  _logTime,
803  _logString
804  );
805  }
806 #endif
807  }
808 
809  // ----------------------------------------------------------------------
810  // Event throttle reset functions
811  // ----------------------------------------------------------------------
812 
815  {
816  // Reset throttle counter
817  this->m_MissedDeadlineThrottle = 0;
818  }
819 
820  // ----------------------------------------------------------------------
821  // Time
822  // ----------------------------------------------------------------------
823 
825  getTime() const
826  {
827  if (this->isConnected_timeCaller_OutputPort(0)) {
828  Fw::Time _time;
829  this->timeCaller_out(0, _time);
830  return _time;
831  }
832  else {
833  return Fw::Time(TimeBase::TB_NONE, 0, 0);
834  }
835  }
836 
837  // ----------------------------------------------------------------------
838  // Message dispatch functions
839  // ----------------------------------------------------------------------
840 
841  Fw::QueuedComponentBase::MsgDispatchStatus ActivePhaserComponentBase ::
842  doDispatch()
843  {
844  ComponentIpcSerializableBuffer _msg;
845  FwQueuePriorityType _priority = 0;
846 
847  Os::Queue::Status _msgStatus = this->m_queue.receive(
848  _msg,
850  _priority
851  );
852  FW_ASSERT(
853  _msgStatus == Os::Queue::OP_OK,
854  static_cast<FwAssertArgType>(_msgStatus)
855  );
856 
857  // Reset to beginning of buffer
858  _msg.resetDeser();
859 
860  FwEnumStoreType _desMsg = 0;
861  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
862  FW_ASSERT(
863  _deserStatus == Fw::FW_SERIALIZE_OK,
864  static_cast<FwAssertArgType>(_deserStatus)
865  );
866 
867  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
868 
869  if (_msgType == ACTIVEPHASER_COMPONENT_EXIT) {
870  return MSG_DISPATCH_EXIT;
871  }
872 
873  FwIndexType portNum = 0;
874  _deserStatus = _msg.deserializeTo(portNum);
875  FW_ASSERT(
876  _deserStatus == Fw::FW_SERIALIZE_OK,
877  static_cast<FwAssertArgType>(_deserStatus)
878  );
879 
880  switch (_msgType) {
881  // Handle async input port CycleIn
882  case CYCLEIN_CYCLE: {
883  // Deserialize argument cycleStart
884  Os::RawTime cycleStart;
885  _deserStatus = _msg.deserializeTo(cycleStart);
886  FW_ASSERT(
887  _deserStatus == Fw::FW_SERIALIZE_OK,
888  static_cast<FwAssertArgType>(_deserStatus)
889  );
890  // Call handler function
891  this->CycleIn_handler(
892  portNum,
893  cycleStart
894  );
895 
896  break;
897  }
898 
899  // Handle internal interface Tick
900  case INT_IF_TICK: {
901  // Make sure there was no data left over.
902  // That means the buffer size was incorrect.
903  FW_ASSERT(
904  _msg.getDeserializeSizeLeft() == 0,
905  static_cast<FwAssertArgType>(_msg.getDeserializeSizeLeft())
906  );
907 
908  // Call handler function
910 
911  break;
912  }
913 
914  default:
915  return MSG_DISPATCH_ERROR;
916  }
917 
918  return MSG_DISPATCH_OK;
919  }
920 
921  // ----------------------------------------------------------------------
922  // Calls for messages received on typed input ports
923  // ----------------------------------------------------------------------
924 
925  void ActivePhaserComponentBase ::
926  m_p_CycleIn_in(
927  Fw::PassiveComponentBase* callComp,
928  FwIndexType portNum,
929  Os::RawTime& cycleStart
930  )
931  {
932  FW_ASSERT(callComp);
933  ActivePhaserComponentBase* compPtr = static_cast<ActivePhaserComponentBase*>(callComp);
934  compPtr->CycleIn_handlerBase(
935  portNum,
936  cycleStart
937  );
938  }
939 
940 #if !FW_DIRECT_PORT_CALLS
941 
942  // ----------------------------------------------------------------------
943  // Invocation functions for special output ports
944  // ----------------------------------------------------------------------
945 
946  void ActivePhaserComponentBase ::
947  logOut_out(
948  FwIndexType portNum,
949  FwEventIdType id,
950  Fw::Time& timeTag,
951  const Fw::LogSeverity& severity,
952  Fw::LogBuffer& args
953  ) const
954  {
955  FW_ASSERT(
956  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
957  static_cast<FwAssertArgType>(portNum)
958  );
959 
960  FW_ASSERT(
961  this->m_logOut_OutputPort[portNum].isConnected(),
962  static_cast<FwAssertArgType>(portNum)
963  );
964  this->m_logOut_OutputPort[portNum].invoke(
965  id,
966  timeTag,
967  severity,
968  args
969  );
970  }
971 
972 #if FW_ENABLE_TEXT_LOGGING
973 
974  void ActivePhaserComponentBase ::
975  logTextOut_out(
976  FwIndexType portNum,
977  FwEventIdType id,
978  Fw::Time& timeTag,
979  const Fw::LogSeverity& severity,
980  Fw::TextLogString& text
981  ) const
982  {
983  FW_ASSERT(
984  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
985  static_cast<FwAssertArgType>(portNum)
986  );
987 
988  FW_ASSERT(
989  this->m_logTextOut_OutputPort[portNum].isConnected(),
990  static_cast<FwAssertArgType>(portNum)
991  );
992  this->m_logTextOut_OutputPort[portNum].invoke(
993  id,
994  timeTag,
995  severity,
996  text
997  );
998  }
999 
1000 #endif
1001 
1002  void ActivePhaserComponentBase ::
1003  timeCaller_out(
1004  FwIndexType portNum,
1005  Fw::Time& time
1006  ) const
1007  {
1008  FW_ASSERT(
1009  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1010  static_cast<FwAssertArgType>(portNum)
1011  );
1012 
1013  FW_ASSERT(
1014  this->m_timeCaller_OutputPort[portNum].isConnected(),
1015  static_cast<FwAssertArgType>(portNum)
1016  );
1017  this->m_timeCaller_OutputPort[portNum].invoke(
1018  time
1019  );
1020  }
1021 
1022 #endif
1023 
1024 }
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
message to exit active component task
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
Operation succeeded.
Definition: Os.hpp:27
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
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
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:79
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
void set_PhaserMemberOut_OutputPort(FwIndexType portNum, Svc::InputSchedPort *port)
Connect port to PhaserMemberOut[portNum].
void PhaserMemberOut_out(FwIndexType portNum, U32 context) const
Invoke output port PhaserMemberOut.
void init()
Initialization function.
Definition: TlmPortAc.cpp:171
No time base has been established (Required)
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
Os::Queue m_queue
queue object for active component
Warning event that rate group has had a missed deadline.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
Message will block until space is available.
Definition: Queue.hpp:47
FwIdType FwEventIdType
The type of an event identifier.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void invoke(U32 context) const
Invoke a port connection.
ActivePhaserComponentBase(const char *compName="")
Construct ActivePhaserComponentBase object.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
FwSizeType SizeType
virtual ~ActivePhaserComponentBase()
Destroy ActivePhaserComponentBase object.
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
A serious but recoverable event.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void setPortNum(FwIndexType portNum)
void Tick_internalInterfaceInvoke()
Internal interface base-class function for Tick.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
Definition: CyclePortAc.cpp:73
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
bool isConnected_PhaserMemberOut_OutputPort(FwIndexType portNum) const
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
static constexpr FwSizeType CAPACITY
Definition: CyclePortAc.hpp:35
A message was sent requesting an exit of the loop.
PlatformIndexType FwIndexType
virtual void Tick_internalInterfaceHandler()=0
Internal interface handler for Tick.
static constexpr FwIndexType getNum_PhaserMemberOut_OutputPorts()
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void log_WARNING_HI_MissedDeadline_ThrottleClear()
Reset throttle value for MissedDeadline.
void init()
Initialization function.
void CycleIn_handlerBase(FwIndexType portNum, Os::RawTime &cycleStart)
Handler base-class function for input port CycleIn.
virtual void CycleIn_handler(FwIndexType portNum, Os::RawTime &cycleStart)=0
Handler for input port CycleIn.
void incNumMsgDropped()
increment the number of messages dropped
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:56
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
virtual void CycleIn_preMsgHook(FwIndexType portNum, Os::RawTime &cycleStart)
Pre-message hook for async input port CycleIn.
void start(FwTaskPriorityType priority=Os::Task::TASK_PRIORITY_DEFAULT, FwSizeType stackSize=Os::Task::TASK_DEFAULT, FwSizeType cpuAffinity=Os::Task::TASK_DEFAULT, FwTaskIdType identifier=static_cast< FwTaskIdType >(Os::Task::TASK_DEFAULT))
called by instantiator when task is to be started
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
Implementation of malloc based allocator.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
static constexpr FwIndexType getNum_logOut_OutputPorts()
void addCallPort(InputSchedPort *callPort)
Register an input port.
void log_WARNING_HI_MissedDeadline(FwIndexType p, U32 start, U32 length, U32 ticks)