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  FW_ASSERT(
784  qStatus == Os::Queue::OP_OK,
785  static_cast<FwAssertArgType>(qStatus)
786  );
787  }
788 
789  // ----------------------------------------------------------------------
790  // Pre-message hooks for typed async input ports
791  //
792  // Each of these functions is invoked just before processing a message
793  // on the corresponding port. By default, they do nothing. You can
794  // override them to provide specific pre-message behavior.
795  // ----------------------------------------------------------------------
796 
799  FwIndexType portNum,
800  U32 context
801  )
802  {
803  // Default: no-op
804  }
805 
808  FwIndexType portNum,
809  U32 key
810  )
811  {
812  // Default: no-op
813  }
814 
815 #if !FW_DIRECT_PORT_CALLS
816 
817  // ----------------------------------------------------------------------
818  // Invocation functions for typed output ports
819  // ----------------------------------------------------------------------
820 
823  FwIndexType portNum,
824  Fw::ComBuffer& data,
825  U32 context
826  ) const
827  {
828  FW_ASSERT(
829  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
830  static_cast<FwAssertArgType>(portNum)
831  );
832 
833  FW_ASSERT(
834  this->m_PktSend_OutputPort[portNum].isConnected(),
835  static_cast<FwAssertArgType>(portNum)
836  );
837  this->m_PktSend_OutputPort[portNum].invoke(
838  data,
839  context
840  );
841  }
842 
845  FwIndexType portNum,
846  U32 key
847  ) const
848  {
849  FW_ASSERT(
850  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
851  static_cast<FwAssertArgType>(portNum)
852  );
853 
854  FW_ASSERT(
855  this->m_pingOut_OutputPort[portNum].isConnected(),
856  static_cast<FwAssertArgType>(portNum)
857  );
858  this->m_pingOut_OutputPort[portNum].invoke(
859  key
860  );
861  }
862 
863 #endif
864 
865  // ----------------------------------------------------------------------
866  // Event logging functions
867  // ----------------------------------------------------------------------
868 
871  U32 numDeferred,
872  U32 numTimesDeferredCountReached
873  ) const
874  {
875  // Get the time
876  Fw::Time _logTime;
877  if (this->isConnected_timeCaller_OutputPort(0)) {
878  this->timeCaller_out(0, _logTime);
879  }
880 
882 
883  // Emit the event on the log port
884  if (this->isConnected_eventOut_OutputPort(0)) {
885  Fw::LogBuffer _logBuff;
887 
888 #if FW_AMPCS_COMPATIBLE
889  // Serialize the number of arguments
890  _status = _logBuff.serializeFrom(static_cast<U8>(2));
891  FW_ASSERT(
892  _status == Fw::FW_SERIALIZE_OK,
893  static_cast<FwAssertArgType>(_status)
894  );
895 #endif
896 
897 #if FW_AMPCS_COMPATIBLE
898  // Serialize the argument size
899  _status = _logBuff.serializeFrom(
900  static_cast<U8>(sizeof(U32))
901  );
902  FW_ASSERT(
903  _status == Fw::FW_SERIALIZE_OK,
904  static_cast<FwAssertArgType>(_status)
905  );
906 #endif
907  _status = _logBuff.serializeFrom(numDeferred);
908  FW_ASSERT(
909  _status == Fw::FW_SERIALIZE_OK,
910  static_cast<FwAssertArgType>(_status)
911  );
912 
913 #if FW_AMPCS_COMPATIBLE
914  // Serialize the argument size
915  _status = _logBuff.serializeFrom(
916  static_cast<U8>(sizeof(U32))
917  );
918  FW_ASSERT(
919  _status == Fw::FW_SERIALIZE_OK,
920  static_cast<FwAssertArgType>(_status)
921  );
922 #endif
923  _status = _logBuff.serializeFrom(numTimesDeferredCountReached);
924  FW_ASSERT(
925  _status == Fw::FW_SERIALIZE_OK,
926  static_cast<FwAssertArgType>(_status)
927  );
928 
929  this->eventOut_out(
930  0,
931  _id,
932  _logTime,
934  _logBuff
935  );
936  }
937 
938  // Emit the event on the text log port
939 #if FW_ENABLE_TEXT_LOGGING
940  if (this->isConnected_eventOutText_OutputPort(0)) {
941 #if FW_OBJECT_NAMES == 1
942  const char* _formatString =
943  "(%s) %s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
944 #else
945  const char* _formatString =
946  "%s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
947 #endif
948 
949  Fw::TextLogString _logString;
950  (void) _logString.format(
951  _formatString,
952 #if FW_OBJECT_NAMES == 1
953  this->m_objName.toChar(),
954 #endif
955  "TlmChanEpochProcessingCapReached ",
956  numDeferred,
957  numTimesDeferredCountReached
958  );
959 
960  this->eventOutText_out(
961  0,
962  _id,
963  _logTime,
965  _logString
966  );
967  }
968 #endif
969  }
970 
973  {
974  // Check throttle value
975  if (this->m_TlmChanBucketPoolExhaustedThrottle >= EVENTID_TLMCHANBUCKETPOOLEXHAUSTED_THROTTLE) {
976  return;
977  }
978  else {
979  this->m_TlmChanBucketPoolExhaustedThrottle++;
980  }
981 
982  // Get the time
983  Fw::Time _logTime;
984  if (this->isConnected_timeCaller_OutputPort(0)) {
985  this->timeCaller_out(0, _logTime);
986  }
987 
989 
990  // Emit the event on the log port
991  if (this->isConnected_eventOut_OutputPort(0)) {
992  Fw::LogBuffer _logBuff;
994 
995 #if FW_AMPCS_COMPATIBLE
996  // Serialize the number of arguments
997  _status = _logBuff.serializeFrom(static_cast<U8>(1));
998  FW_ASSERT(
999  _status == Fw::FW_SERIALIZE_OK,
1000  static_cast<FwAssertArgType>(_status)
1001  );
1002 #endif
1003 
1004 #if FW_AMPCS_COMPATIBLE
1005  // Serialize the argument size
1006  _status = _logBuff.serializeFrom(
1007  static_cast<U8>(sizeof(FwChanIdType))
1008  );
1009  FW_ASSERT(
1010  _status == Fw::FW_SERIALIZE_OK,
1011  static_cast<FwAssertArgType>(_status)
1012  );
1013 #endif
1014  _status = _logBuff.serializeFrom(Id);
1015  FW_ASSERT(
1016  _status == Fw::FW_SERIALIZE_OK,
1017  static_cast<FwAssertArgType>(_status)
1018  );
1019 
1020  this->eventOut_out(
1021  0,
1022  _id,
1023  _logTime,
1025  _logBuff
1026  );
1027  }
1028 
1029  // Emit the event on the text log port
1030 #if FW_ENABLE_TEXT_LOGGING
1031  if (this->isConnected_eventOutText_OutputPort(0)) {
1032 #if FW_OBJECT_NAMES == 1
1033  const char* _formatString =
1034  "(%s) %s: TlmChan bucket pool exhausted: dropping new telemetry ID 0x%" PRIx32 "";
1035 #else
1036  const char* _formatString =
1037  "%s: TlmChan bucket pool exhausted: dropping new telemetry ID 0x%" PRIx32 "";
1038 #endif
1039 
1040  Fw::TextLogString _logString;
1041  (void) _logString.format(
1042  _formatString,
1043 #if FW_OBJECT_NAMES == 1
1044  this->m_objName.toChar(),
1045 #endif
1046  "TlmChanBucketPoolExhausted ",
1047  Id
1048  );
1049 
1050  this->eventOutText_out(
1051  0,
1052  _id,
1053  _logTime,
1055  _logString
1056  );
1057  }
1058 #endif
1059  }
1060 
1061  // ----------------------------------------------------------------------
1062  // Event throttle reset functions
1063  // ----------------------------------------------------------------------
1064 
1067  {
1068  // Reset throttle counter
1069  this->m_TlmChanBucketPoolExhaustedThrottle = 0;
1070  }
1071 
1072  // ----------------------------------------------------------------------
1073  // Time
1074  // ----------------------------------------------------------------------
1075 
1077  getTime() const
1078  {
1079  if (this->isConnected_timeCaller_OutputPort(0)) {
1080  Fw::Time _time;
1081  this->timeCaller_out(0, _time);
1082  return _time;
1083  }
1084  else {
1085  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1086  }
1087  }
1088 
1089  // ----------------------------------------------------------------------
1090  // Mutex operations for guarded ports
1091  //
1092  // You can override these operations to provide more sophisticated
1093  // synchronization
1094  // ----------------------------------------------------------------------
1095 
1098  {
1099  this->m_guardedPortMutex.lock();
1100  }
1101 
1104  {
1105  this->m_guardedPortMutex.unLock();
1106  }
1107 
1108  // ----------------------------------------------------------------------
1109  // Message dispatch functions
1110  // ----------------------------------------------------------------------
1111 
1112  Fw::QueuedComponentBase::MsgDispatchStatus TlmChanComponentBase ::
1113  doDispatch()
1114  {
1115  ComponentIpcSerializableBuffer _msg;
1116  FwQueuePriorityType _priority = 0;
1117 
1118  Os::Queue::Status _msgStatus = this->m_queue.receive(
1119  _msg,
1121  _priority
1122  );
1123  FW_ASSERT(
1124  _msgStatus == Os::Queue::OP_OK,
1125  static_cast<FwAssertArgType>(_msgStatus)
1126  );
1127 
1128  // Reset to beginning of buffer
1129  _msg.resetDeser();
1130 
1131  FwEnumStoreType _desMsg = 0;
1132  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1133  FW_ASSERT(
1134  _deserStatus == Fw::FW_SERIALIZE_OK,
1135  static_cast<FwAssertArgType>(_deserStatus)
1136  );
1137 
1138  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1139 
1140  if (_msgType == TLMCHAN_COMPONENT_EXIT) {
1141  return MSG_DISPATCH_EXIT;
1142  }
1143 
1144  FwIndexType portNum = 0;
1145  _deserStatus = _msg.deserializeTo(portNum);
1146  FW_ASSERT(
1147  _deserStatus == Fw::FW_SERIALIZE_OK,
1148  static_cast<FwAssertArgType>(_deserStatus)
1149  );
1150 
1151  switch (_msgType) {
1152  // Handle async input port Run
1153  case RUN_SCHED: {
1154  // Deserialize argument context
1155  U32 context;
1156  _deserStatus = _msg.deserializeTo(context);
1157  FW_ASSERT(
1158  _deserStatus == Fw::FW_SERIALIZE_OK,
1159  static_cast<FwAssertArgType>(_deserStatus)
1160  );
1161  // Call handler function
1162  this->Run_handler(
1163  portNum,
1164  context
1165  );
1166 
1167  break;
1168  }
1169 
1170  // Handle async input port pingIn
1171  case PINGIN_PING: {
1172  // Deserialize argument key
1173  U32 key;
1174  _deserStatus = _msg.deserializeTo(key);
1175  FW_ASSERT(
1176  _deserStatus == Fw::FW_SERIALIZE_OK,
1177  static_cast<FwAssertArgType>(_deserStatus)
1178  );
1179  // Call handler function
1180  this->pingIn_handler(
1181  portNum,
1182  key
1183  );
1184 
1185  break;
1186  }
1187 
1188  default:
1189  return MSG_DISPATCH_ERROR;
1190  }
1191 
1192  return MSG_DISPATCH_OK;
1193  }
1194 
1195  // ----------------------------------------------------------------------
1196  // Calls for messages received on typed input ports
1197  // ----------------------------------------------------------------------
1198 
1199  void TlmChanComponentBase ::
1200  m_p_Run_in(
1201  Fw::PassiveComponentBase* callComp,
1202  FwIndexType portNum,
1203  U32 context
1204  )
1205  {
1206  FW_ASSERT(callComp != nullptr);
1207  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1208  compPtr->Run_handlerBase(
1209  portNum,
1210  context
1211  );
1212  }
1213 
1214  Fw::TlmValid TlmChanComponentBase ::
1215  m_p_TlmGet_in(
1216  Fw::PassiveComponentBase* callComp,
1217  FwIndexType portNum,
1218  FwChanIdType id,
1219  Fw::Time& timeTag,
1220  Fw::TlmBuffer& val
1221  )
1222  {
1223  FW_ASSERT(callComp != nullptr);
1224  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1225  return compPtr->TlmGet_handlerBase(
1226  portNum,
1227  id,
1228  timeTag,
1229  val
1230  );
1231  }
1232 
1233  void TlmChanComponentBase ::
1234  m_p_TlmRecv_in(
1235  Fw::PassiveComponentBase* callComp,
1236  FwIndexType portNum,
1237  FwChanIdType id,
1238  Fw::Time& timeTag,
1239  Fw::TlmBuffer& val
1240  )
1241  {
1242  FW_ASSERT(callComp != nullptr);
1243  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1244  compPtr->TlmRecv_handlerBase(
1245  portNum,
1246  id,
1247  timeTag,
1248  val
1249  );
1250  }
1251 
1252  void TlmChanComponentBase ::
1253  m_p_pingIn_in(
1254  Fw::PassiveComponentBase* callComp,
1255  FwIndexType portNum,
1256  U32 key
1257  )
1258  {
1259  FW_ASSERT(callComp != nullptr);
1260  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1261  compPtr->pingIn_handlerBase(
1262  portNum,
1263  key
1264  );
1265  }
1266 
1267 #if !FW_DIRECT_PORT_CALLS
1268 
1269  // ----------------------------------------------------------------------
1270  // Invocation functions for special output ports
1271  // ----------------------------------------------------------------------
1272 
1273  void TlmChanComponentBase ::
1274  eventOut_out(
1275  FwIndexType portNum,
1276  FwEventIdType id,
1277  Fw::Time& timeTag,
1278  const Fw::LogSeverity& severity,
1279  Fw::LogBuffer& args
1280  ) const
1281  {
1282  FW_ASSERT(
1283  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
1284  static_cast<FwAssertArgType>(portNum)
1285  );
1286 
1287  FW_ASSERT(
1288  this->m_eventOut_OutputPort[portNum].isConnected(),
1289  static_cast<FwAssertArgType>(portNum)
1290  );
1291  this->m_eventOut_OutputPort[portNum].invoke(
1292  id,
1293  timeTag,
1294  severity,
1295  args
1296  );
1297  }
1298 
1299 #if FW_ENABLE_TEXT_LOGGING
1300 
1301  void TlmChanComponentBase ::
1302  eventOutText_out(
1303  FwIndexType portNum,
1304  FwEventIdType id,
1305  Fw::Time& timeTag,
1306  const Fw::LogSeverity& severity,
1307  Fw::TextLogString& text
1308  ) const
1309  {
1310  FW_ASSERT(
1311  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
1312  static_cast<FwAssertArgType>(portNum)
1313  );
1314 
1315  FW_ASSERT(
1316  this->m_eventOutText_OutputPort[portNum].isConnected(),
1317  static_cast<FwAssertArgType>(portNum)
1318  );
1319  this->m_eventOutText_OutputPort[portNum].invoke(
1320  id,
1321  timeTag,
1322  severity,
1323  text
1324  );
1325  }
1326 
1327 #endif
1328 
1329  void TlmChanComponentBase ::
1330  timeCaller_out(
1331  FwIndexType portNum,
1332  Fw::Time& time
1333  ) const
1334  {
1335  FW_ASSERT(
1336  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1337  static_cast<FwAssertArgType>(portNum)
1338  );
1339 
1340  FW_ASSERT(
1341  this->m_timeCaller_OutputPort[portNum].isConnected(),
1342  static_cast<FwAssertArgType>(portNum)
1343  );
1344  this->m_timeCaller_OutputPort[portNum].invoke(
1345  time
1346  );
1347  }
1348 
1349 #endif
1350 
1351 }
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
message to exit active component task
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
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
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.
Epoch Processing cap reached; one or more telemetry entries were deferred this cycle.
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
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
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
static constexpr FwIndexType getNum_pingIn_InputPorts()
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
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
Throttle reset count for TlmChanBucketPoolExhausted.
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.
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)
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.
Hash bucket pool is exhausted; the new telemetry channel was dropped.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
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 lock()
lock the mutex and assert success
Definition: Mutex.cpp:34
void log_WARNING_HI_TlmChanBucketPoolExhausted_ThrottleClear()
Reset throttle value for TlmChanBucketPoolExhausted.
void log_WARNING_HI_TlmChanBucketPoolExhausted(FwChanIdType Id)