Browse Source

Fixed logging time base

QGC4.4
lm 15 years ago
parent
commit
e45ffc8026
  1. 15
      src/ui/MainWindow.cc
  2. 2
      src/ui/MainWindow.h
  3. 7
      src/ui/QGCDataPlot2D.cc
  4. 27
      src/ui/linechart/LinechartPlot.cc
  5. 4
      src/ui/linechart/LinechartPlot.h
  6. 46
      src/ui/linechart/LinechartWidget.cc
  7. 1
      src/ui/linechart/LinechartWidget.h

15
src/ui/MainWindow.cc

@ -1375,23 +1375,8 @@ void MainWindow::loadWidgets() @@ -1375,23 +1375,8 @@ void MainWindow::loadWidgets()
//loadPilotView();
}
void MainWindow::loadDataView()
{
clearView();
// DATAPLOT
if (dataplotWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
centerStack->setCurrentWidget(dataplotWidget);
}
}
void MainWindow::loadDataView(QString fileName)
{
clearView();
// DATAPLOT
if (dataplotWidget)
{

2
src/ui/MainWindow.h

@ -151,8 +151,6 @@ public slots: @@ -151,8 +151,6 @@ public slots:
void loadWidgets();
/** @brief Load data view, allowing to plot flight data */
void loadDataView();
/** @brief Load data view, allowing to plot flight data */
void loadDataView(QString fileName);
/** @brief Load 3D map view */

7
src/ui/QGCDataPlot2D.cc

@ -126,6 +126,13 @@ void QGCDataPlot2D::savePlot() @@ -126,6 +126,13 @@ void QGCDataPlot2D::savePlot()
fileName = QFileDialog::getSaveFileName(
this, "Export File Name", QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
"PDF Documents (*.pdf);;SVG Images (*.svg)");
if (!fileName.contains("."))
{
// .csv is default extension
fileName.append(".pdf");
}
while(!(fileName.endsWith(".svg") || fileName.endsWith(".pdf")))
{
QMessageBox msgBox;

27
src/ui/linechart/LinechartPlot.cc

@ -57,7 +57,7 @@ maxTime(QUINT64_MIN), @@ -57,7 +57,7 @@ maxTime(QUINT64_MIN),
maxInterval(MAX_STORAGE_INTERVAL),
timeScaleStep(DEFAULT_SCALE_INTERVAL), // 10 seconds
automaticScrollActive(false),
m_active(true),
m_active(false),
m_groundTime(true),
d_data(NULL),
d_curve(NULL)
@ -286,6 +286,14 @@ void LinechartPlot::enforceGroundTime(bool enforce) @@ -286,6 +286,14 @@ void LinechartPlot::enforceGroundTime(bool enforce)
m_groundTime = enforce;
}
/**
* @return True if the data points are stamped with the packet receive time
*/
bool LinechartPlot::groundTime()
{
return m_groundTime;
}
void LinechartPlot::addCurve(QString id)
{
QColor currentColor = getNextColor();
@ -469,6 +477,23 @@ bool LinechartPlot::isVisible(QString id) @@ -469,6 +477,23 @@ bool LinechartPlot::isVisible(QString id)
}
/**
* @return The visibility, true if it is visible, false otherwise
**/
bool LinechartPlot::anyCurveVisible()
{
bool visible = false;
foreach (QString key, curves.keys())
{
if (curves.value(key)->isVisible())
{
visible = true;
}
}
return visible;
}
/**
* @brief Allows to block interference of the automatic scrolling with user interaction
* When the plot is updated very fast (at 1 ms for example) with new data, it might
* get impossible for an user to interact. Therefore the automatic scrolling must be

4
src/ui/linechart/LinechartPlot.h

@ -190,6 +190,8 @@ public: @@ -190,6 +190,8 @@ public:
QList<QwtPlotCurve*> getCurves();
bool isVisible(QString id);
/** @brief Check if any curve is visible */
bool anyCurveVisible();
int getPlotId();
/** @brief Get the number of values to average over */
@ -243,6 +245,8 @@ public slots: @@ -243,6 +245,8 @@ public slots:
/** @brief Enforce the use of the receive timestamp */
void enforceGroundTime(bool enforce);
/** @brief Check if the receive timestamp is enforced */
bool groundTime();
// General interaction
void setWindowPosition(quint64 end);

46
src/ui/linechart/LinechartWidget.cc

@ -48,6 +48,7 @@ This file is part of the PIXHAWK project @@ -48,6 +48,7 @@ This file is part of the PIXHAWK project
#include "LinechartWidget.h"
#include "LinechartPlot.h"
#include "LogCompressor.h"
#include "QGC.h"
#include "MG.h"
@ -225,7 +226,18 @@ void LinechartWidget::appendData(int uasId, QString curve, double value, quint64 @@ -225,7 +226,18 @@ void LinechartWidget::appendData(int uasId, QString curve, double value, quint64
{
if (activePlot->isVisible(curve))
{
logFile->write(QString(QString::number(usec) + "\t" + QString::number(uasId) + "\t" + curve + "\t" + QString::number(value) + "\n").toLatin1());
quint64 time = 0;
// Adjust time
if (activePlot->groundTime())
{
time = QGC::groundTimeUsecs() - logStartTime;
}
else
{
time = usec - logStartTime;
}
logFile->write(QString(QString::number(time) + "\t" + QString::number(uasId) + "\t" + curve + "\t" + QString::number(value) + "\n").toLatin1());
logFile->flush();
}
}
@ -261,14 +273,35 @@ void LinechartWidget::refresh() @@ -261,14 +273,35 @@ void LinechartWidget::refresh()
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 (*.txt, *.csv);;"));
// Store reference to file
// Append correct file ending if needed
bool abort = false;
while (!(fileName.endsWith(".txt") || fileName.endsWith(".csv")))
// Check if any curve is enabled
if (!activePlot->anyCurveVisible())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("No curves selected for logging.");
msgBox.setInformativeText("Please check all curves you want to log. Currently no data would be logged, aborting the logging.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
// 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);;"));
if (!fileName.contains("."))
{
// .csv is default extension
fileName.append(".csv");
}
while (!(fileName.endsWith(".txt") || fileName.endsWith(".csv")) && !abort)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
@ -292,6 +325,7 @@ void LinechartWidget::startLogging() @@ -292,6 +325,7 @@ void LinechartWidget::startLogging()
if (logFile->open(QIODevice::WriteOnly | QIODevice::Text))
{
logging = true;
logStartTime = QGC::groundTimeUsecs();
logindex++;
logButton->setText(tr("Stop logging"));
disconnect(logButton, SIGNAL(clicked()), this, SLOT(startLogging()));

1
src/ui/linechart/LinechartWidget.h

@ -131,6 +131,7 @@ protected: @@ -131,6 +131,7 @@ protected:
bool logging;
QTimer* updateTimer;
LogCompressor* compressor;
quint64 logStartTime;
static const int MAX_CURVE_MENUITEM_NUMBER = 8;
static const int PAGESTEP_TIME_SCROLLBAR_VALUE = (MAX_TIME_SCROLLBAR_VALUE - MIN_TIME_SCROLLBAR_VALUE) / 10;

Loading…
Cancel
Save