1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

Add warning to let user know if Scope refresh interval is quicker than the telemetry data

This commit is contained in:
banig 2012-02-11 15:59:34 +02:00
parent 81f01a0b96
commit 8e1a7ae709
3 changed files with 88 additions and 0 deletions

View File

@ -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<UAVObjectManager>();
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<UAVDataObject*>(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("");
}

View File

@ -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();

View File

@ -14,6 +14,60 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lblWarnings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">