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
68b77d7f
Commit
68b77d7f
authored
Feb 05, 2016
by
Nate Weibley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve log gap handling algorithm efficiency
parent
51ddffa0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
77 deletions
+78
-77
LogDownloadController.cc
src/ViewWidgets/LogDownloadController.cc
+68
-67
LogDownloadController.h
src/ViewWidgets/LogDownloadController.h
+10
-10
No files found.
src/ViewWidgets/LogDownloadController.cc
View file @
68b77d7f
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <QUrl>
#include <QUrl>
#define kTimeOutMilliseconds 500
#define kTimeOutMilliseconds 500
#define kGUIRateMilliseconds 17
QGC_LOGGING_CATEGORY
(
LogDownloadLog
,
"LogDownloadLog"
)
QGC_LOGGING_CATEGORY
(
LogDownloadLog
,
"LogDownloadLog"
)
...
@@ -275,17 +276,40 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
...
@@ -275,17 +276,40 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
return
;
return
;
}
}
bool
result
=
false
;
bool
result
=
false
;
//-- Find offset table entry
uint
o_index
=
ofs
/
MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN
;
if
(
ofs
<=
_downloadData
->
entry
->
size
())
{
if
(
o_index
<=
(
uint
)
_downloadData
->
offsets
.
count
())
{
// Check for a gap
_downloadData
->
offsets
[
o_index
]
=
count
;
qint64
pos
=
_downloadData
->
file
.
pos
();
if
(
pos
!=
ofs
)
{
// Check for a gap collision
if
(
_downloadData
->
gaps
.
contains
(
ofs
))
{
// The gap is being filled. Shrink it
const
int32_t
gap
=
_downloadData
->
gaps
.
take
(
ofs
)
-
count
;
if
(
gap
>
0
)
{
_downloadData
->
gaps
[
ofs
+
count
]
=
qMax
(
static_cast
<
uint32_t
>
(
gap
),
_downloadData
->
gaps
.
value
(
ofs
+
count
,
0
));
}
}
else
if
(
pos
<
ofs
)
{
// Mind the gap
uint32_t
gap
=
ofs
-
pos
;
_downloadData
->
gaps
[
pos
]
=
gap
;
}
// Seek to correct position
if
(
!
_downloadData
->
file
.
seek
(
ofs
))
{
qWarning
()
<<
"Error while seeking log file offset"
;
return
;
}
}
//-- Write chunk to file
//-- Write chunk to file
if
(
_downloadData
->
file
.
seek
(
ofs
))
{
if
(
_downloadData
->
file
.
write
((
const
char
*
)
data
,
count
))
{
if
(
_downloadData
->
file
.
write
((
const
char
*
)
data
,
count
))
{
_downloadData
->
written
+=
count
;
_downloadData
->
written
+=
count
;
if
(
_downloadData
->
elapsed
.
elapsed
()
>=
kGUIRateMilliseconds
)
{
//-- Update status
//-- Update status
QString
comma_value
=
kLocale
.
toString
(
_downloadData
->
written
);
QString
comma_value
=
kLocale
.
toString
(
_downloadData
->
written
);
_downloadData
->
entry
->
setStatus
(
comma_value
);
_downloadData
->
entry
->
setStatus
(
comma_value
);
_downloadData
->
elapsed
.
start
();
}
result
=
true
;
result
=
true
;
//-- reset retries
//-- reset retries
_retries
=
0
;
_retries
=
0
;
...
@@ -300,9 +324,6 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
...
@@ -300,9 +324,6 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
}
else
{
}
else
{
qWarning
()
<<
"Error while writing log file chunk"
;
qWarning
()
<<
"Error while writing log file chunk"
;
}
}
}
else
{
qWarning
()
<<
"Error while seeking log file offset"
;
}
}
else
{
}
else
{
qWarning
()
<<
"Received log offset greater than expected"
;
qWarning
()
<<
"Received log offset greater than expected"
;
}
}
...
@@ -315,14 +336,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
...
@@ -315,14 +336,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
bool
bool
LogDownloadController
::
_logComplete
()
LogDownloadController
::
_logComplete
()
{
{
//-- Iterate entries and look for a gap
return
_downloadData
->
file
.
pos
()
==
_downloadData
->
entry
->
size
()
&&
int
num_ofs
=
_downloadData
->
offsets
.
count
();
_downloadData
->
gaps
.
count
()
==
0
;
for
(
int
i
=
0
;
i
<
num_ofs
;
i
++
)
{
if
(
_downloadData
->
offsets
[
i
]
==
0
)
{
return
false
;
}
}
return
true
;
}
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
...
@@ -344,25 +359,11 @@ LogDownloadController::_receivedAllData()
...
@@ -344,25 +359,11 @@ LogDownloadController::_receivedAllData()
void
void
LogDownloadController
::
_findMissingData
()
LogDownloadController
::
_findMissingData
()
{
{
int
start
=
-
1
;
if
(
_logComplete
())
{
int
end
=
-
1
;
_receivedAllData
();
int
num_ofs
=
_downloadData
->
offsets
.
count
();
return
;
//-- Iterate offsets and look for a gap
for
(
int
i
=
0
;
i
<
num_ofs
;
i
++
)
{
if
(
_downloadData
->
offsets
[
i
]
==
0
)
{
if
(
start
<
0
)
start
=
i
;
else
end
=
i
;
}
else
{
if
(
start
>=
0
)
{
break
;
}
}
}
}
//-- Is there something missing?
if
(
start
>=
0
)
{
//-- Have we tried too many times?
if
(
_retries
++
>
2
)
{
if
(
_retries
++
>
2
)
{
_downloadData
->
entry
->
setStatus
(
QString
(
"Timed Out"
));
_downloadData
->
entry
->
setStatus
(
QString
(
"Timed Out"
));
//-- Give up
//-- Give up
...
@@ -370,16 +371,20 @@ LogDownloadController::_findMissingData()
...
@@ -370,16 +371,20 @@ LogDownloadController::_findMissingData()
_receivedAllData
();
_receivedAllData
();
return
;
return
;
}
}
//-- Is it a sequence or just one entry?
if
(
end
<
0
)
{
const
qint64
pos
=
_downloadData
->
file
.
pos
(),
end
=
start
;
size
=
_downloadData
->
entry
->
size
();
}
if
(
!
_downloadData
->
gaps
.
isEmpty
())
{
const
uint32_t
start
=
_downloadData
->
gaps
.
firstKey
();
const
uint32_t
count
=
_downloadData
->
gaps
.
value
(
start
);
//-- Request these log chunks again
//-- Request these log chunks again
_requestLogData
(
_requestLogData
(
_downloadData
->
ID
,
start
,
count
);
_downloadData
->
ID
,
}
else
if
(
pos
!=
size
)
{
(
uint32_t
)(
start
*
MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN
),
// Request where we left off
(
uint32_t
)((
end
-
start
+
1
)
*
MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN
)
);
_requestLogData
(
_downloadData
->
ID
,
pos
,
size
-
pos
);
}
else
{
}
else
{
qWarning
()
<<
"Apparently we're missing data but can't figure out what. Giving up."
;
_receivedAllData
();
_receivedAllData
();
}
}
}
}
...
@@ -534,11 +539,7 @@ LogDownloadController::_prepareLogDownload()
...
@@ -534,11 +539,7 @@ LogDownloadController::_prepareLogDownload()
if
(
!
_downloadData
->
file
.
resize
(
entry
->
size
()))
{
if
(
!
_downloadData
->
file
.
resize
(
entry
->
size
()))
{
qWarning
()
<<
"Failed to allocate space for log file:"
<<
_downloadData
->
filename
;
qWarning
()
<<
"Failed to allocate space for log file:"
<<
_downloadData
->
filename
;
}
else
{
}
else
{
//-- Prepare Offset Table
_downloadData
->
elapsed
.
start
();
uint
o_count
=
(
uint
)
ceil
(
entry
->
size
()
/
(
double
)
MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN
);
for
(
uint
i
=
0
;
i
<
o_count
;
i
++
)
{
_downloadData
->
offsets
.
append
(
0
);
}
result
=
true
;
result
=
true
;
}
}
}
}
...
...
src/ViewWidgets/LogDownloadController.h
View file @
68b77d7f
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <QTimer>
#include <QTimer>
#include <QAbstractListModel>
#include <QAbstractListModel>
#include <QLocale>
#include <QLocale>
#include <QElapsedTimer>
#include <memory>
#include <memory>
...
@@ -39,7 +40,7 @@ class MultiVehicleManager;
...
@@ -39,7 +40,7 @@ class MultiVehicleManager;
class
UASInterface
;
class
UASInterface
;
class
Vehicle
;
class
Vehicle
;
class
QGCLogEntry
;
class
QGCLogEntry
;
class
LogDownloadData
;
struct
LogDownloadData
;
Q_DECLARE_LOGGING_CATEGORY
(
LogDownloadLog
)
Q_DECLARE_LOGGING_CATEGORY
(
LogDownloadLog
)
...
@@ -122,16 +123,15 @@ private:
...
@@ -122,16 +123,15 @@ private:
};
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
class
LogDownloadData
{
struct
LogDownloadData
{
public:
LogDownloadData
(
QGCLogEntry
*
entry
);
LogDownloadData
(
QGCLogEntry
*
entry
);
Q
List
<
uint
>
offset
s
;
Q
Map
<
uint32_t
,
uint32_t
>
gap
s
;
QFile
file
;
QFile
file
;
QString
filename
;
QString
filename
;
uint
ID
;
uint
ID
;
QTimer
processDataTimer
;
QGCLogEntry
*
entry
;
QGCLogEntry
*
entry
;
uint
written
;
uint
written
;
QElapsedTimer
elapsed
;
};
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
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