F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ComLoggerDp.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComLoggerDp.hpp
3 // \author tcanham
4 // \brief hpp file for ComLoggerDp component implementation class
5 // ======================================================================
6 
7 #ifndef Svc_ComLoggerDp_HPP
8 #define Svc_ComLoggerDp_HPP
9 
10 #include "Fw/Dp/DpContainer.hpp"
12 #include "config/ComLoggerDpCfg.hpp"
13 
14 namespace Svc {
15 
16 // Forward declaration for testing
17 class ComLoggerDpTester;
18 
19 class ComLoggerDp final : public ComLoggerDpComponentBase {
20  // Grant test access to private methods for unit testing
21  friend class ComLoggerDpTester;
22 
23  public:
24  // ----------------------------------------------------------------------
25  // Public interface
26  // ----------------------------------------------------------------------
27 
30 
33 
49  static constexpr FwSizeType ComLoggerDpBuffSize(FwSizeType packetsPerContainer) {
50  return DpContainer::MIN_PACKET_SIZE + packetsPerContainer * RECORD_SIZE;
51  }
52 
53  // ----------------------------------------------------------------------
54  // Component construction and destruction
55  // ----------------------------------------------------------------------
56 
58  explicit ComLoggerDp(const char* const compName
59  );
60 
62  ~ComLoggerDp();
63 
65  ComLoggerDp(const ComLoggerDp&) = delete;
66 
68  ComLoggerDp& operator=(const ComLoggerDp&) = delete;
69 
71  ComLoggerDp(ComLoggerDp&&) = delete;
72 
74  ComLoggerDp& operator=(ComLoggerDp&&) = delete;
75 
82  void configure(bool enabled, FwSizeType packetsPerContainer, FwDpPriorityType priority, U32 flushTimeout);
83 
84  private:
85  // ----------------------------------------------------------------------
86  // Handler implementations for typed input ports
87  // ----------------------------------------------------------------------
88 
92  void comIn_handler(FwIndexType portNum,
93  Fw::ComBuffer& data,
94  U32 context
95  ) override;
96 
100  void pingIn_handler(FwIndexType portNum,
101  U32 key
102  ) override;
103 
107  void schedIn_handler(FwIndexType portNum,
108  U32 context
109  ) override;
110 
114  void startRecordingIn_handler(FwIndexType portNum,
115  FwSizeType packetsPerContainer,
116  FwDpPriorityType priority
117  ) override;
118 
122  void stopRecordingIn_handler(FwIndexType portNum
123  ) override;
124 
125  private:
126  // ----------------------------------------------------------------------
127  // Handler implementations for commands
128  // ----------------------------------------------------------------------
129 
133  void StartComDp_cmdHandler(FwOpcodeType opCode,
134  U32 cmdSeq,
135  FwSizeType packetsPerContainer,
136  FwDpPriorityType priority) override;
137 
141  void UpdatePriority_cmdHandler(FwOpcodeType opCode,
142  U32 cmdSeq,
143  FwDpPriorityType priority) override;
144 
148  void StopComDp_cmdHandler(FwOpcodeType opCode,
149  U32 cmdSeq
150  ) override;
151 
155  void CLEAR_COUNTERS_cmdHandler(FwOpcodeType opCode,
156  U32 cmdSeq
157  ) override;
158 
159  private:
160  // ----------------------------------------------------------------------
161  // Private helper functions
162  // ----------------------------------------------------------------------
163 
168  Fw::Success startRecordingInternal(FwSizeType packetsPerContainer, FwDpPriorityType priority);
169 
172  ComLoggerDp_PartialContainerStatus stopRecordingInternal();
173 
176  Fw::Success allocateAndSetupContainer();
177 
181  void serializePacket(const U8* dataPtr, FwSizeType dataSize);
182 
186  ComLoggerDp_PartialContainerStatus sendContainerIfNonEmpty();
187 
189  void finalizeContainer();
190 
193  void handleBufferDrop(U32 size);
194 
195  private:
196  // ----------------------------------------------------------------------
197  // Private member variables
198  // ----------------------------------------------------------------------
199 
201  bool m_enabled{false};
202 
204  DpContainer m_container;
205 
207  FwSizeType m_packetsPerContainer{0};
208 
210  FwSizeType m_currentPacketCount{0};
211 
213  U32 m_numBuffersLogged{0};
214 
216  U32 m_numBuffersDropped{0};
217 
219  U32 m_schedCallsSinceLastPacket{0};
220 
222  U32 m_flushTimeout{0};
223 
225  FwDpPriorityType m_priority{ContainerPriority::ComBuffContainer}; // Default priority from FPP
226 
228  U8 m_recordBuffer[MAX_RECORD_DATA_SIZE];
229 };
230 
231 } // namespace Svc
232 
233 #endif
static constexpr FwSizeType SIZE_OF_ComBufferRecord_RECORD(FwSizeType arraySize)
Record sizes.
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
U32 FwDpPriorityType
The type of a data product priority.
void configure(bool enabled, FwSizeType packetsPerContainer, FwDpPriorityType priority, U32 flushTimeout)
Definition: ComLoggerDp.cpp:24
static constexpr FwSizeType MIN_PACKET_SIZE
Definition: DpContainer.hpp:65
ComLoggerDp(const char *const compName)
Construct ComLoggerDp object.
Definition: ComLoggerDp.cpp:16
Auto-generated base for ComLoggerDp component.
~ComLoggerDp()
Destroy ComLoggerDp object.
Definition: ComLoggerDp.cpp:18
static constexpr FwSizeType MAX_RECORD_DATA_SIZE
Maximum data size of one record: a sentry followed by a maximum-size ComBuffer.
Definition: ComLoggerDp.hpp:29
friend class ComLoggerDpTester
Definition: ComLoggerDp.hpp:21
static constexpr FwSizeType ComLoggerDpBuffSize(FwSizeType packetsPerContainer)
Definition: ComLoggerDp.hpp:49
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
constexpr U32 ComLoggerDpSentry
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
Whether a partial container was sent when recording stopped.
Success/Failure.
ComLoggerDp & operator=(const ComLoggerDp &)=delete
Copy assignment operator (deleted)
static constexpr FwSizeType RECORD_SIZE
Serialized size of one ComBufferRecord holding MAX_RECORD_DATA_SIZE bytes.
Definition: ComLoggerDp.hpp:32