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 "Os/FileSystem.hpp"
18 
19 namespace Svc {
20 
21 class FileManager final : public FileManagerComponentBase {
22  friend class FileManagerTester;
23 
24  public:
25  // ----------------------------------------------------------------------
26  // Construction, initialization, and destruction
27  // ----------------------------------------------------------------------
28 
31  FileManager(const char* const compName
32  );
33 
36  ~FileManager();
37 
38  private:
39  // ----------------------------------------------------------------------
40  // Command handler implementations
41  // ----------------------------------------------------------------------
42 
45  void CreateDirectory_cmdHandler(const FwOpcodeType opCode,
46  const U32 cmdSeq,
47  const Fw::CmdStringArg& dirName
48  );
49 
52  void RemoveFile_cmdHandler(const FwOpcodeType opCode,
53  const U32 cmdSeq,
54  const Fw::CmdStringArg& fileName,
55  const bool ignoreErrors
56  );
57 
60  void MoveFile_cmdHandler(const FwOpcodeType opCode,
61  const U32 cmdSeq,
62  const Fw::CmdStringArg& sourceFileName,
63  const Fw::CmdStringArg& destFileName
64  );
65 
68  void RemoveDirectory_cmdHandler(const FwOpcodeType opCode,
69  const U32 cmdSeq,
70  const Fw::CmdStringArg& dirName
71  );
72 
75  void ShellCommand_cmdHandler(const FwOpcodeType opCode,
76  const U32 cmdSeq,
77  const Fw::CmdStringArg& command,
78  const Fw::CmdStringArg& logFileName
79  );
80 
83  void AppendFile_cmdHandler(const FwOpcodeType opCode,
84  const U32 cmdSeq,
85  const Fw::CmdStringArg& source,
86  const Fw::CmdStringArg& target
87  );
88 
91  void FileSize_cmdHandler(const FwOpcodeType opCode,
92  const U32 cmdSeq,
93  const Fw::CmdStringArg& fileName
94  );
95 
98  void ListDirectory_cmdHandler(const FwOpcodeType opCode,
99  const U32 cmdSeq,
100  const Fw::CmdStringArg& dirName
101  );
102 
105  void pingIn_handler(const FwIndexType portNum,
106  U32 key
107  );
108 
114  void schedIn_handler(const FwIndexType portNum,
115  U32 context
116  );
117 
118  private:
119  // ----------------------------------------------------------------------
120  // Helper methods
121  // ----------------------------------------------------------------------
122 
125  int systemCall(const Fw::CmdStringArg& command,
126  const Fw::CmdStringArg& logFileName
127  ) const;
128 
131  void emitTelemetry(const Os::FileSystem::Status status
132  );
133 
136  void sendCommandResponse(const FwOpcodeType opCode,
137  const U32 cmdSeq,
138  const Os::FileSystem::Status status
139  );
140 
141  private:
142  // ----------------------------------------------------------------------
143  // Variables
144  // ----------------------------------------------------------------------
145 
148  U32 commandCount;
149 
152  U32 errorCount;
153 
154  // ----------------------------------------------------------------------
155  // Directory listing state machine variables
156  // ----------------------------------------------------------------------
157  // The FileManager uses an asynchronous state machine to process
158  // directory listings through Rate Group 2. This prevents event
159  // flooding and ensures bounded execution time by processing one
160  // directory entry per rate tick (0.5Hz).
161 
163  enum ListDirectoryState {
164  IDLE,
165  LISTING_IN_PROGRESS
166  };
167 
169  ListDirectoryState m_listState;
170 
172  Os::Directory m_currentDir;
173 
175  Fw::String m_currentDirName;
176 
178  U32 m_totalEntries;
179 
181  FwOpcodeType m_currentOpCode;
182 
184  U32 m_currentCmdSeq;
185 };
186 
187 } // end namespace Svc
188 
189 #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:22
Directory class.
Definition: Directory.hpp:114
PlatformIndexType FwIndexType
RateGroupDivider component implementation.