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