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 
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 {
26  BYTE CycleInPortSize[Svc::CyclePortBuffer::CAPACITY];
27  BYTE PingInPortSize[Svc::PingPortBuffer::CAPACITY];
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 getCapacity() 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 #if !FW_DIRECT_PORT_CALLS
80  // Connect input port CycleIn
81  for (
82  FwIndexType port = 0;
83  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
84  port++
85  ) {
86  this->m_CycleIn_InputPort[port].init();
87  this->m_CycleIn_InputPort[port].addCallComp(
88  this,
89  m_p_CycleIn_in
90  );
91  this->m_CycleIn_InputPort[port].setPortNum(port);
92 
93 #if FW_OBJECT_NAMES == 1
94  Fw::ObjectName portName;
95  portName.format(
96  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
97  this->m_objName.toChar(),
98  port
99  );
100  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
101 #endif
102  }
103 #endif
104 
105 #if !FW_DIRECT_PORT_CALLS
106  // Connect input port PingIn
107  for (
108  FwIndexType port = 0;
109  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
110  port++
111  ) {
112  this->m_PingIn_InputPort[port].init();
113  this->m_PingIn_InputPort[port].addCallComp(
114  this,
115  m_p_PingIn_in
116  );
117  this->m_PingIn_InputPort[port].setPortNum(port);
118 
119 #if FW_OBJECT_NAMES == 1
120  Fw::ObjectName portName;
121  portName.format(
122  "%s_PingIn_InputPort[%" PRI_FwIndexType "]",
123  this->m_objName.toChar(),
124  port
125  );
126  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
127 #endif
128  }
129 #endif
130 
131 #if !FW_DIRECT_PORT_CALLS
132  // Connect output port Log
133  for (
134  FwIndexType port = 0;
135  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
136  port++
137  ) {
138  this->m_Log_OutputPort[port].init();
139 
140 #if FW_OBJECT_NAMES == 1
141  Fw::ObjectName portName;
142  portName.format(
143  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
144  this->m_objName.toChar(),
145  port
146  );
147  this->m_Log_OutputPort[port].setObjName(portName.toChar());
148 #endif
149  }
150 #endif
151 
152 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
153  // Connect output port LogText
154  for (
155  FwIndexType port = 0;
156  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
157  port++
158  ) {
159  this->m_LogText_OutputPort[port].init();
160 
161 #if FW_OBJECT_NAMES == 1
162  Fw::ObjectName portName;
163  portName.format(
164  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
165  this->m_objName.toChar(),
166  port
167  );
168  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
169 #endif
170  }
171 #endif
172 
173 #if !FW_DIRECT_PORT_CALLS
174  // Connect output port Time
175  for (
176  FwIndexType port = 0;
177  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
178  port++
179  ) {
180  this->m_Time_OutputPort[port].init();
181 
182 #if FW_OBJECT_NAMES == 1
183  Fw::ObjectName portName;
184  portName.format(
185  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
186  this->m_objName.toChar(),
187  port
188  );
189  this->m_Time_OutputPort[port].setObjName(portName.toChar());
190 #endif
191  }
192 #endif
193 
194 #if !FW_DIRECT_PORT_CALLS
195  // Connect output port Tlm
196  for (
197  FwIndexType port = 0;
198  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
199  port++
200  ) {
201  this->m_Tlm_OutputPort[port].init();
202 
203 #if FW_OBJECT_NAMES == 1
204  Fw::ObjectName portName;
205  portName.format(
206  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
207  this->m_objName.toChar(),
208  port
209  );
210  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
211 #endif
212  }
213 #endif
214 
215 #if !FW_DIRECT_PORT_CALLS
216  // Connect output port PingOut
217  for (
218  FwIndexType port = 0;
219  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
220  port++
221  ) {
222  this->m_PingOut_OutputPort[port].init();
223 
224 #if FW_OBJECT_NAMES == 1
225  Fw::ObjectName portName;
226  portName.format(
227  "%s_PingOut_OutputPort[%" PRI_FwIndexType "]",
228  this->m_objName.toChar(),
229  port
230  );
231  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
232 #endif
233  }
234 #endif
235 
236 #if !FW_DIRECT_PORT_CALLS
237  // Connect output port RateGroupMemberOut
238  for (
239  FwIndexType port = 0;
240  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
241  port++
242  ) {
243  this->m_RateGroupMemberOut_OutputPort[port].init();
244 
245 #if FW_OBJECT_NAMES == 1
246  Fw::ObjectName portName;
247  portName.format(
248  "%s_RateGroupMemberOut_OutputPort[%" PRI_FwIndexType "]",
249  this->m_objName.toChar(),
250  port
251  );
252  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
253 #endif
254  }
255 #endif
256 
257  // Create the queue
258  Os::Queue::Status qStat = this->createQueue(
259  queueDepth,
260  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
261  );
262  FW_ASSERT(
263  Os::Queue::Status::OP_OK == qStat,
264  static_cast<FwAssertArgType>(qStat)
265  );
266  }
267 
268 #if !FW_DIRECT_PORT_CALLS
269 
270  // ----------------------------------------------------------------------
271  // Getters for typed input ports
272  // ----------------------------------------------------------------------
273 
276  {
277  FW_ASSERT(
278  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
279  static_cast<FwAssertArgType>(portNum)
280  );
281 
282  return &this->m_CycleIn_InputPort[portNum];
283  }
284 
287  {
288  FW_ASSERT(
289  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
290  static_cast<FwAssertArgType>(portNum)
291  );
292 
293  return &this->m_PingIn_InputPort[portNum];
294  }
295 
296 #endif
297 
298 #if !FW_DIRECT_PORT_CALLS
299 
300  // ----------------------------------------------------------------------
301  // Connect input ports to special output ports
302  // ----------------------------------------------------------------------
303 
306  FwIndexType portNum,
307  Fw::InputLogPort* port
308  )
309  {
310  FW_ASSERT(
311  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
312  static_cast<FwAssertArgType>(portNum)
313  );
314 
315  this->m_Log_OutputPort[portNum].addCallPort(port);
316  }
317 
318 #if FW_ENABLE_TEXT_LOGGING == 1
319 
320  void ActiveRateGroupComponentBase ::
321  set_LogText_OutputPort(
322  FwIndexType portNum,
324  )
325  {
326  FW_ASSERT(
327  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
328  static_cast<FwAssertArgType>(portNum)
329  );
330 
331  this->m_LogText_OutputPort[portNum].addCallPort(port);
332  }
333 
334 #endif
335 
338  FwIndexType portNum,
339  Fw::InputTimePort* port
340  )
341  {
342  FW_ASSERT(
343  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
344  static_cast<FwAssertArgType>(portNum)
345  );
346 
347  this->m_Time_OutputPort[portNum].addCallPort(port);
348  }
349 
352  FwIndexType portNum,
353  Fw::InputTlmPort* port
354  )
355  {
356  FW_ASSERT(
357  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
358  static_cast<FwAssertArgType>(portNum)
359  );
360 
361  this->m_Tlm_OutputPort[portNum].addCallPort(port);
362  }
363 
364 #endif
365 
366 #if !FW_DIRECT_PORT_CALLS
367 
368  // ----------------------------------------------------------------------
369  // Connect typed input ports to typed output ports
370  // ----------------------------------------------------------------------
371 
374  FwIndexType portNum,
375  Svc::InputPingPort* port
376  )
377  {
378  FW_ASSERT(
379  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
380  static_cast<FwAssertArgType>(portNum)
381  );
382 
383  this->m_PingOut_OutputPort[portNum].addCallPort(port);
384  }
385 
388  FwIndexType portNum,
389  Svc::InputSchedPort* port
390  )
391  {
392  FW_ASSERT(
393  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
394  static_cast<FwAssertArgType>(portNum)
395  );
396 
397  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
398  }
399 
400 #endif
401 
402 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
403 
404  // ----------------------------------------------------------------------
405  // Connect serial input ports to special output ports
406  // ----------------------------------------------------------------------
407 
410  FwIndexType portNum,
411  Fw::InputSerializePort* port
412  )
413  {
414  FW_ASSERT(
415  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
416  static_cast<FwAssertArgType>(portNum)
417  );
418 
419  this->m_Log_OutputPort[portNum].registerSerialPort(port);
420  }
421 
422 #if FW_ENABLE_TEXT_LOGGING == 1
423 
424  void ActiveRateGroupComponentBase ::
425  set_LogText_OutputPort(
426  FwIndexType portNum,
427  Fw::InputSerializePort* port
428  )
429  {
430  FW_ASSERT(
431  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
432  static_cast<FwAssertArgType>(portNum)
433  );
434 
435  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
436  }
437 
438 #endif
439 
442  FwIndexType portNum,
443  Fw::InputSerializePort* port
444  )
445  {
446  FW_ASSERT(
447  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
448  static_cast<FwAssertArgType>(portNum)
449  );
450 
451  this->m_Time_OutputPort[portNum].registerSerialPort(port);
452  }
453 
456  FwIndexType portNum,
457  Fw::InputSerializePort* port
458  )
459  {
460  FW_ASSERT(
461  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
462  static_cast<FwAssertArgType>(portNum)
463  );
464 
465  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
466  }
467 
468 #endif
469 
470 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
471 
472  // ----------------------------------------------------------------------
473  // Connect serial input ports to typed output ports
474  // ----------------------------------------------------------------------
475 
478  FwIndexType portNum,
479  Fw::InputSerializePort* port
480  )
481  {
482  FW_ASSERT(
483  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
484  static_cast<FwAssertArgType>(portNum)
485  );
486 
487  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
488  }
489 
492  FwIndexType portNum,
493  Fw::InputSerializePort* port
494  )
495  {
496  FW_ASSERT(
497  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
498  static_cast<FwAssertArgType>(portNum)
499  );
500 
501  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
502  }
503 
504 #endif
505 
506  // ----------------------------------------------------------------------
507  // Component construction and destruction
508  // ----------------------------------------------------------------------
509 
511  ActiveRateGroupComponentBase(const char* compName) :
512  Fw::ActiveComponentBase(compName)
513  {
514 
515  }
516 
519  {
520 
521  }
522 
523 #if !FW_DIRECT_PORT_CALLS
524 
525  // ----------------------------------------------------------------------
526  // Connection status queries for special output ports
527  // ----------------------------------------------------------------------
528 
531  {
532  FW_ASSERT(
533  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
534  static_cast<FwAssertArgType>(portNum)
535  );
536 
537  return this->m_Log_OutputPort[portNum].isConnected();
538  }
539 
540 #if FW_ENABLE_TEXT_LOGGING == 1
541 
542  bool ActiveRateGroupComponentBase ::
543  isConnected_LogText_OutputPort(FwIndexType portNum) const
544  {
545  FW_ASSERT(
546  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
547  static_cast<FwAssertArgType>(portNum)
548  );
549 
550  return this->m_LogText_OutputPort[portNum].isConnected();
551  }
552 
553 #endif
554 
557  {
558  FW_ASSERT(
559  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
560  static_cast<FwAssertArgType>(portNum)
561  );
562 
563  return this->m_Time_OutputPort[portNum].isConnected();
564  }
565 
568  {
569  FW_ASSERT(
570  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
571  static_cast<FwAssertArgType>(portNum)
572  );
573 
574  return this->m_Tlm_OutputPort[portNum].isConnected();
575  }
576 
577 #endif
578 
579 #if !FW_DIRECT_PORT_CALLS
580 
581  // ----------------------------------------------------------------------
582  // Connection status queries for typed output ports
583  // ----------------------------------------------------------------------
584 
587  {
588  FW_ASSERT(
589  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
590  static_cast<FwAssertArgType>(portNum)
591  );
592 
593  return this->m_PingOut_OutputPort[portNum].isConnected();
594  }
595 
598  {
599  FW_ASSERT(
600  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
601  static_cast<FwAssertArgType>(portNum)
602  );
603 
604  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
605  }
606 
607 #endif
608 
609  // ----------------------------------------------------------------------
610  // Port handler base-class functions for typed input ports
611  //
612  // Call these functions directly to bypass the corresponding ports
613  // ----------------------------------------------------------------------
614 
617  FwIndexType portNum,
618  Os::RawTime& cycleStart
619  )
620  {
621  // Make sure port number is valid
622  FW_ASSERT(
623  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
624  static_cast<FwAssertArgType>(portNum)
625  );
626 
627  // Call pre-message hook
629  portNum,
630  cycleStart
631  );
632  ComponentIpcSerializableBuffer msg;
634 
635  // Serialize message ID
636  _status = msg.serializeFrom(
637  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
638  );
639  FW_ASSERT(
640  _status == Fw::FW_SERIALIZE_OK,
641  static_cast<FwAssertArgType>(_status)
642  );
643 
644  // Serialize port number
645  _status = msg.serializeFrom(portNum);
646  FW_ASSERT(
647  _status == Fw::FW_SERIALIZE_OK,
648  static_cast<FwAssertArgType>(_status)
649  );
650 
651  // Serialize argument cycleStart
652  _status = msg.serializeFrom(cycleStart);
653  FW_ASSERT(
654  _status == Fw::FW_SERIALIZE_OK,
655  static_cast<FwAssertArgType>(_status)
656  );
657 
658  // Send message
660  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
661 
662  if (qStatus == Os::Queue::Status::FULL) {
663  this->incNumMsgDropped();
664  return;
665  }
666 
667  FW_ASSERT(
668  qStatus == Os::Queue::OP_OK,
669  static_cast<FwAssertArgType>(qStatus)
670  );
671  }
672 
675  FwIndexType portNum,
676  U32 key
677  )
678  {
679  // Make sure port number is valid
680  FW_ASSERT(
681  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
682  static_cast<FwAssertArgType>(portNum)
683  );
684 
685  // Call pre-message hook
687  portNum,
688  key
689  );
690  ComponentIpcSerializableBuffer msg;
692 
693  // Serialize message ID
694  _status = msg.serializeFrom(
695  static_cast<FwEnumStoreType>(PINGIN_PING)
696  );
697  FW_ASSERT(
698  _status == Fw::FW_SERIALIZE_OK,
699  static_cast<FwAssertArgType>(_status)
700  );
701 
702  // Serialize port number
703  _status = msg.serializeFrom(portNum);
704  FW_ASSERT(
705  _status == Fw::FW_SERIALIZE_OK,
706  static_cast<FwAssertArgType>(_status)
707  );
708 
709  // Serialize argument key
710  _status = msg.serializeFrom(key);
711  FW_ASSERT(
712  _status == Fw::FW_SERIALIZE_OK,
713  static_cast<FwAssertArgType>(_status)
714  );
715 
716  // Send message
718  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
719 
720  FW_ASSERT(
721  qStatus == Os::Queue::OP_OK,
722  static_cast<FwAssertArgType>(qStatus)
723  );
724  }
725 
726  // ----------------------------------------------------------------------
727  // Pre-message hooks for typed async input ports
728  //
729  // Each of these functions is invoked just before processing a message
730  // on the corresponding port. By default, they do nothing. You can
731  // override them to provide specific pre-message behavior.
732  // ----------------------------------------------------------------------
733 
736  FwIndexType portNum,
737  Os::RawTime& cycleStart
738  )
739  {
740  // Default: no-op
741  }
742 
745  FwIndexType portNum,
746  U32 key
747  )
748  {
749  // Default: no-op
750  }
751 
752 #if !FW_DIRECT_PORT_CALLS
753 
754  // ----------------------------------------------------------------------
755  // Invocation functions for typed output ports
756  // ----------------------------------------------------------------------
757 
760  FwIndexType portNum,
761  U32 key
762  ) const
763  {
764  FW_ASSERT(
765  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
766  static_cast<FwAssertArgType>(portNum)
767  );
768 
769  FW_ASSERT(
770  this->m_PingOut_OutputPort[portNum].isConnected(),
771  static_cast<FwAssertArgType>(portNum)
772  );
773  this->m_PingOut_OutputPort[portNum].invoke(
774  key
775  );
776  }
777 
780  FwIndexType portNum,
781  U32 context
782  ) const
783  {
784  FW_ASSERT(
785  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
786  static_cast<FwAssertArgType>(portNum)
787  );
788 
789  FW_ASSERT(
790  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
791  static_cast<FwAssertArgType>(portNum)
792  );
793  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
794  context
795  );
796  }
797 
798 #endif
799 
800  // ----------------------------------------------------------------------
801  // Event logging functions
802  // ----------------------------------------------------------------------
803 
806  {
807  // Get the time
808  Fw::Time _logTime;
809  if (this->isConnected_Time_OutputPort(0)) {
810  this->Time_out(0, _logTime);
811  }
812 
813  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
814 
815  // Emit the event on the log port
816  if (this->isConnected_Log_OutputPort(0)) {
817  Fw::LogBuffer _logBuff;
818 
819 #if FW_AMPCS_COMPATIBLE
821  // Serialize the number of arguments
822  _status = _logBuff.serializeFrom(static_cast<U8>(0));
823  FW_ASSERT(
824  _status == Fw::FW_SERIALIZE_OK,
825  static_cast<FwAssertArgType>(_status)
826  );
827 #endif
828 
829  this->Log_out(
830  0,
831  _id,
832  _logTime,
834  _logBuff
835  );
836  }
837 
838  // Emit the event on the text log port
839 #if FW_ENABLE_TEXT_LOGGING
840  if (this->isConnected_LogText_OutputPort(0)) {
841 #if FW_OBJECT_NAMES == 1
842  const char* _formatString =
843  "(%s) %s: Rate group started.";
844 #else
845  const char* _formatString =
846  "%s: Rate group started.";
847 #endif
848 
849  Fw::TextLogString _logString;
850  _logString.format(
851  _formatString,
852 #if FW_OBJECT_NAMES == 1
853  this->m_objName.toChar(),
854 #endif
855  "RateGroupStarted "
856  );
857 
858  this->LogText_out(
859  0,
860  _id,
861  _logTime,
863  _logString
864  );
865  }
866 #endif
867  }
868 
871  {
872  // Get the time
873  Fw::Time _logTime;
874  if (this->isConnected_Time_OutputPort(0)) {
875  this->Time_out(0, _logTime);
876  }
877 
878  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
879 
880  // Emit the event on the log port
881  if (this->isConnected_Log_OutputPort(0)) {
882  Fw::LogBuffer _logBuff;
884 
885 #if FW_AMPCS_COMPATIBLE
886  // Serialize the number of arguments
887  _status = _logBuff.serializeFrom(static_cast<U8>(1));
888  FW_ASSERT(
889  _status == Fw::FW_SERIALIZE_OK,
890  static_cast<FwAssertArgType>(_status)
891  );
892 #endif
893 
894 #if FW_AMPCS_COMPATIBLE
895  // Serialize the argument size
896  _status = _logBuff.serializeFrom(
897  static_cast<U8>(sizeof(U32))
898  );
899  FW_ASSERT(
900  _status == Fw::FW_SERIALIZE_OK,
901  static_cast<FwAssertArgType>(_status)
902  );
903 #endif
904  _status = _logBuff.serializeFrom(cycle);
905  FW_ASSERT(
906  _status == Fw::FW_SERIALIZE_OK,
907  static_cast<FwAssertArgType>(_status)
908  );
909 
910  this->Log_out(
911  0,
912  _id,
913  _logTime,
915  _logBuff
916  );
917  }
918 
919  // Emit the event on the text log port
920 #if FW_ENABLE_TEXT_LOGGING
921  if (this->isConnected_LogText_OutputPort(0)) {
922 #if FW_OBJECT_NAMES == 1
923  const char* _formatString =
924  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
925 #else
926  const char* _formatString =
927  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
928 #endif
929 
930  Fw::TextLogString _logString;
931  _logString.format(
932  _formatString,
933 #if FW_OBJECT_NAMES == 1
934  this->m_objName.toChar(),
935 #endif
936  "RateGroupCycleSlip ",
937  cycle
938  );
939 
940  this->LogText_out(
941  0,
942  _id,
943  _logTime,
945  _logString
946  );
947  }
948 #endif
949  }
950 
951  // ----------------------------------------------------------------------
952  // Telemetry serialized write
953  // ----------------------------------------------------------------------
954 
957  FwChanIdType id,
958  Fw::TlmBuffer& _tlmBuff,
959  Fw::Time _tlmTime
960  ) const
961  {
962  if (this->isConnected_Tlm_OutputPort(0)) {
963  if (
964  this->isConnected_Time_OutputPort(0) &&
965  (_tlmTime == Fw::ZERO_TIME)
966  ) {
967  this->Time_out(0, _tlmTime);
968  }
969 
970  FwChanIdType _id;
971  _id = this->getIdBase() + id;
972 
973  this->Tlm_out(
974  0,
975  _id,
976  _tlmTime,
977  _tlmBuff
978  );
979  }
980  }
981 
982  // ----------------------------------------------------------------------
983  // Telemetry write functions
984  // ----------------------------------------------------------------------
985 
988  U32 arg,
989  Fw::Time _tlmTime
990  )
991  {
992  // Check to see if it is the first time
993  if (not this->m_first_update_RgMaxTime) {
994  // Check to see if value has changed. If not, don't write it.
995  if (arg == this->m_last_RgMaxTime) {
996  return;
997  }
998  else {
999  this->m_last_RgMaxTime = arg;
1000  }
1001  }
1002  else {
1003  this->m_first_update_RgMaxTime = false;
1004  this->m_last_RgMaxTime = arg;
1005  }
1006 
1007  if (this->isConnected_Tlm_OutputPort(0)) {
1008  Fw::TlmBuffer _tlmBuff;
1009  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1010  FW_ASSERT(
1011  _stat == Fw::FW_SERIALIZE_OK,
1012  static_cast<FwAssertArgType>(_stat)
1013  );
1014 
1015  this->tlmWrite(
1017  _tlmBuff,
1018  _tlmTime
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->isConnected_Tlm_OutputPort(0)) {
1045  Fw::TlmBuffer _tlmBuff;
1046  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1047  FW_ASSERT(
1048  _stat == Fw::FW_SERIALIZE_OK,
1049  static_cast<FwAssertArgType>(_stat)
1050  );
1051 
1052  this->tlmWrite(
1054  _tlmBuff,
1055  _tlmTime
1056  );
1057  }
1058  }
1059 
1060  // ----------------------------------------------------------------------
1061  // Time
1062  // ----------------------------------------------------------------------
1063 
1065  getTime() const
1066  {
1067  if (this->isConnected_Time_OutputPort(0)) {
1068  Fw::Time _time;
1069  this->Time_out(0, _time);
1070  return _time;
1071  }
1072  else {
1073  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1074  }
1075  }
1076 
1077  // ----------------------------------------------------------------------
1078  // Message dispatch functions
1079  // ----------------------------------------------------------------------
1080 
1081  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1082  doDispatch()
1083  {
1084  ComponentIpcSerializableBuffer _msg;
1085  FwQueuePriorityType _priority = 0;
1086 
1087  Os::Queue::Status _msgStatus = this->m_queue.receive(
1088  _msg,
1090  _priority
1091  );
1092  FW_ASSERT(
1093  _msgStatus == Os::Queue::OP_OK,
1094  static_cast<FwAssertArgType>(_msgStatus)
1095  );
1096 
1097  // Reset to beginning of buffer
1098  _msg.resetDeser();
1099 
1100  FwEnumStoreType _desMsg = 0;
1101  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1102  FW_ASSERT(
1103  _deserStatus == Fw::FW_SERIALIZE_OK,
1104  static_cast<FwAssertArgType>(_deserStatus)
1105  );
1106 
1107  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1108 
1109  if (_msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1110  return MSG_DISPATCH_EXIT;
1111  }
1112 
1113  FwIndexType portNum = 0;
1114  _deserStatus = _msg.deserializeTo(portNum);
1115  FW_ASSERT(
1116  _deserStatus == Fw::FW_SERIALIZE_OK,
1117  static_cast<FwAssertArgType>(_deserStatus)
1118  );
1119 
1120  switch (_msgType) {
1121  // Handle async input port CycleIn
1122  case CYCLEIN_CYCLE: {
1123  // Deserialize argument cycleStart
1124  Os::RawTime cycleStart;
1125  _deserStatus = _msg.deserializeTo(cycleStart);
1126  FW_ASSERT(
1127  _deserStatus == Fw::FW_SERIALIZE_OK,
1128  static_cast<FwAssertArgType>(_deserStatus)
1129  );
1130  // Call handler function
1131  this->CycleIn_handler(
1132  portNum,
1133  cycleStart
1134  );
1135 
1136  break;
1137  }
1138 
1139  // Handle async input port PingIn
1140  case PINGIN_PING: {
1141  // Deserialize argument key
1142  U32 key;
1143  _deserStatus = _msg.deserializeTo(key);
1144  FW_ASSERT(
1145  _deserStatus == Fw::FW_SERIALIZE_OK,
1146  static_cast<FwAssertArgType>(_deserStatus)
1147  );
1148  // Call handler function
1149  this->PingIn_handler(
1150  portNum,
1151  key
1152  );
1153 
1154  break;
1155  }
1156 
1157  default:
1158  return MSG_DISPATCH_ERROR;
1159  }
1160 
1161  return MSG_DISPATCH_OK;
1162  }
1163 
1164  // ----------------------------------------------------------------------
1165  // Calls for messages received on typed input ports
1166  // ----------------------------------------------------------------------
1167 
1168  void ActiveRateGroupComponentBase ::
1169  m_p_CycleIn_in(
1170  Fw::PassiveComponentBase* callComp,
1171  FwIndexType portNum,
1172  Os::RawTime& cycleStart
1173  )
1174  {
1175  FW_ASSERT(callComp);
1176  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1177  compPtr->CycleIn_handlerBase(
1178  portNum,
1179  cycleStart
1180  );
1181  }
1182 
1183  void ActiveRateGroupComponentBase ::
1184  m_p_PingIn_in(
1185  Fw::PassiveComponentBase* callComp,
1186  FwIndexType portNum,
1187  U32 key
1188  )
1189  {
1190  FW_ASSERT(callComp);
1191  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1192  compPtr->PingIn_handlerBase(
1193  portNum,
1194  key
1195  );
1196  }
1197 
1198 #if !FW_DIRECT_PORT_CALLS
1199 
1200  // ----------------------------------------------------------------------
1201  // Invocation functions for special output ports
1202  // ----------------------------------------------------------------------
1203 
1204  void ActiveRateGroupComponentBase ::
1205  Log_out(
1206  FwIndexType portNum,
1207  FwEventIdType id,
1208  Fw::Time& timeTag,
1209  const Fw::LogSeverity& severity,
1210  Fw::LogBuffer& args
1211  ) const
1212  {
1213  FW_ASSERT(
1214  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
1215  static_cast<FwAssertArgType>(portNum)
1216  );
1217 
1218  FW_ASSERT(
1219  this->m_Log_OutputPort[portNum].isConnected(),
1220  static_cast<FwAssertArgType>(portNum)
1221  );
1222  this->m_Log_OutputPort[portNum].invoke(
1223  id,
1224  timeTag,
1225  severity,
1226  args
1227  );
1228  }
1229 
1230 #if FW_ENABLE_TEXT_LOGGING
1231 
1232  void ActiveRateGroupComponentBase ::
1233  LogText_out(
1234  FwIndexType portNum,
1235  FwEventIdType id,
1236  Fw::Time& timeTag,
1237  const Fw::LogSeverity& severity,
1238  Fw::TextLogString& text
1239  ) const
1240  {
1241  FW_ASSERT(
1242  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1243  static_cast<FwAssertArgType>(portNum)
1244  );
1245 
1246  FW_ASSERT(
1247  this->m_LogText_OutputPort[portNum].isConnected(),
1248  static_cast<FwAssertArgType>(portNum)
1249  );
1250  this->m_LogText_OutputPort[portNum].invoke(
1251  id,
1252  timeTag,
1253  severity,
1254  text
1255  );
1256  }
1257 
1258 #endif
1259 
1260  void ActiveRateGroupComponentBase ::
1261  Time_out(
1262  FwIndexType portNum,
1263  Fw::Time& time
1264  ) const
1265  {
1266  FW_ASSERT(
1267  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
1268  static_cast<FwAssertArgType>(portNum)
1269  );
1270 
1271  FW_ASSERT(
1272  this->m_Time_OutputPort[portNum].isConnected(),
1273  static_cast<FwAssertArgType>(portNum)
1274  );
1275  this->m_Time_OutputPort[portNum].invoke(
1276  time
1277  );
1278  }
1279 
1280  void ActiveRateGroupComponentBase ::
1281  Tlm_out(
1282  FwIndexType portNum,
1283  FwChanIdType id,
1284  Fw::Time& timeTag,
1285  Fw::TlmBuffer& val
1286  ) const
1287  {
1288  FW_ASSERT(
1289  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
1290  static_cast<FwAssertArgType>(portNum)
1291  );
1292 
1293  FW_ASSERT(
1294  this->m_Tlm_OutputPort[portNum].isConnected(),
1295  static_cast<FwAssertArgType>(portNum)
1296  );
1297  this->m_Tlm_OutputPort[portNum].invoke(
1298  id,
1299  timeTag,
1300  val
1301  );
1302  }
1303 
1304 #endif
1305 
1306 }
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:157
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
Operation succeeded.
Definition: Os.hpp:26
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_PingIn_InputPorts()
static constexpr FwIndexType getNum_RateGroupMemberOut_OutputPorts()
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:71
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:79
I32 FwEnumStoreType
static constexpr FwIndexType getNum_Log_OutputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
Warning event that rate group has had a cycle slip.
void PingOut_out(FwIndexType portNum, U32 key) const
Invoke output port PingOut.
bool isConnected_Tlm_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_Time_OutputPorts()
void invoke(U32 key) const
Invoke a port connection.
Definition: PingPortAc.cpp:170
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:171
No time base has been established (Required)
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:177
void init()
Object initializer.
Definition: ObjBase.cpp:24
ActiveRateGroupComponentBase(const char *compName="")
Construct ActiveRateGroupComponentBase object.
SerializeStatus
forward declaration for string
bool isConnected_Time_OutputPort(FwIndexType portNum) const
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.
bool isConnected_PingOut_OutputPort(FwIndexType portNum) const
static constexpr FwSizeType CAPACITY
Definition: PingPortAc.hpp:34
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void invoke(U32 context) const
Invoke a port connection.
void init()
Initialization function.
Definition: PingPortAc.cpp:151
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
message to exit active component task
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
static constexpr FwIndexType getNum_PingOut_OutputPorts()
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:157
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
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 connection.
Definition: TlmPortAc.cpp:190
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
Definition: CyclePortAc.cpp:73
bool isConnected_Log_OutputPort(FwIndexType portNum) const
void RateGroupMemberOut_out(FwIndexType portNum, U32 context) const
Invoke output port RateGroupMemberOut.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
static constexpr FwSizeType CAPACITY
Definition: CyclePortAc.hpp:35
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
static constexpr FwIndexType getNum_Tlm_OutputPorts()
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void init()
Initialization function.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
void incNumMsgDropped()
increment the number of messages dropped
void init()
Initialization function.
Definition: PingPortAc.cpp:73
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
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:79
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum) const
Implementation of malloc based allocator.
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
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.