F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TlmChanComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TlmChanComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for TlmChan component base class
5 // ======================================================================
6 
7 #ifndef Svc_TlmChanComponentAc_HPP
8 #define Svc_TlmChanComponentAc_HPP
9 
10 #include <atomic>
11 
12 #include "Fw/Com/ComPortAc.hpp"
14 #include "Fw/FPrimeBasicTypes.hpp"
15 #include "Fw/Log/LogPortAc.hpp"
16 #include "Fw/Log/LogString.hpp"
17 #include "Fw/Log/LogTextPortAc.hpp"
18 #if !FW_DIRECT_PORT_CALLS
20 #endif
21 #if !FW_DIRECT_PORT_CALLS
23 #endif
24 #include "Fw/Time/TimePortAc.hpp"
25 #include "Fw/Tlm/TlmGetPortAc.hpp"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Os/Mutex.hpp"
28 #include "Svc/Ping/PingPortAc.hpp"
31 
32 namespace Svc {
33 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
47  friend class TlmChanTesterBase;
49  friend class TlmChanTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
63  };
64 
66  enum {
70  };
71 
73  enum {
76  };
77 
79  enum {
82  };
83 
85  enum {
87  };
88 
89  public:
90 
91  // ----------------------------------------------------------------------
92  // Component initialization
93  // ----------------------------------------------------------------------
94 
96  void init(
97  FwSizeType queueDepth,
98  FwEnumStoreType instance = 0
99  );
100 
101 #if !FW_DIRECT_PORT_CALLS
102 
103  public:
104 
105  // ----------------------------------------------------------------------
106  // Getters for typed input ports
107  // ----------------------------------------------------------------------
108 
113  FwIndexType portNum
114  );
115 
120  FwIndexType portNum
121  );
122 
127  FwIndexType portNum
128  );
129 
134  FwIndexType portNum
135  );
136 
137 #endif
138 
139 #if !FW_DIRECT_PORT_CALLS
140 
141  public:
142 
143  // ----------------------------------------------------------------------
144  // Connect input ports to special output ports
145  // ----------------------------------------------------------------------
146 
149  FwIndexType portNum,
150  Fw::InputLogPort* port
151  );
152 
153 #if FW_ENABLE_TEXT_LOGGING == 1
154 
156  void set_eventOutText_OutputPort(
157  FwIndexType portNum,
158  Fw::InputLogTextPort* port
159  );
160 
161 #endif
162 
165  FwIndexType portNum,
166  Fw::InputTimePort* port
167  );
168 
169 #endif
170 
171 #if !FW_DIRECT_PORT_CALLS
172 
173  public:
174 
175  // ----------------------------------------------------------------------
176  // Connect typed input ports to typed output ports
177  // ----------------------------------------------------------------------
178 
181  FwIndexType portNum,
182  Fw::InputComPort* port
183  );
184 
187  FwIndexType portNum,
188  Svc::InputPingPort* port
189  );
190 
191 #endif
192 
193 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
194 
195  public:
196 
197  // ----------------------------------------------------------------------
198  // Connect serial input ports to special output ports
199  // ----------------------------------------------------------------------
200 
203  FwIndexType portNum,
204  Fw::InputSerializePort* port
205  );
206 
207 #if FW_ENABLE_TEXT_LOGGING == 1
208 
210  void set_eventOutText_OutputPort(
211  FwIndexType portNum,
212  Fw::InputSerializePort* port
213  );
214 
215 #endif
216 
219  FwIndexType portNum,
220  Fw::InputSerializePort* port
221  );
222 
223 #endif
224 
225 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
226 
227  public:
228 
229  // ----------------------------------------------------------------------
230  // Connect serial input ports to typed output ports
231  // ----------------------------------------------------------------------
232 
235  FwIndexType portNum,
236  Fw::InputSerializePort* port
237  );
238 
241  FwIndexType portNum,
242  Fw::InputSerializePort* port
243  );
244 
245 #endif
246 
247  protected:
248 
249  // ----------------------------------------------------------------------
250  // Component construction and destruction
251  // ----------------------------------------------------------------------
252 
255  const char* compName = ""
256  );
257 
259  virtual ~TlmChanComponentBase();
260 
261  protected:
262 
263  // ----------------------------------------------------------------------
264  // Getters for numbers of typed input ports
265  // ----------------------------------------------------------------------
266 
270  static constexpr FwIndexType getNum_Run_InputPorts() {
271  return NUM_RUN_INPUT_PORTS;
272  }
273 
278  return NUM_TLMGET_INPUT_PORTS;
279  }
280 
286  }
287 
292  return NUM_PINGIN_INPUT_PORTS;
293  }
294 
295  protected:
296 
297  // ----------------------------------------------------------------------
298  // Getters for numbers of special output ports
299  // ----------------------------------------------------------------------
300 
306  }
307 
308 #if FW_ENABLE_TEXT_LOGGING == 1
309 
313  static constexpr FwIndexType getNum_eventOutText_OutputPorts() {
315  }
316 
317 #endif
318 
324  }
325 
326  protected:
327 
328  // ----------------------------------------------------------------------
329  // Getters for numbers of typed output ports
330  // ----------------------------------------------------------------------
331 
337  }
338 
344  }
345 
346  protected:
347 
348  // ----------------------------------------------------------------------
349  // Connection status queries for special output ports
350  // ----------------------------------------------------------------------
351 
356  FwIndexType portNum
357  ) const;
358 
359 #if FW_ENABLE_TEXT_LOGGING == 1
360 
364  bool isConnected_eventOutText_OutputPort(
365  FwIndexType portNum
366  ) const;
367 
368 #endif
369 
374  FwIndexType portNum
375  ) const;
376 
377  protected:
378 
379  // ----------------------------------------------------------------------
380  // Connection status queries for typed output ports
381  // ----------------------------------------------------------------------
382 
387  FwIndexType portNum
388  ) const;
389 
394  FwIndexType portNum
395  ) const;
396 
397  protected:
398 
399  // ----------------------------------------------------------------------
400  // Handlers to implement for typed input ports
401  // ----------------------------------------------------------------------
402 
404  virtual void Run_handler(
405  FwIndexType portNum,
406  U32 context
407  ) = 0;
408 
411  FwIndexType portNum,
412  FwChanIdType id,
413  Fw::Time& timeTag,
414  Fw::TlmBuffer& val
415  ) = 0;
418 
420  virtual void TlmRecv_handler(
421  FwIndexType portNum,
422  FwChanIdType id,
423  Fw::Time& timeTag,
424  Fw::TlmBuffer& val
425  ) = 0;
426 
428  virtual void pingIn_handler(
429  FwIndexType portNum,
430  U32 key
431  ) = 0;
432 
433 #if FW_DIRECT_PORT_CALLS
434  public:
435 #else
436  protected:
437 #endif
438 
439  // ----------------------------------------------------------------------
440  // Port handler base-class functions for typed input ports
441  //
442  // Call these functions directly to bypass the corresponding ports
443  // ----------------------------------------------------------------------
444 
446  void Run_handlerBase(
447  FwIndexType portNum,
448  U32 context
449  );
450 
453  FwIndexType portNum,
454  FwChanIdType id,
455  Fw::Time& timeTag,
456  Fw::TlmBuffer& val
457  );
460 
462  void TlmRecv_handlerBase(
463  FwIndexType portNum,
464  FwChanIdType id,
465  Fw::Time& timeTag,
466  Fw::TlmBuffer& val
467  );
468 
470  void pingIn_handlerBase(
471  FwIndexType portNum,
472  U32 key
473  );
474 
475  protected:
476 
477  // ----------------------------------------------------------------------
478  // Pre-message hooks for typed async input ports
479  //
480  // Each of these functions is invoked just before processing a message
481  // on the corresponding port. By default, they do nothing. You can
482  // override them to provide specific pre-message behavior.
483  // ----------------------------------------------------------------------
484 
486  virtual void Run_preMsgHook(
487  FwIndexType portNum,
488  U32 context
489  );
490 
492  virtual void pingIn_preMsgHook(
493  FwIndexType portNum,
494  U32 key
495  );
496 
497  protected:
498 
499  // ----------------------------------------------------------------------
500  // Invocation functions for typed output ports
501  // ----------------------------------------------------------------------
502 
504  void PktSend_out(
505  FwIndexType portNum,
506  Fw::ComBuffer& data,
507  U32 context
508  ) const;
509 
511  void pingOut_out(
512  FwIndexType portNum,
513  U32 key
514  ) const;
515 
516  protected:
517 
518  // ----------------------------------------------------------------------
519  // Event logging functions
520  // ----------------------------------------------------------------------
521 
526  U32 numDeferred,
527  U32 numTimesDeferredCountReached
528  ) const;
529 
534  FwChanIdType Id
535  );
536 
537  protected:
538 
539  // ----------------------------------------------------------------------
540  // Event throttle reset functions
541  // ----------------------------------------------------------------------
542 
545 
546  protected:
547 
548  // ----------------------------------------------------------------------
549  // Time
550  // ----------------------------------------------------------------------
551 
555  Fw::Time getTime() const;
556 
557  protected:
558 
559  // ----------------------------------------------------------------------
560  // Mutex operations for guarded ports
561  //
562  // You can override these operations to provide more sophisticated
563  // synchronization
564  // ----------------------------------------------------------------------
565 
567  virtual void lock();
568 
570  virtual void unLock();
571 
572  private:
573 
574  // ----------------------------------------------------------------------
575  // Message dispatch functions
576  // ----------------------------------------------------------------------
577 
579  virtual MsgDispatchStatus doDispatch();
580 
581  private:
582 
583  // ----------------------------------------------------------------------
584  // Calls for messages received on typed input ports
585  // ----------------------------------------------------------------------
586 
588  static void m_p_Run_in(
589  Fw::PassiveComponentBase* callComp,
590  FwIndexType portNum,
591  U32 context
592  );
593 
595  static Fw::TlmValid m_p_TlmGet_in(
596  Fw::PassiveComponentBase* callComp,
597  FwIndexType portNum,
598  FwChanIdType id,
599  Fw::Time& timeTag,
600  Fw::TlmBuffer& val
601  );
604 
606  static void m_p_TlmRecv_in(
607  Fw::PassiveComponentBase* callComp,
608  FwIndexType portNum,
609  FwChanIdType id,
610  Fw::Time& timeTag,
611  Fw::TlmBuffer& val
612  );
613 
615  static void m_p_pingIn_in(
616  Fw::PassiveComponentBase* callComp,
617  FwIndexType portNum,
618  U32 key
619  );
620 
621  private:
622 
623  // ----------------------------------------------------------------------
624  // Invocation functions for special output ports
625  // ----------------------------------------------------------------------
626 
628  void eventOut_out(
629  FwIndexType portNum,
630  FwEventIdType id,
631  Fw::Time& timeTag,
632  const Fw::LogSeverity& severity,
633  Fw::LogBuffer& args
634  ) const;
635 
636 #if FW_ENABLE_TEXT_LOGGING
637 
639  void eventOutText_out(
640  FwIndexType portNum,
641  FwEventIdType id,
642  Fw::Time& timeTag,
643  const Fw::LogSeverity& severity,
644  Fw::TextLogString& text
645  ) const;
646 
647 #endif
648 
650  void timeCaller_out(
651  FwIndexType portNum,
652  Fw::Time& time
653  ) const;
654 
655 #if !FW_DIRECT_PORT_CALLS
656 
657  private:
658 
659  // ----------------------------------------------------------------------
660  // Typed input ports
661  // ----------------------------------------------------------------------
662 
664  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
665 
667  Fw::InputTlmGetPort m_TlmGet_InputPort[NUM_TLMGET_INPUT_PORTS];
668 
670  Fw::InputTlmPort m_TlmRecv_InputPort[NUM_TLMRECV_INPUT_PORTS];
671 
673  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
674 
675 #endif
676 
677 #if !FW_DIRECT_PORT_CALLS
678 
679  private:
680 
681  // ----------------------------------------------------------------------
682  // Special output ports
683  // ----------------------------------------------------------------------
684 
686  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
687 
688 #if FW_ENABLE_TEXT_LOGGING == 1
689 
691  Fw::OutputLogTextPort m_eventOutText_OutputPort[NUM_EVENTOUTTEXT_OUTPUT_PORTS];
692 
693 #endif
694 
696  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
697 
698 #endif
699 
700 #if !FW_DIRECT_PORT_CALLS
701 
702  private:
703 
704  // ----------------------------------------------------------------------
705  // Typed output ports
706  // ----------------------------------------------------------------------
707 
709  Fw::OutputComPort m_PktSend_OutputPort[NUM_PKTSEND_OUTPUT_PORTS];
710 
712  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
713 
714 #endif
715 
716  private:
717 
718  // ----------------------------------------------------------------------
719  // Counter values for event throttling
720  // ----------------------------------------------------------------------
721 
723  std::atomic<FwIndexType> m_TlmChanBucketPoolExhaustedThrottle;
724 
725  private:
726 
727  // ----------------------------------------------------------------------
728  // Mutexes
729  // ----------------------------------------------------------------------
730 
732  Os::Mutex m_guardedPortMutex;
733 
734  };
735 
736 }
737 
738 #endif
virtual void TlmRecv_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmRecv.
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)
I32 FwEnumStoreType
friend class TlmChanTesterBase
Friend class tester to support autocoded test harness.
Fw::TlmValid TlmGet_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmGet.
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
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.
Auto-generated base for TlmChan component.
static constexpr FwIndexType getNum_Run_InputPorts()
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
FwIdType FwEventIdType
The type of an event identifier.
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port PktSend.
virtual void lock()
Lock the guarded mutex.
Svc::InputSchedPort * get_Run_InputPort(FwIndexType portNum)
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
static constexpr FwIndexType getNum_pingIn_InputPorts()
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void log_WARNING_HI_TlmChanEpochProcessingCapReached(U32 numDeferred, U32 numTimesDeferredCountReached) const
static constexpr FwIndexType getNum_TlmRecv_InputPorts()
Enum representing event severity.
void set_PktSend_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to PktSend[portNum].
static constexpr FwIndexType getNum_eventOut_OutputPorts()
static constexpr FwIndexType getNum_PktSend_OutputPorts()
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.
static constexpr FwIndexType getNum_pingOut_OutputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
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.
friend class TlmChanTester
Friend class tester implementation to support white-box testing.
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].
RateGroupDivider component implementation.
Fw::InputTlmGetPort * get_TlmGet_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
static constexpr FwIndexType getNum_TlmGet_InputPorts()
TlmChanComponentBase(const char *compName="")
Construct TlmChanComponentBase object.
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)