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