From d74a19ce0098f7ace35423535b2dd9476d0059d9 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 6 Dec 2014 20:55:16 -0800 Subject: [PATCH 1/2] Don't request parameter list unless user requested Also only update the full tree one time once the full parameter list is ready. --- src/ui/QGCBaseParamWidget.cc | 5 +++-- src/ui/QGCParamWidget.cc | 11 +++++++++-- src/ui/QGCParamWidget.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ui/QGCBaseParamWidget.cc b/src/ui/QGCBaseParamWidget.cc index eda71c2..35e8685 100644 --- a/src/ui/QGCBaseParamWidget.cc +++ b/src/ui/QGCBaseParamWidget.cc @@ -40,8 +40,6 @@ void QGCBaseParamWidget::setUAS(UASInterface* uas) connectToParamManager(); connectViewSignalsAndSlots(); layoutWidget(); - - paramMgr->requestParameterListIfEmpty(); } } @@ -62,6 +60,9 @@ void QGCBaseParamWidget::connectToParamManager() // Listen for param list reload finished connect(paramMgr, SIGNAL(parameterListUpToDate()), this, SLOT(handleOnboardParameterListUpToDate())); + if (paramMgr->parametersReady()) { + handleOnboardParameterListUpToDate(); + } // Listen to communications status messages so we can display them connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc index a995726..d0ab534 100644 --- a/src/ui/QGCParamWidget.cc +++ b/src/ui/QGCParamWidget.cc @@ -51,7 +51,8 @@ QGCParamWidget::QGCParamWidget(QWidget *parent) : QGCBaseParamWidget(parent), componentItems(new QMap()), statusLabel(new QLabel(this)), - tree(new QTreeWidget(this)) + tree(new QTreeWidget(this)), + _fullParamListLoaded(false) { @@ -236,9 +237,15 @@ void QGCParamWidget::handleOnboardParamUpdate(int compId, const QString& paramNa void QGCParamWidget::handleOnboardParameterListUpToDate() { + // Don't load full param list more than once + if (_fullParamListLoaded) { + return; + } + + _fullParamListLoaded = true; + //turn off updates while we refresh the entire list tree->setUpdatesEnabled(false); - qDebug() << "WARN: LIST UPDATE"; //rewrite the component item tree after receiving the full list QMap*>::iterator i; diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h index 5581c5f..5db5a6f 100644 --- a/src/ui/QGCParamWidget.h +++ b/src/ui/QGCParamWidget.h @@ -104,7 +104,9 @@ protected: QLabel* statusLabel; ///< User-facing parameter status label QTreeWidget* tree; ///< The parameter tree QStringList _filterList; - + +private: + bool _fullParamListLoaded; }; #endif // QGCPARAMWIDGET_H From bd3bb47522cd9b953db3975996c0b91e05e3c74b Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 6 Dec 2014 20:55:31 -0800 Subject: [PATCH 2/2] UAS responsible for getting first time parameter list --- src/uas/QGCMAVLinkUASFactory.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/uas/QGCMAVLinkUASFactory.cc b/src/uas/QGCMAVLinkUASFactory.cc index 190b7ce..39df612 100644 --- a/src/uas/QGCMAVLinkUASFactory.cc +++ b/src/uas/QGCMAVLinkUASFactory.cc @@ -78,8 +78,11 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte // Make UAS aware that this link can be used to communicate with the actual robot uas->addLink(link); + // First thing we do with a new UAS is get the parameters + uas->requestParameters(); + // Now add UAS to "official" list, which makes the whole application aware of it UASManager::instance()->addUAS(uas); - + return uas; }