F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
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  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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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.serializeFrom(
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.serializeFrom(portNum);
682  FW_ASSERT(
683  _status == Fw::FW_SERIALIZE_OK,
684  static_cast<FwAssertArgType>(_status)
685  );
686 
687  // Serialize argument cycleStart
688  _status = msg.serializeFrom(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  (0 <= portNum) && (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.serializeFrom(
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.serializeFrom(portNum);
740  FW_ASSERT(
741  _status == Fw::FW_SERIALIZE_OK,
742  static_cast<FwAssertArgType>(_status)
743  );
744 
745  // Serialize argument key
746  _status = msg.serializeFrom(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  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
800  static_cast<FwAssertArgType>(portNum)
801  );
802 
803  FW_ASSERT(
804  this->m_PingOut_OutputPort[portNum].isConnected(),
805  static_cast<FwAssertArgType>(portNum)
806  );
807  this->m_PingOut_OutputPort[portNum].invoke(
808  key
809  );
810  }
811 
814  FwIndexType portNum,
815  U32 context
816  )
817  {
818  FW_ASSERT(
819  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
820  static_cast<FwAssertArgType>(portNum)
821  );
822 
823  FW_ASSERT(
824  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
825  static_cast<FwAssertArgType>(portNum)
826  );
827  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
828  context
829  );
830  }
831 
832  // ----------------------------------------------------------------------
833  // Event logging functions
834  // ----------------------------------------------------------------------
835 
838  {
839  // Get the time
840  Fw::Time _logTime;
841  if (this->m_Time_OutputPort[0].isConnected()) {
842  this->m_Time_OutputPort[0].invoke(_logTime);
843  }
844 
845  FwEventIdType _id = static_cast<FwEventIdType>(0);
846 
847  _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
848 
849  // Emit the event on the log port
850  if (this->m_Log_OutputPort[0].isConnected()) {
851  Fw::LogBuffer _logBuff;
852 
853 #if FW_AMPCS_COMPATIBLE
855  // Serialize the number of arguments
856  _status = _logBuff.serializeFrom(static_cast<U8>(0));
857  FW_ASSERT(
858  _status == Fw::FW_SERIALIZE_OK,
859  static_cast<FwAssertArgType>(_status)
860  );
861 #endif
862 
863  this->m_Log_OutputPort[0].invoke(
864  _id,
865  _logTime,
867  _logBuff
868  );
869  }
870 
871  // Emit the event on the text log port
872 #if FW_ENABLE_TEXT_LOGGING
873  if (this->m_LogText_OutputPort[0].isConnected()) {
874 #if FW_OBJECT_NAMES == 1
875  const char* _formatString =
876  "(%s) %s: Rate group started.";
877 #else
878  const char* _formatString =
879  "%s: Rate group started.";
880 #endif
881 
882  Fw::TextLogString _logString;
883  _logString.format(
884  _formatString,
885 #if FW_OBJECT_NAMES == 1
886  this->m_objName.toChar(),
887 #endif
888  "RateGroupStarted "
889  );
890 
891  this->m_LogText_OutputPort[0].invoke(
892  _id,
893  _logTime,
895  _logString
896  );
897  }
898 #endif
899  }
900 
903  {
904  // Get the time
905  Fw::Time _logTime;
906  if (this->m_Time_OutputPort[0].isConnected()) {
907  this->m_Time_OutputPort[0].invoke(_logTime);
908  }
909 
910  FwEventIdType _id = static_cast<FwEventIdType>(0);
911 
912  _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
913 
914  // Emit the event on the log port
915  if (this->m_Log_OutputPort[0].isConnected()) {
916  Fw::LogBuffer _logBuff;
918 
919 #if FW_AMPCS_COMPATIBLE
920  // Serialize the number of arguments
921  _status = _logBuff.serializeFrom(static_cast<U8>(1));
922  FW_ASSERT(
923  _status == Fw::FW_SERIALIZE_OK,
924  static_cast<FwAssertArgType>(_status)
925  );
926 #endif
927 
928 #if FW_AMPCS_COMPATIBLE
929  // Serialize the argument size
930  _status = _logBuff.serializeFrom(
931  static_cast<U8>(sizeof(U32))
932  );
933  FW_ASSERT(
934  _status == Fw::FW_SERIALIZE_OK,
935  static_cast<FwAssertArgType>(_status)
936  );
937 #endif
938  _status = _logBuff.serializeFrom(cycle);
939  FW_ASSERT(
940  _status == Fw::FW_SERIALIZE_OK,
941  static_cast<FwAssertArgType>(_status)
942  );
943 
944  this->m_Log_OutputPort[0].invoke(
945  _id,
946  _logTime,
948  _logBuff
949  );
950  }
951 
952  // Emit the event on the text log port
953 #if FW_ENABLE_TEXT_LOGGING
954  if (this->m_LogText_OutputPort[0].isConnected()) {
955 #if FW_OBJECT_NAMES == 1
956  const char* _formatString =
957  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
958 #else
959  const char* _formatString =
960  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
961 #endif
962 
963  Fw::TextLogString _logString;
964  _logString.format(
965  _formatString,
966 #if FW_OBJECT_NAMES == 1
967  this->m_objName.toChar(),
968 #endif
969  "RateGroupCycleSlip ",
970  cycle
971  );
972 
973  this->m_LogText_OutputPort[0].invoke(
974  _id,
975  _logTime,
977  _logString
978  );
979  }
980 #endif
981  }
982 
983  // ----------------------------------------------------------------------
984  // Telemetry write functions
985  // ----------------------------------------------------------------------
986 
989  U32 arg,
990  Fw::Time _tlmTime
991  )
992  {
993  // Check to see if it is the first time
994  if (not this->m_first_update_RgMaxTime) {
995  // Check to see if value has changed. If not, don't write it.
996  if (arg == this->m_last_RgMaxTime) {
997  return;
998  }
999  else {
1000  this->m_last_RgMaxTime = arg;
1001  }
1002  }
1003  else {
1004  this->m_first_update_RgMaxTime = false;
1005  this->m_last_RgMaxTime = arg;
1006  }
1007 
1008  if (this->m_Tlm_OutputPort[0].isConnected()) {
1009  if (
1010  this->m_Time_OutputPort[0].isConnected() &&
1011  (_tlmTime == Fw::ZERO_TIME)
1012  ) {
1013  this->m_Time_OutputPort[0].invoke(_tlmTime);
1014  }
1015 
1016  Fw::TlmBuffer _tlmBuff;
1017  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1018  FW_ASSERT(
1019  _stat == Fw::FW_SERIALIZE_OK,
1020  static_cast<FwAssertArgType>(_stat)
1021  );
1022 
1023  FwChanIdType _id;
1024 
1025  _id = this->getIdBase() + CHANNELID_RGMAXTIME;
1026 
1027  this->m_Tlm_OutputPort[0].invoke(
1028  _id,
1029  _tlmTime,
1030  _tlmBuff
1031  );
1032  }
1033  }
1034 
1037  U32 arg,
1038  Fw::Time _tlmTime
1039  )
1040  {
1041  // Check to see if it is the first time
1042  if (not this->m_first_update_RgCycleSlips) {
1043  // Check to see if value has changed. If not, don't write it.
1044  if (arg == this->m_last_RgCycleSlips) {
1045  return;
1046  }
1047  else {
1048  this->m_last_RgCycleSlips = arg;
1049  }
1050  }
1051  else {
1052  this->m_first_update_RgCycleSlips = false;
1053  this->m_last_RgCycleSlips = arg;
1054  }
1055 
1056  if (this->m_Tlm_OutputPort[0].isConnected()) {
1057  if (
1058  this->m_Time_OutputPort[0].isConnected() &&
1059  (_tlmTime == Fw::ZERO_TIME)
1060  ) {
1061  this->m_Time_OutputPort[0].invoke(_tlmTime);
1062  }
1063 
1064  Fw::TlmBuffer _tlmBuff;
1065  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1066  FW_ASSERT(
1067  _stat == Fw::FW_SERIALIZE_OK,
1068  static_cast<FwAssertArgType>(_stat)
1069  );
1070 
1071  FwChanIdType _id;
1072 
1073  _id = this->getIdBase() + CHANNELID_RGCYCLESLIPS;
1074 
1075  this->m_Tlm_OutputPort[0].invoke(
1076  _id,
1077  _tlmTime,
1078  _tlmBuff
1079  );
1080  }
1081  }
1082 
1083  // ----------------------------------------------------------------------
1084  // Time
1085  // ----------------------------------------------------------------------
1086 
1088  getTime() const
1089  {
1090  if (this->m_Time_OutputPort[0].isConnected()) {
1091  Fw::Time _time;
1092  this->m_Time_OutputPort[0].invoke(_time);
1093  return _time;
1094  }
1095  else {
1096  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1097  }
1098  }
1099 
1100  // ----------------------------------------------------------------------
1101  // Message dispatch functions
1102  // ----------------------------------------------------------------------
1103 
1104  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1105  doDispatch()
1106  {
1107  ComponentIpcSerializableBuffer _msg;
1108  FwQueuePriorityType _priority = 0;
1109 
1110  Os::Queue::Status _msgStatus = this->m_queue.receive(
1111  _msg,
1113  _priority
1114  );
1115  FW_ASSERT(
1116  _msgStatus == Os::Queue::OP_OK,
1117  static_cast<FwAssertArgType>(_msgStatus)
1118  );
1119 
1120  // Reset to beginning of buffer
1121  _msg.resetDeser();
1122 
1123  FwEnumStoreType _desMsg = 0;
1124  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1125  FW_ASSERT(
1126  _deserStatus == Fw::FW_SERIALIZE_OK,
1127  static_cast<FwAssertArgType>(_deserStatus)
1128  );
1129 
1130  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1131 
1132  if (_msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1133  return MSG_DISPATCH_EXIT;
1134  }
1135 
1136  FwIndexType portNum = 0;
1137  _deserStatus = _msg.deserializeTo(portNum);
1138  FW_ASSERT(
1139  _deserStatus == Fw::FW_SERIALIZE_OK,
1140  static_cast<FwAssertArgType>(_deserStatus)
1141  );
1142 
1143  switch (_msgType) {
1144  // Handle async input port CycleIn
1145  case CYCLEIN_CYCLE: {
1146  // Deserialize argument cycleStart
1147  Os::RawTime cycleStart;
1148  _deserStatus = _msg.deserializeTo(cycleStart);
1149  FW_ASSERT(
1150  _deserStatus == Fw::FW_SERIALIZE_OK,
1151  static_cast<FwAssertArgType>(_deserStatus)
1152  );
1153  // Call handler function
1154  this->CycleIn_handler(
1155  portNum,
1156  cycleStart
1157  );
1158 
1159  break;
1160  }
1161 
1162  // Handle async input port PingIn
1163  case PINGIN_PING: {
1164  // Deserialize argument key
1165  U32 key;
1166  _deserStatus = _msg.deserializeTo(key);
1167  FW_ASSERT(
1168  _deserStatus == Fw::FW_SERIALIZE_OK,
1169  static_cast<FwAssertArgType>(_deserStatus)
1170  );
1171  // Call handler function
1172  this->PingIn_handler(
1173  portNum,
1174  key
1175  );
1176 
1177  break;
1178  }
1179 
1180  default:
1181  return MSG_DISPATCH_ERROR;
1182  }
1183 
1184  return MSG_DISPATCH_OK;
1185  }
1186 
1187  // ----------------------------------------------------------------------
1188  // Calls for messages received on typed input ports
1189  // ----------------------------------------------------------------------
1190 
1191  void ActiveRateGroupComponentBase ::
1192  m_p_CycleIn_in(
1193  Fw::PassiveComponentBase* callComp,
1194  FwIndexType portNum,
1195  Os::RawTime& cycleStart
1196  )
1197  {
1198  FW_ASSERT(callComp);
1199  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1200  compPtr->CycleIn_handlerBase(
1201  portNum,
1202  cycleStart
1203  );
1204  }
1205 
1206  void ActiveRateGroupComponentBase ::
1207  m_p_PingIn_in(
1208  Fw::PassiveComponentBase* callComp,
1209  FwIndexType portNum,
1210  U32 key
1211  )
1212  {
1213  FW_ASSERT(callComp);
1214  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1215  compPtr->PingIn_handlerBase(
1216  portNum,
1217  key
1218  );
1219  }
1220 
1221 }
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
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
Operation succeeded.
Definition: Os.hpp:26
PlatformSizeType FwSizeType
void CycleIn_handlerBase(FwIndexType portNum, Os::RawTime &cycleStart)
Handler base-class function for input port CycleIn.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:63
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
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
message to exit active component task
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
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.
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
No time base has been established (Required)
bool isConnected_Time_OutputPort(FwIndexType portNum)
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:24
The size of the serial representations of the port arguments.
Definition: CyclePortAc.hpp:37
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: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:41
void init()
Initialization function.
Definition: TimePortAc.cpp:128
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
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Definition: ObjectName.hpp:50
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
Warning event that rate group has had a cycle slip.
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
Definition: Queue.cpp:46
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:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
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 interface.
Definition: LogPortAc.cpp:170
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
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.
PlatformIndexType FwIndexType
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:90
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)
RateGroupDivider component implementation.
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:56
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
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:48
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_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputSchedPort *callPort)
Register an input port.