F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ActiveRateGroupComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ActiveRateGroupComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ActiveRateGroup component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  ACTIVERATEGROUP_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  CYCLEIN_CYCLE,
20  PINGIN_PING,
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 {
28  };
29 
30  // Define a message buffer class large enough to handle all the
31  // asynchronous inputs to the component
32  class ComponentIpcSerializableBuffer :
34  {
35 
36  public:
37 
38  enum {
39  // Max. message size = size of data + message id + port
40  SERIALIZATION_SIZE =
41  sizeof(BuffUnion) +
42  sizeof(FwEnumStoreType) +
43  sizeof(FwIndexType)
44  };
45 
46  Fw::Serializable::SizeType getBuffCapacity() 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 
70  init(
71  FwQueueSizeType queueDepth,
72  FwEnumStoreType instance
73  )
74  {
75  // Initialize base class
77 
78  // Connect input port CycleIn
79  for (
80  FwIndexType port = 0;
81  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
82  port++
83  ) {
84  this->m_CycleIn_InputPort[port].init();
85  this->m_CycleIn_InputPort[port].addCallComp(
86  this,
87  m_p_CycleIn_in
88  );
89  this->m_CycleIn_InputPort[port].setPortNum(port);
90 
91 #if FW_OBJECT_NAMES == 1
92  Fw::ObjectName portName;
93  portName.format(
94  "%s_CycleIn_InputPort[%" PRI_PlatformIntType "]",
95  this->m_objName.toChar(),
96  port
97  );
98  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
99 #endif
100  }
101 
102  // Connect input port PingIn
103  for (
104  FwIndexType port = 0;
105  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
106  port++
107  ) {
108  this->m_PingIn_InputPort[port].init();
109  this->m_PingIn_InputPort[port].addCallComp(
110  this,
111  m_p_PingIn_in
112  );
113  this->m_PingIn_InputPort[port].setPortNum(port);
114 
115 #if FW_OBJECT_NAMES == 1
116  Fw::ObjectName portName;
117  portName.format(
118  "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
119  this->m_objName.toChar(),
120  port
121  );
122  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
123 #endif
124  }
125 
126  // Connect output port Log
127  for (
128  FwIndexType port = 0;
129  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
130  port++
131  ) {
132  this->m_Log_OutputPort[port].init();
133 
134 #if FW_OBJECT_NAMES == 1
135  Fw::ObjectName portName;
136  portName.format(
137  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
138  this->m_objName.toChar(),
139  port
140  );
141  this->m_Log_OutputPort[port].setObjName(portName.toChar());
142 #endif
143  }
144 
145 #if FW_ENABLE_TEXT_LOGGING == 1
146  // Connect output port LogText
147  for (
148  FwIndexType port = 0;
149  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
150  port++
151  ) {
152  this->m_LogText_OutputPort[port].init();
153 
154 #if FW_OBJECT_NAMES == 1
155  Fw::ObjectName portName;
156  portName.format(
157  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
158  this->m_objName.toChar(),
159  port
160  );
161  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
162 #endif
163  }
164 #endif
165 
166  // Connect output port Time
167  for (
168  FwIndexType port = 0;
169  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
170  port++
171  ) {
172  this->m_Time_OutputPort[port].init();
173 
174 #if FW_OBJECT_NAMES == 1
175  Fw::ObjectName portName;
176  portName.format(
177  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
178  this->m_objName.toChar(),
179  port
180  );
181  this->m_Time_OutputPort[port].setObjName(portName.toChar());
182 #endif
183  }
184 
185  // Connect output port Tlm
186  for (
187  FwIndexType port = 0;
188  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
189  port++
190  ) {
191  this->m_Tlm_OutputPort[port].init();
192 
193 #if FW_OBJECT_NAMES == 1
194  Fw::ObjectName portName;
195  portName.format(
196  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
197  this->m_objName.toChar(),
198  port
199  );
200  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
201 #endif
202  }
203 
204  // Connect output port PingOut
205  for (
206  FwIndexType port = 0;
207  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
208  port++
209  ) {
210  this->m_PingOut_OutputPort[port].init();
211 
212 #if FW_OBJECT_NAMES == 1
213  Fw::ObjectName portName;
214  portName.format(
215  "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
216  this->m_objName.toChar(),
217  port
218  );
219  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
220 #endif
221  }
222 
223  // Connect output port RateGroupMemberOut
224  for (
225  FwIndexType port = 0;
226  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
227  port++
228  ) {
229  this->m_RateGroupMemberOut_OutputPort[port].init();
230 
231 #if FW_OBJECT_NAMES == 1
232  Fw::ObjectName portName;
233  portName.format(
234  "%s_RateGroupMemberOut_OutputPort[%" PRI_PlatformIntType "]",
235  this->m_objName.toChar(),
236  port
237  );
238  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
239 #endif
240  }
241 
242  Os::Queue::QueueStatus qStat = this->createQueue(
243  queueDepth,
244  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
245  );
246  FW_ASSERT(
247  Os::Queue::QUEUE_OK == qStat,
248  static_cast<FwAssertArgType>(qStat)
249  );
250  }
251 
252  // ----------------------------------------------------------------------
253  // Getters for typed input ports
254  // ----------------------------------------------------------------------
255 
258  {
259  FW_ASSERT(
260  portNum < this->getNum_CycleIn_InputPorts(),
261  static_cast<FwAssertArgType>(portNum)
262  );
263 
264  return &this->m_CycleIn_InputPort[portNum];
265  }
266 
269  {
270  FW_ASSERT(
271  portNum < this->getNum_PingIn_InputPorts(),
272  static_cast<FwAssertArgType>(portNum)
273  );
274 
275  return &this->m_PingIn_InputPort[portNum];
276  }
277 
278  // ----------------------------------------------------------------------
279  // Connect input ports to special output ports
280  // ----------------------------------------------------------------------
281 
284  FwIndexType portNum,
285  Fw::InputLogPort* port
286  )
287  {
288  FW_ASSERT(
289  portNum < this->getNum_Log_OutputPorts(),
290  static_cast<FwAssertArgType>(portNum)
291  );
292 
293  this->m_Log_OutputPort[portNum].addCallPort(port);
294  }
295 
296 #if FW_ENABLE_TEXT_LOGGING == 1
297 
298  void ActiveRateGroupComponentBase ::
299  set_LogText_OutputPort(
300  FwIndexType portNum,
302  )
303  {
304  FW_ASSERT(
305  portNum < this->getNum_LogText_OutputPorts(),
306  static_cast<FwAssertArgType>(portNum)
307  );
308 
309  this->m_LogText_OutputPort[portNum].addCallPort(port);
310  }
311 
312 #endif
313 
316  FwIndexType portNum,
317  Fw::InputTimePort* port
318  )
319  {
320  FW_ASSERT(
321  portNum < this->getNum_Time_OutputPorts(),
322  static_cast<FwAssertArgType>(portNum)
323  );
324 
325  this->m_Time_OutputPort[portNum].addCallPort(port);
326  }
327 
330  FwIndexType portNum,
331  Fw::InputTlmPort* port
332  )
333  {
334  FW_ASSERT(
335  portNum < this->getNum_Tlm_OutputPorts(),
336  static_cast<FwAssertArgType>(portNum)
337  );
338 
339  this->m_Tlm_OutputPort[portNum].addCallPort(port);
340  }
341 
342  // ----------------------------------------------------------------------
343  // Connect typed input ports to typed output ports
344  // ----------------------------------------------------------------------
345 
348  FwIndexType portNum,
349  Svc::InputPingPort* port
350  )
351  {
352  FW_ASSERT(
353  portNum < this->getNum_PingOut_OutputPorts(),
354  static_cast<FwAssertArgType>(portNum)
355  );
356 
357  this->m_PingOut_OutputPort[portNum].addCallPort(port);
358  }
359 
362  FwIndexType portNum,
363  Svc::InputSchedPort* port
364  )
365  {
366  FW_ASSERT(
367  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
368  static_cast<FwAssertArgType>(portNum)
369  );
370 
371  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
372  }
373 
374 #if FW_PORT_SERIALIZATION
375 
376  // ----------------------------------------------------------------------
377  // Connect serial input ports to special output ports
378  // ----------------------------------------------------------------------
379 
382  FwIndexType portNum,
383  Fw::InputSerializePort* port
384  )
385  {
386  FW_ASSERT(
387  portNum < this->getNum_Log_OutputPorts(),
388  static_cast<FwAssertArgType>(portNum)
389  );
390 
391  this->m_Log_OutputPort[portNum].registerSerialPort(port);
392  }
393 
394 #if FW_ENABLE_TEXT_LOGGING == 1
395 
396  void ActiveRateGroupComponentBase ::
397  set_LogText_OutputPort(
398  FwIndexType portNum,
399  Fw::InputSerializePort* port
400  )
401  {
402  FW_ASSERT(
403  portNum < this->getNum_LogText_OutputPorts(),
404  static_cast<FwAssertArgType>(portNum)
405  );
406 
407  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
408  }
409 
410 #endif
411 
414  FwIndexType portNum,
415  Fw::InputSerializePort* port
416  )
417  {
418  FW_ASSERT(
419  portNum < this->getNum_Time_OutputPorts(),
420  static_cast<FwAssertArgType>(portNum)
421  );
422 
423  this->m_Time_OutputPort[portNum].registerSerialPort(port);
424  }
425 
428  FwIndexType portNum,
429  Fw::InputSerializePort* port
430  )
431  {
432  FW_ASSERT(
433  portNum < this->getNum_Tlm_OutputPorts(),
434  static_cast<FwAssertArgType>(portNum)
435  );
436 
437  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
438  }
439 
440 #endif
441 
442 #if FW_PORT_SERIALIZATION
443 
444  // ----------------------------------------------------------------------
445  // Connect serial input ports to typed output ports
446  // ----------------------------------------------------------------------
447 
450  FwIndexType portNum,
451  Fw::InputSerializePort* port
452  )
453  {
454  FW_ASSERT(
455  portNum < this->getNum_PingOut_OutputPorts(),
456  static_cast<FwAssertArgType>(portNum)
457  );
458 
459  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
460  }
461 
464  FwIndexType portNum,
465  Fw::InputSerializePort* port
466  )
467  {
468  FW_ASSERT(
469  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
470  static_cast<FwAssertArgType>(portNum)
471  );
472 
473  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
474  }
475 
476 #endif
477 
478  // ----------------------------------------------------------------------
479  // Component construction and destruction
480  // ----------------------------------------------------------------------
481 
483  ActiveRateGroupComponentBase(const char* compName) :
484  Fw::ActiveComponentBase(compName)
485  {
486  // Write telemetry channel RgMaxTime
487  this->m_first_update_RgMaxTime = true;
488  this->m_last_RgMaxTime = 0;
489 
490  // Write telemetry channel RgCycleSlips
491  this->m_first_update_RgCycleSlips = true;
492  this->m_last_RgCycleSlips = 0;
493  }
494 
497  {
498 
499  }
500 
501  // ----------------------------------------------------------------------
502  // Getters for numbers of typed input ports
503  // ----------------------------------------------------------------------
504 
507  {
508  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
509  }
510 
513  {
514  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
515  }
516 
517  // ----------------------------------------------------------------------
518  // Getters for numbers of special output ports
519  // ----------------------------------------------------------------------
520 
523  {
524  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
525  }
526 
527 #if FW_ENABLE_TEXT_LOGGING == 1
528 
529  FwIndexType ActiveRateGroupComponentBase ::
530  getNum_LogText_OutputPorts() const
531  {
532  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
533  }
534 
535 #endif
536 
539  {
540  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
541  }
542 
545  {
546  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
547  }
548 
549  // ----------------------------------------------------------------------
550  // Getters for numbers of typed output ports
551  // ----------------------------------------------------------------------
552 
555  {
556  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
557  }
558 
561  {
562  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_RateGroupMemberOut_OutputPort));
563  }
564 
565  // ----------------------------------------------------------------------
566  // Connection status queries for special output ports
567  // ----------------------------------------------------------------------
568 
571  {
572  FW_ASSERT(
573  portNum < this->getNum_Log_OutputPorts(),
574  static_cast<FwAssertArgType>(portNum)
575  );
576 
577  return this->m_Log_OutputPort[portNum].isConnected();
578  }
579 
580 #if FW_ENABLE_TEXT_LOGGING == 1
581 
582  bool ActiveRateGroupComponentBase ::
583  isConnected_LogText_OutputPort(FwIndexType portNum)
584  {
585  FW_ASSERT(
586  portNum < this->getNum_LogText_OutputPorts(),
587  static_cast<FwAssertArgType>(portNum)
588  );
589 
590  return this->m_LogText_OutputPort[portNum].isConnected();
591  }
592 
593 #endif
594 
597  {
598  FW_ASSERT(
599  portNum < this->getNum_Time_OutputPorts(),
600  static_cast<FwAssertArgType>(portNum)
601  );
602 
603  return this->m_Time_OutputPort[portNum].isConnected();
604  }
605 
608  {
609  FW_ASSERT(
610  portNum < this->getNum_Tlm_OutputPorts(),
611  static_cast<FwAssertArgType>(portNum)
612  );
613 
614  return this->m_Tlm_OutputPort[portNum].isConnected();
615  }
616 
617  // ----------------------------------------------------------------------
618  // Connection status queries for typed output ports
619  // ----------------------------------------------------------------------
620 
623  {
624  FW_ASSERT(
625  portNum < this->getNum_PingOut_OutputPorts(),
626  static_cast<FwAssertArgType>(portNum)
627  );
628 
629  return this->m_PingOut_OutputPort[portNum].isConnected();
630  }
631 
634  {
635  FW_ASSERT(
636  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
637  static_cast<FwAssertArgType>(portNum)
638  );
639 
640  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
641  }
642 
643  // ----------------------------------------------------------------------
644  // Port handler base-class functions for typed input ports
645  //
646  // Call these functions directly to bypass the corresponding ports
647  // ----------------------------------------------------------------------
648 
651  FwIndexType portNum,
652  Svc::TimerVal& cycleStart
653  )
654  {
655  // Make sure port number is valid
656  FW_ASSERT(
657  portNum < this->getNum_CycleIn_InputPorts(),
658  static_cast<FwAssertArgType>(portNum)
659  );
660 
661  // Call pre-message hook
663  portNum,
664  cycleStart
665  );
666  ComponentIpcSerializableBuffer msg;
668 
669  // Serialize message ID
670  _status = msg.serialize(
671  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
672  );
673  FW_ASSERT(
674  _status == Fw::FW_SERIALIZE_OK,
675  static_cast<FwAssertArgType>(_status)
676  );
677 
678  // Serialize port number
679  _status = msg.serialize(portNum);
680  FW_ASSERT(
681  _status == Fw::FW_SERIALIZE_OK,
682  static_cast<FwAssertArgType>(_status)
683  );
684 
685  // Serialize argument cycleStart
686  _status = msg.serialize(cycleStart);
687  FW_ASSERT(
688  _status == Fw::FW_SERIALIZE_OK,
689  static_cast<FwAssertArgType>(_status)
690  );
691 
692  // Send message
694  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
695 
696  if (qStatus == Os::Queue::QUEUE_FULL) {
697  this->incNumMsgDropped();
698  return;
699  }
700 
701  FW_ASSERT(
702  qStatus == Os::Queue::QUEUE_OK,
703  static_cast<FwAssertArgType>(qStatus)
704  );
705  }
706 
709  FwIndexType portNum,
710  U32 key
711  )
712  {
713  // Make sure port number is valid
714  FW_ASSERT(
715  portNum < this->getNum_PingIn_InputPorts(),
716  static_cast<FwAssertArgType>(portNum)
717  );
718 
719  // Call pre-message hook
721  portNum,
722  key
723  );
724  ComponentIpcSerializableBuffer msg;
726 
727  // Serialize message ID
728  _status = msg.serialize(
729  static_cast<FwEnumStoreType>(PINGIN_PING)
730  );
731  FW_ASSERT(
732  _status == Fw::FW_SERIALIZE_OK,
733  static_cast<FwAssertArgType>(_status)
734  );
735 
736  // Serialize port number
737  _status = msg.serialize(portNum);
738  FW_ASSERT(
739  _status == Fw::FW_SERIALIZE_OK,
740  static_cast<FwAssertArgType>(_status)
741  );
742 
743  // Serialize argument key
744  _status = msg.serialize(key);
745  FW_ASSERT(
746  _status == Fw::FW_SERIALIZE_OK,
747  static_cast<FwAssertArgType>(_status)
748  );
749 
750  // Send message
752  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
753 
754  FW_ASSERT(
755  qStatus == Os::Queue::QUEUE_OK,
756  static_cast<FwAssertArgType>(qStatus)
757  );
758  }
759 
760  // ----------------------------------------------------------------------
761  // Pre-message hooks for typed async input ports
762  //
763  // Each of these functions is invoked just before processing a message
764  // on the corresponding port. By default, they do nothing. You can
765  // override them to provide specific pre-message behavior.
766  // ----------------------------------------------------------------------
767 
770  FwIndexType portNum,
771  Svc::TimerVal& cycleStart
772  )
773  {
774  // Default: no-op
775  }
776 
779  FwIndexType portNum,
780  U32 key
781  )
782  {
783  // Default: no-op
784  }
785 
786  // ----------------------------------------------------------------------
787  // Invocation functions for typed output ports
788  // ----------------------------------------------------------------------
789 
792  FwIndexType portNum,
793  U32 key
794  )
795  {
796  FW_ASSERT(
797  portNum < this->getNum_PingOut_OutputPorts(),
798  static_cast<FwAssertArgType>(portNum)
799  );
800  this->m_PingOut_OutputPort[portNum].invoke(
801  key
802  );
803  }
804 
807  FwIndexType portNum,
808  U32 context
809  )
810  {
811  FW_ASSERT(
812  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
813  static_cast<FwAssertArgType>(portNum)
814  );
815  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
816  context
817  );
818  }
819 
820  // ----------------------------------------------------------------------
821  // Event logging functions
822  // ----------------------------------------------------------------------
823 
826  {
827  // Get the time
828  Fw::Time _logTime;
829  if (this->m_Time_OutputPort[0].isConnected()) {
830  this->m_Time_OutputPort[0].invoke(_logTime);
831  }
832 
833  FwEventIdType _id = static_cast<FwEventIdType>(0);
834 
835  _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
836 
837  // Emit the event on the log port
838  if (this->m_Log_OutputPort[0].isConnected()) {
839  Fw::LogBuffer _logBuff;
840 
841 #if FW_AMPCS_COMPATIBLE
843  // Serialize the number of arguments
844  _status = _logBuff.serialize(static_cast<U8>(0));
845  FW_ASSERT(
846  _status == Fw::FW_SERIALIZE_OK,
847  static_cast<FwAssertArgType>(_status)
848  );
849 #endif
850 
851  this->m_Log_OutputPort[0].invoke(
852  _id,
853  _logTime,
855  _logBuff
856  );
857  }
858 
859  // Emit the event on the text log port
860 #if FW_ENABLE_TEXT_LOGGING
861  if (this->m_LogText_OutputPort[0].isConnected()) {
862 #if FW_OBJECT_NAMES == 1
863  const char* _formatString =
864  "(%s) %s: Rate group started.";
865 #else
866  const char* _formatString =
867  "%s: Rate group started.";
868 #endif
869 
870  Fw::TextLogString _logString;
871  _logString.format(
872  _formatString,
873 #if FW_OBJECT_NAMES == 1
874  this->m_objName.toChar(),
875 #endif
876  "RateGroupStarted "
877  );
878 
879  this->m_LogText_OutputPort[0].invoke(
880  _id,
881  _logTime,
883  _logString
884  );
885  }
886 #endif
887  }
888 
891  {
892  // Get the time
893  Fw::Time _logTime;
894  if (this->m_Time_OutputPort[0].isConnected()) {
895  this->m_Time_OutputPort[0].invoke(_logTime);
896  }
897 
898  FwEventIdType _id = static_cast<FwEventIdType>(0);
899 
900  _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
901 
902  // Emit the event on the log port
903  if (this->m_Log_OutputPort[0].isConnected()) {
904  Fw::LogBuffer _logBuff;
906 
907 #if FW_AMPCS_COMPATIBLE
908  // Serialize the number of arguments
909  _status = _logBuff.serialize(static_cast<U8>(1));
910  FW_ASSERT(
911  _status == Fw::FW_SERIALIZE_OK,
912  static_cast<FwAssertArgType>(_status)
913  );
914 #endif
915 
916 #if FW_AMPCS_COMPATIBLE
917  // Serialize the argument size
918  _status = _logBuff.serialize(
919  static_cast<U8>(sizeof(U32))
920  );
921  FW_ASSERT(
922  _status == Fw::FW_SERIALIZE_OK,
923  static_cast<FwAssertArgType>(_status)
924  );
925 #endif
926  _status = _logBuff.serialize(cycle);
927  FW_ASSERT(
928  _status == Fw::FW_SERIALIZE_OK,
929  static_cast<FwAssertArgType>(_status)
930  );
931 
932  this->m_Log_OutputPort[0].invoke(
933  _id,
934  _logTime,
936  _logBuff
937  );
938  }
939 
940  // Emit the event on the text log port
941 #if FW_ENABLE_TEXT_LOGGING
942  if (this->m_LogText_OutputPort[0].isConnected()) {
943 #if FW_OBJECT_NAMES == 1
944  const char* _formatString =
945  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
946 #else
947  const char* _formatString =
948  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
949 #endif
950 
951  Fw::TextLogString _logString;
952  _logString.format(
953  _formatString,
954 #if FW_OBJECT_NAMES == 1
955  this->m_objName.toChar(),
956 #endif
957  "RateGroupCycleSlip ",
958  cycle
959  );
960 
961  this->m_LogText_OutputPort[0].invoke(
962  _id,
963  _logTime,
965  _logString
966  );
967  }
968 #endif
969  }
970 
971  // ----------------------------------------------------------------------
972  // Telemetry write functions
973  // ----------------------------------------------------------------------
974 
977  U32 arg,
978  Fw::Time _tlmTime
979  )
980  {
981  // Check to see if it is the first time
982  if (not this->m_first_update_RgMaxTime) {
983  // Check to see if value has changed. If not, don't write it.
984  if (arg == this->m_last_RgMaxTime) {
985  return;
986  }
987  else {
988  this->m_last_RgMaxTime = arg;
989  }
990  }
991  else {
992  this->m_first_update_RgMaxTime = false;
993  this->m_last_RgMaxTime = arg;
994  }
995 
996  if (this->m_Tlm_OutputPort[0].isConnected()) {
997  if (
998  this->m_Time_OutputPort[0].isConnected() &&
999  (_tlmTime == Fw::ZERO_TIME)
1000  ) {
1001  this->m_Time_OutputPort[0].invoke(_tlmTime);
1002  }
1003 
1004  Fw::TlmBuffer _tlmBuff;
1005  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1006  FW_ASSERT(
1007  _stat == Fw::FW_SERIALIZE_OK,
1008  static_cast<FwAssertArgType>(_stat)
1009  );
1010 
1011  FwChanIdType _id;
1012 
1013  _id = this->getIdBase() + CHANNELID_RGMAXTIME;
1014 
1015  this->m_Tlm_OutputPort[0].invoke(
1016  _id,
1017  _tlmTime,
1018  _tlmBuff
1019  );
1020  }
1021  }
1022 
1025  U32 arg,
1026  Fw::Time _tlmTime
1027  )
1028  {
1029  // Check to see if it is the first time
1030  if (not this->m_first_update_RgCycleSlips) {
1031  // Check to see if value has changed. If not, don't write it.
1032  if (arg == this->m_last_RgCycleSlips) {
1033  return;
1034  }
1035  else {
1036  this->m_last_RgCycleSlips = arg;
1037  }
1038  }
1039  else {
1040  this->m_first_update_RgCycleSlips = false;
1041  this->m_last_RgCycleSlips = arg;
1042  }
1043 
1044  if (this->m_Tlm_OutputPort[0].isConnected()) {
1045  if (
1046  this->m_Time_OutputPort[0].isConnected() &&
1047  (_tlmTime == Fw::ZERO_TIME)
1048  ) {
1049  this->m_Time_OutputPort[0].invoke(_tlmTime);
1050  }
1051 
1052  Fw::TlmBuffer _tlmBuff;
1053  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1054  FW_ASSERT(
1055  _stat == Fw::FW_SERIALIZE_OK,
1056  static_cast<FwAssertArgType>(_stat)
1057  );
1058 
1059  FwChanIdType _id;
1060 
1061  _id = this->getIdBase() + CHANNELID_RGCYCLESLIPS;
1062 
1063  this->m_Tlm_OutputPort[0].invoke(
1064  _id,
1065  _tlmTime,
1066  _tlmBuff
1067  );
1068  }
1069  }
1070 
1071  // ----------------------------------------------------------------------
1072  // Time
1073  // ----------------------------------------------------------------------
1074 
1076  getTime()
1077  {
1078  if (this->m_Time_OutputPort[0].isConnected()) {
1079  Fw::Time _time;
1080  this->m_Time_OutputPort[0].invoke(_time);
1081  return _time;
1082  }
1083  else {
1084  return Fw::Time(TB_NONE, 0, 0);
1085  }
1086  }
1087 
1088  // ----------------------------------------------------------------------
1089  // Message dispatch functions
1090  // ----------------------------------------------------------------------
1091 
1092  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1093  doDispatch()
1094  {
1095  ComponentIpcSerializableBuffer msg;
1096  FwQueuePriorityType priority = 0;
1097 
1098  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
1099  msg,
1100  priority,
1102  );
1103  FW_ASSERT(
1104  msgStatus == Os::Queue::QUEUE_OK,
1105  static_cast<FwAssertArgType>(msgStatus)
1106  );
1107 
1108  // Reset to beginning of buffer
1109  msg.resetDeser();
1110 
1111  FwEnumStoreType desMsg = 0;
1112  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1113  FW_ASSERT(
1114  deserStatus == Fw::FW_SERIALIZE_OK,
1115  static_cast<FwAssertArgType>(deserStatus)
1116  );
1117 
1118  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1119 
1120  if (msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1121  return MSG_DISPATCH_EXIT;
1122  }
1123 
1124  FwIndexType portNum = 0;
1125  deserStatus = msg.deserialize(portNum);
1126  FW_ASSERT(
1127  deserStatus == Fw::FW_SERIALIZE_OK,
1128  static_cast<FwAssertArgType>(deserStatus)
1129  );
1130 
1131  switch (msgType) {
1132  // Handle async input port CycleIn
1133  case CYCLEIN_CYCLE: {
1134  // Deserialize argument cycleStart
1135  Svc::TimerVal cycleStart;
1136  deserStatus = msg.deserialize(cycleStart);
1137  FW_ASSERT(
1138  deserStatus == Fw::FW_SERIALIZE_OK,
1139  static_cast<FwAssertArgType>(deserStatus)
1140  );
1141  // Call handler function
1142  this->CycleIn_handler(
1143  portNum,
1144  cycleStart
1145  );
1146 
1147  break;
1148  }
1149 
1150  // Handle async input port PingIn
1151  case PINGIN_PING: {
1152  // Deserialize argument key
1153  U32 key;
1154  deserStatus = msg.deserialize(key);
1155  FW_ASSERT(
1156  deserStatus == Fw::FW_SERIALIZE_OK,
1157  static_cast<FwAssertArgType>(deserStatus)
1158  );
1159  // Call handler function
1160  this->PingIn_handler(
1161  portNum,
1162  key
1163  );
1164 
1165  break;
1166  }
1167 
1168  default:
1169  return MSG_DISPATCH_ERROR;
1170  }
1171 
1172  return MSG_DISPATCH_OK;
1173  }
1174 
1175  // ----------------------------------------------------------------------
1176  // Calls for messages received on typed input ports
1177  // ----------------------------------------------------------------------
1178 
1179  void ActiveRateGroupComponentBase ::
1180  m_p_CycleIn_in(
1181  Fw::PassiveComponentBase* callComp,
1182  FwIndexType portNum,
1183  Svc::TimerVal& cycleStart
1184  )
1185  {
1186  FW_ASSERT(callComp);
1187  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1188  compPtr->CycleIn_handlerBase(
1189  portNum,
1190  cycleStart
1191  );
1192  }
1193 
1194  void ActiveRateGroupComponentBase ::
1195  m_p_PingIn_in(
1196  Fw::PassiveComponentBase* callComp,
1197  FwIndexType portNum,
1198  U32 key
1199  )
1200  {
1201  FW_ASSERT(callComp);
1202  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1203  compPtr->PingIn_handlerBase(
1204  portNum,
1205  key
1206  );
1207  }
1208 
1209 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
U8 BYTE
byte type
Definition: BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:57
I32 FwEnumStoreType
Definition: FpConfig.h:51
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:34
U32 FwChanIdType
Definition: FpConfig.h:82
U32 FwEventIdType
Definition: FpConfig.h:86
FwIndexType FwQueueSizeType
Definition: FpConfig.h:117
I32 FwQueuePriorityType
Definition: FpConfig.h:98
PlatformIndexType FwIndexType
Definition: FpConfig.h:20
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:135
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected()
Definition: PortBase.cpp:41
Os::Queue::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
void incNumMsgDropped()
increment the number of messages dropped
@ MSG_DISPATCH_OK
Dispatch was normal.
@ MSG_DISPATCH_EXIT
A message was sent requesting an exit of the loop.
@ MSG_DISPATCH_ERROR
Errors dispatching messages.
NATIVE_UINT_TYPE SizeType
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
Definition: Time.hpp:9
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
@ QUEUE_FULL
queue was full when attempting to send a message
Definition: Queue.hpp:36
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
void tlmWrite_RgMaxTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void set_PingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
bool isConnected_Time_OutputPort(FwIndexType portNum)
@ CHANNELID_RGMAXTIME
Channel ID for RgMaxTime.
@ CHANNELID_RGCYCLESLIPS
Channel ID for RgCycleSlips.
virtual ~ActiveRateGroupComponentBase()
Destroy ActiveRateGroupComponentBase object.
void RateGroupMemberOut_out(FwIndexType portNum, U32 context)
Invoke output port RateGroupMemberOut.
virtual void PingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port PingIn.
bool isConnected_PingOut_OutputPort(FwIndexType portNum)
ActiveRateGroupComponentBase(const char *compName="")
Construct ActiveRateGroupComponentBase object.
bool isConnected_Log_OutputPort(FwIndexType portNum)
void CycleIn_handlerBase(FwIndexType portNum, Svc::TimerVal &cycleStart)
Handler base-class function for input port CycleIn.
virtual void CycleIn_handler(FwIndexType portNum, Svc::TimerVal &cycleStart)=0
Handler for input port CycleIn.
Svc::InputPingPort * get_PingIn_InputPort(FwIndexType portNum)
virtual void PingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port PingIn.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
void set_RateGroupMemberOut_OutputPort(FwIndexType portNum, Svc::InputSchedPort *port)
Connect port to RateGroupMemberOut[portNum].
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
void PingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port PingIn.
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
virtual void CycleIn_preMsgHook(FwIndexType portNum, Svc::TimerVal &cycleStart)
Pre-message hook for async input port CycleIn.
@ EVENTID_RATEGROUPSTARTED
Informational event that rate group has started.
@ EVENTID_RATEGROUPCYCLESLIP
Warning event that rate group has had a cycle slip.
void PingOut_out(FwIndexType portNum, U32 key)
Invoke output port PingOut.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: CyclePortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void init()
Initialization function.
Definition: PingPortAc.cpp:56
void invoke(U32 key)
Invoke a port interface.
Definition: PingPortAc.cpp:147
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
void init()
Initialization function.
void addCallPort(InputSchedPort *callPort)
Register an input port.
void invoke(U32 context)
Invoke a port interface.
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization function.
Definition: TimerVal.cpp:54
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5