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
21 #if !FW_DIRECT_PORT_CALLS
23 #endif
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #include "Fw/Time/TimePortAc.hpp"
28 #include "Fw/Tlm/TlmPortAc.hpp"
29 #include "Fw/Tlm/TlmString.hpp"
30 #include "Os/Mutex.hpp"
33 
34 namespace Svc {
35 
42  {
43 
44  // ----------------------------------------------------------------------
45  // Friend classes
46  // ----------------------------------------------------------------------
47 
51  friend class BufferManagerTester;
52 
53  protected:
54 
55  // ----------------------------------------------------------------------
56  // Constants
57  // ----------------------------------------------------------------------
58 
60  enum {
64  };
65 
67  enum {
72  };
73 
75  enum {
78  };
79 
81  enum {
84  };
85 
87  enum {
93  };
94 
95  public:
96 
97  // ----------------------------------------------------------------------
98  // Component initialization
99  // ----------------------------------------------------------------------
100 
102  void init(
103  FwEnumStoreType instance = 0
104  );
105 
106 #if !FW_DIRECT_PORT_CALLS
107 
108  public:
109 
110  // ----------------------------------------------------------------------
111  // Getters for typed input ports
112  // ----------------------------------------------------------------------
113 
118  FwIndexType portNum
119  );
120 
125  FwIndexType portNum
126  );
127 
132  FwIndexType portNum
133  );
134 
135 #endif
136 
137 #if !FW_DIRECT_PORT_CALLS
138 
139  public:
140 
141  // ----------------------------------------------------------------------
142  // Connect input ports to special output ports
143  // ----------------------------------------------------------------------
144 
147  FwIndexType portNum,
148  Fw::InputLogPort* port
149  );
150 
151 #if FW_ENABLE_TEXT_LOGGING == 1
152 
154  void set_textEventOut_OutputPort(
155  FwIndexType portNum,
156  Fw::InputLogTextPort* port
157  );
158 
159 #endif
160 
163  FwIndexType portNum,
164  Fw::InputTimePort* port
165  );
166 
169  FwIndexType portNum,
170  Fw::InputTlmPort* port
171  );
172 
173 #endif
174 
175 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
176 
177  public:
178 
179  // ----------------------------------------------------------------------
180  // Connect serial input ports to special output ports
181  // ----------------------------------------------------------------------
182 
185  FwIndexType portNum,
186  Fw::InputSerializePort* port
187  );
188 
189 #if FW_ENABLE_TEXT_LOGGING == 1
190 
192  void set_textEventOut_OutputPort(
193  FwIndexType portNum,
194  Fw::InputSerializePort* port
195  );
196 
197 #endif
198 
201  FwIndexType portNum,
202  Fw::InputSerializePort* port
203  );
204 
207  FwIndexType portNum,
208  Fw::InputSerializePort* port
209  );
210 
211 #endif
212 
213  protected:
214 
215  // ----------------------------------------------------------------------
216  // Component construction and destruction
217  // ----------------------------------------------------------------------
218 
221  const char* compName = ""
222  );
223 
225  virtual ~BufferManagerComponentBase();
226 
227  protected:
228 
229  // ----------------------------------------------------------------------
230  // Getters for numbers of typed input ports
231  // ----------------------------------------------------------------------
232 
238  }
239 
245  }
246 
252  }
253 
254  protected:
255 
256  // ----------------------------------------------------------------------
257  // Getters for numbers of special output ports
258  // ----------------------------------------------------------------------
259 
265  }
266 
267 #if FW_ENABLE_TEXT_LOGGING == 1
268 
272  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
274  }
275 
276 #endif
277 
283  }
284 
290  }
291 
292  protected:
293 
294  // ----------------------------------------------------------------------
295  // Connection status queries for special output ports
296  // ----------------------------------------------------------------------
297 
302  FwIndexType portNum
303  ) const;
304 
305 #if FW_ENABLE_TEXT_LOGGING == 1
306 
310  bool isConnected_textEventOut_OutputPort(
311  FwIndexType portNum
312  ) const;
313 
314 #endif
315 
320  FwIndexType portNum
321  ) const;
322 
327  FwIndexType portNum
328  ) const;
329 
330  protected:
331 
332  // ----------------------------------------------------------------------
333  // Handlers to implement for typed input ports
334  // ----------------------------------------------------------------------
335 
338  FwIndexType portNum,
339  FwSizeType size
340  ) = 0;
341 
343  virtual void bufferSendIn_handler(
344  FwIndexType portNum,
345  Fw::Buffer& fwBuffer
346  ) = 0;
347 
349  virtual void schedIn_handler(
350  FwIndexType portNum,
351  U32 context
352  ) = 0;
353 
354 #if FW_DIRECT_PORT_CALLS
355  public:
356 #else
357  protected:
358 #endif
359 
360  // ----------------------------------------------------------------------
361  // Port handler base-class functions for typed input ports
362  //
363  // Call these functions directly to bypass the corresponding ports
364  // ----------------------------------------------------------------------
365 
368  FwIndexType portNum,
369  FwSizeType size
370  );
371 
374  FwIndexType portNum,
375  Fw::Buffer& fwBuffer
376  );
377 
379  void schedIn_handlerBase(
380  FwIndexType portNum,
381  U32 context
382  );
383 
384  protected:
385 
386  // ----------------------------------------------------------------------
387  // Event logging functions
388  // ----------------------------------------------------------------------
389 
394  FwSizeType size
395  );
396 
401 
402  protected:
403 
404  // ----------------------------------------------------------------------
405  // Event throttle reset functions
406  // ----------------------------------------------------------------------
407 
410 
413 
414  protected:
415 
416  // ----------------------------------------------------------------------
417  // Telemetry serialized write
418  // ----------------------------------------------------------------------
419 
424  void tlmWrite(
425  FwChanIdType id,
426  Fw::TlmBuffer& _tlmBuff,
427  Fw::Time _tlmTime = Fw::Time()
428  ) const;
429 
430  protected:
431 
432  // ----------------------------------------------------------------------
433  // Telemetry write functions
434  // ----------------------------------------------------------------------
435 
439  void tlmWrite_TotalBuffs(
440  U32 arg,
441  Fw::Time _tlmTime = Fw::Time()
442  );
443 
447  void tlmWrite_CurrBuffs(
448  U32 arg,
449  Fw::Time _tlmTime = Fw::Time()
450  );
451 
455  void tlmWrite_HiBuffs(
456  U32 arg,
457  Fw::Time _tlmTime = Fw::Time()
458  );
459 
463  void tlmWrite_NoBuffs(
464  U32 arg,
465  Fw::Time _tlmTime = Fw::Time()
466  );
467 
471  void tlmWrite_EmptyBuffs(
472  U32 arg,
473  Fw::Time _tlmTime = Fw::Time()
474  );
475 
476  protected:
477 
478  // ----------------------------------------------------------------------
479  // Time
480  // ----------------------------------------------------------------------
481 
485  Fw::Time getTime() const;
486 
487  protected:
488 
489  // ----------------------------------------------------------------------
490  // Mutex operations for guarded ports
491  //
492  // You can override these operations to provide more sophisticated
493  // synchronization
494  // ----------------------------------------------------------------------
495 
497  virtual void lock();
498 
500  virtual void unLock();
501 
502  private:
503 
504  // ----------------------------------------------------------------------
505  // Calls for messages received on typed input ports
506  // ----------------------------------------------------------------------
507 
509  static Fw::Buffer m_p_bufferGetCallee_in(
510  Fw::PassiveComponentBase* callComp,
511  FwIndexType portNum,
512  FwSizeType size
513  );
514 
516  static void m_p_bufferSendIn_in(
517  Fw::PassiveComponentBase* callComp,
518  FwIndexType portNum,
519  Fw::Buffer& fwBuffer
520  );
521 
523  static void m_p_schedIn_in(
524  Fw::PassiveComponentBase* callComp,
525  FwIndexType portNum,
526  U32 context
527  );
528 
529  private:
530 
531  // ----------------------------------------------------------------------
532  // Invocation functions for special output ports
533  // ----------------------------------------------------------------------
534 
536  void eventOut_out(
537  FwIndexType portNum,
538  FwEventIdType id,
539  Fw::Time& timeTag,
540  const Fw::LogSeverity& severity,
541  Fw::LogBuffer& args
542  ) const;
543 
544 #if FW_ENABLE_TEXT_LOGGING
545 
547  void textEventOut_out(
548  FwIndexType portNum,
549  FwEventIdType id,
550  Fw::Time& timeTag,
551  const Fw::LogSeverity& severity,
552  Fw::TextLogString& text
553  ) const;
554 
555 #endif
556 
558  void timeCaller_out(
559  FwIndexType portNum,
560  Fw::Time& time
561  ) const;
562 
564  void tlmOut_out(
565  FwIndexType portNum,
566  FwChanIdType id,
567  Fw::Time& timeTag,
568  Fw::TlmBuffer& val
569  ) const;
570 
571 #if !FW_DIRECT_PORT_CALLS
572 
573  private:
574 
575  // ----------------------------------------------------------------------
576  // Typed input ports
577  // ----------------------------------------------------------------------
578 
580  Fw::InputBufferGetPort m_bufferGetCallee_InputPort[NUM_BUFFERGETCALLEE_INPUT_PORTS];
581 
583  Fw::InputBufferSendPort m_bufferSendIn_InputPort[NUM_BUFFERSENDIN_INPUT_PORTS];
584 
586  Svc::InputSchedPort m_schedIn_InputPort[NUM_SCHEDIN_INPUT_PORTS];
587 
588 #endif
589 
590 #if !FW_DIRECT_PORT_CALLS
591 
592  private:
593 
594  // ----------------------------------------------------------------------
595  // Special output ports
596  // ----------------------------------------------------------------------
597 
599  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
600 
601 #if FW_ENABLE_TEXT_LOGGING == 1
602 
604  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
605 
606 #endif
607 
609  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
610 
612  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
613 
614 #endif
615 
616  private:
617 
618  // ----------------------------------------------------------------------
619  // Counter values for event throttling
620  // ----------------------------------------------------------------------
621 
623  std::atomic<FwIndexType> m_NoBuffsAvailableThrottle;
624 
626  std::atomic<FwIndexType> m_NullEmptyBufferThrottle;
627 
628  private:
629 
630  // ----------------------------------------------------------------------
631  // First update flags for telemetry channels
632  // ----------------------------------------------------------------------
633 
635  bool m_first_update_TotalBuffs = true;
636 
638  bool m_first_update_CurrBuffs = true;
639 
641  bool m_first_update_HiBuffs = true;
642 
644  bool m_first_update_NoBuffs = true;
645 
647  bool m_first_update_EmptyBuffs = true;
648 
649  private:
650 
651  // ----------------------------------------------------------------------
652  // Last value storage for telemetry channels
653  // ----------------------------------------------------------------------
654 
656  U32 m_last_TotalBuffs = {};
657 
659  U32 m_last_CurrBuffs = {};
660 
662  U32 m_last_HiBuffs = {};
663 
665  U32 m_last_NoBuffs = {};
666 
668  U32 m_last_EmptyBuffs = {};
669 
670  private:
671 
672  // ----------------------------------------------------------------------
673  // Mutexes
674  // ----------------------------------------------------------------------
675 
677  Os::Mutex m_guardedPortMutex;
678 
679  };
680 
681 }
682 
683 #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].
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
Fw::Buffer bufferGetCallee_handlerBase(FwIndexType portNum, FwSizeType size)
Handler base-class function for input port bufferGetCallee.
static constexpr FwIndexType getNum_schedIn_InputPorts()
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
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].
FwIdType FwEventIdType
The type of an event identifier.
void log_WARNING_HI_NoBuffsAvailable_ThrottleClear()
Reset throttle value for NoBuffsAvailable.
Fw::InputBufferGetPort * get_bufferGetCallee_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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())
Enum representing event severity.
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.
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
virtual void lock()
Lock the guarded mutex.
The buffer manager received a null pointer and zero-sized buffer as a return. Probably undetected fai...
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 tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
virtual Fw::Buffer bufferGetCallee_handler(FwIndexType portNum, FwSizeType size)=0
Handler for input port bufferGetCallee.
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
The BufferManager was unable to allocate a requested buffer.
Auto-generated base for BufferManager component.
BufferManagerComponentBase(const char *compName="")
Construct BufferManagerComponentBase object.