F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
DpCatalog.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title DpCatalog.hpp
3// \author tcanham
4// \brief hpp file for DpCatalog component implementation class
5// ======================================================================
6
7#ifndef Svc_DpCatalog_HPP
8#define Svc_DpCatalog_HPP
9
12
14
15#include <DpCfg.hpp>
16#include <DpCatalogCfg.hpp>
18
19namespace Svc {
20
21 class DpCatalog :
23 {
24
25 public:
26
27 // ----------------------------------------------------------------------
28 // Component construction and destruction
29 // ----------------------------------------------------------------------
30
34 const char* const compName
35 );
36
38 ~DpCatalog();
39
48 void configure(
50 FwSizeType numDirs,
51 Fw::FileNameString& stateFile,
52 NATIVE_UINT_TYPE memId,
53 Fw::MemAllocator& allocator
54 );
55
56 // @brief clean up component.
57 // Deallocates memory.
58 void shutdown();
59
60 PRIVATE:
61
62 // ----------------------------------------------------------------------
63 // Handler implementations for user-defined typed input ports
64 // ----------------------------------------------------------------------
65
69 void fileDone_handler(
70 NATIVE_INT_TYPE portNum,
71 const Svc::SendFileResponse& resp
72 ) override;
73
77 void pingIn_handler(
78 NATIVE_INT_TYPE portNum,
79 U32 key
80 ) override;
81
82 PRIVATE:
83
84 // ----------------------------------------------------------------------
85 // Handler implementations for commands
86 // ----------------------------------------------------------------------
87
91 void BUILD_CATALOG_cmdHandler(
92 FwOpcodeType opCode,
93 U32 cmdSeq
94 ) override;
95
99 void START_XMIT_CATALOG_cmdHandler(
100 FwOpcodeType opCode,
101 U32 cmdSeq,
102 Fw::Wait wait
103 ) override;
104
108 void STOP_XMIT_CATALOG_cmdHandler(
109 FwOpcodeType opCode,
110 U32 cmdSeq
111 ) override;
112
116 void CLEAR_CATALOG_cmdHandler(
117 FwOpcodeType opCode,
118 U32 cmdSeq
119 ) override;
120
121
122 // ----------------------------------
123 // Private data structures
124 // ----------------------------------
125
126 struct DpStateEntry {
127 FwIndexType dir;
128 DpRecord record;
129 };
130
131 struct DpDstateFileEntry {
132 bool used;
133 bool visited;
134 DpStateEntry entry;
135 };
136
138 struct DpBtreeNode {
139 DpStateEntry entry;
140 DpBtreeNode* left;
141 DpBtreeNode* right;
142 };
143
144 // ----------------------------------
145 // Private helpers
146 // ----------------------------------
147
151 bool insertEntry(DpStateEntry& entry);
152
155 void deleteEntry(DpStateEntry& entry);
156
158 enum CheckStat {
159 CHECK_OK,
160 CHECK_CONT,
161 CHECK_ERROR,
162 };
163
165 CheckStat checkLeftRight(bool condition, DpBtreeNode* &node, const DpStateEntry& newEntry);
166
168 void resetBinaryTree();
169
171 Fw::CmdResponse fillBinaryTree();
172
174 void resetTreeStack();
175
177 void resetStateFileData();
178
181 void getFileState(DpStateEntry& entry);
182
184 void pruneAndWriteStateFile();
185
187 Fw::CmdResponse loadStateFile();
188
191 void appendFileState(const DpStateEntry& entry);
192
196 bool allocateNode(
197 DpBtreeNode* &newNode,
198 const DpStateEntry& newEntry);
199
201 void sendNextEntry();
202
206 DpBtreeNode* findNextTreeNode();
207
210 bool checkInit();
211
214 Fw::CmdResponse doCatalogBuild();
215
218 Fw::CmdResponse doCatalogXmit();
219
220 // ----------------------------------
221 // Private data
222 // ----------------------------------
223 bool m_initialized;
224
225 DpBtreeNode* m_dpTree;
226 DpBtreeNode* m_freeListHead;
227 DpBtreeNode* m_freeListFoot;
228 DpBtreeNode** m_traverseStack;
229 DpBtreeNode* m_currentNode;
230 DpBtreeNode* m_currentXmitNode;
231
232 FwSizeType m_numDpRecords;
233 FwSizeType m_numDpSlots;
234
236 FwSizeType m_numDirectories;
237 Fw::String m_fileList[DP_MAX_FILES];
238
239 Fw::FileNameString m_stateFile;
240 DpDstateFileEntry* m_stateFileData;
241 FwSizeType m_stateFileEntries;
242
243 NATIVE_UINT_TYPE m_memSize;
244 void* m_memPtr;
245 NATIVE_UINT_TYPE m_allocatorId;
246 Fw::MemAllocator* m_allocator;
247
248 bool m_xmitInProgress;
249 FwIndexType m_currStackEntry;
250 Fw::FileNameString m_currXmitFileName;
251 bool m_xmitCmdWait;
252 U64 m_xmitBytes;
253 FwOpcodeType m_xmitOpCode;
254 U32 m_xmitCmdSeq;
255
256 };
257
258}
259
260#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:56
U32 FwOpcodeType
Definition FpConfig.h:91
PlatformSizeType FwSizeType
Definition FpConfig.h:35
PlatformIndexType FwIndexType
Definition FpConfig.h:25
Defines a base class for a memory allocator for classes.
Enum representing a command response.
Wait or don't wait for something.
Auto-generated base for DpCatalog component.
void configure(Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, Fw::FileNameString &stateFile, NATIVE_UINT_TYPE memId, Fw::MemAllocator &allocator)
Configure the DpCatalog.
Definition DpCatalog.cpp:54
~DpCatalog()
DpCatalog destructor.
Definition DpCatalog.cpp:51
Data structure representing a data product.
static const FwSizeType DP_MAX_FILES
static const FwSizeType DP_MAX_DIRECTORIES
#define U64(C)
Definition sha.h:176