Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
a85cdd59
Commit
a85cdd59
authored
Oct 25, 2016
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final UI tweaks and fixes.
parent
dc2be3bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
51 deletions
+121
-51
MavlinkLogManager.cc
src/Vehicle/MavlinkLogManager.cc
+66
-25
MavlinkLogManager.h
src/Vehicle/MavlinkLogManager.h
+8
-2
MavlinkSettings.qml
src/ui/preferences/MavlinkSettings.qml
+47
-24
No files found.
src/Vehicle/MavlinkLogManager.cc
View file @
a85cdd59
...
...
@@ -29,19 +29,28 @@ static const char* kDefaultPx4URL = "http://logs.px4.io/upload";
static
const
char
*
kEnableAutoUploadKey
=
"EnableAutoUploadKey"
;
static
const
char
*
kEnableAutoStartKey
=
"EnableAutoStartKey"
;
static
const
char
*
kEnableDeletetKey
=
"EnableDeleteKey"
;
static
const
char
*
kUlogExtension
=
".ulg"
;
static
const
char
*
kSidecarExtension
=
".uploaded"
;
//-----------------------------------------------------------------------------
MavlinkLogFiles
::
MavlinkLogFiles
(
MavlinkLogManager
*
manager
,
const
QString
&
filePath
)
MavlinkLogFiles
::
MavlinkLogFiles
(
MavlinkLogManager
*
manager
,
const
QString
&
filePath
,
bool
newFile
)
:
_manager
(
manager
)
,
_size
(
0
)
,
_selected
(
false
)
,
_uploading
(
false
)
,
_progress
(
0
)
,
_writing
(
false
)
,
_uploaded
(
false
)
{
QFileInfo
fi
(
filePath
);
_name
=
fi
.
baseName
();
_size
=
(
quint32
)
fi
.
size
();
if
(
!
newFile
)
{
_size
=
(
quint32
)
fi
.
size
();
QString
sideCar
=
filePath
;
sideCar
.
replace
(
kUlogExtension
,
kSidecarExtension
);
QFileInfo
sc
(
sideCar
);
_uploaded
=
sc
.
exists
();
}
}
//-----------------------------------------------------------------------------
...
...
@@ -85,6 +94,14 @@ MavlinkLogFiles::setWriting(bool writing)
emit
writingChanged
();
}
//-----------------------------------------------------------------------------
void
MavlinkLogFiles
::
setUploaded
(
bool
uploaded
)
{
_uploaded
=
uploaded
;
emit
uploadedChanged
();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
CurrentRunningLog
::
close
()
...
...
@@ -122,14 +139,16 @@ MavlinkLogManager::MavlinkLogManager(QGCApplication* app)
_logPath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
);
_logPath
+=
"/MavlinkLogs"
;
if
(
!
QDir
(
_logPath
).
exists
())
{
if
(
QDir
().
mkpath
(
_logPath
))
{
if
(
!
QDir
().
mkpath
(
_logPath
))
{
qCCritical
(
MavlinkLogManagerLog
)
<<
"Could not create Mavlink log download path:"
<<
_logPath
;
_loggingDisabled
=
true
;
}
}
if
(
!
_loggingDisabled
)
{
//-- Load current list of logs
QDirIterator
it
(
_logPath
,
QStringList
()
<<
"*.ulg"
,
QDir
::
Files
);
QString
filter
=
"*"
;
filter
+=
kUlogExtension
;
QDirIterator
it
(
_logPath
,
QStringList
()
<<
filter
,
QDir
::
Files
);
while
(
it
.
hasNext
())
{
_insertNewLog
(
new
MavlinkLogFiles
(
this
,
it
.
next
()));
}
...
...
@@ -153,11 +172,6 @@ MavlinkLogManager::setToolbox(QGCToolbox* toolbox)
if
(
!
_loggingDisabled
)
{
connect
(
toolbox
->
multiVehicleManager
(),
&
MultiVehicleManager
::
activeVehicleChanged
,
this
,
&
MavlinkLogManager
::
_activeVehicleChanged
);
}
// _uploadURL = "http://192.168.1.21/px4";
// _uploadURL = "http://192.168.1.9:8080";
// _emailAddress = "gus.grubba.com";
// _description = "Test from QGroundControl - Discard";
// _sendLog("/Users/gus/github/work/logs/simulator.ulg");
}
//-----------------------------------------------------------------------------
...
...
@@ -242,15 +256,14 @@ MavlinkLogManager::uploadLog()
Q_ASSERT
(
_currentLogfile
);
if
(
_currentLogfile
->
selected
())
{
_currentLogfile
->
setSelected
(
false
);
_currentLogfile
->
setUploading
(
true
);
_currentLogfile
->
setProgress
(
0.0
);
QString
filePath
=
_logPath
;
filePath
+=
"/"
;
filePath
+=
_currentLogfile
->
name
();
filePath
+=
".ulg"
;
_sendLog
(
filePath
);
emit
uploadingChanged
();
return
;
if
(
!
_currentLogfile
->
uploaded
()
&&
!
_emailAddress
.
isEmpty
()
&&
!
_uploadURL
.
isEmpty
())
{
_currentLogfile
->
setUploading
(
true
);
_currentLogfile
->
setProgress
(
0.0
);
QString
filePath
=
_makeFilename
(
_currentLogfile
->
name
());
_sendLog
(
filePath
);
emit
uploadingChanged
();
return
;
}
}
}
_currentLogfile
=
NULL
;
...
...
@@ -309,14 +322,18 @@ MavlinkLogManager::deleteLog()
void
MavlinkLogManager
::
_deleteLog
(
MavlinkLogFiles
*
log
)
{
QString
filePath
=
_logPath
;
filePath
+=
"/"
;
filePath
+=
log
->
name
();
filePath
+=
".ulg"
;
QString
filePath
=
_makeFilename
(
log
->
name
());
QFile
gone
(
filePath
);
if
(
!
gone
.
remove
())
{
qCWarning
(
MavlinkLogManagerLog
)
<<
"Could not delete Mavlink log file:"
<<
_logPath
;
}
//-- Remove sidecar file (if any)
filePath
.
replace
(
kUlogExtension
,
kSidecarExtension
);
QFile
sgone
(
filePath
);
if
(
sgone
.
exists
())
{
sgone
.
remove
();
}
//-- Remove file from list and delete record
_logFiles
.
removeOne
(
log
);
delete
log
;
emit
logFilesChanged
();
...
...
@@ -494,6 +511,17 @@ MavlinkLogManager::_uploadFinished()
_deleteLog
(
_currentLogfile
);
_currentLogfile
=
NULL
;
}
}
else
{
if
(
_currentLogfile
)
{
_currentLogfile
->
setUploaded
(
true
);
//-- Write side-car file to flag it as uploaded
QString
sideCar
=
_makeFilename
(
_currentLogfile
->
name
());
sideCar
.
replace
(
kUlogExtension
,
kSidecarExtension
);
FILE
*
f
=
fopen
(
sideCar
.
toLatin1
().
data
(),
"wb"
);
if
(
f
)
{
fclose
(
f
);
}
}
}
}
else
{
qCWarning
(
MavlinkLogManagerLog
)
<<
QString
(
"Log Upload Error: %1 status: %2"
).
arg
(
reply
->
errorString
(),
reply
->
attribute
(
QNetworkRequest
::
HttpStatusCodeAttribute
).
toString
());
...
...
@@ -525,6 +553,7 @@ MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle)
// connects/disconnects. In reality, if QGC is connected to multiple vehicles,
// this is called each time the user switches from one vehicle to another. So
// far, I'm working on the assumption that multiple vehicles is a rare exception.
// For now, we only handle one log download at a time.
// Disconnect the previous one (if any)
if
(
_vehicle
)
{
disconnect
(
_vehicle
,
&
Vehicle
::
armedChanged
,
this
,
&
MavlinkLogManager
::
_armedChanged
);
...
...
@@ -586,13 +615,14 @@ MavlinkLogManager::_createNewLog()
_currentSavingFile
=
NULL
;
}
_currentSavingFile
=
new
CurrentRunningLog
;
_currentSavingFile
->
fileName
.
sprintf
(
"%s/%03d-%s
.ulg
"
,
_currentSavingFile
->
fileName
.
sprintf
(
"%s/%03d-%s
%s
"
,
_logPath
.
toLatin1
().
data
(),
_vehicle
->
id
(),
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd-hh-mm-ss-zzz"
).
toLatin1
().
data
());
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd-hh-mm-ss-zzz"
).
toLatin1
().
data
(),
kUlogExtension
);
_currentSavingFile
->
fd
=
fopen
(
_currentSavingFile
->
fileName
.
toLatin1
().
data
(),
"wb"
);
if
(
_currentSavingFile
->
fd
)
{
MavlinkLogFiles
*
newLog
=
new
MavlinkLogFiles
(
this
,
_currentSavingFile
->
fileName
);
MavlinkLogFiles
*
newLog
=
new
MavlinkLogFiles
(
this
,
_currentSavingFile
->
fileName
,
true
);
newLog
->
setWriting
(
true
);
_insertNewLog
(
newLog
);
_currentSavingFile
->
record
=
newLog
;
...
...
@@ -622,3 +652,14 @@ MavlinkLogManager::_armedChanged(bool armed)
}
}
}
//-----------------------------------------------------------------------------
QString
MavlinkLogManager
::
_makeFilename
(
const
QString
&
baseName
)
{
QString
filePath
=
_logPath
;
filePath
+=
"/"
;
filePath
+=
baseName
;
filePath
+=
kUlogExtension
;
return
filePath
;
}
src/Vehicle/MavlinkLogManager.h
View file @
a85cdd59
...
...
@@ -28,7 +28,7 @@ class MavlinkLogFiles : public QObject
{
Q_OBJECT
public:
MavlinkLogFiles
(
MavlinkLogManager
*
manager
,
const
QString
&
filePath
);
MavlinkLogFiles
(
MavlinkLogManager
*
manager
,
const
QString
&
filePath
,
bool
newFile
=
false
);
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
Q_PROPERTY
(
quint32
size
READ
size
NOTIFY
sizeChanged
)
...
...
@@ -36,6 +36,7 @@ public:
Q_PROPERTY
(
bool
uploading
READ
uploading
NOTIFY
uploadingChanged
)
Q_PROPERTY
(
qreal
progress
READ
progress
NOTIFY
progressChanged
)
Q_PROPERTY
(
bool
writing
READ
writing
NOTIFY
writingChanged
)
Q_PROPERTY
(
bool
uploaded
READ
uploaded
NOTIFY
uploadedChanged
)
QString
name
()
{
return
_name
;
}
quint32
size
()
{
return
_size
;
}
...
...
@@ -43,12 +44,14 @@ public:
bool
uploading
()
{
return
_uploading
;
}
qreal
progress
()
{
return
_progress
;
}
bool
writing
()
{
return
_writing
;
}
bool
uploaded
()
{
return
_uploaded
;
}
void
setSelected
(
bool
selected
);
void
setUploading
(
bool
uploading
);
void
setProgress
(
qreal
progress
);
void
setWriting
(
bool
writing
);
void
setSize
(
quint32
size
);
void
setUploaded
(
bool
uploaded
);
signals:
void
sizeChanged
();
...
...
@@ -56,6 +59,7 @@ signals:
void
uploadingChanged
();
void
progressChanged
();
void
writingChanged
();
void
uploadedChanged
();
private:
MavlinkLogManager
*
_manager
;
...
...
@@ -65,6 +69,7 @@ private:
bool
_uploading
;
qreal
_progress
;
bool
_writing
;
bool
_uploaded
;
};
//-----------------------------------------------------------------------------
...
...
@@ -144,7 +149,7 @@ signals:
void
enableAutoStartChanged
();
void
logFilesChanged
();
void
selectedCountChanged
();
void
uploadingChanged
();
void
uploadingChanged
();
void
readyRead
(
QByteArray
data
);
void
failed
();
void
succeed
();
...
...
@@ -168,6 +173,7 @@ private:
int
_getFirstSelected
();
void
_insertNewLog
(
MavlinkLogFiles
*
newLog
);
void
_deleteLog
(
MavlinkLogFiles
*
log
);
QString
_makeFilename
(
const
QString
&
baseName
);
private:
QString
_description
;
...
...
src/ui/preferences/MavlinkSettings.qml
View file @
a85cdd59
...
...
@@ -28,6 +28,8 @@ Rectangle {
property
real
_labelWidth
:
ScreenTools
.
defaultFontPixelWidth
*
28
property
real
_valueWidth
:
ScreenTools
.
defaultFontPixelWidth
*
24
property
int
_selectedCount
:
0
property
real
_columnSpacing
:
ScreenTools
.
defaultFontPixelHeight
*
0.25
QGCPalette
{
id
:
qgcPal
}
...
...
@@ -59,6 +61,7 @@ Rectangle {
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
contentHeight
:
settingsColumn
.
height
contentWidth
:
settingsColumn
.
width
flickableDirection
:
Flickable
.
VerticalFlick
Column
{
id
:
settingsColumn
...
...
@@ -86,7 +89,7 @@ Rectangle {
anchors.horizontalCenter
:
parent
.
horizontalCenter
Column
{
id
:
gcsColumn
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
_columnSpacing
anchors.centerIn
:
parent
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
...
...
@@ -148,31 +151,40 @@ Rectangle {
Column
{
id
:
mavlogColumn
width
:
gcsColumn
.
width
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
_columnSpacing
anchors.centerIn
:
parent
//-----------------------------------------------------------------
//-- Enable auto log on arming
QGCCheckBox
{
text
:
qsTr
(
"
Enable automatic logging start when vehicle is armed
"
)
checked
:
QGroundControl
.
mavlinkLogManager
.
enableAutoStart
onClicked
:
{
QGroundControl
.
mavlinkLogManager
.
enableAutoStart
=
checked
}
}
//-----------------------------------------------------------------
//-- Manual Start/Stop
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
anchors.horizontalCenter
:
parent
.
horizontalCenter
QGCLabel
{
width
:
_labelWidth
text
:
qsTr
(
"
Manual Start/Stop:
"
)
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCButton
{
text
:
"
Start Logging
"
enabled
:
!
QGroundControl
.
mavlinkLogManager
.
logRunning
&&
QGroundControl
.
mavlinkLogManager
.
canStartLog
onClicked
:
QGroundControl
.
mavlinkLogManager
.
startLogging
()
text
:
qsTr
(
"
Start Logging
"
)
width
:
(
_valueWidth
*
0.5
)
-
(
ScreenTools
.
defaultFontPixelWidth
*
0.5
)
enabled
:
!
QGroundControl
.
mavlinkLogManager
.
logRunning
&&
QGroundControl
.
mavlinkLogManager
.
canStartLog
onClicked
:
QGroundControl
.
mavlinkLogManager
.
startLogging
()
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCButton
{
text
:
"
Stop Logging
"
enabled
:
QGroundControl
.
mavlinkLogManager
.
logRunning
onClicked
:
QGroundControl
.
mavlinkLogManager
.
stopLogging
()
text
:
qsTr
(
"
Stop Logging
"
)
width
:
(
_valueWidth
*
0.5
)
-
(
ScreenTools
.
defaultFontPixelWidth
*
0.5
)
enabled
:
QGroundControl
.
mavlinkLogManager
.
logRunning
onClicked
:
QGroundControl
.
mavlinkLogManager
.
stopLogging
()
anchors.verticalCenter
:
parent
.
verticalCenter
}
}
//-----------------------------------------------------------------
//-- Enable auto log on arming
QGCCheckBox
{
text
:
qsTr
(
"
Enable automatic logging
"
)
checked
:
QGroundControl
.
mavlinkLogManager
.
enableAutoStart
onClicked
:
{
QGroundControl
.
mavlinkLogManager
.
enableAutoStart
=
checked
}
}
}
...
...
@@ -198,7 +210,7 @@ Rectangle {
anchors.horizontalCenter
:
parent
.
horizontalCenter
Column
{
id
:
logColumn
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
_columnSpacing
anchors.centerIn
:
parent
//-----------------------------------------------------------------
//-- Email address Field
...
...
@@ -303,35 +315,37 @@ Rectangle {
anchors.horizontalCenter
:
parent
.
horizontalCenter
Column
{
id
:
logFilesColumn
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
_columnSpacing
*
4
anchors.centerIn
:
parent
width
:
ScreenTools
.
defaultFontPixelWidth
*
68
Rectangle
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
64
height
:
ScreenTools
.
defaultFontPixelHeight
*
1
0
height
:
ScreenTools
.
defaultFontPixelHeight
*
1
4
anchors.horizontalCenter
:
parent
.
horizontalCenter
color
:
qgcPal
.
window
border.color
:
qgcPal
.
text
border.width
:
0.5
ListView
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
56
height
:
ScreenTools
.
defaultFontPixelHeight
*
8.75
height
:
ScreenTools
.
defaultFontPixelHeight
*
12
anchors.centerIn
:
parent
orientation
:
ListView
.
Vertical
model
:
QGroundControl
.
mavlinkLogManager
.
logFiles
clip
:
true
delegate
:
Rectangle
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
52
height
:
ScreenTools
.
defaultFontPixelHeight
*
1.25
height
:
selectCheck
.
height
color
:
qgcPal
.
window
Row
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
50
anchors.centerIn
:
parent
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCCheckBox
{
id
:
selectCheck
width
:
ScreenTools
.
defaultFontPixelWidth
*
4
checked
:
object
.
selected
enabled
:
!
object
.
writing
&&
!
object
.
uploading
anchors.verticalCenter
:
parent
.
verticalCenter
onClicked
:
{
object
.
selected
=
checked
}
...
...
@@ -340,16 +354,25 @@ Rectangle {
text
:
object
.
name
width
:
ScreenTools
.
defaultFontPixelWidth
*
28
color
:
object
.
writing
?
qgcPal
.
warningText
:
qgcPal
.
text
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCLabel
{
text
:
Number
(
object
.
size
).
toLocaleString
(
Qt
.
locale
(),
'
f
'
,
0
)
visible
:
!
object
.
uploading
visible
:
!
object
.
uploading
&&
!
object
.
uploaded
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
;
color
:
object
.
writing
?
qgcPal
.
warningText
:
qgcPal
.
text
horizontalAlignment
:
Text
.
AlignRight
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCLabel
{
text
:
"
Uploaded
"
visible
:
object
.
uploaded
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
;
horizontalAlignment
:
Text
.
AlignRight
anchors.verticalCenter
:
parent
.
verticalCenter
}
ProgressBar
{
visible
:
object
.
uploading
visible
:
object
.
uploading
&&
!
object
.
uploaded
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
;
height
:
ScreenTools
.
defaultFontPixelHeight
anchors.verticalCenter
:
parent
.
verticalCenter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment