F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
BufferAccumulatorComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferAccumulatorComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for BufferAccumulator component base class
5 // ======================================================================
6 
7 #ifndef Svc_BufferAccumulatorComponentAc_HPP
8 #define Svc_BufferAccumulatorComponentAc_HPP
9 
10 #include <atomic>
11 
13 #include "Fw/Cmd/CmdPortAc.hpp"
14 #include "Fw/Cmd/CmdRegPortAc.hpp"
16 #include "Fw/Cmd/CmdString.hpp"
18 #include "Fw/FPrimeBasicTypes.hpp"
19 #include "Fw/Log/LogPortAc.hpp"
20 #include "Fw/Log/LogString.hpp"
21 #if FW_ENABLE_TEXT_LOGGING == 1
22 #include "Fw/Log/LogTextPortAc.hpp"
23 #endif
26 #include "Fw/Time/TimePortAc.hpp"
27 #include "Fw/Tlm/TlmPortAc.hpp"
28 #include "Fw/Tlm/TlmString.hpp"
31 #include "Svc/Ping/PingPortAc.hpp"
32 
33 namespace Svc {
34 
39  {
40 
41  // ----------------------------------------------------------------------
42  // Friend classes
43  // ----------------------------------------------------------------------
44 
49 
50  protected:
51 
52  // ----------------------------------------------------------------------
53  // Constants
54  // ----------------------------------------------------------------------
55 
57  enum {
59  };
60 
62  enum {
66  };
67 
69  enum {
76  };
77 
79  enum {
83  };
84 
86  enum {
89  };
90 
92  enum {
100  };
101 
103  enum {
105  };
106 
107  public:
108 
109  // ----------------------------------------------------------------------
110  // Component initialization
111  // ----------------------------------------------------------------------
112 
114  void init(
115  FwSizeType queueDepth,
116  FwEnumStoreType instance = 0
117  );
118 
119  public:
120 
121  // ----------------------------------------------------------------------
122  // Getters for special input ports
123  // ----------------------------------------------------------------------
124 
129  FwIndexType portNum
130  );
131 
132  public:
133 
134  // ----------------------------------------------------------------------
135  // Getters for typed input ports
136  // ----------------------------------------------------------------------
137 
142  FwIndexType portNum
143  );
144 
149  FwIndexType portNum
150  );
151 
156  FwIndexType portNum
157  );
158 
159  public:
160 
161  // ----------------------------------------------------------------------
162  // Connect input ports to special output ports
163  // ----------------------------------------------------------------------
164 
167  FwIndexType portNum,
168  Fw::InputCmdRegPort* port
169  );
170 
173  FwIndexType portNum,
175  );
176 
179  FwIndexType portNum,
180  Fw::InputLogPort* port
181  );
182 
183 #if FW_ENABLE_TEXT_LOGGING == 1
184 
186  void set_eventOutText_OutputPort(
187  FwIndexType portNum,
188  Fw::InputLogTextPort* port
189  );
190 
191 #endif
192 
195  FwIndexType portNum,
196  Fw::InputTimePort* port
197  );
198 
201  FwIndexType portNum,
202  Fw::InputTlmPort* port
203  );
204 
205  public:
206 
207  // ----------------------------------------------------------------------
208  // Connect typed input ports to typed output ports
209  // ----------------------------------------------------------------------
210 
213  FwIndexType portNum,
215  );
216 
219  FwIndexType portNum,
221  );
222 
225  FwIndexType portNum,
226  Svc::InputPingPort* port
227  );
228 
229 #if FW_PORT_SERIALIZATION
230 
231  public:
232 
233  // ----------------------------------------------------------------------
234  // Connect serial input ports to special output ports
235  // ----------------------------------------------------------------------
236 
239  FwIndexType portNum,
240  Fw::InputSerializePort* port
241  );
242 
245  FwIndexType portNum,
246  Fw::InputSerializePort* port
247  );
248 
251  FwIndexType portNum,
252  Fw::InputSerializePort* port
253  );
254 
255 #if FW_ENABLE_TEXT_LOGGING == 1
256 
258  void set_eventOutText_OutputPort(
259  FwIndexType portNum,
260  Fw::InputSerializePort* port
261  );
262 
263 #endif
264 
267  FwIndexType portNum,
268  Fw::InputSerializePort* port
269  );
270 
273  FwIndexType portNum,
274  Fw::InputSerializePort* port
275  );
276 
277 #endif
278 
279 #if FW_PORT_SERIALIZATION
280 
281  public:
282 
283  // ----------------------------------------------------------------------
284  // Connect serial input ports to typed output ports
285  // ----------------------------------------------------------------------
286 
289  FwIndexType portNum,
290  Fw::InputSerializePort* port
291  );
292 
295  FwIndexType portNum,
296  Fw::InputSerializePort* port
297  );
298 
301  FwIndexType portNum,
302  Fw::InputSerializePort* port
303  );
304 
305 #endif
306 
307  public:
308 
309  // ----------------------------------------------------------------------
310  // Command registration
311  // ----------------------------------------------------------------------
312 
316  void regCommands();
317 
318  protected:
319 
320  // ----------------------------------------------------------------------
321  // Component construction and destruction
322  // ----------------------------------------------------------------------
323 
326  const char* compName = ""
327  );
328 
331 
332  protected:
333 
334  // ----------------------------------------------------------------------
335  // Getters for numbers of special input ports
336  // ----------------------------------------------------------------------
337 
342  return NUM_CMDIN_INPUT_PORTS;
343  }
344 
345  protected:
346 
347  // ----------------------------------------------------------------------
348  // Getters for numbers of typed input ports
349  // ----------------------------------------------------------------------
350 
356  }
357 
363  }
364 
369  return NUM_PINGIN_INPUT_PORTS;
370  }
371 
372  protected:
373 
374  // ----------------------------------------------------------------------
375  // Getters for numbers of special output ports
376  // ----------------------------------------------------------------------
377 
383  }
384 
390  }
391 
397  }
398 
399 #if FW_ENABLE_TEXT_LOGGING == 1
400 
404  static constexpr FwIndexType getNum_eventOutText_OutputPorts() {
406  }
407 
408 #endif
409 
415  }
416 
422  }
423 
424  protected:
425 
426  // ----------------------------------------------------------------------
427  // Getters for numbers of typed output ports
428  // ----------------------------------------------------------------------
429 
435  }
436 
442  }
443 
449  }
450 
451  protected:
452 
453  // ----------------------------------------------------------------------
454  // Connection status queries for special output ports
455  // ----------------------------------------------------------------------
456 
461  FwIndexType portNum
462  );
463 
468  FwIndexType portNum
469  );
470 
475  FwIndexType portNum
476  );
477 
478 #if FW_ENABLE_TEXT_LOGGING == 1
479 
483  bool isConnected_eventOutText_OutputPort(
484  FwIndexType portNum
485  );
486 
487 #endif
488 
493  FwIndexType portNum
494  );
495 
500  FwIndexType portNum
501  );
502 
503  protected:
504 
505  // ----------------------------------------------------------------------
506  // Connection status queries for typed output ports
507  // ----------------------------------------------------------------------
508 
513  FwIndexType portNum
514  );
515 
520  FwIndexType portNum
521  );
522 
527  FwIndexType portNum
528  );
529 
530  protected:
531 
532  // ----------------------------------------------------------------------
533  // Handlers to implement for typed input ports
534  // ----------------------------------------------------------------------
535 
537  virtual void bufferSendInFill_handler(
538  FwIndexType portNum,
539  Fw::Buffer& fwBuffer
540  ) = 0;
541 
543  virtual void bufferSendInReturn_handler(
544  FwIndexType portNum,
545  Fw::Buffer& fwBuffer
546  ) = 0;
547 
549  virtual void pingIn_handler(
550  FwIndexType portNum,
551  U32 key
552  ) = 0;
553 
554  protected:
555 
556  // ----------------------------------------------------------------------
557  // Port handler base-class functions for typed input ports
558  //
559  // Call these functions directly to bypass the corresponding ports
560  // ----------------------------------------------------------------------
561 
564  FwIndexType portNum,
565  Fw::Buffer& fwBuffer
566  );
567 
570  FwIndexType portNum,
571  Fw::Buffer& fwBuffer
572  );
573 
575  void pingIn_handlerBase(
576  FwIndexType portNum,
577  U32 key
578  );
579 
580  protected:
581 
582  // ----------------------------------------------------------------------
583  // Pre-message hooks for typed async input ports
584  //
585  // Each of these functions is invoked just before processing a message
586  // on the corresponding port. By default, they do nothing. You can
587  // override them to provide specific pre-message behavior.
588  // ----------------------------------------------------------------------
589 
591  virtual void bufferSendInFill_preMsgHook(
592  FwIndexType portNum,
593  Fw::Buffer& fwBuffer
594  );
595 
597  virtual void bufferSendInReturn_preMsgHook(
598  FwIndexType portNum,
599  Fw::Buffer& fwBuffer
600  );
601 
603  virtual void pingIn_preMsgHook(
604  FwIndexType portNum,
605  U32 key
606  );
607 
608  protected:
609 
610  // ----------------------------------------------------------------------
611  // Invocation functions for typed output ports
612  // ----------------------------------------------------------------------
613 
616  FwIndexType portNum,
617  Fw::Buffer& fwBuffer
618  );
619 
622  FwIndexType portNum,
623  Fw::Buffer& fwBuffer
624  );
625 
627  void pingOut_out(
628  FwIndexType portNum,
629  U32 key
630  );
631 
632  protected:
633 
634  // ----------------------------------------------------------------------
635  // Command response
636  // ----------------------------------------------------------------------
637 
639  void cmdResponse_out(
640  FwOpcodeType opCode,
641  U32 cmdSeq,
642  Fw::CmdResponse response
643  );
644 
645  protected:
646 
647  // ----------------------------------------------------------------------
648  // Command handlers to implement
649  // ----------------------------------------------------------------------
650 
654  virtual void BA_SetMode_cmdHandler(
655  FwOpcodeType opCode,
656  U32 cmdSeq,
658  ) = 0;
659 
663  virtual void BA_DrainBuffers_cmdHandler(
664  FwOpcodeType opCode,
665  U32 cmdSeq,
666  U32 numToDrain,
668  ) = 0;
669 
670  protected:
671 
672  // ----------------------------------------------------------------------
673  // Command handler base-class functions
674  //
675  // Call these functions directly to bypass the command input port
676  // ----------------------------------------------------------------------
677 
682  FwOpcodeType opCode,
683  U32 cmdSeq,
684  Fw::CmdArgBuffer& args
685  );
686 
691  FwOpcodeType opCode,
692  U32 cmdSeq,
693  Fw::CmdArgBuffer& args
694  );
695 
696  protected:
697 
698  // ----------------------------------------------------------------------
699  // Pre-message hooks for async commands
700  //
701  // Each of these functions is invoked just before processing the
702  // corresponding command. By default they do nothing. You can
703  // override them to provide specific pre-command behavior.
704  // ----------------------------------------------------------------------
705 
707  virtual void BA_SetMode_preMsgHook(
708  FwOpcodeType opCode,
709  U32 cmdSeq
710  );
711 
713  virtual void BA_DrainBuffers_preMsgHook(
714  FwOpcodeType opCode,
715  U32 cmdSeq
716  );
717 
718  protected:
719 
720  // ----------------------------------------------------------------------
721  // Event logging functions
722  // ----------------------------------------------------------------------
723 
728 
732  void log_WARNING_HI_BA_QueueFull() const;
733 
738  U32 numDrained,
739  U32 numToDrain
740  ) const;
741 
746 
751  U32 numDrained,
752  U32 numToDrain
753  ) const;
754 
758  void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained) const;
759 
764  U32 numWillDrain,
765  U32 numReqDrain
766  ) const;
767 
768  protected:
769 
770  // ----------------------------------------------------------------------
771  // Telemetry write functions
772  // ----------------------------------------------------------------------
773 
778  U32 arg,
779  Fw::Time _tlmTime = Fw::Time()
780  ) const;
781 
782  protected:
783 
784  // ----------------------------------------------------------------------
785  // Time
786  // ----------------------------------------------------------------------
787 
791  Fw::Time getTime() const;
792 
793  private:
794 
795  // ----------------------------------------------------------------------
796  // Message dispatch functions
797  // ----------------------------------------------------------------------
798 
800  virtual MsgDispatchStatus doDispatch();
801 
802  private:
803 
804  // ----------------------------------------------------------------------
805  // Calls for messages received on special input ports
806  // ----------------------------------------------------------------------
807 
809  static void m_p_cmdIn_in(
810  Fw::PassiveComponentBase* callComp,
811  FwIndexType portNum,
812  FwOpcodeType opCode,
813  U32 cmdSeq,
814  Fw::CmdArgBuffer& args
815  );
816 
817  private:
818 
819  // ----------------------------------------------------------------------
820  // Calls for messages received on typed input ports
821  // ----------------------------------------------------------------------
822 
824  static void m_p_bufferSendInFill_in(
825  Fw::PassiveComponentBase* callComp,
826  FwIndexType portNum,
827  Fw::Buffer& fwBuffer
828  );
829 
831  static void m_p_bufferSendInReturn_in(
832  Fw::PassiveComponentBase* callComp,
833  FwIndexType portNum,
834  Fw::Buffer& fwBuffer
835  );
836 
838  static void m_p_pingIn_in(
839  Fw::PassiveComponentBase* callComp,
840  FwIndexType portNum,
841  U32 key
842  );
843 
844  private:
845 
846  // ----------------------------------------------------------------------
847  // Special input ports
848  // ----------------------------------------------------------------------
849 
851  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
852 
853  private:
854 
855  // ----------------------------------------------------------------------
856  // Typed input ports
857  // ----------------------------------------------------------------------
858 
860  Fw::InputBufferSendPort m_bufferSendInFill_InputPort[NUM_BUFFERSENDINFILL_INPUT_PORTS];
861 
863  Fw::InputBufferSendPort m_bufferSendInReturn_InputPort[NUM_BUFFERSENDINRETURN_INPUT_PORTS];
864 
866  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
867 
868  private:
869 
870  // ----------------------------------------------------------------------
871  // Special output ports
872  // ----------------------------------------------------------------------
873 
875  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
876 
878  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
879 
881  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
882 
883 #if FW_ENABLE_TEXT_LOGGING == 1
884 
886  Fw::OutputLogTextPort m_eventOutText_OutputPort[NUM_EVENTOUTTEXT_OUTPUT_PORTS];
887 
888 #endif
889 
891  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
892 
894  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
895 
896  private:
897 
898  // ----------------------------------------------------------------------
899  // Typed output ports
900  // ----------------------------------------------------------------------
901 
903  Fw::OutputBufferSendPort m_bufferSendOutDrain_OutputPort[NUM_BUFFERSENDOUTDRAIN_OUTPUT_PORTS];
904 
906  Fw::OutputBufferSendPort m_bufferSendOutReturn_OutputPort[NUM_BUFFERSENDOUTRETURN_OUTPUT_PORTS];
907 
909  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
910 
911  };
912 
913 }
914 
915 #endif
void bufferSendOutReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutReturn.
virtual void BA_SetMode_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::BufferAccumulator_OpState mode)=0
static constexpr FwIndexType getNum_pingIn_InputPorts()
bool isConnected_bufferSendOutDrain_OutputPort(FwIndexType portNum)
FwIdType FwOpcodeType
The type of a command opcode.
virtual void bufferSendInReturn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendInReturn.
static constexpr FwIndexType getNum_eventOut_OutputPorts()
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
I32 FwEnumStoreType
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
virtual ~BufferAccumulatorComponentBase()
Destroy BufferAccumulatorComponentBase object.
friend class BufferAccumulatorTester
Friend class tester implementation to support white-box testing.
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_bufferSendInReturn_InputPorts()
Got DrainBuffers command while executing DrainBuffers command.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_pingOut_OutputPorts()
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
static constexpr FwIndexType getNum_bufferSendInFill_InputPorts()
void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained) const
Enum representing a command response.
BufferAccumulatorComponentBase(const char *compName="")
Construct BufferAccumulatorComponentBase object.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
friend class BufferAccumulatorTesterBase
Friend class tester to support autocoded test harness.
void init()
Object initializer.
Definition: ObjBase.cpp:24
void log_WARNING_LO_BA_NonBlockDrain(U32 numWillDrain, U32 numReqDrain) const
static constexpr FwIndexType getNum_bufferSendOutDrain_OutputPorts()
void set_bufferSendOutReturn_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOutReturn[portNum].
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
Ran out of buffers while executing DrainBuffers command.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
void log_WARNING_HI_BA_StillDraining(U32 numDrained, U32 numToDrain) const
void tlmWrite_BA_NumQueuedBuffers(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
virtual void bufferSendInFill_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendInFill.
The Buffer Accumulator instance received a buffer when its queue was full. To avoid uncontrolled send...
void BA_DrainBuffers_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
void regCommands()
Register commands with the Command Dispatcher.
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
void BA_SetMode_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
static constexpr FwIndexType getNum_cmdIn_InputPorts()
virtual void BA_DrainBuffers_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BA_DrainBuffers.
bool isConnected_bufferSendOutReturn_OutputPort(FwIndexType portNum)
Not enough buffers to complete requested drain, and NOBLOCK was set; will only drain what we have...
void set_bufferSendOutDrain_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOutDrain[portNum].
The Buffer Accumulator instance accepted and enqueued a buffer. To avoid uncontrolled sending of even...
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
Fw::InputBufferSendPort * get_bufferSendInReturn_InputPort(FwIndexType portNum)
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
virtual void bufferSendInFill_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendInFill.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_bufferSendOutReturn_OutputPorts()
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
Fw::InputBufferSendPort * get_bufferSendInFill_InputPort(FwIndexType portNum)
void log_WARNING_HI_BA_DrainStalled(U32 numDrained, U32 numToDrain) const
RateGroupDivider component implementation.
void bufferSendOutDrain_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutDrain.
virtual void bufferSendInReturn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendInReturn.
void bufferSendInFill_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendInFill.
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
Auto-generated base for BufferAccumulator component.
void bufferSendInReturn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendInReturn.
virtual void BA_DrainBuffers_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 numToDrain, Svc::BufferAccumulator_BlockMode blockMode)=0
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual void BA_SetMode_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BA_SetMode.