F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileManager.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileManager.hpp
3 // \author bocchino
4 // \brief hpp file for FileManager component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef Svc_FileManager_HPP
14 #define Svc_FileManager_HPP
15 
16 #include <atomic>
17 #include "Os/FileSystem.hpp"
19 
20 namespace Svc {
21 
22 class FileManager final : public FileManagerComponentBase {
23  friend class FileManagerTester;
24 
25  public:
26  // ----------------------------------------------------------------------
27  // Construction, initialization, and destruction
28  // ----------------------------------------------------------------------
29 
32  FileManager(const char* const compName
33  );
34 
37  ~FileManager();
38 
39  private:
40  // ----------------------------------------------------------------------
41  // Command handler implementations
42  // ----------------------------------------------------------------------
43 
46  void CreateDirectory_cmdHandler(const FwOpcodeType opCode,
47  const U32 cmdSeq,
48  const Fw::CmdStringArg& dirName
49  ) override;
50 
53  void RemoveFile_cmdHandler(const FwOpcodeType opCode,
54  const U32 cmdSeq,
55  const Fw::CmdStringArg& fileName,
56  const bool ignoreErrors
57  ) override;
58 
61  void MoveFile_cmdHandler(const FwOpcodeType opCode,
62  const U32 cmdSeq,
63  const Fw::CmdStringArg& sourceFileName,
64  const Fw::CmdStringArg& destFileName
65  ) override;
66 
69  void RemoveDirectory_cmdHandler(const FwOpcodeType opCode,
70  const U32 cmdSeq,
71  const Fw::CmdStringArg& dirName
72  ) override;
73 
76  void AppendFile_cmdHandler(const FwOpcodeType opCode,
77  const U32 cmdSeq,
78  const Fw::CmdStringArg& source,
79  const Fw::CmdStringArg& target
80  ) override;
81 
84  void FileSize_cmdHandler(const FwOpcodeType opCode,
85  const U32 cmdSeq,
86  const Fw::CmdStringArg& fileName
87  ) override;
88 
91  void ListDirectory_cmdHandler(const FwOpcodeType opCode,
92  const U32 cmdSeq,
93  const Fw::CmdStringArg& dirName
94  ) override;
95 
99  void CalculateCrc_cmdHandler(FwOpcodeType opCode,
100  U32 cmdSeq,
101  const Fw::CmdStringArg& filename
102  ) override;
103 
106  void pingIn_handler(const FwIndexType portNum,
107  U32 key
108  ) override;
109 
115  void schedIn_handler(const FwIndexType portNum,
116  U32 context
117  ) override;
118 
119  private:
120  // ----------------------------------------------------------------------
121  // Helper methods
122  // ----------------------------------------------------------------------
123 
126  void emitTelemetry(const Os::FileSystem::Status status
127  );
128 
131  void sendCommandResponse(const FwOpcodeType opCode,
132  const U32 cmdSeq,
133  const Os::FileSystem::Status status
134  );
135 
136  private:
137  // ----------------------------------------------------------------------
138  // Handler implementations for user-defined internal interfaces
139  // ----------------------------------------------------------------------
140 
144  void run_internalInterfaceHandler() override;
145 
146  private:
147  // ----------------------------------------------------------------------
148  // Variables
149  // ----------------------------------------------------------------------
150 
153  U32 commandCount;
154 
157  U32 errorCount;
158 
159  // ----------------------------------------------------------------------
160  // Directory listing state machine variables
161  // ----------------------------------------------------------------------
162  // The FileManager uses an asynchronous state machine to process
163  // directory listings through Rate Group 2. This prevents event
164  // flooding and ensures bounded execution time by processing one
165  // directory entry per rate tick (0.5Hz).
166 
168  enum ListDirectoryState {
169  IDLE,
170  LISTING_IN_PROGRESS
171  };
172 
174  ListDirectoryState m_listState;
175 
177  Os::Directory m_currentDir;
178 
180  Fw::String m_currentDirName;
181 
183  U32 m_totalEntries;
184 
186  FwOpcodeType m_currentOpCode;
187 
189  U32 m_currentCmdSeq;
190 
191  std::atomic<bool> m_runQueued;
192 };
193 
194 } // end namespace Svc
195 
196 #endif
FwIdType FwOpcodeType
The type of a command opcode.
FileManager(const char *const compName)
Definition: FileManager.cpp:29
Auto-generated base for FileManager component.
friend class FileManagerTester
Definition: FileManager.hpp:23
Directory class.
Definition: Directory.hpp:114
PlatformIndexType FwIndexType
RateGroupDivider component implementation.