From 8e1a7ae7093edd8e475bd75185720d0df8a562d4 Mon Sep 17 00:00:00 2001 From: banig Date: Sat, 11 Feb 2012 15:59:34 +0200 Subject: [PATCH 1/2] Add warning to let user know if Scope refresh interval is quicker than the telemetry data --- .../plugins/scope/scopegadgetoptionspage.cpp | 32 +++++++++++ .../plugins/scope/scopegadgetoptionspage.h | 2 + .../plugins/scope/scopegadgetoptionspage.ui | 54 +++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index d0d364b68..a4187f1a4 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -114,6 +114,7 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) connect(options_page->btnRemoveCurve, SIGNAL(clicked()), this, SLOT(on_btnRemoveCurve_clicked())); connect(options_page->lstCurves, SIGNAL(currentRowChanged(int)), this, SLOT(on_lstCurves_currentRowChanged(int))); connect(options_page->btnColor, SIGNAL(clicked()), this, SLOT(on_btnColor_clicked())); + connect(options_page->spnRefreshInterval, SIGNAL(valueChanged(int )), this, SLOT(on_spnRefreshInterval_valueChanged(int))); setYAxisWidgetFromPlotCurve(); @@ -349,3 +350,34 @@ void ScopeGadgetOptionsPage::on_loggingEnable_clicked() options_page->LoggingLabel->setEnabled(en); } + +void ScopeGadgetOptionsPage::on_spnRefreshInterval_valueChanged(int ) +{ + validateRefresh(); +} + +void ScopeGadgetOptionsPage::validateRefresh() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + for(int iIndex = 0; iIndex < options_page->lstCurves->count();iIndex++) { + QListWidgetItem* listItem = options_page->lstCurves->item(iIndex); + + QString uavObject = listItem->data(Qt::UserRole + 0).toString(); + + UAVDataObject* obj = dynamic_cast(objManager->getObject((uavObject))); + if(!obj) { + qDebug() << "Object " << uavObject << " is missing"; + continue; + } + + if(options_page->spnRefreshInterval->value() < obj->getMetadata().flightTelemetryUpdatePeriod) + { + options_page->lblWarnings->setText("The refresh interval is faster than some or all telemetry objects."); + return; + } + } + + options_page->lblWarnings->setText(""); +} + diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h index 39c0b3ea5..baf933fc3 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h @@ -70,8 +70,10 @@ private: void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor); void setYAxisWidgetFromPlotCurve(); void setButtonColor(const QColor &color); + void validateRefresh(); private slots: + void on_spnRefreshInterval_valueChanged(int ); void on_lstCurves_currentRowChanged(int currentRow); void on_btnRemoveCurve_clicked(); void on_btnAddCurve_clicked(); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui index b3d22faa0..1b4e156e3 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -14,6 +14,60 @@ Form + + + + + + true + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 1 + + + + + + + + From 2aead6a7c615935630d18a7eaf0c5b6966e83ab1 Mon Sep 17 00:00:00 2001 From: banig Date: Sat, 11 Feb 2012 16:17:20 +0200 Subject: [PATCH 2/2] Made method name more descriptive --- .../openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp | 4 ++-- .../openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h | 2 +- .../openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index a4187f1a4..8489811a5 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -353,10 +353,10 @@ void ScopeGadgetOptionsPage::on_loggingEnable_clicked() void ScopeGadgetOptionsPage::on_spnRefreshInterval_valueChanged(int ) { - validateRefresh(); + validateRefreshInterval(); } -void ScopeGadgetOptionsPage::validateRefresh() +void ScopeGadgetOptionsPage::validateRefreshInterval() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h index baf933fc3..54042741e 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h @@ -70,7 +70,7 @@ private: void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor); void setYAxisWidgetFromPlotCurve(); void setButtonColor(const QColor &color); - void validateRefresh(); + void validateRefreshInterval(); private slots: void on_spnRefreshInterval_valueChanged(int ); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui index 1b4e156e3..320c3d314 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -6,8 +6,8 @@ 0 0 - 550 - 405 + 544 + 342