Commit c615f477 authored by Gus Grubba's avatar Gus Grubba

Finished. Needs testing and debugging.

parent 4d23912a
This diff is collapsed.
......@@ -31,25 +31,31 @@ public:
MavlinkLogFiles (MavlinkLogManager* manager, const QString& filePath);
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(quint32 size READ size CONSTANT)
Q_PROPERTY(quint32 size READ size NOTIFY sizeChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool uploading READ uploading NOTIFY uploadingChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool writing READ writing NOTIFY writingChanged)
QString name () { return _name; }
quint32 size () { return _size; }
bool selected () { return _selected; }
bool uploading () { return _uploading; }
qreal progress () { return _progress; }
bool writing () { return _writing; }
void setSelected (bool selected);
void setUploading (bool uploading);
void setProgress (qreal progress);
void setWriting (bool writing);
void setSize (quint32 size);
signals:
void sizeChanged ();
void selectedChanged ();
void uploadingChanged ();
void progressChanged ();
void writingChanged ();
private:
MavlinkLogManager* _manager;
......@@ -58,8 +64,37 @@ private:
bool _selected;
bool _uploading;
qreal _progress;
bool _writing;
};
//-----------------------------------------------------------------------------
class CurrentRunningLog
{
public:
CurrentRunningLog()
: fd(NULL)
, record(NULL)
, written(0)
{
}
~CurrentRunningLog()
{
close();
}
void close()
{
if(fd) {
fclose(fd);
fd = NULL;
}
}
FILE* fd;
QString fileName;
MavlinkLogFiles* record;
quint32 written;
};
//-----------------------------------------------------------------------------
class MavlinkLogManager : public QGCTool
{
Q_OBJECT
......@@ -73,7 +108,8 @@ public:
Q_PROPERTY(QString uploadURL READ uploadURL WRITE setUploadURL NOTIFY uploadURLChanged)
Q_PROPERTY(bool enableAutoUpload READ enableAutoUpload WRITE setEnableAutoUpload NOTIFY enableAutoUploadChanged)
Q_PROPERTY(bool enableAutoStart READ enableAutoStart WRITE setEnableAutoStart NOTIFY enableAutoStartChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
Q_PROPERTY(bool deleteAfterUpload READ deleteAfterUpload WRITE setDeleteAfterUpload NOTIFY deleteAfterUploadChanged)
Q_PROPERTY(bool uploading READ uploading NOTIFY uploadingChanged)
Q_PROPERTY(bool logRunning READ logRunning NOTIFY logRunningChanged)
Q_PROPERTY(bool canStartLog READ canStartLog NOTIFY canStartLogChanged)
Q_PROPERTY(QmlObjectListModel* logFiles READ logFiles NOTIFY logFilesChanged)
......@@ -89,9 +125,10 @@ public:
QString uploadURL () { return _uploadURL; }
bool enableAutoUpload () { return _enableAutoUpload; }
bool enableAutoStart () { return _enableAutoStart; }
bool busy ();
bool uploading ();
bool logRunning () { return _logRunning; }
bool canStartLog () { return _vehicle != NULL; }
bool deleteAfterUpload () { return _deleteAfterUpload; }
QmlObjectListModel* logFiles () { return &_logFiles; }
......@@ -100,6 +137,7 @@ public:
void setUploadURL (QString url);
void setEnableAutoUpload (bool enable);
void setEnableAutoStart (bool enable);
void setDeleteAfterUpload(bool enable);
// Override from QGCTool
void setToolbox (QGCToolbox *toolbox);
......@@ -112,13 +150,14 @@ signals:
void enableAutoStartChanged ();
void logFilesChanged ();
void selectedCountChanged ();
void busyChanged ();
void uploadingChanged ();
void readyRead (QByteArray data);
void failed ();
void succeed ();
void abortUpload ();
void logRunningChanged ();
void canStartLogChanged ();
void deleteAfterUploadChanged ();
private slots:
void _uploadFinished ();
......@@ -133,6 +172,8 @@ private:
bool _processUploadResponse (int http_code, QByteArray &data);
bool _createNewLog ();
int _getFirstSelected ();
void _insertNewLog (MavlinkLogFiles* newLog);
void _deleteLog (MavlinkLogFiles* log);
private:
QString _description;
......@@ -147,9 +188,9 @@ private:
Vehicle* _vehicle;
bool _logRunning;
bool _loggingDisabled;
FILE* _currentSavingFileFd;
QString _currentSavingFileStr;
CurrentRunningLog* _currentSavingFile;
uint16_t _sequence;
bool _deleteAfterUpload;
};
#endif
......@@ -262,6 +262,7 @@ Rectangle {
//-----------------------------------------------------------------
//-- Automatic Upload
QGCCheckBox {
id: autoUploadCheck
text: qsTr("Enable automatic log uploads")
checked: QGroundControl.mavlinkLogManager.enableAutoUpload
enabled: emailField.text !== "" && urlField !== ""
......@@ -269,6 +270,16 @@ Rectangle {
QGroundControl.mavlinkLogManager.enableAutoUpload = checked
}
}
//-----------------------------------------------------------------
//-- Delete log after upload
QGCCheckBox {
text: qsTr("Delete log file after uploading")
checked: QGroundControl.mavlinkLogManager.deleteAfterUpload
enabled: emailField.text !== "" && urlField !== "" && autoUploadCheck.checked
onClicked: {
QGroundControl.mavlinkLogManager.deleteAfterUpload = checked
}
}
}
}
//-----------------------------------------------------------------
......@@ -327,11 +338,13 @@ Rectangle {
QGCLabel {
text: object.name
width: ScreenTools.defaultFontPixelWidth * 28
color: object.writing ? qgcPal.warningText : qgcPal.text
}
QGCLabel {
text: Number(object.size).toLocaleString(Qt.locale(), 'f', 0)
visible: !object.uploading
width: ScreenTools.defaultFontPixelWidth * 20;
color: object.writing ? qgcPal.warningText : qgcPal.text
horizontalAlignment: Text.AlignRight
}
ProgressBar {
......@@ -352,7 +365,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
QGCButton {
text: "Check All"
enabled: !QGroundControl.mavlinkLogManager.busy
enabled: !QGroundControl.mavlinkLogManager.uploading && !QGroundControl.mavlinkLogManager.logRunning
onClicked: {
for(var i = 0; i < QGroundControl.mavlinkLogManager.logFiles.count; i++) {
var logFile = QGroundControl.mavlinkLogManager.logFiles.get(i)
......@@ -362,7 +375,7 @@ Rectangle {
}
QGCButton {
text: "Check None"
enabled: !QGroundControl.mavlinkLogManager.busy
enabled: !QGroundControl.mavlinkLogManager.uploading && !QGroundControl.mavlinkLogManager.logRunning
onClicked: {
for(var i = 0; i < QGroundControl.mavlinkLogManager.logFiles.count; i++) {
var logFile = QGroundControl.mavlinkLogManager.logFiles.get(i)
......@@ -372,7 +385,7 @@ Rectangle {
}
QGCButton {
text: "Delete Selected"
enabled: _selectedCount > 0 && !QGroundControl.mavlinkLogManager.busy
enabled: _selectedCount > 0 && !QGroundControl.mavlinkLogManager.uploading && !QGroundControl.mavlinkLogManager.logRunning
onClicked: deleteDialog.open()
MessageDialog {
id: deleteDialog
......@@ -388,8 +401,8 @@ Rectangle {
}
QGCButton {
text: "Upload Selected"
enabled: _selectedCount > 0 && !QGroundControl.mavlinkLogManager.busy
visible: !QGroundControl.mavlinkLogManager.busy
enabled: _selectedCount > 0 && !QGroundControl.mavlinkLogManager.uploading && !QGroundControl.mavlinkLogManager.logRunning
visible: !QGroundControl.mavlinkLogManager.uploading
onClicked: {
QGroundControl.mavlinkLogManager.emailAddress = emailField.text
if(QGroundControl.mavlinkLogManager.emailAddress === "")
......@@ -411,8 +424,8 @@ Rectangle {
}
QGCButton {
text: "Cancel"
enabled: QGroundControl.mavlinkLogManager.busy
visible: QGroundControl.mavlinkLogManager.busy
enabled: QGroundControl.mavlinkLogManager.uploading && !QGroundControl.mavlinkLogManager.logRunning
visible: QGroundControl.mavlinkLogManager.uploading
onClicked: cancelDialog.open()
MessageDialog {
id: cancelDialog
......
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