Commit 5218dcaf authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #333 from tstellanova/flow_debug

Avoid re-requesting paramlist when opening new param widget; Fix widget promotion 
parents 46d27b94 f22f7f7f
...@@ -45,7 +45,6 @@ void QGCUASParamManager::requestParameterList() ...@@ -45,7 +45,6 @@ void QGCUASParamManager::requestParameterList()
if (!mav) { if (!mav) {
return; return;
} }
//paramDataModel->forgetAllOnboardParameters(); //TODO really??
setParameterStatusMsg(tr("Requested param list.. waiting")); setParameterStatusMsg(tr("Requested param list.. waiting"));
paramCommsMgr->requestParameterList(); paramCommsMgr->requestParameterList();
} }
......
...@@ -60,6 +60,15 @@ void UASParameterCommsMgr::loadParamCommsSettings() ...@@ -60,6 +60,15 @@ void UASParameterCommsMgr::loadParamCommsSettings()
} }
void UASParameterCommsMgr::requestParameterListIfEmpty()
{
int totalOnboard = paramDataModel->countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
requestParameterList();
}
}
/** /**
* Send a request to deliver the list of onboard parameters * Send a request to deliver the list of onboard parameters
......
...@@ -72,6 +72,8 @@ public slots: ...@@ -72,6 +72,8 @@ public slots:
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
virtual void requestParameterList(); virtual void requestParameterList();
/** @brief Request a list of params onboard the MAV if the onboard param list we have is empty */
virtual void requestParameterListIfEmpty();
/** @brief Check for missing parameters */ /** @brief Check for missing parameters */
virtual void retransmissionGuardTick(); virtual void retransmissionGuardTick();
......
...@@ -20,15 +20,28 @@ UASParameterDataModel::UASParameterDataModel(QObject *parent) : ...@@ -20,15 +20,28 @@ UASParameterDataModel::UASParameterDataModel(QObject *parent) :
int UASParameterDataModel::countPendingParams() int UASParameterDataModel::countPendingParams()
{ {
int totalPending = 0; int total = 0;
QMap<int, QMap<QString, QVariant>*>::iterator i; QMap<int, QMap<QString, QVariant>*>::iterator i;
for (i = pendingParameters.begin(); i != pendingParameters.end(); ++i) { for (i = pendingParameters.begin(); i != pendingParameters.end(); ++i) {
// Iterate through the parameters of the component // Iterate through the parameters of the component
QMap<QString, QVariant>* paramList = i.value(); QMap<QString, QVariant>* paramList = i.value();
totalPending += paramList->count(); total += paramList->count();
} }
return totalPending; return total;
}
int UASParameterDataModel::countOnboardParams()
{
int total = 0;
QMap<int, QMap<QString, QVariant>*>::iterator i;
for (i = onboardParameters.begin(); i != onboardParameters.end(); ++i) {
// Iterate through the parameters of the component
QMap<QString, QVariant>* paramList = i.value();
total += paramList->count();
}
return total;
} }
......
...@@ -69,8 +69,10 @@ public: ...@@ -69,8 +69,10 @@ public:
} }
/** @brief return a count of all pending parameters */ /** @brief return a count of all pending parameters */
int countPendingParams(); virtual int countPendingParams();
/** @brief return a count of all onboard parameters we've received */
virtual int countOnboardParams();
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName); virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName);
virtual void readUpdateParamsFromStream(QTextStream &stream); virtual void readUpdateParamsFromStream(QTextStream &stream);
......
...@@ -802,7 +802,7 @@ void QGCPX4VehicleConfig::loadConfig() ...@@ -802,7 +802,7 @@ void QGCPX4VehicleConfig::loadConfig()
} }
doneLoadingConfig = true; doneLoadingConfig = true;
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished. //Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
mav->getParamCommsMgr()->requestParameterList(); paramCommsMgr->requestParameterListIfEmpty();
} }
void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
......
...@@ -1272,7 +1272,7 @@ p, li { white-space: pre-wrap; } ...@@ -1272,7 +1272,7 @@ p, li { white-space: pre-wrap; }
<customwidget> <customwidget>
<class>QGCPendingParamWidget</class> <class>QGCPendingParamWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>/ui/QGCPendingParamWidget.h</header> <header>ui/QGCPendingParamWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
......
...@@ -62,8 +62,9 @@ void QGCParamWidget::init() ...@@ -62,8 +62,9 @@ void QGCParamWidget::init()
layoutWidget(); layoutWidget();
connectSignalsAndSlots(); connectSignalsAndSlots();
// Ensure we're receiving the list of params // Ensure we have a list of params
requestAllParamsUpdate(); paramCommsMgr->requestParameterListIfEmpty();
} }
void QGCParamWidget::connectSignalsAndSlots() void QGCParamWidget::connectSignalsAndSlots()
...@@ -497,6 +498,7 @@ void QGCParamWidget::requestAllParamsUpdate() ...@@ -497,6 +498,7 @@ void QGCParamWidget::requestAllParamsUpdate()
// Clear view and request param list // Clear view and request param list
clear(); clear();
//paramDataModel->forgetAllOnboardParameters(); //TODO really??
requestParameterList(); requestParameterList();
} }
......
...@@ -791,7 +791,7 @@ void QGCVehicleConfig::loadConfig() ...@@ -791,7 +791,7 @@ void QGCVehicleConfig::loadConfig()
mav->getParamManager()->setParamDescriptions(paramTooltips); mav->getParamManager()->setParamDescriptions(paramTooltips);
doneLoadingConfig = true; doneLoadingConfig = true;
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished. //Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
mav->getParamCommsMgr()->requestParameterList(); mav->getParamCommsMgr()->requestParameterListIfEmpty();
} }
void QGCVehicleConfig::setActiveUAS(UASInterface* active) void QGCVehicleConfig::setActiveUAS(UASInterface* active)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment