diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index d0d364b68..8489811a5 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 ) +{ + validateRefreshInterval(); +} + +void ScopeGadgetOptionsPage::validateRefreshInterval() +{ + 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..54042741e 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 validateRefreshInterval(); 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..320c3d314 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -6,14 +6,68 @@ 0 0 - 550 - 405 + 544 + 342 Form + + + + + + true + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + 1 + + + + + + + +