From fb5829864bba0969eb04febecaa81bbb399726cd Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 6 Nov 2012 14:40:05 +0100 Subject: [PATCH] Fixed logging --- src/LogCompressor.cc | 9 ++++++--- src/ui/linechart/LinechartPlot.cc | 2 +- src/ui/linechart/LinechartWidget.cc | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/LogCompressor.cc b/src/LogCompressor.cc index ffaeed864..92f20f750 100644 --- a/src/LogCompressor.cc +++ b/src/LogCompressor.cc @@ -28,6 +28,8 @@ This file is part of the QGROUNDCONTROL project */ #include +#include +#include #include #include #include @@ -64,14 +66,15 @@ void LogCompressor::run() QString outFileName; - QStringList parts = QFileInfo(infile.fileName()).absoluteFilePath().split(".", QString::SkipEmptyParts); + QStringList parts = QFileInfo(infile.fileName()).absoluteFilePath().split(".", QString::SkipEmptyParts); - parts.replace(parts.size()-2, "compressed." + parts.last()); + parts.replace(0, parts.first() + "_compressed"); + parts.replace(parts.size()-1, "txt"); outFileName = parts.join("."); // Verify that the output file is useable QFile outTmpFile(outFileName); - if (!outTmpFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + if (!outTmpFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { emit logProcessingStatusChanged(tr("Log Compressor: Cannot start/compress log file, since output file %1 is not writable").arg(QFileInfo(outTmpFile.fileName()).absoluteFilePath())); return; } diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index baf7dcc49..d4b33d279 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -47,7 +47,7 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): Qwt this->plotid = plotid; this->plotInterval = interval; - maxValue = DBL_MIN; + maxValue = -DBL_MAX; minValue = DBL_MAX; //lastMaxTimeAdded = QTime(); diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 1b009ce6f..f3d0dad84 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -548,13 +548,13 @@ void LinechartWidget::startLogging() // Let user select the log file name //QDate date(QDate::currentDate()); // QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log") - QString fileName = QFileDialog::getSaveFileName(this, tr("Specify log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Logfile (*.csv *.txt);;")); + QString fileName = QFileDialog::getSaveFileName(this, tr("Specify log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Logfile (*.log);;")); - while (!(fileName.endsWith(".txt") || fileName.endsWith(".csv")) && !abort && fileName != "") { + while (!(fileName.endsWith(".log")) && !abort && fileName != "") { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Critical); msgBox.setText("Unsuitable file extension for logfile"); - msgBox.setInformativeText("Please choose .txt or .csv as file extension. Click OK to change the file extension, cancel to not start logging."); + msgBox.setInformativeText("Please choose .log as file extension. Click OK to change the file extension, cancel to not start logging."); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); if(msgBox.exec() != QMessageBox::Ok) @@ -562,7 +562,7 @@ void LinechartWidget::startLogging() abort = true; break; } - fileName = QFileDialog::getSaveFileName(this, tr("Specify log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Logfile (*.txt *.csv);;")); + fileName = QFileDialog::getSaveFileName(this, tr("Specify log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Logfile (*.log);;")); } qDebug() << "SAVE FILE" << fileName; @@ -570,7 +570,7 @@ void LinechartWidget::startLogging() // Check if the user did not abort the file save dialog if (!abort && fileName != "") { logFile = new QFile(fileName); - if (logFile->open(QIODevice::WriteOnly | QIODevice::Text)) { + if (logFile->open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { logging = true; logStartTime = 0; curvesWidget->setEnabled(false); -- 2.22.0