F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
BufferManagerComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferManagerComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for BufferManager component base class
5 // ======================================================================
6 
7 #ifndef Svc_BufferManagerComponentAc_HPP
8 #define Svc_BufferManagerComponentAc_HPP
9 
10 #include <atomic>
11 
15 #include "Fw/FPrimeBasicTypes.hpp"
16 #include "Fw/Log/LogPortAc.hpp"
17 #include "Fw/Log/LogString.hpp"
18 #if FW_ENABLE_TEXT_LOGGING == 1
19 #include "Fw/Log/LogTextPortAc.hpp"
20 #endif
23 #include "Fw/Time/TimePortAc.hpp"
24 #include "Fw/Tlm/TlmPortAc.hpp"
25 #include "Fw/Tlm/TlmString.hpp"
26 #include "Os/Mutex.hpp"
29 
30 namespace Svc {
31 
38  {
39 
40  // ----------------------------------------------------------------------
41  // Friend classes
42  // ----------------------------------------------------------------------
43 
47  friend class BufferManagerTester;
48 
49  protected:
50 
51  // ----------------------------------------------------------------------
52  // Constants
53  // ----------------------------------------------------------------------
54 
56  enum {
60  };
61 
63  enum {
68  };
69 
71  enum {
74  };
75 
77  enum {
80  };
81 
83  enum {
89  };
90 
91  public:
92 
93  // ----------------------------------------------------------------------
94  // Component initialization
95  // ----------------------------------------------------------------------
96 
98  void init(
99  FwEnumStoreType instance = 0
100  );
101 
102  public:
103 
104  // ----------------------------------------------------------------------
105  // Getters for typed input ports
106  // ----------------------------------------------------------------------
107 
112  FwIndexType portNum
113  );
114 
119  FwIndexType portNum
120  );
121 
126  FwIndexType portNum
127  );
128 
129  public:
130 
131  // ----------------------------------------------------------------------
132  // Connect input ports to special output ports
133  // ----------------------------------------------------------------------
134 
137  FwIndexType portNum,
138  Fw::InputLogPort* port
139  );
140 
141 #if FW_ENABLE_TEXT_LOGGING == 1
142 
144  void set_textEventOut_OutputPort(
145  FwIndexType portNum,
146  Fw::InputLogTextPort* port
147  );
148 
149 #endif
150 
153  FwIndexType portNum,
154  Fw::InputTimePort* port
155  );
156 
159  FwIndexType portNum,
160  Fw::InputTlmPort* port
161  );
162 
163 #if FW_PORT_SERIALIZATION
164 
165  public:
166 
167  // ----------------------------------------------------------------------
168  // Connect serial input ports to special output ports
169  // ----------------------------------------------------------------------
170 
173  FwIndexType portNum,
174  Fw::InputSerializePort* port
175  );
176 
177 #if FW_ENABLE_TEXT_LOGGING == 1
178 
180  void set_textEventOut_OutputPort(
181  FwIndexType portNum,
182  Fw::InputSerializePort* port
183  );
184 
185 #endif
186 
189  FwIndexType portNum,
190  Fw::InputSerializePort* port
191  );
192 
195  FwIndexType portNum,
196  Fw::InputSerializePort* port
197  );
198 
199 #endif
200 
201  protected:
202 
203  // ----------------------------------------------------------------------
204  // Component construction and destruction
205  // ----------------------------------------------------------------------
206 
209  const char* compName = ""
210  );
211 
213  virtual ~BufferManagerComponentBase();
214 
215  protected:
216 
217  // ----------------------------------------------------------------------
218  // Getters for numbers of typed input ports
219  // ----------------------------------------------------------------------
220 
226  }
227 
233  }
234 
240  }
241 
242  protected:
243 
244  // ----------------------------------------------------------------------
245  // Getters for numbers of special output ports
246  // ----------------------------------------------------------------------
247 
253  }
254 
255 #if FW_ENABLE_TEXT_LOGGING == 1
256 
260  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
262  }
263 
264 #endif
265 
271  }
272 
278  }
279 
280  protected:
281 
282  // ----------------------------------------------------------------------
283  // Connection status queries for special output ports
284  // ----------------------------------------------------------------------
285 
290  FwIndexType portNum
291  );
292 
293 #if FW_ENABLE_TEXT_LOGGING == 1
294 
298  bool isConnected_textEventOut_OutputPort(
299  FwIndexType portNum
300  );
301 
302 #endif
303 
308  FwIndexType portNum
309  );
310 
315  FwIndexType portNum
316  );
317 
318  protected:
319 
320  // ----------------------------------------------------------------------
321  // Handlers to implement for typed input ports
322  // ----------------------------------------------------------------------
323 
326  FwIndexType portNum,
327  FwSizeType size
328  ) = 0;
329 
331  virtual void bufferSendIn_handler(
332  FwIndexType portNum,
333  Fw::Buffer& fwBuffer
334  ) = 0;
335 
337  virtual void schedIn_handler(
338  FwIndexType portNum,
339  U32 context
340  ) = 0;
341 
342  protected:
343 
344  // ----------------------------------------------------------------------
345  // Port handler base-class functions for typed input ports
346  //
347  // Call these functions directly to bypass the corresponding ports
348  // ----------------------------------------------------------------------
349 
352  FwIndexType portNum,
353  FwSizeType size
354  );
355 
358  FwIndexType portNum,
359  Fw::Buffer& fwBuffer
360  );
361 
363  void schedIn_handlerBase(
364  FwIndexType portNum,
365  U32 context
366  );
367 
368  protected:
369 
370  // ----------------------------------------------------------------------
371  // Event logging functions
372  // ----------------------------------------------------------------------
373 
378  FwSizeType size
379  );
380 
385 
386  protected:
387 
388  // ----------------------------------------------------------------------
389  // Event throttle reset functions
390  // ----------------------------------------------------------------------
391 
394 
397 
398  protected:
399 
400  // ----------------------------------------------------------------------
401  // Telemetry write functions
402  // ----------------------------------------------------------------------
403 
407  void tlmWrite_TotalBuffs(
408  U32 arg,
409  Fw::Time _tlmTime = Fw::Time()
410  );
411 
415  void tlmWrite_CurrBuffs(
416  U32 arg,
417  Fw::Time _tlmTime = Fw::Time()
418  );
419 
423  void tlmWrite_HiBuffs(
424  U32 arg,
425  Fw::Time _tlmTime = Fw::Time()
426  );
427 
431  void tlmWrite_NoBuffs(
432  U32 arg,
433  Fw::Time _tlmTime = Fw::Time()
434  );
435 
439  void tlmWrite_EmptyBuffs(
440  U32 arg,
441  Fw::Time _tlmTime = Fw::Time()
442  );
443 
444  protected:
445 
446  // ----------------------------------------------------------------------
447  // Time
448  // ----------------------------------------------------------------------
449 
453  Fw::Time getTime() const;
454 
455  protected:
456 
457  // ----------------------------------------------------------------------
458  // Mutex operations for guarded ports
459  //
460  // You can override these operations to provide more sophisticated
461  // synchronization
462  // ----------------------------------------------------------------------
463 
465  virtual void lock();
466 
468  virtual void unLock();
469 
470  private:
471 
472  // ----------------------------------------------------------------------
473  // Calls for messages received on typed input ports
474  // ----------------------------------------------------------------------
475 
477  static Fw::Buffer m_p_bufferGetCallee_in(
478  Fw::PassiveComponentBase* callComp,
479  FwIndexType portNum,
480  FwSizeType size
481  );
482 
484  static void m_p_bufferSendIn_in(
485  Fw::PassiveComponentBase* callComp,
486  FwIndexType portNum,
487  Fw::Buffer& fwBuffer
488  );
489 
491  static void m_p_schedIn_in(
492  Fw::PassiveComponentBase* callComp,
493  FwIndexType portNum,
494  U32 context
495  );
496 
497  private:
498 
499  // ----------------------------------------------------------------------
500  // Typed input ports
501  // ----------------------------------------------------------------------
502 
504  Fw::InputBufferGetPort m_bufferGetCallee_InputPort[NUM_BUFFERGETCALLEE_INPUT_PORTS];
505 
507  Fw::InputBufferSendPort m_bufferSendIn_InputPort[NUM_BUFFERSENDIN_INPUT_PORTS];
508 
510  Svc::InputSchedPort m_schedIn_InputPort[NUM_SCHEDIN_INPUT_PORTS];
511 
512  private:
513 
514  // ----------------------------------------------------------------------
515  // Special output ports
516  // ----------------------------------------------------------------------
517 
519  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
520 
521 #if FW_ENABLE_TEXT_LOGGING == 1
522 
524  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
525 
526 #endif
527 
529  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
530 
532  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
533 
534  private:
535 
536  // ----------------------------------------------------------------------
537  // Counter values for event throttling
538  // ----------------------------------------------------------------------
539 
541  std::atomic<FwIndexType> m_NoBuffsAvailableThrottle;
542 
544  std::atomic<FwIndexType> m_NullEmptyBufferThrottle;
545 
546  private:
547 
548  // ----------------------------------------------------------------------
549  // First update flags for telemetry channels
550  // ----------------------------------------------------------------------
551 
553  bool m_first_update_TotalBuffs = true;
554 
556  bool m_first_update_CurrBuffs = true;
557 
559  bool m_first_update_HiBuffs = true;
560 
562  bool m_first_update_NoBuffs = true;
563 
565  bool m_first_update_EmptyBuffs = true;
566 
567  private:
568 
569  // ----------------------------------------------------------------------
570  // Last value storage for telemetry channels
571  // ----------------------------------------------------------------------
572 
574  U32 m_last_TotalBuffs = {};
575 
577  U32 m_last_CurrBuffs = {};
578 
580  U32 m_last_HiBuffs = {};
581 
583  U32 m_last_NoBuffs = {};
584 
586  U32 m_last_EmptyBuffs = {};
587 
588  private:
589 
590  // ----------------------------------------------------------------------
591  // Mutexes
592  // ----------------------------------------------------------------------
593 
595  Os::Mutex m_guardedPortMutex;
596 
597  };
598 
599 }
600 
601 #endif
void log_WARNING_HI_NoBuffsAvailable(FwSizeType size)
static constexpr FwIndexType getNum_bufferGetCallee_InputPorts()
virtual ~BufferManagerComponentBase()
Destroy BufferManagerComponentBase object.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
Fw::Buffer bufferGetCallee_handlerBase(FwIndexType portNum, FwSizeType size)
Handler base-class function for input port bufferGetCallee.
static constexpr FwIndexType getNum_schedIn_InputPorts()
The BufferManager was unable to allocate a requested buffer.
virtual void bufferSendIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendIn.
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
void init()
Object initializer.
Definition: ObjBase.cpp:24
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void log_WARNING_HI_NoBuffsAvailable_ThrottleClear()
Reset throttle value for NoBuffsAvailable.
Fw::InputBufferGetPort * get_bufferGetCallee_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void schedIn_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port schedIn.
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
void tlmWrite_NoBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
static constexpr FwIndexType getNum_bufferSendIn_InputPorts()
void tlmWrite_CurrBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_HiBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
friend class BufferManagerTester
Friend class tester implementation to support white-box testing.
virtual void unLock()
Unlock the guarded mutex.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
virtual void lock()
Lock the guarded mutex.
static constexpr FwIndexType getNum_eventOut_OutputPorts()
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
void tlmWrite_EmptyBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
friend class BufferManagerTesterBase
Friend class tester to support autocoded test harness.
PlatformIndexType FwIndexType
void log_WARNING_HI_NullEmptyBuffer_ThrottleClear()
Reset throttle value for NullEmptyBuffer.
RateGroupDivider component implementation.
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
virtual Fw::Buffer bufferGetCallee_handler(FwIndexType portNum, FwSizeType size)=0
Handler for input port bufferGetCallee.
bool isConnected_eventOut_OutputPort(FwIndexType portNum)
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
Auto-generated base for BufferManager component.
The buffer manager received a null pointer and zero-sized buffer as a return. Probably undetected fai...
bool isConnected_tlmOut_OutputPort(FwIndexType portNum)
BufferManagerComponentBase(const char *compName="")
Construct BufferManagerComponentBase object.