diff --git a/src/uas/UASParameterCommsMgr.cc b/src/uas/UASParameterCommsMgr.cc index db74186..1a3df2d 100644 --- a/src/uas/UASParameterCommsMgr.cc +++ b/src/uas/UASParameterCommsMgr.cc @@ -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 diff --git a/src/uas/UASParameterCommsMgr.h b/src/uas/UASParameterCommsMgr.h index acdab75..39a67d1 100644 --- a/src/uas/UASParameterCommsMgr.h +++ b/src/uas/UASParameterCommsMgr.h @@ -72,6 +72,8 @@ public slots: /** @brief Request list of parameters from MAV */ 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 */ virtual void retransmissionGuardTick(); diff --git a/src/uas/UASParameterDataModel.cc b/src/uas/UASParameterDataModel.cc index 66b847e..012749f 100644 --- a/src/uas/UASParameterDataModel.cc +++ b/src/uas/UASParameterDataModel.cc @@ -20,15 +20,28 @@ UASParameterDataModel::UASParameterDataModel(QObject *parent) : int UASParameterDataModel::countPendingParams() { - int totalPending = 0; + int total = 0; QMap*>::iterator i; for (i = pendingParameters.begin(); i != pendingParameters.end(); ++i) { // Iterate through the parameters of the component QMap* paramList = i.value(); - totalPending += paramList->count(); + total += paramList->count(); } - return totalPending; + return total; +} + +int UASParameterDataModel::countOnboardParams() +{ + int total = 0; + QMap*>::iterator i; + for (i = onboardParameters.begin(); i != onboardParameters.end(); ++i) { + // Iterate through the parameters of the component + QMap* paramList = i.value(); + total += paramList->count(); + } + + return total; } diff --git a/src/uas/UASParameterDataModel.h b/src/uas/UASParameterDataModel.h index 2ca9796..40c6cea 100644 --- a/src/uas/UASParameterDataModel.h +++ b/src/uas/UASParameterDataModel.h @@ -69,8 +69,10 @@ public: } /** @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 readUpdateParamsFromStream(QTextStream &stream); diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index e285693..4f69090 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -802,7 +802,7 @@ void QGCPX4VehicleConfig::loadConfig() } doneLoadingConfig = true; //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) diff --git a/src/ui/QGCVehicleConfig.cc b/src/ui/QGCVehicleConfig.cc index 2aa2ead..6282368 100644 --- a/src/ui/QGCVehicleConfig.cc +++ b/src/ui/QGCVehicleConfig.cc @@ -791,7 +791,7 @@ void QGCVehicleConfig::loadConfig() mav->getParamManager()->setParamDescriptions(paramTooltips); doneLoadingConfig = true; //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)