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 
343  PROTECTED:
344 
345  // ----------------------------------------------------------------------
346  // Getters for numbers of typed input ports
347  // ----------------------------------------------------------------------
348 
353 
358 
363 
364  PROTECTED:
365 
366  // ----------------------------------------------------------------------
367  // Getters for numbers of special output ports
368  // ----------------------------------------------------------------------
369 
374 
379 
384 
385 #if FW_ENABLE_TEXT_LOGGING == 1
386 
390  FwIndexType getNum_eventOutText_OutputPorts() const;
391 
392 #endif
393 
398 
403 
404  PROTECTED:
405 
406  // ----------------------------------------------------------------------
407  // Getters for numbers of typed output ports
408  // ----------------------------------------------------------------------
409 
414 
419 
424 
425  PROTECTED:
426 
427  // ----------------------------------------------------------------------
428  // Connection status queries for special output ports
429  // ----------------------------------------------------------------------
430 
435  FwIndexType portNum
436  );
437 
442  FwIndexType portNum
443  );
444 
449  FwIndexType portNum
450  );
451 
452 #if FW_ENABLE_TEXT_LOGGING == 1
453 
457  bool isConnected_eventOutText_OutputPort(
458  FwIndexType portNum
459  );
460 
461 #endif
462 
467  FwIndexType portNum
468  );
469 
474  FwIndexType portNum
475  );
476 
477  PROTECTED:
478 
479  // ----------------------------------------------------------------------
480  // Connection status queries for typed output ports
481  // ----------------------------------------------------------------------
482 
487  FwIndexType portNum
488  );
489 
494  FwIndexType portNum
495  );
496 
501  FwIndexType portNum
502  );
503 
504  PROTECTED:
505 
506  // ----------------------------------------------------------------------
507  // Handlers to implement for typed input ports
508  // ----------------------------------------------------------------------
509 
511  virtual void bufferSendInFill_handler(
512  FwIndexType portNum,
513  Fw::Buffer& fwBuffer
514  ) = 0;
515 
517  virtual void bufferSendInReturn_handler(
518  FwIndexType portNum,
519  Fw::Buffer& fwBuffer
520  ) = 0;
521 
523  virtual void pingIn_handler(
524  FwIndexType portNum,
525  U32 key
526  ) = 0;
527 
528  PROTECTED:
529 
530  // ----------------------------------------------------------------------
531  // Port handler base-class functions for typed input ports
532  //
533  // Call these functions directly to bypass the corresponding ports
534  // ----------------------------------------------------------------------
535 
538  FwIndexType portNum,
539  Fw::Buffer& fwBuffer
540  );
541 
544  FwIndexType portNum,
545  Fw::Buffer& fwBuffer
546  );
547 
549  void pingIn_handlerBase(
550  FwIndexType portNum,
551  U32 key
552  );
553 
554  PROTECTED:
555 
556  // ----------------------------------------------------------------------
557  // Pre-message hooks for typed async input ports
558  //
559  // Each of these functions is invoked just before processing a message
560  // on the corresponding port. By default, they do nothing. You can
561  // override them to provide specific pre-message behavior.
562  // ----------------------------------------------------------------------
563 
565  virtual void bufferSendInFill_preMsgHook(
566  FwIndexType portNum,
567  Fw::Buffer& fwBuffer
568  );
569 
571  virtual void bufferSendInReturn_preMsgHook(
572  FwIndexType portNum,
573  Fw::Buffer& fwBuffer
574  );
575 
577  virtual void pingIn_preMsgHook(
578  FwIndexType portNum,
579  U32 key
580  );
581 
582  PROTECTED:
583 
584  // ----------------------------------------------------------------------
585  // Invocation functions for typed output ports
586  // ----------------------------------------------------------------------
587 
590  FwIndexType portNum,
591  Fw::Buffer& fwBuffer
592  );
593 
596  FwIndexType portNum,
597  Fw::Buffer& fwBuffer
598  );
599 
601  void pingOut_out(
602  FwIndexType portNum,
603  U32 key
604  );
605 
606  PROTECTED:
607 
608  // ----------------------------------------------------------------------
609  // Command response
610  // ----------------------------------------------------------------------
611 
613  void cmdResponse_out(
614  FwOpcodeType opCode,
615  U32 cmdSeq,
616  Fw::CmdResponse response
617  );
618 
619  PROTECTED:
620 
621  // ----------------------------------------------------------------------
622  // Command handlers to implement
623  // ----------------------------------------------------------------------
624 
628  virtual void BA_SetMode_cmdHandler(
629  FwOpcodeType opCode,
630  U32 cmdSeq,
632  ) = 0;
633 
637  virtual void BA_DrainBuffers_cmdHandler(
638  FwOpcodeType opCode,
639  U32 cmdSeq,
640  U32 numToDrain,
642  ) = 0;
643 
644  PROTECTED:
645 
646  // ----------------------------------------------------------------------
647  // Command handler base-class functions
648  //
649  // Call these functions directly to bypass the command input port
650  // ----------------------------------------------------------------------
651 
656  FwOpcodeType opCode,
657  U32 cmdSeq,
658  Fw::CmdArgBuffer& args
659  );
660 
665  FwOpcodeType opCode,
666  U32 cmdSeq,
667  Fw::CmdArgBuffer& args
668  );
669 
670  PROTECTED:
671 
672  // ----------------------------------------------------------------------
673  // Pre-message hooks for async commands
674  //
675  // Each of these functions is invoked just before processing the
676  // corresponding command. By default they do nothing. You can
677  // override them to provide specific pre-command behavior.
678  // ----------------------------------------------------------------------
679 
681  virtual void BA_SetMode_preMsgHook(
682  FwOpcodeType opCode,
683  U32 cmdSeq
684  );
685 
687  virtual void BA_DrainBuffers_preMsgHook(
688  FwOpcodeType opCode,
689  U32 cmdSeq
690  );
691 
692  PROTECTED:
693 
694  // ----------------------------------------------------------------------
695  // Event logging functions
696  // ----------------------------------------------------------------------
697 
702 
706  void log_WARNING_HI_BA_QueueFull() const;
707 
712  U32 numDrained,
713  U32 numToDrain
714  ) const;
715 
720 
725  U32 numDrained,
726  U32 numToDrain
727  ) const;
728 
732  void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained) const;
733 
738  U32 numWillDrain,
739  U32 numReqDrain
740  ) const;
741 
742  PROTECTED:
743 
744  // ----------------------------------------------------------------------
745  // Telemetry write functions
746  // ----------------------------------------------------------------------
747 
752  U32 arg,
753  Fw::Time _tlmTime = Fw::Time()
754  ) const;
755 
756  PROTECTED:
757 
758  // ----------------------------------------------------------------------
759  // Time
760  // ----------------------------------------------------------------------
761 
765  Fw::Time getTime() const;
766 
767  PRIVATE:
768 
769  // ----------------------------------------------------------------------
770  // Message dispatch functions
771  // ----------------------------------------------------------------------
772 
774  virtual MsgDispatchStatus doDispatch();
775 
776  PRIVATE:
777 
778  // ----------------------------------------------------------------------
779  // Calls for messages received on special input ports
780  // ----------------------------------------------------------------------
781 
783  static void m_p_cmdIn_in(
784  Fw::PassiveComponentBase* callComp,
785  FwIndexType portNum,
786  FwOpcodeType opCode,
787  U32 cmdSeq,
788  Fw::CmdArgBuffer& args
789  );
790 
791  PRIVATE:
792 
793  // ----------------------------------------------------------------------
794  // Calls for messages received on typed input ports
795  // ----------------------------------------------------------------------
796 
798  static void m_p_bufferSendInFill_in(
799  Fw::PassiveComponentBase* callComp,
800  FwIndexType portNum,
801  Fw::Buffer& fwBuffer
802  );
803 
805  static void m_p_bufferSendInReturn_in(
806  Fw::PassiveComponentBase* callComp,
807  FwIndexType portNum,
808  Fw::Buffer& fwBuffer
809  );
810 
812  static void m_p_pingIn_in(
813  Fw::PassiveComponentBase* callComp,
814  FwIndexType portNum,
815  U32 key
816  );
817 
818  PRIVATE:
819 
820  // ----------------------------------------------------------------------
821  // Special input ports
822  // ----------------------------------------------------------------------
823 
825  Fw::InputCmdPort m_cmdIn_InputPort[NUM_CMDIN_INPUT_PORTS];
826 
827  PRIVATE:
828 
829  // ----------------------------------------------------------------------
830  // Typed input ports
831  // ----------------------------------------------------------------------
832 
834  Fw::InputBufferSendPort m_bufferSendInFill_InputPort[NUM_BUFFERSENDINFILL_INPUT_PORTS];
835 
837  Fw::InputBufferSendPort m_bufferSendInReturn_InputPort[NUM_BUFFERSENDINRETURN_INPUT_PORTS];
838 
840  Svc::InputPingPort m_pingIn_InputPort[NUM_PINGIN_INPUT_PORTS];
841 
842  PRIVATE:
843 
844  // ----------------------------------------------------------------------
845  // Special output ports
846  // ----------------------------------------------------------------------
847 
849  Fw::OutputCmdRegPort m_cmdRegOut_OutputPort[NUM_CMDREGOUT_OUTPUT_PORTS];
850 
852  Fw::OutputCmdResponsePort m_cmdResponseOut_OutputPort[NUM_CMDRESPONSEOUT_OUTPUT_PORTS];
853 
855  Fw::OutputLogPort m_eventOut_OutputPort[NUM_EVENTOUT_OUTPUT_PORTS];
856 
857 #if FW_ENABLE_TEXT_LOGGING == 1
858 
860  Fw::OutputLogTextPort m_eventOutText_OutputPort[NUM_EVENTOUTTEXT_OUTPUT_PORTS];
861 
862 #endif
863 
865  Fw::OutputTimePort m_timeCaller_OutputPort[NUM_TIMECALLER_OUTPUT_PORTS];
866 
868  Fw::OutputTlmPort m_tlmOut_OutputPort[NUM_TLMOUT_OUTPUT_PORTS];
869 
870  PRIVATE:
871 
872  // ----------------------------------------------------------------------
873  // Typed output ports
874  // ----------------------------------------------------------------------
875 
877  Fw::OutputBufferSendPort m_bufferSendOutDrain_OutputPort[NUM_BUFFERSENDOUTDRAIN_OUTPUT_PORTS];
878 
880  Fw::OutputBufferSendPort m_bufferSendOutReturn_OutputPort[NUM_BUFFERSENDOUTRETURN_OUTPUT_PORTS];
881 
883  Svc::OutputPingPort m_pingOut_OutputPort[NUM_PINGOUT_OUTPUT_PORTS];
884 
885  };
886 
887 }
888 
889 #endif
Definition: Time.hpp:9
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
bool isConnected_bufferSendOutDrain_OutputPort(FwIndexType portNum)
virtual void bufferSendInReturn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendInReturn.
PlatformSizeType FwSizeType
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)
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
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.
Not enough buffers to complete requested drain, and NOBLOCK was set; will only drain what we have...
friend class BufferAccumulatorTesterBase
Friend class tester to support autocoded test harness.
void init()
Object initializer.
Definition: ObjBase.cpp:26
void log_WARNING_LO_BA_NonBlockDrain(U32 numWillDrain, U32 numReqDrain) const
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.
U32 FwOpcodeType
The type of a command opcode.
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.
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.
void BA_SetMode_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
virtual void BA_DrainBuffers_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BA_DrainBuffers.
bool isConnected_bufferSendOutReturn_OutputPort(FwIndexType portNum)
void set_bufferSendOutDrain_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOutDrain[portNum].
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
The Buffer Accumulator instance accepted and enqueued a buffer. To avoid uncontrolled sending of even...
Fw::InputBufferSendPort * get_bufferSendInFill_InputPort(FwIndexType portNum)
void log_WARNING_HI_BA_DrainStalled(U32 numDrained, U32 numToDrain) const
RateGroupDivider component implementation.
Got DrainBuffers command while executing DrainBuffers command.
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.
The Buffer Accumulator instance received a buffer when its queue was full. To avoid uncontrolled send...
Ran out of buffers while executing DrainBuffers command.
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.