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"
30 
31 namespace Svc {
32 
39  {
40 
41  // ----------------------------------------------------------------------
42  // Friend classes
43  // ----------------------------------------------------------------------
44 
46  friend class TlmChanTesterBase;
48  friend class TlmChanTester;
49 
50  protected:
51 
52  // ----------------------------------------------------------------------
53  // Constants
54  // ----------------------------------------------------------------------
55 
57  enum {
62  };
63 
65  enum {
69  };
70 
72  enum {
75  };
76 
78  enum {
80  };
81 
82  public:
83 
84  // ----------------------------------------------------------------------
85  // Component initialization
86  // ----------------------------------------------------------------------
87 
89  void init(
90  FwSizeType queueDepth,
91  FwEnumStoreType instance = 0
92  );
93 
94 #if !FW_DIRECT_PORT_CALLS
95 
96  public:
97 
98  // ----------------------------------------------------------------------
99  // Getters for typed input ports
100  // ----------------------------------------------------------------------
101 
106  FwIndexType portNum
107  );
108 
113  FwIndexType portNum
114  );
115 
120  FwIndexType portNum
121  );
122 
127  FwIndexType portNum
128  );
129 
130 #endif
131 
132 #if !FW_DIRECT_PORT_CALLS
133 
134  public:
135 
136  // ----------------------------------------------------------------------
137  // Connect input ports to special output ports
138  // ----------------------------------------------------------------------
139 
142  FwIndexType portNum,
143  Fw::InputLogPort* port
144  );
145 
146 #if FW_ENABLE_TEXT_LOGGING == 1
147 
149  void set_eventOutText_OutputPort(
150  FwIndexType portNum,
151  Fw::InputLogTextPort* port
152  );
153 
154 #endif
155 
158  FwIndexType portNum,
159  Fw::InputTimePort* port
160  );
161 
162 #endif
163 
164 #if !FW_DIRECT_PORT_CALLS
165 
166  public:
167 
168  // ----------------------------------------------------------------------
169  // Connect typed input ports to typed output ports
170  // ----------------------------------------------------------------------
171 
174  FwIndexType portNum,
175  Fw::InputComPort* port
176  );
177 
180  FwIndexType portNum,
181  Svc::InputPingPort* port
182  );
183 
184 #endif
185 
186 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
187 
188  public:
189 
190  // ----------------------------------------------------------------------
191  // Connect serial input ports to special output ports
192  // ----------------------------------------------------------------------
193 
196  FwIndexType portNum,
197  Fw::InputSerializePort* port
198  );
199 
200 #if FW_ENABLE_TEXT_LOGGING == 1
201 
203  void set_eventOutText_OutputPort(
204  FwIndexType portNum,
205  Fw::InputSerializePort* port
206  );
207 
208 #endif
209 
212  FwIndexType portNum,
213  Fw::InputSerializePort* port
214  );
215 
216 #endif
217 
218 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
219 
220  public:
221 
222  // ----------------------------------------------------------------------
223  // Connect serial input ports to typed output ports
224  // ----------------------------------------------------------------------
225 
228  FwIndexType portNum,
229  Fw::InputSerializePort* port
230  );
231 
234  FwIndexType portNum,
235  Fw::InputSerializePort* port
236  );
237 
238 #endif
239 
240  protected:
241 
242  // ----------------------------------------------------------------------
243  // Component construction and destruction
244  // ----------------------------------------------------------------------
245 
248  const char* compName = ""
249  );
250 
252  virtual ~TlmChanComponentBase();
253 
254  protected:
255 
256  // ----------------------------------------------------------------------
257  // Getters for numbers of typed input ports
258  // ----------------------------------------------------------------------
259 
263  static constexpr FwIndexType getNum_Run_InputPorts() {
264  return NUM_RUN_INPUT_PORTS;
265  }
266 
271  return NUM_TLMGET_INPUT_PORTS;
272  }
273 
279  }
280 
285  return NUM_PINGIN_INPUT_PORTS;
286  }
287 
288  protected:
289 
290  // ----------------------------------------------------------------------
291  // Getters for numbers of special output ports
292  // ----------------------------------------------------------------------
293 
299  }
300 
301 #if FW_ENABLE_TEXT_LOGGING == 1
302 
306  static constexpr FwIndexType getNum_eventOutText_OutputPorts() {
308  }
309 
310 #endif
311 
317  }
318 
319  protected:
320 
321  // ----------------------------------------------------------------------
322  // Getters for numbers of typed output ports
323  // ----------------------------------------------------------------------
324 
330  }
331 
337  }
338 
339  protected:
340 
341  // ----------------------------------------------------------------------
342  // Connection status queries for special output ports
343  // ----------------------------------------------------------------------
344 
349  FwIndexType portNum
350  ) const;
351 
352 #if FW_ENABLE_TEXT_LOGGING == 1
353 
357  bool isConnected_eventOutText_OutputPort(
358  FwIndexType portNum
359  ) const;
360 
361 #endif
362 
367  FwIndexType portNum
368  ) const;
369 
370  protected:
371 
372  // ----------------------------------------------------------------------
373  // Connection status queries for typed output ports
374  // ----------------------------------------------------------------------
375 
380  FwIndexType portNum
381  ) const;
382 
387  FwIndexType portNum
388  ) const;
389 
390  protected:
391 
392  // ----------------------------------------------------------------------
393  // Handlers to implement for typed input ports
394  // ----------------------------------------------------------------------
395 
397  virtual void Run_handler(
398  FwIndexType portNum,
399  U32 context
400  ) = 0;
401 
404  FwIndexType portNum,
405  FwChanIdType id,
406  Fw::Time& timeTag,
407  Fw::TlmBuffer& val
408  ) = 0;
411 
413  virtual void TlmRecv_handler(
414  FwIndexType portNum,
415  FwChanIdType id,
416  Fw::Time& timeTag,
417  Fw::TlmBuffer& val
418  ) = 0;
419 
421  virtual void pingIn_handler(
422  FwIndexType portNum,
423  U32 key
424  ) = 0;
425 
426 #if FW_DIRECT_PORT_CALLS
427  public:
428 #else
429  protected:
430 #endif
431 
432  // ----------------------------------------------------------------------
433  // Port handler base-class functions for typed input ports
434  //
435  // Call these functions directly to bypass the corresponding ports
436  // ----------------------------------------------------------------------
437 
439  void Run_handlerBase(
440  FwIndexType portNum,
441  U32 context
442  );
443 
446  FwIndexType portNum,
447  FwChanIdType id,
448  Fw::Time& timeTag,
449  Fw::TlmBuffer& val
450  );
453 
455  void TlmRecv_handlerBase(
456  FwIndexType portNum,
457  FwChanIdType id,
458  Fw::Time& timeTag,
459  Fw::TlmBuffer& val
460  );
461 
463  void pingIn_handlerBase(
464  FwIndexType portNum,
465  U32 key
466  );
467 
468  protected:
469 
470  // ----------------------------------------------------------------------
471  // Pre-message hooks for typed async input ports
472  //
473  // Each of these functions is invoked just before processing a message
474  // on the corresponding port. By default, they do nothing. You can
475  // override them to provide specific pre-message behavior.
476  // ----------------------------------------------------------------------
477 
479  virtual void Run_preMsgHook(
480  FwIndexType portNum,
481  U32 context
482  );
483 
485  virtual void pingIn_preMsgHook(
486  FwIndexType portNum,
487  U32 key
488  );
489 
490  protected:
491 
492  // ----------------------------------------------------------------------
493  // Invocation functions for typed output ports
494  // ----------------------------------------------------------------------
495 
497  void PktSend_out(
498  FwIndexType portNum,
499  Fw::ComBuffer& data,
500  U32 context
501  ) const;
502 
504  void pingOut_out(
505  FwIndexType portNum,
506  U32 key
507  ) const;
508 
509  protected:
510 
511  // ----------------------------------------------------------------------
512  // Event logging functions
513  // ----------------------------------------------------------------------
514 
519  U32 numDeferred,
520  U32 numTimesDeferredCountReached
521  ) const;
522 
523  protected:
524 
525  // ----------------------------------------------------------------------
526  // Time
527  // ----------------------------------------------------------------------
528 
532  Fw::Time getTime() const;
533 
534  protected:
535 
536  // ----------------------------------------------------------------------
537  // Mutex operations for guarded ports
538  //
539  // You can override these operations to provide more sophisticated
540  // synchronization
541  // ----------------------------------------------------------------------
542 
544  virtual void lock();
545 
547  virtual void unLock();
548 
549  private:
550 
551  // ----------------------------------------------------------------------
552  // Message dispatch functions
553  // ----------------------------------------------------------------------
554 
556  virtual MsgDispatchStatus doDispatch();
557 
558  private:
559 
560  // ----------------------------------------------------------------------
561  // Calls for messages received on typed input ports
562  // ----------------------------------------------------------------------
563 
565  static void m_p_Run_in(
566  Fw::PassiveComponentBase* callComp,
567  FwIndexType portNum,
568  U32 context
569  );
570 
572  static Fw::TlmValid m_p_TlmGet_in(
573  Fw::PassiveComponentBase* callComp,
574  FwIndexType portNum,
575  FwChanIdType id,
576  Fw::Time& timeTag,
577  Fw::TlmBuffer& val
578  );
581 
583  static void m_p_TlmRecv_in(
584  Fw::PassiveComponentBase* callComp,
585  FwIndexType portNum,
586  FwChanIdType id,
587  Fw::Time& timeTag,
588  Fw::TlmBuffer& val
589  );
590 
592  static void m_p_pingIn_in(
593  Fw::PassiveComponentBase* callComp,
594  FwIndexType portNum,
595  U32 key
596  );
597 
598  private:
599 
600  // ----------------------------------------------------------------------
601  // Invocation functions for special output ports
602  // ----------------------------------------------------------------------
603 
605  void eventOut_out(
606  FwIndexType portNum,
607  FwEventIdType id,
608  Fw::Time& timeTag,
609  const Fw::LogSeverity& severity,
610  Fw::LogBuffer& args
611  ) const;
612 
613 #if FW_ENABLE_TEXT_LOGGING
614 
616  void eventOutText_out(
617  FwIndexType portNum,
618  FwEventIdType id,
619  Fw::Time& timeTag,
620  const Fw::LogSeverity& severity,
621  Fw::TextLogString& text
622  ) const;
623 
624 #endif
625 
627  void timeCaller_out(
628  FwIndexType portNum,
629  Fw::Time& time
630  ) const;
631 
632 #if !FW_DIRECT_PORT_CALLS
633 
634  private:
635 
636  // ----------------------------------------------------------------------
637  // Typed input ports
638  // ----------------------------------------------------------------------
639 
641  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
642 
644  Fw::InputTlmGetPort m_TlmGet_InputPort[NUM_TLMGET_INPUT_PORTS];
645 
647  Fw::InputTlmPort m_TlmRecv_InputPort[NUM_TLMRECV_INPUT_PORTS];
648 
650  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
651 
652 #endif
653 
654 #if !FW_DIRECT_PORT_CALLS
655 
656  private:
657 
658  // ----------------------------------------------------------------------
659  // Special output ports
660  // ----------------------------------------------------------------------
661 
663  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
664 
665 #if FW_ENABLE_TEXT_LOGGING == 1
666 
668  Fw::OutputLogTextPort m_eventOutText_OutputPort[NUM_EVENTOUTTEXT_OUTPUT_PORTS];
669 
670 #endif
671 
673  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
674 
675 #endif
676 
677 #if !FW_DIRECT_PORT_CALLS
678 
679  private:
680 
681  // ----------------------------------------------------------------------
682  // Typed output ports
683  // ----------------------------------------------------------------------
684 
686  Fw::OutputComPort m_PktSend_OutputPort[NUM_PKTSEND_OUTPUT_PORTS];
687 
689  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
690 
691 #endif
692 
693  private:
694 
695  // ----------------------------------------------------------------------
696  // Mutexes
697  // ----------------------------------------------------------------------
698 
700  Os::Mutex m_guardedPortMutex;
701 
702  };
703 
704 }
705 
706 #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.
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
Epoch Processing cap reached; one or more telemetry entries were deferred this cycle.
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()
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.
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.