F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
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 
19 namespace Svc {
20 
21  class DpCatalog :
23  {
24 
25  public:
26 
27  // ----------------------------------------------------------------------
28  // Component construction and destruction
29  // ----------------------------------------------------------------------
30 
33  DpCatalog(
34  const char* const compName
35  );
36 
38  ~DpCatalog();
39 
47  void configure(
49  FwSizeType numDirs,
50  NATIVE_UINT_TYPE memId,
51  Fw::MemAllocator& allocator
52  );
53 
54  // @brief clean up component.
55  // Deallocates memory.
56  void shutdown();
57 
58 
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  bool entry;
128  FwIndexType dir;
129  DpRecord record;
130 
131  };
132 
134  struct DpSortedList {
135  DpStateEntry* recPtr;
136  bool sent;
137  };
138 
139 
140  // ----------------------------------
141  // Private helpers
142  // ----------------------------------
143 
147  bool insertEntry(DpStateEntry& entry);
148 
151  void deleteEntry(DpStateEntry& entry);
152 
154  void sendNextEntry();
155 
158  bool checkInit();
159 
162  Fw::CmdResponse doCatalogBuild();
163 
166  Fw::CmdResponse doCatalogXmit();
167 
168  // ----------------------------------
169  // Private data
170  // ----------------------------------
171  bool m_initialized;
172  DpStateEntry* m_dpList;
173  DpSortedList* m_sortedDpList;
174 
175  FwSizeType m_numDpRecords;
176  FwSizeType m_numDpSlots;
177 
178  Fw::FileNameString m_directories[DP_MAX_DIRECTORIES];
179  FwSizeType m_numDirectories;
180  Fw::String m_fileList[DP_MAX_FILES];
181 
182  NATIVE_UINT_TYPE m_memSize;
183  void* m_memPtr;
184  NATIVE_UINT_TYPE m_allocatorId;
185  Fw::MemAllocator* m_allocator;
186 
187  bool m_xmitInProgress;
188  DpSortedList* m_currXmitRecord;
189  Fw::FileNameString m_currXmitFileName;
190  bool m_xmitCmdWait;
191  U64 m_xmitBytes;
192 
193  FwOpcodeType m_xmitOpCode;
194  U32 m_xmitCmdSeq;
195 
196  };
197 
198 }
199 
200 #endif
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
U32 FwOpcodeType
Definition: FpConfig.h:78
PlatformSizeType FwSizeType
Definition: FpConfig.h:30
PlatformIndexType FwIndexType
Definition: FpConfig.h:20
Defines a base class for a memory allocator for classes.
Enum representing a command response.
Wait or don't wait for something.
Definition: WaitEnumAc.hpp:19
Auto-generated base for DpCatalog component.
void configure(Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, NATIVE_UINT_TYPE memId, Fw::MemAllocator &allocator)
Configure the DpCatalog.
Definition: DpCatalog.cpp:48
DpCatalog(const char *const compName)
DpCatalog constructor.
Definition: DpCatalog.cpp:22
~DpCatalog()
DpCatalog destructor.
Definition: DpCatalog.cpp:45
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