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 #include "Fw/Log/LogTextPortAc.hpp"
19 #if !FW_DIRECT_PORT_CALLS
21 #endif
22 #if !FW_DIRECT_PORT_CALLS
24 #endif
25 #include "Fw/Time/TimePortAc.hpp"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Fw/Tlm/TlmString.hpp"
28 #include "Os/Mutex.hpp"
31 
32 namespace Svc {
33 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
49  friend class BufferManagerTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
62  };
63 
65  enum {
70  };
71 
73  enum {
76  };
77 
79  enum {
82  };
83 
85  enum {
91  };
92 
93  public:
94 
95  // ----------------------------------------------------------------------
96  // Component initialization
97  // ----------------------------------------------------------------------
98 
100  void init(
101  FwEnumStoreType instance = 0
102  );
103 
104 #if !FW_DIRECT_PORT_CALLS
105 
106  public:
107 
108  // ----------------------------------------------------------------------
109  // Getters for typed input ports
110  // ----------------------------------------------------------------------
111 
116  FwIndexType portNum
117  );
118 
123  FwIndexType portNum
124  );
125 
130  FwIndexType portNum
131  );
132 
133 #endif
134 
135 #if !FW_DIRECT_PORT_CALLS
136 
137  public:
138 
139  // ----------------------------------------------------------------------
140  // Connect input ports to special output ports
141  // ----------------------------------------------------------------------
142 
145  FwIndexType portNum,
146  Fw::InputLogPort* port
147  );
148 
149 #if FW_ENABLE_TEXT_LOGGING == 1
150 
152  void set_textEventOut_OutputPort(
153  FwIndexType portNum,
154  Fw::InputLogTextPort* port
155  );
156 
157 #endif
158 
161  FwIndexType portNum,
162  Fw::InputTimePort* port
163  );
164 
167  FwIndexType portNum,
168  Fw::InputTlmPort* port
169  );
170 
171 #endif
172 
173 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
174 
175  public:
176 
177  // ----------------------------------------------------------------------
178  // Connect serial input ports to special output ports
179  // ----------------------------------------------------------------------
180 
183  FwIndexType portNum,
184  Fw::InputSerializePort* port
185  );
186 
187 #if FW_ENABLE_TEXT_LOGGING == 1
188 
190  void set_textEventOut_OutputPort(
191  FwIndexType portNum,
192  Fw::InputSerializePort* port
193  );
194 
195 #endif
196 
199  FwIndexType portNum,
200  Fw::InputSerializePort* port
201  );
202 
205  FwIndexType portNum,
206  Fw::InputSerializePort* port
207  );
208 
209 #endif
210 
211  protected:
212 
213  // ----------------------------------------------------------------------
214  // Component construction and destruction
215  // ----------------------------------------------------------------------
216 
219  const char* compName = ""
220  );
221 
223  virtual ~BufferManagerComponentBase();
224 
225  protected:
226 
227  // ----------------------------------------------------------------------
228  // Getters for numbers of typed input ports
229  // ----------------------------------------------------------------------
230 
236  }
237 
243  }
244 
250  }
251 
252  protected:
253 
254  // ----------------------------------------------------------------------
255  // Getters for numbers of special output ports
256  // ----------------------------------------------------------------------
257 
263  }
264 
265 #if FW_ENABLE_TEXT_LOGGING == 1
266 
270  static constexpr FwIndexType getNum_textEventOut_OutputPorts() {
272  }
273 
274 #endif
275 
281  }
282 
288  }
289 
290  protected:
291 
292  // ----------------------------------------------------------------------
293  // Connection status queries for special output ports
294  // ----------------------------------------------------------------------
295 
300  FwIndexType portNum
301  ) const;
302 
303 #if FW_ENABLE_TEXT_LOGGING == 1
304 
308  bool isConnected_textEventOut_OutputPort(
309  FwIndexType portNum
310  ) const;
311 
312 #endif
313 
318  FwIndexType portNum
319  ) const;
320 
325  FwIndexType portNum
326  ) const;
327 
328  protected:
329 
330  // ----------------------------------------------------------------------
331  // Handlers to implement for typed input ports
332  // ----------------------------------------------------------------------
333 
336  FwIndexType portNum,
337  FwSizeType size
338  ) = 0;
339 
341  virtual void bufferSendIn_handler(
342  FwIndexType portNum,
343  Fw::Buffer& fwBuffer
344  ) = 0;
345 
347  virtual void schedIn_handler(
348  FwIndexType portNum,
349  U32 context
350  ) = 0;
351 
352 #if FW_DIRECT_PORT_CALLS
353  public:
354 #else
355  protected:
356 #endif
357 
358  // ----------------------------------------------------------------------
359  // Port handler base-class functions for typed input ports
360  //
361  // Call these functions directly to bypass the corresponding ports
362  // ----------------------------------------------------------------------
363 
366  FwIndexType portNum,
367  FwSizeType size
368  );
369 
372  FwIndexType portNum,
373  Fw::Buffer& fwBuffer
374  );
375 
377  void schedIn_handlerBase(
378  FwIndexType portNum,
379  U32 context
380  );
381 
382  protected:
383 
384  // ----------------------------------------------------------------------
385  // Event logging functions
386  // ----------------------------------------------------------------------
387 
392  FwSizeType size
393  );
394 
399 
400  protected:
401 
402  // ----------------------------------------------------------------------
403  // Event throttle reset functions
404  // ----------------------------------------------------------------------
405 
408 
411 
412  protected:
413 
414  // ----------------------------------------------------------------------
415  // Telemetry serialized write
416  // ----------------------------------------------------------------------
417 
422  void tlmWrite(
423  FwChanIdType id,
424  Fw::TlmBuffer& _tlmBuff,
425  Fw::Time _tlmTime = Fw::Time()
426  ) const;
427 
428  protected:
429 
430  // ----------------------------------------------------------------------
431  // Telemetry write functions
432  // ----------------------------------------------------------------------
433 
437  void tlmWrite_TotalBuffs(
438  U32 arg,
439  Fw::Time _tlmTime = Fw::Time()
440  );
441 
445  void tlmWrite_CurrBuffs(
446  U32 arg,
447  Fw::Time _tlmTime = Fw::Time()
448  );
449 
453  void tlmWrite_HiBuffs(
454  U32 arg,
455  Fw::Time _tlmTime = Fw::Time()
456  );
457 
461  void tlmWrite_NoBuffs(
462  U32 arg,
463  Fw::Time _tlmTime = Fw::Time()
464  );
465 
469  void tlmWrite_EmptyBuffs(
470  U32 arg,
471  Fw::Time _tlmTime = Fw::Time()
472  );
473 
474  protected:
475 
476  // ----------------------------------------------------------------------
477  // Time
478  // ----------------------------------------------------------------------
479 
483  Fw::Time getTime() const;
484 
485  protected:
486 
487  // ----------------------------------------------------------------------
488  // Mutex operations for guarded ports
489  //
490  // You can override these operations to provide more sophisticated
491  // synchronization
492  // ----------------------------------------------------------------------
493 
495  virtual void lock();
496 
498  virtual void unLock();
499 
500  private:
501 
502  // ----------------------------------------------------------------------
503  // Calls for messages received on typed input ports
504  // ----------------------------------------------------------------------
505 
507  static Fw::Buffer m_p_bufferGetCallee_in(
508  Fw::PassiveComponentBase* callComp,
509  FwIndexType portNum,
510  FwSizeType size
511  );
512 
514  static void m_p_bufferSendIn_in(
515  Fw::PassiveComponentBase* callComp,
516  FwIndexType portNum,
517  Fw::Buffer& fwBuffer
518  );
519 
521  static void m_p_schedIn_in(
522  Fw::PassiveComponentBase* callComp,
523  FwIndexType portNum,
524  U32 context
525  );
526 
527  private:
528 
529  // ----------------------------------------------------------------------
530  // Invocation functions for special output ports
531  // ----------------------------------------------------------------------
532 
534  void eventOut_out(
535  FwIndexType portNum,
536  FwEventIdType id,
537  Fw::Time& timeTag,
538  const Fw::LogSeverity& severity,
539  Fw::LogBuffer& args
540  ) const;
541 
542 #if FW_ENABLE_TEXT_LOGGING
543 
545  void textEventOut_out(
546  FwIndexType portNum,
547  FwEventIdType id,
548  Fw::Time& timeTag,
549  const Fw::LogSeverity& severity,
550  Fw::TextLogString& text
551  ) const;
552 
553 #endif
554 
556  void timeCaller_out(
557  FwIndexType portNum,
558  Fw::Time& time
559  ) const;
560 
562  void tlmOut_out(
563  FwIndexType portNum,
564  FwChanIdType id,
565  Fw::Time& timeTag,
566  Fw::TlmBuffer& val
567  ) const;
568 
569 #if !FW_DIRECT_PORT_CALLS
570 
571  private:
572 
573  // ----------------------------------------------------------------------
574  // Typed input ports
575  // ----------------------------------------------------------------------
576 
578  Fw::InputBufferGetPort m_bufferGetCallee_InputPort[NUM_BUFFERGETCALLEE_INPUT_PORTS];
579 
581  Fw::InputBufferSendPort m_bufferSendIn_InputPort[NUM_BUFFERSENDIN_INPUT_PORTS];
582 
584  Svc::InputSchedPort m_schedIn_InputPort[NUM_SCHEDIN_INPUT_PORTS];
585 
586 #endif
587 
588 #if !FW_DIRECT_PORT_CALLS
589 
590  private:
591 
592  // ----------------------------------------------------------------------
593  // Special output ports
594  // ----------------------------------------------------------------------
595 
597  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
598 
599 #if FW_ENABLE_TEXT_LOGGING == 1
600 
602  Fw::OutputLogTextPort m_textEventOut_OutputPort[NUM_TEXTEVENTOUT_OUTPUT_PORTS];
603 
604 #endif
605 
607  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
608 
610  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
611 
612 #endif
613 
614  private:
615 
616  // ----------------------------------------------------------------------
617  // Counter values for event throttling
618  // ----------------------------------------------------------------------
619 
621  std::atomic<FwIndexType> m_NoBuffsAvailableThrottle;
622 
624  std::atomic<FwIndexType> m_NullEmptyBufferThrottle;
625 
626  private:
627 
628  // ----------------------------------------------------------------------
629  // First update flags for telemetry channels
630  // ----------------------------------------------------------------------
631 
633  bool m_first_update_TotalBuffs = true;
634 
636  bool m_first_update_CurrBuffs = true;
637 
639  bool m_first_update_HiBuffs = true;
640 
642  bool m_first_update_NoBuffs = true;
643 
645  bool m_first_update_EmptyBuffs = true;
646 
647  private:
648 
649  // ----------------------------------------------------------------------
650  // Last value storage for telemetry channels
651  // ----------------------------------------------------------------------
652 
654  U32 m_last_TotalBuffs = {};
655 
657  U32 m_last_CurrBuffs = {};
658 
660  U32 m_last_HiBuffs = {};
661 
663  U32 m_last_NoBuffs = {};
664 
666  U32 m_last_EmptyBuffs = {};
667 
668  private:
669 
670  // ----------------------------------------------------------------------
671  // Mutexes
672  // ----------------------------------------------------------------------
673 
675  Os::Mutex m_guardedPortMutex;
676 
677  };
678 
679 }
680 
681 #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()
The BufferManager was unable to allocate a requested buffer.
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.
The buffer manager received a null pointer and zero-sized buffer as a return. Probably undetected fai...
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.
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.
Auto-generated base for BufferManager component.
BufferManagerComponentBase(const char *compName="")
Construct BufferManagerComponentBase object.