F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DpWriter.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpWriter.hpp
3 // \author bocchino
4 // \brief hpp file for DpWriter component implementation class
5 // ======================================================================
6 
7 #ifndef Svc_DpWriter_HPP
8 #define Svc_DpWriter_HPP
9 
10 #include <config/DpCfg.hpp>
11 
12 #include <atomic>
13 
14 #include "Fw/Dp/DpContainer.hpp"
16 #include "Fw/Types/String.hpp"
19 
20 namespace Svc {
21 
22 class DpWriter final : public DpWriterComponentBase {
23  friend class DpWriterTester;
24 
25  // Keep the generated routing arrays consistent with the forwarding contract.
26  static_assert(DpWriter::NUM_BUFFERSENDIN_INPUT_PORTS == static_cast<FwSizeType>(DpWriterNumPorts),
27  "Number of buffer send in ports must equal DpWriterNumPorts");
28  static_assert(DpWriter::NUM_DPWRITTENOUT_OUTPUT_PORTS == static_cast<FwSizeType>(DpWriterNumPorts),
29  "Number of dp written out ports must equal DpWriterNumPorts");
30  static_assert(DpWriter::NUM_DEALLOCBUFFERSENDOUT_OUTPUT_PORTS == static_cast<FwSizeType>(DpWriterNumPorts),
31  "Number of dealloc buffer send out ports must equal DpWriterNumPorts");
32 
33  public:
34  // ----------------------------------------------------------------------
35  // Construction, initialization, and destruction
36  // ----------------------------------------------------------------------
37 
40  DpWriter(const char* const compName
41  );
42 
45  ~DpWriter();
46 
48  void configure(const Fw::ConstStringBase& dpFileNamePrefix
49  );
50 
51  private:
52  // ----------------------------------------------------------------------
53  // Handler implementations for user-defined typed input ports
54  // ----------------------------------------------------------------------
55 
58  void bufferSendIn_handler(const FwIndexType portNum,
59  Fw::Buffer& fwBuffer
60  ) final;
61 
64  void schedIn_handler(const FwIndexType portNum,
65  U32 context
66  ) final;
67 
69  void schedInInternal_internalInterfaceHandler() final;
70 
72  void schedInInternal_overflowHook() final;
73 
74  private:
75  // ----------------------------------------------------------------------
76  // Handler implementations for commands
77  // ----------------------------------------------------------------------
78 
82  void CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode,
83  U32 cmdSeq
84  ) final;
85 
86  private:
87  // ----------------------------------------------------------------------
88  // Private helper functions
89  // ----------------------------------------------------------------------
90 
93  Fw::Success::T deserializePacketHeader(Fw::Buffer& buffer,
94  Fw::DpContainer& container
95  );
96 
98  void performProcessing(Fw::DpContainer& container
99  );
100 
103  Fw::Success::T writeFile(const Fw::DpContainer& container,
104  const Fw::FileNameString& fileName,
105  FwSizeType& fileSize
106  );
107 
109  void sendNotification(FwIndexType portNum,
110  const Fw::DpContainer& container,
111  const Fw::FileNameString& fileName,
112  FwSizeType fileSize
113  );
114 
115  private:
116  // ----------------------------------------------------------------------
117  // Private member variables
118  // ----------------------------------------------------------------------
119 
121  U32 m_numBuffersReceived = 0;
122 
124  U64 m_numBytesWritten = 0;
125 
127  U32 m_numSuccessfulWrites = 0;
128 
130  U32 m_numFailedWrites = 0;
131 
133  U32 m_numErrors = 0;
134 
136  std::atomic<bool> m_schedInQueued{false};
137 
141  Fw::FileNameString m_dpFileNamePrefix;
142 };
143 
144 } // end namespace Svc
145 
146 #endif
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
StringTemplate< FileNameStringSize > FileNameString
A read-only abstract superclass for StringBase.
PlatformIndexType FwIndexType
void configure(const Fw::ConstStringBase &dpFileNamePrefix)
Configure writer.
Definition: DpWriter.cpp:26
RateGroupDivider component implementation.
Implementation of malloc based allocator.
DpWriter(const char *const compName)
Definition: DpWriter.cpp:22
friend class DpWriterTester
Definition: DpWriter.hpp:23
Auto-generated base for DpWriter component.