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
ec958ad5
Commit
ec958ad5
authored
May 16, 2017
by
Gus Grubba
Committed by
GitHub
May 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5160 from dogmaphobic/uLog
Moving ulogs to AppSettings save path.
parents
77749b5c
11ecf5f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
30 deletions
+54
-30
AppSettings.cc
src/Settings/AppSettings.cc
+19
-3
AppSettings.h
src/Settings/AppSettings.h
+5
-0
MAVLinkLogManager.cc
src/Vehicle/MAVLinkLogManager.cc
+27
-27
MAVLinkLogManager.h
src/Vehicle/MAVLinkLogManager.h
+3
-0
No files found.
src/Settings/AppSettings.cc
View file @
ec958ad5
...
...
@@ -41,10 +41,12 @@ const char* AppSettings::waypointsFileExtension = "waypoints";
const
char
*
AppSettings
::
fenceFileExtension
=
"fence"
;
const
char
*
AppSettings
::
rallyPointFileExtension
=
"rally"
;
const
char
*
AppSettings
::
telemetryFileExtension
=
"tlog"
;
const
char
*
AppSettings
::
logFileExtension
=
"ulg"
;
const
char
*
AppSettings
::
parameterDirectory
=
"Parameters"
;
const
char
*
AppSettings
::
telemetryDirectory
=
"Telemetry"
;
const
char
*
AppSettings
::
missionDirectory
=
"Missions"
;
const
char
*
AppSettings
::
parameterDirectory
=
"Parameters"
;
const
char
*
AppSettings
::
telemetryDirectory
=
"Telemetry"
;
const
char
*
AppSettings
::
missionDirectory
=
"Missions"
;
const
char
*
AppSettings
::
logDirectory
=
"Logs"
;
AppSettings
::
AppSettings
(
QObject
*
parent
)
:
SettingsGroup
(
appSettingsGroupName
,
QString
()
/* root settings group */
,
parent
)
...
...
@@ -100,6 +102,7 @@ void AppSettings::_checkSavePathDirectories(void)
savePathDir
.
mkdir
(
parameterDirectory
);
savePathDir
.
mkdir
(
telemetryDirectory
);
savePathDir
.
mkdir
(
missionDirectory
);
savePathDir
.
mkdir
(
logDirectory
);
}
}
...
...
@@ -273,6 +276,19 @@ QString AppSettings::telemetrySavePath(void)
return
fullPath
;
}
QString
AppSettings
::
logSavePath
(
void
)
{
QString
fullPath
;
QString
path
=
savePath
()
->
rawValue
().
toString
();
if
(
!
path
.
isEmpty
()
&&
QDir
(
path
).
exists
())
{
QDir
dir
(
path
);
return
dir
.
filePath
(
logDirectory
);
}
return
fullPath
;
}
Fact
*
AppSettings
::
autoLoadMissions
(
void
)
{
if
(
!
_autoLoadMissionsFact
)
{
...
...
src/Settings/AppSettings.h
View file @
ec958ad5
...
...
@@ -41,12 +41,14 @@ public:
Q_PROPERTY
(
QString
missionSavePath
READ
missionSavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
parameterSavePath
READ
parameterSavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
telemetrySavePath
READ
telemetrySavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
logSavePath
READ
logSavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
planFileExtension
MEMBER
planFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
missionFileExtension
MEMBER
missionFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
waypointsFileExtension
MEMBER
waypointsFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
parameterFileExtension
MEMBER
parameterFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
telemetryFileExtension
MEMBER
telemetryFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
logFileExtension
MEMBER
logFileExtension
CONSTANT
)
Fact
*
offlineEditingFirmwareType
(
void
);
Fact
*
offlineEditingVehicleType
(
void
);
...
...
@@ -69,6 +71,7 @@ public:
QString
missionSavePath
(
void
);
QString
parameterSavePath
(
void
);
QString
telemetrySavePath
(
void
);
QString
logSavePath
(
void
);
static
MAV_AUTOPILOT
offlineEditingFirmwareTypeFromFirmwareType
(
MAV_AUTOPILOT
firmwareType
);
static
MAV_TYPE
offlineEditingVehicleTypeFromVehicleType
(
MAV_TYPE
vehicleType
);
...
...
@@ -101,11 +104,13 @@ public:
static
const
char
*
fenceFileExtension
;
static
const
char
*
rallyPointFileExtension
;
static
const
char
*
telemetryFileExtension
;
static
const
char
*
logFileExtension
;
// Child directories of savePath for specific file types
static
const
char
*
parameterDirectory
;
static
const
char
*
telemetryDirectory
;
static
const
char
*
missionDirectory
;
static
const
char
*
logDirectory
;
signals:
void
savePathsChanged
(
void
);
...
...
src/Vehicle/MAVLinkLogManager.cc
View file @
ec958ad5
...
...
@@ -9,6 +9,8 @@
#include "MAVLinkLogManager.h"
#include "QGCApplication.h"
#include "SettingsManager.h"
#include <QQmlContext>
#include <QQmlProperty>
#include <QQmlEngine>
...
...
@@ -30,7 +32,6 @@ static const char* kDefaultPx4URL = "http://logs.px4.io/upload";
static
const
char
*
kEnableAutoUploadKey
=
"EnableAutoUpload"
;
static
const
char
*
kEnableAutoStartKey
=
"EnableAutoStart"
;
static
const
char
*
kEnableDeletetKey
=
"EnableDelete"
;
static
const
char
*
kUlogExtension
=
".ulg"
;
static
const
char
*
kSidecarExtension
=
".uploaded"
;
static
const
char
*
kVideoURLKey
=
"VideoURL"
;
static
const
char
*
kWindSpeedKey
=
"WindSpeed"
;
...
...
@@ -54,7 +55,7 @@ MAVLinkLogFiles::MAVLinkLogFiles(MAVLinkLogManager* manager, const QString& file
if
(
!
newFile
)
{
_size
=
(
quint32
)
fi
.
size
();
QString
sideCar
=
filePath
;
sideCar
.
replace
(
kUlogExtension
,
kSidecarExtension
);
sideCar
.
replace
(
manager
->
logExtension
()
,
kSidecarExtension
);
QFileInfo
sc
(
sideCar
);
_uploaded
=
sc
.
exists
();
}
...
...
@@ -152,9 +153,9 @@ MAVLinkLogProcessor::create(MAVLinkLogManager* manager, const QString path, uint
_fileName
.
sprintf
(
"%s/%03d-%s%s"
,
path
.
toLatin1
().
data
(),
id
,
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd-hh-mm-ss-zzz"
).
toL
atin1
().
data
(),
kUlogExtension
);
_fd
=
fopen
(
_fileName
.
toL
atin1
().
data
(),
"wb"
);
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd-hh-mm-ss-zzz"
).
toL
ocal8Bit
().
data
(),
manager
->
logExtension
().
toLocal8Bit
().
data
()
);
_fd
=
fopen
(
_fileName
.
toL
ocal8Bit
().
data
(),
"wb"
);
if
(
_fd
)
{
_record
=
new
MAVLinkLogFiles
(
manager
,
_fileName
,
true
);
_record
->
setWriting
(
true
);
...
...
@@ -322,25 +323,6 @@ MAVLinkLogManager::MAVLinkLogManager(QGCApplication* app, QGCToolbox* toolbox)
setWindSpeed
(
settings
.
value
(
kWindSpeedKey
,
-
1
).
toInt
());
setRating
(
settings
.
value
(
kRateKey
,
"notset"
).
toString
());
setPublicLog
(
settings
.
value
(
kPublicLogKey
,
true
).
toBool
());
//-- Logging location
_logPath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
);
_logPath
+=
"/MAVLinkLogs"
;
if
(
!
QDir
(
_logPath
).
exists
())
{
if
(
!
QDir
().
mkpath
(
_logPath
))
{
qCWarning
(
MAVLinkLogManagerLog
)
<<
"Could not create MAVLink log download path:"
<<
_logPath
;
_loggingDisabled
=
true
;
}
}
if
(
!
_loggingDisabled
)
{
//-- Load current list of logs
QString
filter
=
"*"
;
filter
+=
kUlogExtension
;
QDirIterator
it
(
_logPath
,
QStringList
()
<<
filter
,
QDir
::
Files
);
while
(
it
.
hasNext
())
{
_insertNewLog
(
new
MAVLinkLogFiles
(
this
,
it
.
next
()));
}
qCDebug
(
MAVLinkLogManagerLog
)
<<
"MAVLink logs directory:"
<<
_logPath
;
}
}
//-----------------------------------------------------------------------------
...
...
@@ -356,7 +338,25 @@ MAVLinkLogManager::setToolbox(QGCToolbox* toolbox)
QGCTool
::
setToolbox
(
toolbox
);
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
qmlRegisterUncreatableType
<
MAVLinkLogManager
>
(
"QGroundControl.MAVLinkLogManager"
,
1
,
0
,
"MAVLinkLogManager"
,
"Reference only"
);
//-- Logging location
_ulogExtension
=
"."
;
_ulogExtension
+=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
logFileExtension
;
_logPath
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
logSavePath
();
if
(
!
QDir
(
_logPath
).
exists
())
{
if
(
!
QDir
().
mkpath
(
_logPath
))
{
qCWarning
(
MAVLinkLogManagerLog
)
<<
"Could not create MAVLink log download path:"
<<
_logPath
;
_loggingDisabled
=
true
;
}
}
if
(
!
_loggingDisabled
)
{
//-- Load current list of logs
QString
filter
=
"*"
;
filter
+=
_ulogExtension
;
QDirIterator
it
(
_logPath
,
QStringList
()
<<
filter
,
QDir
::
Files
);
while
(
it
.
hasNext
())
{
_insertNewLog
(
new
MAVLinkLogFiles
(
this
,
it
.
next
()));
}
qCDebug
(
MAVLinkLogManagerLog
)
<<
"MAVLink logs directory:"
<<
_logPath
;
connect
(
toolbox
->
multiVehicleManager
(),
&
MultiVehicleManager
::
activeVehicleChanged
,
this
,
&
MAVLinkLogManager
::
_activeVehicleChanged
);
}
}
...
...
@@ -579,7 +579,7 @@ MAVLinkLogManager::_deleteLog(MAVLinkLogFiles* log)
qCWarning
(
MAVLinkLogManagerLog
)
<<
"Could not delete MAVLink log file:"
<<
_logPath
;
}
//-- Remove sidecar file (if any)
filePath
.
replace
(
kU
logExtension
,
kSidecarExtension
);
filePath
.
replace
(
_u
logExtension
,
kSidecarExtension
);
QFile
sgone
(
filePath
);
if
(
sgone
.
exists
())
{
sgone
.
remove
();
...
...
@@ -796,7 +796,7 @@ MAVLinkLogManager::_uploadFinished()
_currentLogfile
->
setUploaded
(
true
);
//-- Write side-car file to flag it as uploaded
QString
sideCar
=
_makeFilename
(
_currentLogfile
->
name
());
sideCar
.
replace
(
kU
logExtension
,
kSidecarExtension
);
sideCar
.
replace
(
_u
logExtension
,
kSidecarExtension
);
FILE
*
f
=
fopen
(
sideCar
.
toLatin1
().
data
(),
"wb"
);
if
(
f
)
{
fclose
(
f
);
...
...
@@ -956,6 +956,6 @@ MAVLinkLogManager::_makeFilename(const QString& baseName)
QString
filePath
=
_logPath
;
filePath
+=
"/"
;
filePath
+=
baseName
;
filePath
+=
kU
logExtension
;
filePath
+=
_u
logExtension
;
return
filePath
;
}
src/Vehicle/MAVLinkLogManager.h
View file @
ec958ad5
...
...
@@ -145,6 +145,7 @@ public:
bool
publicLog
()
{
return
_publicLog
;
}
int
windSpeed
()
{
return
_windSpeed
;
}
QString
rating
()
{
return
_rating
;
}
QString
logExtension
()
{
return
_ulogExtension
;
}
QmlObjectListModel
*
logFiles
()
{
return
&
_logFiles
;
}
...
...
@@ -224,6 +225,8 @@ private:
int
_windSpeed
;
QString
_rating
;
bool
_publicLog
;
QString
_ulogExtension
;
};
#endif
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