F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TlmChanComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TlmChanComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TlmChan 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  TLMCHAN_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  RUN_SCHED,
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  ComponentIpcSerializableBuffer() : Fw::LinearBufferBase(m_buff, sizeof(m_buff)) {
48 
49  }
50 
51  private:
52  // Should be the max of all the input ports serialized sizes...
53  U8 m_buff[SERIALIZATION_SIZE];
54 
55  };
56  }
57 
58  // ----------------------------------------------------------------------
59  // Component initialization
60  // ----------------------------------------------------------------------
61 
64  FwSizeType queueDepth,
65  FwEnumStoreType instance
66  )
67  {
68  // Initialize base class
70 
71 #if !FW_DIRECT_PORT_CALLS
72  // Connect input port Run
73  for (
74  FwIndexType port = 0;
75  port < static_cast<FwIndexType>(this->getNum_Run_InputPorts());
76  port++
77  ) {
78  this->m_Run_InputPort[port].init();
79  this->m_Run_InputPort[port].addCallComp(
80  this,
81  m_p_Run_in
82  );
83  this->m_Run_InputPort[port].setPortNum(port);
84 
85 #if FW_OBJECT_NAMES == 1
86  Fw::ObjectName portName;
87  portName.format(
88  "%s_Run_InputPort[%" PRI_FwIndexType "]",
89  this->m_objName.toChar(),
90  port
91  );
92  this->m_Run_InputPort[port].setObjName(portName.toChar());
93 #endif
94  }
95 #endif
96 
97 #if !FW_DIRECT_PORT_CALLS
98  // Connect input port TlmGet
99  for (
100  FwIndexType port = 0;
101  port < static_cast<FwIndexType>(this->getNum_TlmGet_InputPorts());
102  port++
103  ) {
104  this->m_TlmGet_InputPort[port].init();
105  this->m_TlmGet_InputPort[port].addCallComp(
106  this,
107  m_p_TlmGet_in
108  );
109  this->m_TlmGet_InputPort[port].setPortNum(port);
110 
111 #if FW_OBJECT_NAMES == 1
112  Fw::ObjectName portName;
113  portName.format(
114  "%s_TlmGet_InputPort[%" PRI_FwIndexType "]",
115  this->m_objName.toChar(),
116  port
117  );
118  this->m_TlmGet_InputPort[port].setObjName(portName.toChar());
119 #endif
120  }
121 #endif
122 
123 #if !FW_DIRECT_PORT_CALLS
124  // Connect input port TlmRecv
125  for (
126  FwIndexType port = 0;
127  port < static_cast<FwIndexType>(this->getNum_TlmRecv_InputPorts());
128  port++
129  ) {
130  this->m_TlmRecv_InputPort[port].init();
131  this->m_TlmRecv_InputPort[port].addCallComp(
132  this,
133  m_p_TlmRecv_in
134  );
135  this->m_TlmRecv_InputPort[port].setPortNum(port);
136 
137 #if FW_OBJECT_NAMES == 1
138  Fw::ObjectName portName;
139  portName.format(
140  "%s_TlmRecv_InputPort[%" PRI_FwIndexType "]",
141  this->m_objName.toChar(),
142  port
143  );
144  this->m_TlmRecv_InputPort[port].setObjName(portName.toChar());
145 #endif
146  }
147 #endif
148 
149 #if !FW_DIRECT_PORT_CALLS
150  // Connect input port pingIn
151  for (
152  FwIndexType port = 0;
153  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
154  port++
155  ) {
156  this->m_pingIn_InputPort[port].init();
157  this->m_pingIn_InputPort[port].addCallComp(
158  this,
159  m_p_pingIn_in
160  );
161  this->m_pingIn_InputPort[port].setPortNum(port);
162 
163 #if FW_OBJECT_NAMES == 1
164  Fw::ObjectName portName;
165  portName.format(
166  "%s_pingIn_InputPort[%" PRI_FwIndexType "]",
167  this->m_objName.toChar(),
168  port
169  );
170  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
171 #endif
172  }
173 #endif
174 
175 #if !FW_DIRECT_PORT_CALLS
176  // Connect output port eventOut
177  for (
178  FwIndexType port = 0;
179  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
180  port++
181  ) {
182  this->m_eventOut_OutputPort[port].init();
183 
184 #if FW_OBJECT_NAMES == 1
185  Fw::ObjectName portName;
186  portName.format(
187  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
188  this->m_objName.toChar(),
189  port
190  );
191  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
192 #endif
193  }
194 #endif
195 
196 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
197  // Connect output port eventOutText
198  for (
199  FwIndexType port = 0;
200  port < static_cast<FwIndexType>(this->getNum_eventOutText_OutputPorts());
201  port++
202  ) {
203  this->m_eventOutText_OutputPort[port].init();
204 
205 #if FW_OBJECT_NAMES == 1
206  Fw::ObjectName portName;
207  portName.format(
208  "%s_eventOutText_OutputPort[%" PRI_FwIndexType "]",
209  this->m_objName.toChar(),
210  port
211  );
212  this->m_eventOutText_OutputPort[port].setObjName(portName.toChar());
213 #endif
214  }
215 #endif
216 
217 #if !FW_DIRECT_PORT_CALLS
218  // Connect output port timeCaller
219  for (
220  FwIndexType port = 0;
221  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
222  port++
223  ) {
224  this->m_timeCaller_OutputPort[port].init();
225 
226 #if FW_OBJECT_NAMES == 1
227  Fw::ObjectName portName;
228  portName.format(
229  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
230  this->m_objName.toChar(),
231  port
232  );
233  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
234 #endif
235  }
236 #endif
237 
238 #if !FW_DIRECT_PORT_CALLS
239  // Connect output port PktSend
240  for (
241  FwIndexType port = 0;
242  port < static_cast<FwIndexType>(this->getNum_PktSend_OutputPorts());
243  port++
244  ) {
245  this->m_PktSend_OutputPort[port].init();
246 
247 #if FW_OBJECT_NAMES == 1
248  Fw::ObjectName portName;
249  portName.format(
250  "%s_PktSend_OutputPort[%" PRI_FwIndexType "]",
251  this->m_objName.toChar(),
252  port
253  );
254  this->m_PktSend_OutputPort[port].setObjName(portName.toChar());
255 #endif
256  }
257 #endif
258 
259 #if !FW_DIRECT_PORT_CALLS
260  // Connect output port pingOut
261  for (
262  FwIndexType port = 0;
263  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
264  port++
265  ) {
266  this->m_pingOut_OutputPort[port].init();
267 
268 #if FW_OBJECT_NAMES == 1
269  Fw::ObjectName portName;
270  portName.format(
271  "%s_pingOut_OutputPort[%" PRI_FwIndexType "]",
272  this->m_objName.toChar(),
273  port
274  );
275  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
276 #endif
277  }
278 #endif
279 
280  // Create the queue
281  Os::Queue::Status qStat = this->createQueue(
282  queueDepth,
283  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
284  );
285  FW_ASSERT(
286  Os::Queue::Status::OP_OK == qStat,
287  static_cast<FwAssertArgType>(qStat)
288  );
289  }
290 
291 #if !FW_DIRECT_PORT_CALLS
292 
293  // ----------------------------------------------------------------------
294  // Getters for typed input ports
295  // ----------------------------------------------------------------------
296 
299  {
300  FW_ASSERT(
301  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
302  static_cast<FwAssertArgType>(portNum)
303  );
304 
305  return &this->m_Run_InputPort[portNum];
306  }
307 
310  {
311  FW_ASSERT(
312  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
313  static_cast<FwAssertArgType>(portNum)
314  );
315 
316  return &this->m_TlmGet_InputPort[portNum];
317  }
318 
321  {
322  FW_ASSERT(
323  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
324  static_cast<FwAssertArgType>(portNum)
325  );
326 
327  return &this->m_TlmRecv_InputPort[portNum];
328  }
329 
332  {
333  FW_ASSERT(
334  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
335  static_cast<FwAssertArgType>(portNum)
336  );
337 
338  return &this->m_pingIn_InputPort[portNum];
339  }
340 
341 #endif
342 
343 #if !FW_DIRECT_PORT_CALLS
344 
345  // ----------------------------------------------------------------------
346  // Connect input ports to special output ports
347  // ----------------------------------------------------------------------
348 
351  FwIndexType portNum,
352  Fw::InputLogPort* port
353  )
354  {
355  FW_ASSERT(
356  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
357  static_cast<FwAssertArgType>(portNum)
358  );
359 
360  this->m_eventOut_OutputPort[portNum].addCallPort(port);
361  }
362 
363 #if FW_ENABLE_TEXT_LOGGING == 1
364 
365  void TlmChanComponentBase ::
366  set_eventOutText_OutputPort(
367  FwIndexType portNum,
369  )
370  {
371  FW_ASSERT(
372  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
373  static_cast<FwAssertArgType>(portNum)
374  );
375 
376  this->m_eventOutText_OutputPort[portNum].addCallPort(port);
377  }
378 
379 #endif
380 
383  FwIndexType portNum,
384  Fw::InputTimePort* port
385  )
386  {
387  FW_ASSERT(
388  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
389  static_cast<FwAssertArgType>(portNum)
390  );
391 
392  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
393  }
394 
395 #endif
396 
397 #if !FW_DIRECT_PORT_CALLS
398 
399  // ----------------------------------------------------------------------
400  // Connect typed input ports to typed output ports
401  // ----------------------------------------------------------------------
402 
405  FwIndexType portNum,
406  Fw::InputComPort* port
407  )
408  {
409  FW_ASSERT(
410  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
411  static_cast<FwAssertArgType>(portNum)
412  );
413 
414  this->m_PktSend_OutputPort[portNum].addCallPort(port);
415  }
416 
419  FwIndexType portNum,
420  Svc::InputPingPort* port
421  )
422  {
423  FW_ASSERT(
424  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
425  static_cast<FwAssertArgType>(portNum)
426  );
427 
428  this->m_pingOut_OutputPort[portNum].addCallPort(port);
429  }
430 
431 #endif
432 
433 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
434 
435  // ----------------------------------------------------------------------
436  // Connect serial input ports to special output ports
437  // ----------------------------------------------------------------------
438 
441  FwIndexType portNum,
442  Fw::InputSerializePort* port
443  )
444  {
445  FW_ASSERT(
446  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
447  static_cast<FwAssertArgType>(portNum)
448  );
449 
450  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
451  }
452 
453 #if FW_ENABLE_TEXT_LOGGING == 1
454 
455  void TlmChanComponentBase ::
456  set_eventOutText_OutputPort(
457  FwIndexType portNum,
458  Fw::InputSerializePort* port
459  )
460  {
461  FW_ASSERT(
462  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
463  static_cast<FwAssertArgType>(portNum)
464  );
465 
466  this->m_eventOutText_OutputPort[portNum].registerSerialPort(port);
467  }
468 
469 #endif
470 
473  FwIndexType portNum,
474  Fw::InputSerializePort* port
475  )
476  {
477  FW_ASSERT(
478  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
479  static_cast<FwAssertArgType>(portNum)
480  );
481 
482  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
483  }
484 
485 #endif
486 
487 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
488 
489  // ----------------------------------------------------------------------
490  // Connect serial input ports to typed output ports
491  // ----------------------------------------------------------------------
492 
495  FwIndexType portNum,
496  Fw::InputSerializePort* port
497  )
498  {
499  FW_ASSERT(
500  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
501  static_cast<FwAssertArgType>(portNum)
502  );
503 
504  this->m_PktSend_OutputPort[portNum].registerSerialPort(port);
505  }
506 
509  FwIndexType portNum,
510  Fw::InputSerializePort* port
511  )
512  {
513  FW_ASSERT(
514  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
515  static_cast<FwAssertArgType>(portNum)
516  );
517 
518  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
519  }
520 
521 #endif
522 
523  // ----------------------------------------------------------------------
524  // Component construction and destruction
525  // ----------------------------------------------------------------------
526 
528  TlmChanComponentBase(const char* compName) :
529  Fw::ActiveComponentBase(compName)
530  {
531  this->m_TlmChanBucketPoolExhaustedThrottle = 0;
532  }
533 
536  {
537 
538  }
539 
540 #if !FW_DIRECT_PORT_CALLS
541 
542  // ----------------------------------------------------------------------
543  // Connection status queries for special output ports
544  // ----------------------------------------------------------------------
545 
548  {
549  FW_ASSERT(
550  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
551  static_cast<FwAssertArgType>(portNum)
552  );
553 
554  return this->m_eventOut_OutputPort[portNum].isConnected();
555  }
556 
557 #if FW_ENABLE_TEXT_LOGGING == 1
558 
559  bool TlmChanComponentBase ::
560  isConnected_eventOutText_OutputPort(FwIndexType portNum) const
561  {
562  FW_ASSERT(
563  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
564  static_cast<FwAssertArgType>(portNum)
565  );
566 
567  return this->m_eventOutText_OutputPort[portNum].isConnected();
568  }
569 
570 #endif
571 
574  {
575  FW_ASSERT(
576  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
577  static_cast<FwAssertArgType>(portNum)
578  );
579 
580  return this->m_timeCaller_OutputPort[portNum].isConnected();
581  }
582 
583 #endif
584 
585 #if !FW_DIRECT_PORT_CALLS
586 
587  // ----------------------------------------------------------------------
588  // Connection status queries for typed output ports
589  // ----------------------------------------------------------------------
590 
593  {
594  FW_ASSERT(
595  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
596  static_cast<FwAssertArgType>(portNum)
597  );
598 
599  return this->m_PktSend_OutputPort[portNum].isConnected();
600  }
601 
604  {
605  FW_ASSERT(
606  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
607  static_cast<FwAssertArgType>(portNum)
608  );
609 
610  return this->m_pingOut_OutputPort[portNum].isConnected();
611  }
612 
613 #endif
614 
615  // ----------------------------------------------------------------------
616  // Port handler base-class functions for typed input ports
617  //
618  // Call these functions directly to bypass the corresponding ports
619  // ----------------------------------------------------------------------
620 
623  FwIndexType portNum,
624  U32 context
625  )
626  {
627  // Make sure port number is valid
628  FW_ASSERT(
629  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
630  static_cast<FwAssertArgType>(portNum)
631  );
632 
633  // Call pre-message hook
635  portNum,
636  context
637  );
638  ComponentIpcSerializableBuffer msg;
640 
641  // Serialize message ID
642  _status = msg.serializeFrom(
643  static_cast<FwEnumStoreType>(RUN_SCHED)
644  );
645  FW_ASSERT(
646  _status == Fw::FW_SERIALIZE_OK,
647  static_cast<FwAssertArgType>(_status)
648  );
649 
650  // Serialize port number
651  _status = msg.serializeFrom(portNum);
652  FW_ASSERT(
653  _status == Fw::FW_SERIALIZE_OK,
654  static_cast<FwAssertArgType>(_status)
655  );
656 
657  // Serialize argument context
658  _status = msg.serializeFrom(context);
659  FW_ASSERT(
660  _status == Fw::FW_SERIALIZE_OK,
661  static_cast<FwAssertArgType>(_status)
662  );
663 
664  // Send message
666  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
667 
668  FW_ASSERT(
669  qStatus == Os::Queue::OP_OK,
670  static_cast<FwAssertArgType>(qStatus)
671  );
672  }
673 
676  FwIndexType portNum,
677  FwChanIdType id,
678  Fw::Time& timeTag,
679  Fw::TlmBuffer& val
680  )
681  {
682  // Make sure port number is valid
683  FW_ASSERT(
684  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
685  static_cast<FwAssertArgType>(portNum)
686  );
687 
688  Fw::TlmValid retVal;
689 
690  // Lock guard mutex before calling
691  this->lock();
692 
693  // Call handler function
694  retVal = this->TlmGet_handler(
695  portNum,
696  id,
697  timeTag,
698  val
699  );
700 
701  // Unlock guard mutex
702  this->unLock();
703 
704  return retVal;
705  }
706 
709  FwIndexType portNum,
710  FwChanIdType id,
711  Fw::Time& timeTag,
712  Fw::TlmBuffer& val
713  )
714  {
715  // Make sure port number is valid
716  FW_ASSERT(
717  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
718  static_cast<FwAssertArgType>(portNum)
719  );
720 
721  // Lock guard mutex before calling
722  this->lock();
723 
724  // Call handler function
725  this->TlmRecv_handler(
726  portNum,
727  id,
728  timeTag,
729  val
730  );
731 
732  // Unlock guard mutex
733  this->unLock();
734  }
735 
738  FwIndexType portNum,
739  U32 key
740  )
741  {
742  // Make sure port number is valid
743  FW_ASSERT(
744  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
745  static_cast<FwAssertArgType>(portNum)
746  );
747 
748  // Call pre-message hook
750  portNum,
751  key
752  );
753  ComponentIpcSerializableBuffer msg;
755 
756  // Serialize message ID
757  _status = msg.serializeFrom(
758  static_cast<FwEnumStoreType>(PINGIN_PING)
759  );
760  FW_ASSERT(
761  _status == Fw::FW_SERIALIZE_OK,
762  static_cast<FwAssertArgType>(_status)
763  );
764 
765  // Serialize port number
766  _status = msg.serializeFrom(portNum);
767  FW_ASSERT(
768  _status == Fw::FW_SERIALIZE_OK,
769  static_cast<FwAssertArgType>(_status)
770  );
771 
772  // Serialize argument key
773  _status = msg.serializeFrom(key);
774  FW_ASSERT(
775  _status == Fw::FW_SERIALIZE_OK,
776  static_cast<FwAssertArgType>(_status)
777  );
778 
779  // Send message
781  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
782 
783  if (qStatus == Os::Queue::Status::FULL) {
784  this->incNumMsgDropped();
785  return;
786  }
787 
788  FW_ASSERT(
789  qStatus == Os::Queue::OP_OK,
790  static_cast<FwAssertArgType>(qStatus)
791  );
792  }
793 
794  // ----------------------------------------------------------------------
795  // Pre-message hooks for typed async input ports
796  //
797  // Each of these functions is invoked just before processing a message
798  // on the corresponding port. By default, they do nothing. You can
799  // override them to provide specific pre-message behavior.
800  // ----------------------------------------------------------------------
801 
804  FwIndexType portNum,
805  U32 context
806  )
807  {
808  // Default: no-op
809  }
810 
813  FwIndexType portNum,
814  U32 key
815  )
816  {
817  // Default: no-op
818  }
819 
820 #if !FW_DIRECT_PORT_CALLS
821 
822  // ----------------------------------------------------------------------
823  // Invocation functions for typed output ports
824  // ----------------------------------------------------------------------
825 
828  FwIndexType portNum,
829  Fw::ComBuffer& data,
830  U32 context
831  ) const
832  {
833  FW_ASSERT(
834  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
835  static_cast<FwAssertArgType>(portNum)
836  );
837 
838  FW_ASSERT(
839  this->m_PktSend_OutputPort[portNum].isConnected(),
840  static_cast<FwAssertArgType>(portNum)
841  );
842  this->m_PktSend_OutputPort[portNum].invoke(
843  data,
844  context
845  );
846  }
847 
850  FwIndexType portNum,
851  U32 key
852  ) const
853  {
854  FW_ASSERT(
855  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
856  static_cast<FwAssertArgType>(portNum)
857  );
858 
859  FW_ASSERT(
860  this->m_pingOut_OutputPort[portNum].isConnected(),
861  static_cast<FwAssertArgType>(portNum)
862  );
863  this->m_pingOut_OutputPort[portNum].invoke(
864  key
865  );
866  }
867 
868 #endif
869 
870  // ----------------------------------------------------------------------
871  // Event logging functions
872  // ----------------------------------------------------------------------
873 
876  U32 numDeferred,
877  U32 numTimesDeferredCountReached
878  ) const
879  {
880  // Get the time
881  Fw::Time _logTime;
882  if (this->isConnected_timeCaller_OutputPort(0)) {
883  this->timeCaller_out(0, _logTime);
884  }
885 
887 
888  // Emit the event on the log port
889  if (this->isConnected_eventOut_OutputPort(0)) {
890  Fw::LogBuffer _logBuff;
892 
893 #if FW_AMPCS_COMPATIBLE
894  // Serialize the number of arguments
895  _status = _logBuff.serializeFrom(static_cast<U8>(2));
896  FW_ASSERT(
897  _status == Fw::FW_SERIALIZE_OK,
898  static_cast<FwAssertArgType>(_status)
899  );
900 #endif
901 
902 #if FW_AMPCS_COMPATIBLE
903  // Serialize the argument size
904  _status = _logBuff.serializeFrom(
905  static_cast<U8>(sizeof(U32))
906  );
907  FW_ASSERT(
908  _status == Fw::FW_SERIALIZE_OK,
909  static_cast<FwAssertArgType>(_status)
910  );
911 #endif
912  _status = _logBuff.serializeFrom(numDeferred);
913  FW_ASSERT(
914  _status == Fw::FW_SERIALIZE_OK,
915  static_cast<FwAssertArgType>(_status)
916  );
917 
918 #if FW_AMPCS_COMPATIBLE
919  // Serialize the argument size
920  _status = _logBuff.serializeFrom(
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.serializeFrom(numTimesDeferredCountReached);
929  FW_ASSERT(
930  _status == Fw::FW_SERIALIZE_OK,
931  static_cast<FwAssertArgType>(_status)
932  );
933 
934  this->eventOut_out(
935  0,
936  _id,
937  _logTime,
939  _logBuff
940  );
941  }
942 
943  // Emit the event on the text log port
944 #if FW_ENABLE_TEXT_LOGGING
945  if (this->isConnected_eventOutText_OutputPort(0)) {
946 #if FW_OBJECT_NAMES == 1
947  const char* _formatString =
948  "(%s) %s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
949 #else
950  const char* _formatString =
951  "%s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
952 #endif
953 
954  Fw::TextLogString _logString;
955  (void) _logString.format(
956  _formatString,
957 #if FW_OBJECT_NAMES == 1
958  this->m_objName.toChar(),
959 #endif
960  "TlmChanEpochProcessingCapReached ",
961  numDeferred,
962  numTimesDeferredCountReached
963  );
964 
965  this->eventOutText_out(
966  0,
967  _id,
968  _logTime,
970  _logString
971  );
972  }
973 #endif
974  }
975 
978  {
979  // Check throttle value
980  if (this->m_TlmChanBucketPoolExhaustedThrottle >= EVENTID_TLMCHANBUCKETPOOLEXHAUSTED_THROTTLE) {
981  return;
982  }
983  else {
984  this->m_TlmChanBucketPoolExhaustedThrottle++;
985  }
986 
987  // Get the time
988  Fw::Time _logTime;
989  if (this->isConnected_timeCaller_OutputPort(0)) {
990  this->timeCaller_out(0, _logTime);
991  }
992 
994 
995  // Emit the event on the log port
996  if (this->isConnected_eventOut_OutputPort(0)) {
997  Fw::LogBuffer _logBuff;
999 
1000 #if FW_AMPCS_COMPATIBLE
1001  // Serialize the number of arguments
1002  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1003  FW_ASSERT(
1004  _status == Fw::FW_SERIALIZE_OK,
1005  static_cast<FwAssertArgType>(_status)
1006  );
1007 #endif
1008 
1009 #if FW_AMPCS_COMPATIBLE
1010  // Serialize the argument size
1011  _status = _logBuff.serializeFrom(
1012  static_cast<U8>(sizeof(FwChanIdType))
1013  );
1014  FW_ASSERT(
1015  _status == Fw::FW_SERIALIZE_OK,
1016  static_cast<FwAssertArgType>(_status)
1017  );
1018 #endif
1019  _status = _logBuff.serializeFrom(Id);
1020  FW_ASSERT(
1021  _status == Fw::FW_SERIALIZE_OK,
1022  static_cast<FwAssertArgType>(_status)
1023  );
1024 
1025  this->eventOut_out(
1026  0,
1027  _id,
1028  _logTime,
1030  _logBuff
1031  );
1032  }
1033 
1034  // Emit the event on the text log port
1035 #if FW_ENABLE_TEXT_LOGGING
1036  if (this->isConnected_eventOutText_OutputPort(0)) {
1037 #if FW_OBJECT_NAMES == 1
1038  const char* _formatString =
1039  "(%s) %s: TlmChan bucket pool exhausted: dropping new telemetry ID 0x%" PRIx32 "";
1040 #else
1041  const char* _formatString =
1042  "%s: TlmChan bucket pool exhausted: dropping new telemetry ID 0x%" PRIx32 "";
1043 #endif
1044 
1045  Fw::TextLogString _logString;
1046  (void) _logString.format(
1047  _formatString,
1048 #if FW_OBJECT_NAMES == 1
1049  this->m_objName.toChar(),
1050 #endif
1051  "TlmChanBucketPoolExhausted ",
1052  Id
1053  );
1054 
1055  this->eventOutText_out(
1056  0,
1057  _id,
1058  _logTime,
1060  _logString
1061  );
1062  }
1063 #endif
1064  }
1065 
1066  // ----------------------------------------------------------------------
1067  // Event throttle reset functions
1068  // ----------------------------------------------------------------------
1069 
1072  {
1073  // Reset throttle counter
1074  this->m_TlmChanBucketPoolExhaustedThrottle = 0;
1075  }
1076 
1077  // ----------------------------------------------------------------------
1078  // Time
1079  // ----------------------------------------------------------------------
1080 
1082  getTime() const
1083  {
1084  if (this->isConnected_timeCaller_OutputPort(0)) {
1085  Fw::Time _time;
1086  this->timeCaller_out(0, _time);
1087  return _time;
1088  }
1089  else {
1090  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1091  }
1092  }
1093 
1094  // ----------------------------------------------------------------------
1095  // Mutex operations for guarded ports
1096  //
1097  // You can override these operations to provide more sophisticated
1098  // synchronization
1099  // ----------------------------------------------------------------------
1100 
1103  {
1104  this->m_guardedPortMutex.lock();
1105  }
1106 
1109  {
1110  this->m_guardedPortMutex.unLock();
1111  }
1112 
1113  // ----------------------------------------------------------------------
1114  // Message dispatch functions
1115  // ----------------------------------------------------------------------
1116 
1117  Fw::QueuedComponentBase::MsgDispatchStatus TlmChanComponentBase ::
1118  doDispatch()
1119  {
1120  ComponentIpcSerializableBuffer _msg;
1121  FwQueuePriorityType _priority = 0;
1122 
1123  Os::Queue::Status _msgStatus = this->m_queue.receive(
1124  _msg,
1126  _priority
1127  );
1128  FW_ASSERT(
1129  _msgStatus == Os::Queue::OP_OK,
1130  static_cast<FwAssertArgType>(_msgStatus)
1131  );
1132 
1133  // Reset to beginning of buffer
1134  _msg.resetDeser();
1135 
1136  FwEnumStoreType _desMsg = 0;
1137  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1138  FW_ASSERT(
1139  _deserStatus == Fw::FW_SERIALIZE_OK,
1140  static_cast<FwAssertArgType>(_deserStatus)
1141  );
1142 
1143  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1144 
1145  if (_msgType == TLMCHAN_COMPONENT_EXIT) {
1146  return MSG_DISPATCH_EXIT;
1147  }
1148 
1149  FwIndexType portNum = 0;
1150  _deserStatus = _msg.deserializeTo(portNum);
1151  FW_ASSERT(
1152  _deserStatus == Fw::FW_SERIALIZE_OK,
1153  static_cast<FwAssertArgType>(_deserStatus)
1154  );
1155 
1156  switch (_msgType) {
1157  // Handle async input port Run
1158  case RUN_SCHED: {
1159  // Deserialize argument context
1160  U32 context;
1161  _deserStatus = _msg.deserializeTo(context);
1162  FW_ASSERT(
1163  _deserStatus == Fw::FW_SERIALIZE_OK,
1164  static_cast<FwAssertArgType>(_deserStatus)
1165  );
1166  // Call handler function
1167  this->Run_handler(
1168  portNum,
1169  context
1170  );
1171 
1172  break;
1173  }
1174 
1175  // Handle async input port pingIn
1176  case PINGIN_PING: {
1177  // Deserialize argument key
1178  U32 key;
1179  _deserStatus = _msg.deserializeTo(key);
1180  FW_ASSERT(
1181  _deserStatus == Fw::FW_SERIALIZE_OK,
1182  static_cast<FwAssertArgType>(_deserStatus)
1183  );
1184  // Call handler function
1185  this->pingIn_handler(
1186  portNum,
1187  key
1188  );
1189 
1190  break;
1191  }
1192 
1193  default:
1194  return MSG_DISPATCH_ERROR;
1195  }
1196 
1197  return MSG_DISPATCH_OK;
1198  }
1199 
1200  // ----------------------------------------------------------------------
1201  // Calls for messages received on typed input ports
1202  // ----------------------------------------------------------------------
1203 
1204  void TlmChanComponentBase ::
1205  m_p_Run_in(
1206  Fw::PassiveComponentBase* callComp,
1207  FwIndexType portNum,
1208  U32 context
1209  )
1210  {
1211  FW_ASSERT(callComp != nullptr);
1212  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1213  compPtr->Run_handlerBase(
1214  portNum,
1215  context
1216  );
1217  }
1218 
1219  Fw::TlmValid TlmChanComponentBase ::
1220  m_p_TlmGet_in(
1221  Fw::PassiveComponentBase* callComp,
1222  FwIndexType portNum,
1223  FwChanIdType id,
1224  Fw::Time& timeTag,
1225  Fw::TlmBuffer& val
1226  )
1227  {
1228  FW_ASSERT(callComp != nullptr);
1229  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1230  return compPtr->TlmGet_handlerBase(
1231  portNum,
1232  id,
1233  timeTag,
1234  val
1235  );
1236  }
1237 
1238  void TlmChanComponentBase ::
1239  m_p_TlmRecv_in(
1240  Fw::PassiveComponentBase* callComp,
1241  FwIndexType portNum,
1242  FwChanIdType id,
1243  Fw::Time& timeTag,
1244  Fw::TlmBuffer& val
1245  )
1246  {
1247  FW_ASSERT(callComp != nullptr);
1248  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1249  compPtr->TlmRecv_handlerBase(
1250  portNum,
1251  id,
1252  timeTag,
1253  val
1254  );
1255  }
1256 
1257  void TlmChanComponentBase ::
1258  m_p_pingIn_in(
1259  Fw::PassiveComponentBase* callComp,
1260  FwIndexType portNum,
1261  U32 key
1262  )
1263  {
1264  FW_ASSERT(callComp != nullptr);
1265  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1266  compPtr->pingIn_handlerBase(
1267  portNum,
1268  key
1269  );
1270  }
1271 
1272 #if !FW_DIRECT_PORT_CALLS
1273 
1274  // ----------------------------------------------------------------------
1275  // Invocation functions for special output ports
1276  // ----------------------------------------------------------------------
1277 
1278  void TlmChanComponentBase ::
1279  eventOut_out(
1280  FwIndexType portNum,
1281  FwEventIdType id,
1282  Fw::Time& timeTag,
1283  const Fw::LogSeverity& severity,
1284  Fw::LogBuffer& args
1285  ) const
1286  {
1287  FW_ASSERT(
1288  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
1289  static_cast<FwAssertArgType>(portNum)
1290  );
1291 
1292  FW_ASSERT(
1293  this->m_eventOut_OutputPort[portNum].isConnected(),
1294  static_cast<FwAssertArgType>(portNum)
1295  );
1296  this->m_eventOut_OutputPort[portNum].invoke(
1297  id,
1298  timeTag,
1299  severity,
1300  args
1301  );
1302  }
1303 
1304 #if FW_ENABLE_TEXT_LOGGING
1305 
1306  void TlmChanComponentBase ::
1307  eventOutText_out(
1308  FwIndexType portNum,
1309  FwEventIdType id,
1310  Fw::Time& timeTag,
1311  const Fw::LogSeverity& severity,
1312  Fw::TextLogString& text
1313  ) const
1314  {
1315  FW_ASSERT(
1316  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
1317  static_cast<FwAssertArgType>(portNum)
1318  );
1319 
1320  FW_ASSERT(
1321  this->m_eventOutText_OutputPort[portNum].isConnected(),
1322  static_cast<FwAssertArgType>(portNum)
1323  );
1324  this->m_eventOutText_OutputPort[portNum].invoke(
1325  id,
1326  timeTag,
1327  severity,
1328  text
1329  );
1330  }
1331 
1332 #endif
1333 
1334  void TlmChanComponentBase ::
1335  timeCaller_out(
1336  FwIndexType portNum,
1337  Fw::Time& time
1338  ) const
1339  {
1340  FW_ASSERT(
1341  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1342  static_cast<FwAssertArgType>(portNum)
1343  );
1344 
1345  FW_ASSERT(
1346  this->m_timeCaller_OutputPort[portNum].isConnected(),
1347  static_cast<FwAssertArgType>(portNum)
1348  );
1349  this->m_timeCaller_OutputPort[portNum].invoke(
1350  time
1351  );
1352  }
1353 
1354 #endif
1355 
1356 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
virtual void TlmRecv_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmRecv.
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port connection.
Definition: ComPortAc.cpp:181
void init()
Initialization function.
Definition: ComPortAc.cpp:162
Operation succeeded.
Definition: Os.hpp:27
virtual Fw::TlmValid TlmGet_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmGet.
PlatformSizeType FwSizeType
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
Fw::InputTlmPort * get_TlmRecv_InputPort(FwIndexType portNum)
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
I32 FwEnumStoreType
void init()
Initialization function.
Status
status returned from the queue send function
Definition: Queue.hpp:30
Fw::TlmValid TlmGet_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmGet.
void init()
Initialization function.
Definition: SchedPortAc.cpp:73
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
BYTE pingInPortSize[Svc::PingPortBuffer::CAPACITY]
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: TlmPortAc.cpp:95
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
void invoke(U32 key) const
Invoke a port connection.
Definition: PingPortAc.cpp:170
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
virtual ~TlmChanComponentBase()
Destroy TlmChanComponentBase object.
void init()
Initialization function.
Definition: TlmPortAc.cpp:89
static constexpr FwIndexType getNum_Run_InputPorts()
No time base has been established (Required)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
Os::Queue m_queue
queue object for active component
void init()
Object initializer.
Definition: ObjBase.cpp:24
Throttle reset count for TlmChanBucketPoolExhausted.
SerializeStatus
forward declaration for string
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
Message will block until space is available.
Definition: Queue.hpp:47
FwIdType FwEventIdType
The type of an event identifier.
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port PktSend.
static constexpr FwSizeType CAPACITY
Definition: PingPortAc.hpp:34
virtual void lock()
Lock the guarded mutex.
#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
Svc::InputSchedPort * get_Run_InputPort(FwIndexType portNum)
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void init()
Initialization function.
Definition: PingPortAc.cpp:151
Hash bucket pool is exhausted; the new telemetry channel was dropped.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
static constexpr FwIndexType getNum_pingIn_InputPorts()
void unLock()
unlock the mutex and assert success
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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 log_WARNING_HI_TlmChanEpochProcessingCapReached(U32 numDeferred, U32 numTimesDeferredCountReached) const
Epoch Processing cap reached; one or more telemetry entries were deferred this cycle.
static constexpr FwIndexType getNum_TlmRecv_InputPorts()
A serious but recoverable event.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
void set_PktSend_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to PktSend[portNum].
static constexpr FwIndexType getNum_eventOut_OutputPorts()
#define PRI_FwIndexType
static constexpr FwIndexType getNum_PktSend_OutputPorts()
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
BlockingType
message type
Definition: Queue.hpp:46
virtual void Run_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port Run.
virtual void Run_handler(FwIndexType portNum, U32 context)=0
Handler for input port Run.
void lock()
lock the mutex and assert success
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:79
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
static constexpr FwIndexType getNum_pingOut_OutputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
message to exit active component task
A message was sent requesting an exit of the loop.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
void TlmRecv_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmRecv.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
PlatformIndexType FwIndexType
virtual void unLock()
Unlock the guarded mutex.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
void incNumMsgDropped()
increment the number of messages dropped
void init()
Initialization function.
Definition: PingPortAc.cpp:73
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:57
Fw::InputTlmGetPort * get_TlmGet_InputPort(FwIndexType portNum)
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:168
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:79
static constexpr FwIndexType getNum_TlmGet_InputPorts()
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
TlmChanComponentBase(const char *compName="")
Construct TlmChanComponentBase object.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
static constexpr FwSizeType CAPACITY
Definition: SchedPortAc.hpp:34
void Run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Run.
void log_WARNING_HI_TlmChanBucketPoolExhausted_ThrottleClear()
Reset throttle value for TlmChanBucketPoolExhausted.
void log_WARNING_HI_TlmChanBucketPoolExhausted(FwChanIdType Id)