Commit 277c1ae1 authored by Don Gagne's avatar Don Gagne

Merge pull request #1542 from DonLakeFlyer/FileManager

Cleanup FileManager
parents 2e3088b8 5e36ee5f
...@@ -53,13 +53,11 @@ private slots: ...@@ -53,13 +53,11 @@ private slots:
void cleanup(void); void cleanup(void);
// Test cases // Test cases
#if 0
void _ackTest(void); void _ackTest(void);
void _noAckTest(void); void _noAckTest(void);
void _resetTest(void); void _resetTest(void);
void _listTest(void); void _listTest(void);
void _readDownloadTest(void); void _readDownloadTest(void);
#endif
void _streamDownloadTest(void); void _streamDownloadTest(void);
// Connected to FileManager listEntry signal // Connected to FileManager listEntry signal
...@@ -70,19 +68,15 @@ private: ...@@ -70,19 +68,15 @@ private:
enum { enum {
listEntrySignalIndex = 0, listEntrySignalIndex = 0,
listCompleteSignalIndex, commandCompleteSignalIndex,
downloadFileLengthSignalIndex, commandErrorSignalIndex,
downloadFileCompleteSignalIndex,
errorMessageSignalIndex,
maxSignalIndex maxSignalIndex
}; };
enum { enum {
listEntrySignalMask = 1 << listEntrySignalIndex, listEntrySignalMask = 1 << listEntrySignalIndex,
listCompleteSignalMask = 1 << listCompleteSignalIndex, commandCompleteSignalMask = 1 << commandCompleteSignalIndex,
downloadFileLengthSignalMask = 1 << downloadFileLengthSignalIndex, commandErrorSignalMask = 1 << errorMessageSignalIndex,
downloadFileCompleteSignalMask = 1 << downloadFileCompleteSignalIndex,
errorMessageSignalMask = 1 << errorMessageSignalIndex,
}; };
static const uint8_t _systemIdQGC = 255; static const uint8_t _systemIdQGC = 255;
......
This diff is collapsed.
...@@ -35,6 +35,7 @@ Q_DECLARE_LOGGING_CATEGORY(FileManagerLog) ...@@ -35,6 +35,7 @@ Q_DECLARE_LOGGING_CATEGORY(FileManagerLog)
class FileManager : public QObject class FileManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FileManager(QObject* parent, UASInterface* uas, uint8_t unitTestSystemIdQGC = 0); FileManager(QObject* parent, UASInterface* uas, uint8_t unitTestSystemIdQGC = 0);
...@@ -65,38 +66,23 @@ public: ...@@ -65,38 +66,23 @@ public:
void uploadPath(const QString& toPath, const QFileInfo& uploadFile); void uploadPath(const QString& toPath, const QFileInfo& uploadFile);
signals: signals:
/// @brief Signalled whenever an error occurs during the listDirectory or downloadPath methods.
void errorMessage(const QString& msg);
// Signals associated with the listDirectory method // Signals associated with the listDirectory method
/// @brief Signalled to indicate a new directory entry was received. /// Signalled to indicate a new directory entry was received.
void listEntry(const QString& entry); void listEntry(const QString& entry);
/// @brief Signalled after listDirectory completes. If an error occurs during directory listing this signal will not be emitted. // Signals associated with all commands
void listComplete(void);
// Signals associated with the downloadPath method
/// @brief Signalled after downloadPath is called to indicate length of file being downloaded
void downloadFileLength(unsigned int length);
/// @brief Signalled during file download to indicate download progress
/// @param bytesReceived Number of bytes currently received from file
void downloadFileProgress(unsigned int bytesReceived);
/// @brief Signaled to indicate completion of file download. If an error occurs during download this signal will not be emitted.
void downloadFileComplete(void);
/// @brief Signalled after createFile acknowledge is returned to indicate length of file being downloaded /// Signalled after a command has completed
void uploadFileLength(unsigned int length); void commandComplete(void);
/// @brief Signalled during file upload to indicate progress /// Signalled when an error occurs during a command. In this case a commandComplete signal will
/// @param bytesReceived Number of bytes currently transmitted to file /// not be sent.
void uploadFileProgress(unsigned int bytesReceived); void commandError(const QString& msg);
/// @brief Signaled to indicate completion of file upload. If an error occurs during download this signal will not be emitted. /// Signalled during a lengthy command to show progress
void uploadFileComplete(void); /// @param value Amount of progress: 0.0 = none, 1.0 = complete
void commandProgress(int value);
public slots: public slots:
void receiveMessage(LinkInterface* link, mavlink_message_t message); void receiveMessage(LinkInterface* link, mavlink_message_t message);
...@@ -184,7 +170,7 @@ private: ...@@ -184,7 +170,7 @@ private:
kCOAck, // waiting for an Ack kCOAck, // waiting for an Ack
kCOList, // waiting for List response kCOList, // waiting for List response
kCOOpenRead, // waiting for Open response followed by Read download kCOOpenRead, // waiting for Open response followed by Read download
kCOOpenStream, // waiting for Open response, followed by Stream download kCOOpenBurst, // waiting for Open response, followed by Burst download
kCORead, // waiting for Read response kCORead, // waiting for Read response
kCOBurst, // waiting for Burst response kCOBurst, // waiting for Burst response
kCOWrite, // waiting for Write response kCOWrite, // waiting for Write response
...@@ -205,8 +191,9 @@ private: ...@@ -205,8 +191,9 @@ private:
void _writeAckResponse(Request* writeAck); void _writeAckResponse(Request* writeAck);
void _writeFileDatablock(void); void _writeFileDatablock(void);
void _sendListCommand(void); void _sendListCommand(void);
void _sendTerminateCommand(void); void _sendResetCommand(void);
void _closeDownloadSession(bool success); void _closeDownloadSession(bool success);
void _closeUploadSession(bool success);
void _downloadWorker(const QString& from, const QDir& downloadDir, bool readFile); void _downloadWorker(const QString& from, const QDir& downloadDir, bool readFile);
static QString errorString(uint8_t errorCode); static QString errorString(uint8_t errorCode);
...@@ -222,15 +209,19 @@ private: ...@@ -222,15 +209,19 @@ private:
QString _listPath; ///< path for the current List operation QString _listPath; ///< path for the current List operation
uint8_t _activeSession; ///< currently active session, 0 for none uint8_t _activeSession; ///< currently active session, 0 for none
uint32_t _readOffset; ///< current read offset uint32_t _readOffset; ///< current read offset
uint32_t _writeOffset; ///< current write offset uint32_t _writeOffset; ///< current write offset
uint32_t _writeSize; ///< current write data size uint32_t _writeSize; ///< current write data size
uint32_t _writeFileSize; ///< current write file size uint32_t _writeFileSize; ///< Size of file being uploaded
QByteArray _writeFileAccumulator; ///< Holds file being uploaded
uint32_t _downloadOffset; ///< current download offset uint32_t _downloadOffset; ///< current download offset
QByteArray _readFileAccumulator; ///< Holds file being downloaded QByteArray _readFileAccumulator; ///< Holds file being downloaded
QByteArray _writeFileAccumulator; ///< Holds file being uploaded
QDir _readFileDownloadDir; ///< Directory to download file to QDir _readFileDownloadDir; ///< Directory to download file to
QString _readFileDownloadFilename; ///< Filename (no path) for download file QString _readFileDownloadFilename; ///< Filename (no path) for download file
uint32_t _downloadFileSize; ///< Size of file being downloaded
uint8_t _systemIdQGC; ///< System ID for QGC uint8_t _systemIdQGC; ///< System ID for QGC
uint8_t _systemIdServer; ///< System ID for server uint8_t _systemIdServer; ///< System ID for server
......
This diff is collapsed.
...@@ -41,26 +41,22 @@ protected: ...@@ -41,26 +41,22 @@ protected:
FileManager* _manager; FileManager* _manager;
private slots: private slots:
void _refreshTree(void);
void _listEntryReceived(const QString& entry); void _listEntryReceived(const QString& entry);
void _listErrorMessage(const QString& msg);
void _listComplete(void);
void _refreshTree(void);
void _downloadFile(void); void _downloadFile(void);
void _uploadFile(void); void _uploadFile(void);
void _downloadLength(unsigned int length);
void _downloadProgress(unsigned int length); void _commandProgress(int value);
void _downloadErrorMessage(const QString& msg); void _commandError(const QString& msg);
void _downloadComplete(void); void _commandComplete(void);
void _currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); void _currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
private: private:
void _connectDownloadSignals(void); void _listComplete(void);
void _disconnectDownloadSignals(void);
void _connectListSignals(void);
void _disconnectListSignals(void);
void _requestDirectoryList(const QString& dir); void _requestDirectoryList(const QString& dir);
void _setAllButtonsEnabled(bool enabled);
static const int _typeFile = QTreeWidgetItem::UserType + 1; static const int _typeFile = QTreeWidgetItem::UserType + 1;
static const int _typeDir = QTreeWidgetItem::UserType + 2; static const int _typeDir = QTreeWidgetItem::UserType + 2;
...@@ -70,12 +66,14 @@ private: ...@@ -70,12 +66,14 @@ private:
QList<QTreeWidgetItem*> _walkItemStack; QList<QTreeWidgetItem*> _walkItemStack;
Ui::QGCUASFileView _ui; Ui::QGCUASFileView _ui;
QString _downloadFilename; ///< File currently being downloaded, not including path enum CommandState {
QTime _downloadStartTime; ///< Time at which download started commandNone, ///< No command active
commandList, ///< List command active
commandDownload, ///< Download command active
commandUpload ///< Upload command active
};
bool _listInProgress; ///< Indicates that a listDirectory command is in progress CommandState _currentCommand; ///< Current active command
bool _downloadInProgress; ///< Indicates that a downloadPath command is in progress
bool _uploadInProgress; ///< Indicates that a upload command is in progress
}; };
#endif // QGCUASFILEVIEW_H #endif // QGCUASFILEVIEW_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment