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  ComponentIpcSerializableBuffer() : Fw::LinearBufferBase(m_buff, sizeof(m_buff)) {
47 
48  }
49 
50  private:
51  // Should be the max of all the input ports serialized sizes...
52  U8 m_buff[SERIALIZATION_SIZE];
53 
54  };
55  }
56 
57  // ----------------------------------------------------------------------
58  // Component initialization
59  // ----------------------------------------------------------------------
60 
63  FwSizeType queueDepth,
64  FwEnumStoreType instance
65  )
66  {
67  // Initialize base class
69 
70 #if !FW_DIRECT_PORT_CALLS
71  // Connect input port CycleIn
72  for (
73  FwIndexType port = 0;
74  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
75  port++
76  ) {
77  this->m_CycleIn_InputPort[port].init();
78  this->m_CycleIn_InputPort[port].addCallComp(
79  this,
80  m_p_CycleIn_in
81  );
82  this->m_CycleIn_InputPort[port].setPortNum(port);
83 
84 #if FW_OBJECT_NAMES == 1
85  Fw::ObjectName portName;
86  portName.format(
87  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
88  this->m_objName.toChar(),
89  port
90  );
91  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
92 #endif
93  }
94 #endif
95 
96 #if !FW_DIRECT_PORT_CALLS
97  // Connect output port logOut
98  for (
99  FwIndexType port = 0;
100  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
101  port++
102  ) {
103  this->m_logOut_OutputPort[port].init();
104 
105 #if FW_OBJECT_NAMES == 1
106  Fw::ObjectName portName;
107  portName.format(
108  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
109  this->m_objName.toChar(),
110  port
111  );
112  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
113 #endif
114  }
115 #endif
116 
117 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
118  // Connect output port logTextOut
119  for (
120  FwIndexType port = 0;
121  port < static_cast<FwIndexType>(this->getNum_logTextOut_OutputPorts());
122  port++
123  ) {
124  this->m_logTextOut_OutputPort[port].init();
125 
126 #if FW_OBJECT_NAMES == 1
127  Fw::ObjectName portName;
128  portName.format(
129  "%s_logTextOut_OutputPort[%" PRI_FwIndexType "]",
130  this->m_objName.toChar(),
131  port
132  );
133  this->m_logTextOut_OutputPort[port].setObjName(portName.toChar());
134 #endif
135  }
136 #endif
137 
138 #if !FW_DIRECT_PORT_CALLS
139  // Connect output port timeCaller
140  for (
141  FwIndexType port = 0;
142  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
143  port++
144  ) {
145  this->m_timeCaller_OutputPort[port].init();
146 
147 #if FW_OBJECT_NAMES == 1
148  Fw::ObjectName portName;
149  portName.format(
150  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
151  this->m_objName.toChar(),
152  port
153  );
154  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
155 #endif
156  }
157 #endif
158 
159 #if !FW_DIRECT_PORT_CALLS
160  // Connect output port tlmOut
161  for (
162  FwIndexType port = 0;
163  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
164  port++
165  ) {
166  this->m_tlmOut_OutputPort[port].init();
167 
168 #if FW_OBJECT_NAMES == 1
169  Fw::ObjectName portName;
170  portName.format(
171  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
172  this->m_objName.toChar(),
173  port
174  );
175  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
176 #endif
177  }
178 #endif
179 
180 #if !FW_DIRECT_PORT_CALLS
181  // Connect output port PhaserMemberOut
182  for (
183  FwIndexType port = 0;
184  port < static_cast<FwIndexType>(this->getNum_PhaserMemberOut_OutputPorts());
185  port++
186  ) {
187  this->m_PhaserMemberOut_OutputPort[port].init();
188 
189 #if FW_OBJECT_NAMES == 1
190  Fw::ObjectName portName;
191  portName.format(
192  "%s_PhaserMemberOut_OutputPort[%" PRI_FwIndexType "]",
193  this->m_objName.toChar(),
194  port
195  );
196  this->m_PhaserMemberOut_OutputPort[port].setObjName(portName.toChar());
197 #endif
198  }
199 #endif
200 
201  // Create the queue
202  Os::Queue::Status qStat = this->createQueue(
203  queueDepth,
204  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
205  );
206  FW_ASSERT(
207  Os::Queue::Status::OP_OK == qStat,
208  static_cast<FwAssertArgType>(qStat)
209  );
210  }
211 
212 #if !FW_DIRECT_PORT_CALLS
213 
214  // ----------------------------------------------------------------------
215  // Getters for typed input ports
216  // ----------------------------------------------------------------------
217 
220  {
221  FW_ASSERT(
222  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
223  static_cast<FwAssertArgType>(portNum)
224  );
225 
226  return &this->m_CycleIn_InputPort[portNum];
227  }
228 
229 #endif
230 
231 #if !FW_DIRECT_PORT_CALLS
232 
233  // ----------------------------------------------------------------------
234  // Connect input ports to special output ports
235  // ----------------------------------------------------------------------
236 
239  FwIndexType portNum,
240  Fw::InputLogPort* port
241  )
242  {
243  FW_ASSERT(
244  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
245  static_cast<FwAssertArgType>(portNum)
246  );
247 
248  this->m_logOut_OutputPort[portNum].addCallPort(port);
249  }
250 
251 #if FW_ENABLE_TEXT_LOGGING == 1
252 
253  void ActivePhaserComponentBase ::
254  set_logTextOut_OutputPort(
255  FwIndexType portNum,
257  )
258  {
259  FW_ASSERT(
260  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
261  static_cast<FwAssertArgType>(portNum)
262  );
263 
264  this->m_logTextOut_OutputPort[portNum].addCallPort(port);
265  }
266 
267 #endif
268 
271  FwIndexType portNum,
272  Fw::InputTimePort* port
273  )
274  {
275  FW_ASSERT(
276  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
277  static_cast<FwAssertArgType>(portNum)
278  );
279 
280  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
281  }
282 
285  FwIndexType portNum,
286  Fw::InputTlmPort* port
287  )
288  {
289  FW_ASSERT(
290  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
291  static_cast<FwAssertArgType>(portNum)
292  );
293 
294  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
295  }
296 
297 #endif
298 
299 #if !FW_DIRECT_PORT_CALLS
300 
301  // ----------------------------------------------------------------------
302  // Connect typed input ports to typed output ports
303  // ----------------------------------------------------------------------
304 
307  FwIndexType portNum,
308  Svc::InputSchedPort* port
309  )
310  {
311  FW_ASSERT(
312  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
313  static_cast<FwAssertArgType>(portNum)
314  );
315 
316  this->m_PhaserMemberOut_OutputPort[portNum].addCallPort(port);
317  }
318 
319 #endif
320 
321 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
322 
323  // ----------------------------------------------------------------------
324  // Connect serial input ports to special output ports
325  // ----------------------------------------------------------------------
326 
329  FwIndexType portNum,
330  Fw::InputSerializePort* port
331  )
332  {
333  FW_ASSERT(
334  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
335  static_cast<FwAssertArgType>(portNum)
336  );
337 
338  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
339  }
340 
341 #if FW_ENABLE_TEXT_LOGGING == 1
342 
343  void ActivePhaserComponentBase ::
344  set_logTextOut_OutputPort(
345  FwIndexType portNum,
346  Fw::InputSerializePort* port
347  )
348  {
349  FW_ASSERT(
350  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
351  static_cast<FwAssertArgType>(portNum)
352  );
353 
354  this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
355  }
356 
357 #endif
358 
361  FwIndexType portNum,
362  Fw::InputSerializePort* port
363  )
364  {
365  FW_ASSERT(
366  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
367  static_cast<FwAssertArgType>(portNum)
368  );
369 
370  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
371  }
372 
375  FwIndexType portNum,
376  Fw::InputSerializePort* port
377  )
378  {
379  FW_ASSERT(
380  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
381  static_cast<FwAssertArgType>(portNum)
382  );
383 
384  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
385  }
386 
387 #endif
388 
389 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
390 
391  // ----------------------------------------------------------------------
392  // Connect serial input ports to typed output ports
393  // ----------------------------------------------------------------------
394 
397  FwIndexType portNum,
398  Fw::InputSerializePort* port
399  )
400  {
401  FW_ASSERT(
402  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
403  static_cast<FwAssertArgType>(portNum)
404  );
405 
406  this->m_PhaserMemberOut_OutputPort[portNum].registerSerialPort(port);
407  }
408 
409 #endif
410 
411  // ----------------------------------------------------------------------
412  // Component construction and destruction
413  // ----------------------------------------------------------------------
414 
416  ActivePhaserComponentBase(const char* compName) :
417  Fw::ActiveComponentBase(compName)
418  {
419  this->m_MissedDeadlineThrottle = 0;
420  }
421 
424  {
425 
426  }
427 
428 #if !FW_DIRECT_PORT_CALLS
429 
430  // ----------------------------------------------------------------------
431  // Connection status queries for special output ports
432  // ----------------------------------------------------------------------
433 
436  {
437  FW_ASSERT(
438  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
439  static_cast<FwAssertArgType>(portNum)
440  );
441 
442  return this->m_logOut_OutputPort[portNum].isConnected();
443  }
444 
445 #if FW_ENABLE_TEXT_LOGGING == 1
446 
447  bool ActivePhaserComponentBase ::
448  isConnected_logTextOut_OutputPort(FwIndexType portNum) const
449  {
450  FW_ASSERT(
451  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
452  static_cast<FwAssertArgType>(portNum)
453  );
454 
455  return this->m_logTextOut_OutputPort[portNum].isConnected();
456  }
457 
458 #endif
459 
462  {
463  FW_ASSERT(
464  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
465  static_cast<FwAssertArgType>(portNum)
466  );
467 
468  return this->m_timeCaller_OutputPort[portNum].isConnected();
469  }
470 
473  {
474  FW_ASSERT(
475  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
476  static_cast<FwAssertArgType>(portNum)
477  );
478 
479  return this->m_tlmOut_OutputPort[portNum].isConnected();
480  }
481 
482 #endif
483 
484 #if !FW_DIRECT_PORT_CALLS
485 
486  // ----------------------------------------------------------------------
487  // Connection status queries for typed output ports
488  // ----------------------------------------------------------------------
489 
492  {
493  FW_ASSERT(
494  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
495  static_cast<FwAssertArgType>(portNum)
496  );
497 
498  return this->m_PhaserMemberOut_OutputPort[portNum].isConnected();
499  }
500 
501 #endif
502 
503  // ----------------------------------------------------------------------
504  // Port handler base-class functions for typed input ports
505  //
506  // Call these functions directly to bypass the corresponding ports
507  // ----------------------------------------------------------------------
508 
511  FwIndexType portNum,
512  Os::RawTime& cycleStart
513  )
514  {
515  // Make sure port number is valid
516  FW_ASSERT(
517  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
518  static_cast<FwAssertArgType>(portNum)
519  );
520 
521  // Call pre-message hook
523  portNum,
524  cycleStart
525  );
526  ComponentIpcSerializableBuffer msg;
528 
529  // Serialize message ID
530  _status = msg.serializeFrom(
531  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
532  );
533  FW_ASSERT(
534  _status == Fw::FW_SERIALIZE_OK,
535  static_cast<FwAssertArgType>(_status)
536  );
537 
538  // Serialize port number
539  _status = msg.serializeFrom(portNum);
540  FW_ASSERT(
541  _status == Fw::FW_SERIALIZE_OK,
542  static_cast<FwAssertArgType>(_status)
543  );
544 
545  // Serialize argument cycleStart
546  _status = msg.serializeFrom(cycleStart);
547  FW_ASSERT(
548  _status == Fw::FW_SERIALIZE_OK,
549  static_cast<FwAssertArgType>(_status)
550  );
551 
552  // Send message
554  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
555 
556  if (qStatus == Os::Queue::Status::FULL) {
557  this->incNumMsgDropped();
558  return;
559  }
560 
561  FW_ASSERT(
562  qStatus == Os::Queue::OP_OK,
563  static_cast<FwAssertArgType>(qStatus)
564  );
565  }
566 
567  // ----------------------------------------------------------------------
568  // Pre-message hooks for typed async input ports
569  //
570  // Each of these functions is invoked just before processing a message
571  // on the corresponding port. By default, they do nothing. You can
572  // override them to provide specific pre-message behavior.
573  // ----------------------------------------------------------------------
574 
577  FwIndexType portNum,
578  Os::RawTime& cycleStart
579  )
580  {
581  // Default: no-op
582  }
583 
584 #if !FW_DIRECT_PORT_CALLS
585 
586  // ----------------------------------------------------------------------
587  // Invocation functions for typed output ports
588  // ----------------------------------------------------------------------
589 
592  FwIndexType portNum,
593  U32 context
594  ) const
595  {
596  FW_ASSERT(
597  (0 <= portNum) && (portNum < this->getNum_PhaserMemberOut_OutputPorts()),
598  static_cast<FwAssertArgType>(portNum)
599  );
600 
601  FW_ASSERT(
602  this->m_PhaserMemberOut_OutputPort[portNum].isConnected(),
603  static_cast<FwAssertArgType>(portNum)
604  );
605  this->m_PhaserMemberOut_OutputPort[portNum].invoke(
606  context
607  );
608  }
609 
610 #endif
611 
612  // ----------------------------------------------------------------------
613  // Internal interface base-class functions
614  // ----------------------------------------------------------------------
615 
618  {
619  ComponentIpcSerializableBuffer msg;
621 
622  // Serialize the message ID
623  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(INT_IF_TICK));
624  FW_ASSERT (
625  _status == Fw::FW_SERIALIZE_OK,
626  static_cast<FwAssertArgType>(_status)
627  );
628 
629  // Fake port number to make message dequeue work
630  _status = msg.serializeFrom(static_cast<FwIndexType>(0));
631  FW_ASSERT (
632  _status == Fw::FW_SERIALIZE_OK,
633  static_cast<FwAssertArgType>(_status)
634  );
635 
636  // Send message
638  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
639 
640  if (qStatus == Os::Queue::Status::FULL) {
641  this->incNumMsgDropped();
642  return;
643  }
644 
645  FW_ASSERT(
646  qStatus == Os::Queue::OP_OK,
647  static_cast<FwAssertArgType>(qStatus)
648  );
649  }
650 
651  // ----------------------------------------------------------------------
652  // Event logging functions
653  // ----------------------------------------------------------------------
654 
657  FwIndexType p,
658  U32 start,
659  U32 length,
660  U32 ticks
661  )
662  {
663  // Check throttle value
664  if (this->m_MissedDeadlineThrottle >= EVENTID_MISSEDDEADLINE_THROTTLE) {
665  return;
666  }
667  else {
668  this->m_MissedDeadlineThrottle++;
669  }
670 
671  // Get the time
672  Fw::Time _logTime;
673  if (this->isConnected_timeCaller_OutputPort(0)) {
674  this->timeCaller_out(0, _logTime);
675  }
676 
677  const FwEventIdType _id = this->getIdBase() + EVENTID_MISSEDDEADLINE;
678 
679  // Emit the event on the log port
680  if (this->isConnected_logOut_OutputPort(0)) {
681  Fw::LogBuffer _logBuff;
683 
684 #if FW_AMPCS_COMPATIBLE
685  // Serialize the number of arguments
686  _status = _logBuff.serializeFrom(static_cast<U8>(4));
687  FW_ASSERT(
688  _status == Fw::FW_SERIALIZE_OK,
689  static_cast<FwAssertArgType>(_status)
690  );
691 #endif
692 
693 #if FW_AMPCS_COMPATIBLE
694  // Serialize the argument size
695  _status = _logBuff.serializeFrom(
696  static_cast<U8>(sizeof(FwIndexType))
697  );
698  FW_ASSERT(
699  _status == Fw::FW_SERIALIZE_OK,
700  static_cast<FwAssertArgType>(_status)
701  );
702 #endif
703  _status = _logBuff.serializeFrom(p);
704  FW_ASSERT(
705  _status == Fw::FW_SERIALIZE_OK,
706  static_cast<FwAssertArgType>(_status)
707  );
708 
709 #if FW_AMPCS_COMPATIBLE
710  // Serialize the argument size
711  _status = _logBuff.serializeFrom(
712  static_cast<U8>(sizeof(U32))
713  );
714  FW_ASSERT(
715  _status == Fw::FW_SERIALIZE_OK,
716  static_cast<FwAssertArgType>(_status)
717  );
718 #endif
719  _status = _logBuff.serializeFrom(start);
720  FW_ASSERT(
721  _status == Fw::FW_SERIALIZE_OK,
722  static_cast<FwAssertArgType>(_status)
723  );
724 
725 #if FW_AMPCS_COMPATIBLE
726  // Serialize the argument size
727  _status = _logBuff.serializeFrom(
728  static_cast<U8>(sizeof(U32))
729  );
730  FW_ASSERT(
731  _status == Fw::FW_SERIALIZE_OK,
732  static_cast<FwAssertArgType>(_status)
733  );
734 #endif
735  _status = _logBuff.serializeFrom(length);
736  FW_ASSERT(
737  _status == Fw::FW_SERIALIZE_OK,
738  static_cast<FwAssertArgType>(_status)
739  );
740 
741 #if FW_AMPCS_COMPATIBLE
742  // Serialize the argument size
743  _status = _logBuff.serializeFrom(
744  static_cast<U8>(sizeof(U32))
745  );
746  FW_ASSERT(
747  _status == Fw::FW_SERIALIZE_OK,
748  static_cast<FwAssertArgType>(_status)
749  );
750 #endif
751  _status = _logBuff.serializeFrom(ticks);
752  FW_ASSERT(
753  _status == Fw::FW_SERIALIZE_OK,
754  static_cast<FwAssertArgType>(_status)
755  );
756 
757  this->logOut_out(
758  0,
759  _id,
760  _logTime,
762  _logBuff
763  );
764  }
765 
766  // Emit the event on the text log port
767 #if FW_ENABLE_TEXT_LOGGING
768  if (this->isConnected_logTextOut_OutputPort(0)) {
769 #if FW_OBJECT_NAMES == 1
770  const char* _formatString =
771  "(%s) %s: Port %" PRIi16 " schedule at %" PRIu32 " for %" PRIu32 " ticks was long by %" PRIu32 " ticks";
772 #else
773  const char* _formatString =
774  "%s: Port %" PRIi16 " schedule at %" PRIu32 " for %" PRIu32 " ticks was long by %" PRIu32 " ticks";
775 #endif
776 
777  Fw::TextLogString _logString;
778  (void) _logString.format(
779  _formatString,
780 #if FW_OBJECT_NAMES == 1
781  this->m_objName.toChar(),
782 #endif
783  "MissedDeadline ",
784  p,
785  start,
786  length,
787  ticks
788  );
789 
790  this->logTextOut_out(
791  0,
792  _id,
793  _logTime,
795  _logString
796  );
797  }
798 #endif
799  }
800 
801  // ----------------------------------------------------------------------
802  // Event throttle reset functions
803  // ----------------------------------------------------------------------
804 
807  {
808  // Reset throttle counter
809  this->m_MissedDeadlineThrottle = 0;
810  }
811 
812  // ----------------------------------------------------------------------
813  // Time
814  // ----------------------------------------------------------------------
815 
817  getTime() const
818  {
819  if (this->isConnected_timeCaller_OutputPort(0)) {
820  Fw::Time _time;
821  this->timeCaller_out(0, _time);
822  return _time;
823  }
824  else {
825  return Fw::Time(TimeBase::TB_NONE, 0, 0);
826  }
827  }
828 
829  // ----------------------------------------------------------------------
830  // Message dispatch functions
831  // ----------------------------------------------------------------------
832 
833  Fw::QueuedComponentBase::MsgDispatchStatus ActivePhaserComponentBase ::
834  doDispatch()
835  {
836  ComponentIpcSerializableBuffer _msg;
837  FwQueuePriorityType _priority = 0;
838 
839  Os::Queue::Status _msgStatus = this->m_queue.receive(
840  _msg,
842  _priority
843  );
844  FW_ASSERT(
845  _msgStatus == Os::Queue::OP_OK,
846  static_cast<FwAssertArgType>(_msgStatus)
847  );
848 
849  // Reset to beginning of buffer
850  _msg.resetDeser();
851 
852  FwEnumStoreType _desMsg = 0;
853  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
854  FW_ASSERT(
855  _deserStatus == Fw::FW_SERIALIZE_OK,
856  static_cast<FwAssertArgType>(_deserStatus)
857  );
858 
859  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
860 
861  if (_msgType == ACTIVEPHASER_COMPONENT_EXIT) {
862  return MSG_DISPATCH_EXIT;
863  }
864 
865  FwIndexType portNum = 0;
866  _deserStatus = _msg.deserializeTo(portNum);
867  FW_ASSERT(
868  _deserStatus == Fw::FW_SERIALIZE_OK,
869  static_cast<FwAssertArgType>(_deserStatus)
870  );
871 
872  switch (_msgType) {
873  // Handle async input port CycleIn
874  case CYCLEIN_CYCLE: {
875  // Deserialize argument cycleStart
876  Os::RawTime cycleStart;
877  _deserStatus = _msg.deserializeTo(cycleStart);
878  FW_ASSERT(
879  _deserStatus == Fw::FW_SERIALIZE_OK,
880  static_cast<FwAssertArgType>(_deserStatus)
881  );
882  // Call handler function
883  this->CycleIn_handler(
884  portNum,
885  cycleStart
886  );
887 
888  break;
889  }
890 
891  // Handle internal interface Tick
892  case INT_IF_TICK: {
893  // Make sure there was no data left over.
894  // That means the buffer size was incorrect.
895  FW_ASSERT(
896  _msg.getDeserializeSizeLeft() == 0,
897  static_cast<FwAssertArgType>(_msg.getDeserializeSizeLeft())
898  );
899 
900  // Call handler function
902 
903  break;
904  }
905 
906  default:
907  return MSG_DISPATCH_ERROR;
908  }
909 
910  return MSG_DISPATCH_OK;
911  }
912 
913  // ----------------------------------------------------------------------
914  // Calls for messages received on typed input ports
915  // ----------------------------------------------------------------------
916 
917  void ActivePhaserComponentBase ::
918  m_p_CycleIn_in(
919  Fw::PassiveComponentBase* callComp,
920  FwIndexType portNum,
921  Os::RawTime& cycleStart
922  )
923  {
924  FW_ASSERT(callComp != nullptr);
925  ActivePhaserComponentBase* compPtr = static_cast<ActivePhaserComponentBase*>(callComp);
926  compPtr->CycleIn_handlerBase(
927  portNum,
928  cycleStart
929  );
930  }
931 
932 #if !FW_DIRECT_PORT_CALLS
933 
934  // ----------------------------------------------------------------------
935  // Invocation functions for special output ports
936  // ----------------------------------------------------------------------
937 
938  void ActivePhaserComponentBase ::
939  logOut_out(
940  FwIndexType portNum,
941  FwEventIdType id,
942  Fw::Time& timeTag,
943  const Fw::LogSeverity& severity,
944  Fw::LogBuffer& args
945  ) const
946  {
947  FW_ASSERT(
948  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
949  static_cast<FwAssertArgType>(portNum)
950  );
951 
952  FW_ASSERT(
953  this->m_logOut_OutputPort[portNum].isConnected(),
954  static_cast<FwAssertArgType>(portNum)
955  );
956  this->m_logOut_OutputPort[portNum].invoke(
957  id,
958  timeTag,
959  severity,
960  args
961  );
962  }
963 
964 #if FW_ENABLE_TEXT_LOGGING
965 
966  void ActivePhaserComponentBase ::
967  logTextOut_out(
968  FwIndexType portNum,
969  FwEventIdType id,
970  Fw::Time& timeTag,
971  const Fw::LogSeverity& severity,
972  Fw::TextLogString& text
973  ) const
974  {
975  FW_ASSERT(
976  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
977  static_cast<FwAssertArgType>(portNum)
978  );
979 
980  FW_ASSERT(
981  this->m_logTextOut_OutputPort[portNum].isConnected(),
982  static_cast<FwAssertArgType>(portNum)
983  );
984  this->m_logTextOut_OutputPort[portNum].invoke(
985  id,
986  timeTag,
987  severity,
988  text
989  );
990  }
991 
992 #endif
993 
994  void ActivePhaserComponentBase ::
995  timeCaller_out(
996  FwIndexType portNum,
997  Fw::Time& time
998  ) const
999  {
1000  FW_ASSERT(
1001  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1002  static_cast<FwAssertArgType>(portNum)
1003  );
1004 
1005  FW_ASSERT(
1006  this->m_timeCaller_OutputPort[portNum].isConnected(),
1007  static_cast<FwAssertArgType>(portNum)
1008  );
1009  this->m_timeCaller_OutputPort[portNum].invoke(
1010  time
1011  );
1012  }
1013 
1014 #endif
1015 
1016 }
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
Operation succeeded.
Definition: Os.hpp:27
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
message to exit active component task
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)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
Os::Queue m_queue
queue object for active component
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()
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:58
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:54
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:57
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
Warning event that rate group has had a missed deadline.
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)