diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index 5f69d513679e51cbd2b5f601efc7f1b8aec7e9d5..f63f4de173ac33d5596848846176a6a0cc6c5202 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -56,6 +56,7 @@ maxInterval(MAX_STORAGE_INTERVAL), timeScaleStep(DEFAULT_SCALE_INTERVAL), // 10 seconds automaticScrollActive(false), m_active(true), +m_groundTime(false), d_data(NULL), d_curve(NULL) { @@ -232,7 +233,16 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value) TimeSeriesData* dataset = data.value(dataname); // Append data - dataset->append(ms, value); + if (m_groundTime) + { + // Use the current (receive) time + dataset->append(MG::TIME::getGroundTimeNow(), value); + } + else + { + // Use timestamp from dataset + dataset->append(ms, value); + } // Scaling values if(ms < minTime) minTime = ms; @@ -253,6 +263,14 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value) datalock.unlock(); } +/** + * @param enforce true to reset the data timestamp with the receive / ground timestamp + */ +void LinechartPlot::enforceGroundTime(bool enforce) +{ + m_groundTime = enforce; +} + void LinechartPlot::addCurve(QString id) { QColor currentColor = getNextColor(); diff --git a/src/ui/linechart/LinechartPlot.h b/src/ui/linechart/LinechartPlot.h index 5df6f9a667cc62abae6443fbeeb7075508b74022..0bf82f1bd56ca6661fede2b2a0cc8a56167db1e0 100644 --- a/src/ui/linechart/LinechartPlot.h +++ b/src/ui/linechart/LinechartPlot.h @@ -241,6 +241,9 @@ public slots: //void showCurve(QString id, int position); void setCurveColor(QString id, QColor color); + /** @brief Enforce the use of the receive timestamp */ + void enforceGroundTime(bool enforce); + // General interaction void setWindowPosition(quint64 end); void setPlotInterval(int interval); @@ -292,6 +295,7 @@ protected: QTime lastMaxTimeAdded; int plotid; bool m_active; ///< Decides wether the plot is active or not + bool m_groundTime; ///< Enforce the use of the receive timestamp instead of the data timestamp // Methods void addCurve(QString id); diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index ba97621c1a803b01912c7435053df74d409cb67b..77cb768e3829b6fdb416c3f5f3da2d75e1b5b347 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -152,6 +152,14 @@ void LinechartWidget::createLayout() layout->setColumnStretch(3, 0); connect(logButton, SIGNAL(clicked()), this, SLOT(startLogging())); + // Ground time button + QToolButton* timeButton = new QToolButton(this); + timeButton->setText(tr("Ground Time")); + timeButton->setCheckable(true); + layout->addWidget(timeButton, 1, 4); + layout->setColumnStretch(4, 0); + connect(timeButton, SIGNAL(clicked(bool)), activePlot, SLOT(enforceGroundTime(bool))); + // Create the scroll bar scrollbar = new QScrollBar(Qt::Horizontal, ui.diagramGroupBox); scrollbar->setMinimum(MIN_TIME_SCROLLBAR_VALUE);