Commit 9c4fd89f authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #3914 from NaterGator/logdlrate

Use human appropriate values for bytes in log downloader
parents a0d80bbb 4eb21337
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "UAS.h" #include "UAS.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCToolbox.h" #include "QGCToolbox.h"
#include "QGCMapEngine.h"
#include "Vehicle.h" #include "Vehicle.h"
#include "MainWindow.h" #include "MainWindow.h"
...@@ -31,7 +32,6 @@ ...@@ -31,7 +32,6 @@
QGC_LOGGING_CATEGORY(LogDownloadLog, "LogDownloadLog") QGC_LOGGING_CATEGORY(LogDownloadLog, "LogDownloadLog")
static QLocale kLocale;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LogDownloadData { struct LogDownloadData {
LogDownloadData(QGCLogEntry* entry); LogDownloadData(QGCLogEntry* entry);
...@@ -42,6 +42,8 @@ struct LogDownloadData { ...@@ -42,6 +42,8 @@ struct LogDownloadData {
uint ID; uint ID;
QGCLogEntry* entry; QGCLogEntry* entry;
uint written; uint written;
size_t rate_bytes;
qreal rate_avg;
QElapsedTimer elapsed; QElapsedTimer elapsed;
void advanceChunk() void advanceChunk()
...@@ -76,6 +78,8 @@ LogDownloadData::LogDownloadData(QGCLogEntry* entry_) ...@@ -76,6 +78,8 @@ LogDownloadData::LogDownloadData(QGCLogEntry* entry_)
: ID(entry_->id()) : ID(entry_->id())
, entry(entry_) , entry(entry_)
, written(0) , written(0)
, rate_bytes(0)
, rate_avg(0)
{ {
} }
...@@ -95,7 +99,7 @@ QGCLogEntry::QGCLogEntry(uint logId, const QDateTime& dateTime, uint logSize, bo ...@@ -95,7 +99,7 @@ QGCLogEntry::QGCLogEntry(uint logId, const QDateTime& dateTime, uint logSize, bo
QString QString
QGCLogEntry::sizeStr() const QGCLogEntry::sizeStr() const
{ {
return kLocale.toString(_logSize); return QGCMapEngine::bigSizeToString(_logSize);
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
...@@ -332,10 +336,18 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui ...@@ -332,10 +336,18 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
//-- Write chunk to file //-- Write chunk to file
if(_downloadData->file.write((const char*)data, count)) { if(_downloadData->file.write((const char*)data, count)) {
_downloadData->written += count; _downloadData->written += count;
_downloadData->rate_bytes += count;
if (_downloadData->elapsed.elapsed() >= kGUIRateMilliseconds) { if (_downloadData->elapsed.elapsed() >= kGUIRateMilliseconds) {
//-- Update download rate
qreal rrate = _downloadData->rate_bytes/(_downloadData->elapsed.elapsed()/1000.0);
_downloadData->rate_avg = _downloadData->rate_avg*0.95 + rrate*0.05;
_downloadData->rate_bytes = 0;
//-- Update status //-- Update status
QString comma_value = kLocale.toString(_downloadData->written); const QString status = QString("%1 (%2/s)").arg(QGCMapEngine::bigSizeToString(_downloadData->written),
_downloadData->entry->setStatus(comma_value); QGCMapEngine::bigSizeToString(_downloadData->rate_avg));
_downloadData->entry->setStatus(status);
_downloadData->elapsed.start(); _downloadData->elapsed.start();
} }
result = true; result = true;
......
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