diff --git a/QGCApplication.pro b/QGCApplication.pro index abe4dac9cbf2e5cbae5f612314f20c606a8e4869..d5f556093e9ad4d66670207f032035d36d963658 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -599,14 +599,13 @@ INCLUDEPATH += \ src/VehicleSetup FORMS += \ - src/VehicleSetup/ParameterEditor.ui \ src/VehicleSetup/SetupView.ui \ HEADERS+= \ src/VehicleSetup/SetupView.h \ - src/VehicleSetup/ParameterEditor.h \ src/VehicleSetup/VehicleComponent.h \ src/VehicleSetup/FirmwareUpgradeController.h \ + src/VehicleSetup/ParameterEditorController.h \ src/VehicleSetup/PX4Bootloader.h \ src/VehicleSetup/PX4FirmwareUpgradeThread.h \ src/AutoPilotPlugins/AutoPilotPluginManager.h \ @@ -629,9 +628,9 @@ HEADERS+= \ SOURCES += \ src/VehicleSetup/SetupView.cc \ - src/VehicleSetup/ParameterEditor.cc \ src/VehicleSetup/VehicleComponent.cc \ src/VehicleSetup/FirmwareUpgradeController.cc \ + src/VehicleSetup/ParameterEditorController.cc \ src/VehicleSetup/PX4Bootloader.cc \ src/VehicleSetup/PX4FirmwareUpgradeThread.cc \ src/AutoPilotPlugins/AutoPilotPluginManager.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 31bae3fc2015bc9dadb42d567e14fe2dd6bb65c1..accd87e43d88992a75d3f4caeb8ccfa74501a7a6 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -1,6 +1,6 @@ - src/qgcunittest/MockLink.param + src/qgcunittest/MockLink.params src/FactSystem/FactSystemTest.qml @@ -35,6 +35,7 @@ src/VehicleSetup/VehicleSummary.qml src/VehicleSetup/FirmwareUpgrade.qml + src/VehicleSetup/ParameterEditor.qml src/AutoPilotPlugins/PX4/SafetyComponent.qml src/AutoPilotPlugins/PX4/PowerComponent.qml src/AutoPilotPlugins/PX4/SensorsComponent.qml diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.cc b/src/AutoPilotPlugins/AutoPilotPlugin.cc index 5908a0fbf751afdf03334398f709ad161bcfc3c5..5b8ddd670e8585e320754e5aeb09624335f87a66 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/AutoPilotPlugin.cc @@ -25,6 +25,7 @@ /// @author Don Gagne #include "AutoPilotPlugin.h" +#include "QGCUASParamManagerInterface.h" AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) : QObject(parent), @@ -34,11 +35,36 @@ AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) : Q_ASSERT(_uas); } +void AutoPilotPlugin::refreshAllParameters(void) +{ + _getParameterLoader()->refreshAllParameters(); +} + +void AutoPilotPlugin::refreshParameter(int componentId, const QString& name) +{ + _getParameterLoader()->refreshParameter(componentId, name); +} + +void AutoPilotPlugin::refreshParametersPrefix(int componentId, const QString& namePrefix) +{ + _getParameterLoader()->refreshParametersPrefix(componentId, namePrefix); +} + +bool AutoPilotPlugin::parameterExists(const QString& name) +{ + return _getParameterLoader()->parameterExists(FactSystem::defaultComponentId, name); +} + +Fact* AutoPilotPlugin::getParameterFact(const QString& name) +{ + return _getParameterLoader()->getFact(FactSystem::defaultComponentId, name); +} + bool AutoPilotPlugin::factExists(FactSystem::Provider_t provider, int componentId, const QString& name) { switch (provider) { case FactSystem::ParameterProvider: - return getParameterLoader()->factExists(componentId, name); + return _getParameterLoader()->parameterExists(componentId, name); // Other providers will go here once they come online } @@ -51,7 +77,7 @@ Fact* AutoPilotPlugin::getFact(FactSystem::Provider_t provider, int componentId, { switch (provider) { case FactSystem::ParameterProvider: - return getParameterLoader()->getFact(componentId, name); + return _getParameterLoader()->getFact(componentId, name); // Other providers will go here once they come online } @@ -59,3 +85,40 @@ Fact* AutoPilotPlugin::getFact(FactSystem::Provider_t provider, int componentId, Q_ASSERT(false); return NULL; } + +QStringList AutoPilotPlugin::parameterNames(void) +{ + return _getParameterLoader()->parameterNames(); +} + +const QMap >& AutoPilotPlugin::getGroupMap(void) +{ + return _getParameterLoader()->getGroupMap(); +} + +void AutoPilotPlugin::writeParametersToStream(QTextStream &stream) +{ + Q_ASSERT(_uas); + + _uas->getParamManager()->writeOnboardParamsToStream(stream, _uas->getUASName()); +} + +void AutoPilotPlugin::readParametersFromStream(QTextStream &stream) +{ + Q_ASSERT(_uas); + + Fact* autoSaveFact = NULL; + int previousAutoSave = 0; + + if (parameterExists("COM_AUTOS_PAR")) { + autoSaveFact = getParameterFact("COM_AUTOS_PAR"); + previousAutoSave = autoSaveFact->value().toInt(); + autoSaveFact->setValue(1); + } + + _uas->getParamManager()->readPendingParamsFromStream(stream); + + if (autoSaveFact) { + autoSaveFact->setValue(previousAutoSave); + } +} diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.h b/src/AutoPilotPlugins/AutoPilotPlugin.h index b25e418ab23726f8a55db36a974f2656dd7f0b7d..dc70d0e2f63c4ddf918aaeeef22540d7e2bb95b7 100644 --- a/src/AutoPilotPlugins/AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/AutoPilotPlugin.h @@ -57,14 +57,32 @@ public: Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT) /// Re-request the full set of parameters from the autopilot - Q_INVOKABLE void refreshAllParameters(void) { getParameterLoader()->refreshAllParameters(); } + Q_INVOKABLE void refreshAllParameters(void); /// Request a refresh on the specific parameter - Q_INVOKABLE void refreshParameter(int componentId, const QString& name) { getParameterLoader()->refreshParameter(componentId, name); } + Q_INVOKABLE void refreshParameter(int componentId, const QString& name); /// Request a refresh on all parameters that begin with the specified prefix - Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix) { getParameterLoader()->refreshParametersPrefix(componentId, namePrefix); } - + Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix); + + /// Returns true if the specifed parameter exists from the default component + Q_INVOKABLE bool parameterExists(const QString& name); + + /// Returns all parameter names + /// FIXME: component id missing, generic to fact + QStringList parameterNames(void); + + /// Returns the specified parameter Fact from the default component + /// WARNING: Will assert if fact does not exists. If that possibility exists, check for existince first with + /// factExists. + Fact* getParameterFact(const QString& name); + + /// Writes the parameter facts to the specified stream + void writeParametersToStream(QTextStream &stream); + + /// Reads the parameters from the stream and updates values + void readParametersFromStream(QTextStream &stream); + /// Returns true if the specifed fact exists Q_INVOKABLE bool factExists(FactSystem::Provider_t provider, ///< fact provider int componentId, ///< fact component, -1=default component @@ -76,21 +94,12 @@ public: Fact* getFact(FactSystem::Provider_t provider, ///< fact provider int componentId, ///< fact component, -1=default component const QString& name); ///< fact name - - /// Returns true if the specifed parameter exists from the default component - Q_INVOKABLE bool parameterExists(const QString& name) { return getParameterLoader()->factExists(FactSystem::defaultComponentId, name); } - - /// Returns the specified parameter Fact from the default component - /// WARNING: Will assert if fact does not exists. If that possibility exists, check for existince first with - /// factExists. - Fact* getParameterFact(const QString& name) { return getParameterLoader()->getFact(FactSystem::defaultComponentId, name); } + const QMap >& getGroupMap(void); + // Must be implemented by derived class virtual const QVariantList& vehicleComponents(void) = 0; - /// Returns the ParameterLoader - virtual ParameterLoader* getParameterLoader(void) = 0; - /// FIXME: Kind of hacky static void clearStaticData(void); @@ -106,6 +115,9 @@ protected: /// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { } + /// Returns the ParameterLoader + virtual ParameterLoader* _getParameterLoader(void) = 0; + UASInterface* _uas; bool _pluginReady; }; diff --git a/src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h b/src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h index 3840b04387cffd5455e8f0cbb69682abdd92ff27..87f37de0880c17be7fdee1c3c3edb8edd481655d 100644 --- a/src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h @@ -42,7 +42,6 @@ public: // Overrides from AutoPilotPlugin virtual const QVariantList& vehicleComponents(void); - virtual ParameterLoader* getParameterLoader(void) { return _parameterFacts; } static QList getModes(void); static QString getShortModeText(uint8_t baseMode, uint32_t customMode); @@ -52,6 +51,9 @@ private slots: void _parametersReady(void); private: + // Overrides from AutoPilotPlugin + virtual ParameterLoader* _getParameterLoader(void) { return _parameterFacts; } + GenericParameterFacts* _parameterFacts; }; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 995853ef12fb8024224a81ecb38585268d5f9aa8..8bcecdebcdcebef74b3bccfb67c21e10e9108c49 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -90,7 +90,6 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) : PX4AutoPilotPlugin::~PX4AutoPilotPlugin() { delete _parameterFacts; - PX4ParameterFacts::deleteParameterFactMetaData(); } QList PX4AutoPilotPlugin::getModes(void) diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h index 9db1554ca432af11f03d22f2803aa638aabfa771..05ee9d1e2fbfa15befa92d41d4d5e07c4cb5c352 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h @@ -51,7 +51,6 @@ public: // Overrides from AutoPilotPlugin virtual const QVariantList& vehicleComponents(void); - virtual ParameterLoader* getParameterLoader(void) { return _parameterFacts; } static QList getModes(void); static QString getShortModeText(uint8_t baseMode, uint32_t customMode); @@ -69,6 +68,9 @@ private slots: void _pluginReadyPreChecks(void); private: + // Overrides from AutoPilotPlugin + virtual ParameterLoader* _getParameterLoader(void) { return _parameterFacts; } + PX4ParameterFacts* _parameterFacts; QVariantList _components; AirframeComponent* _airframeComponent; diff --git a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc index 1d1272930e3f29baef05f00ba88b51b5723daad6..e74d0b282696f46bbc255124d66c11127a55cb75 100644 --- a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc +++ b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc @@ -42,14 +42,6 @@ PX4ParameterFacts::PX4ParameterFacts(UASInterface* uas, QObject* parent) : Q_ASSERT(uas); } -void PX4ParameterFacts::deleteParameterFactMetaData(void) -{ - foreach (QString param, _mapParameterName2FactMetaData.keys()) { - delete _mapParameterName2FactMetaData[param]; - } - _mapParameterName2FactMetaData.clear(); -} - /// Parse the Parameter element of parameter xml meta data /// @param[in] xml stream reader /// @param[in] group fact group associated with this Param element @@ -69,6 +61,8 @@ FactMetaData* PX4ParameterFacts::_parseParameter(QXmlStreamReader& xml, const QS FactMetaData* metaData = new FactMetaData(); Q_CHECK_PTR(metaData); + metaData->group = group; + // Convert type from string to FactMetaData::ValueType_t struct String2Type { diff --git a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.h b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.h index 3b733777620aa717ab23433aea788c3407db20c9..018f4b5aa84f64e562869dc17a89517f14b3ed25 100644 --- a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.h +++ b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.h @@ -52,7 +52,6 @@ public: virtual QString getDefaultComponentIdParam(void) const { return QString("SYS_AUTOSTART"); } static void loadParameterFactMetaData(void); - static void deleteParameterFactMetaData(void); static void clearStaticData(void); private: diff --git a/src/FactSystem/Fact.cc b/src/FactSystem/Fact.cc index d50d429ee02610881f57b94eae4e521ed3df9886..a8390b5e9f5956e4252b010cb1b91920247967aa 100644 --- a/src/FactSystem/Fact.cc +++ b/src/FactSystem/Fact.cc @@ -107,7 +107,7 @@ QString Fact::shortDescription(void) if (_metaData) { return _metaData->shortDescription; } else { - return QString(); + return QString(""); } } @@ -116,7 +116,7 @@ QString Fact::longDescription(void) if (_metaData) { return _metaData->longDescription; } else { - return QString(); + return QString(""); } } @@ -125,7 +125,7 @@ QString Fact::units(void) if (_metaData) { return _metaData->units; } else { - return QString(); + return QString(""); } } @@ -141,6 +141,15 @@ QVariant Fact::max(void) return _metaData->max; } +QString Fact::group(void) +{ + if (_metaData) { + return _metaData->group; + } else { + return "Default Group"; + } +} + void Fact::setMetaData(FactMetaData* metaData) { _metaData = metaData; diff --git a/src/FactSystem/Fact.h b/src/FactSystem/Fact.h index 798b23e61982dc5e631865cc869a64a0b0f36dd8..7e92102032ba18d726451246856e137236e1747d 100644 --- a/src/FactSystem/Fact.h +++ b/src/FactSystem/Fact.h @@ -54,6 +54,7 @@ class Fact : public QObject Q_PROPERTY(QString units READ units CONSTANT) Q_PROPERTY(QVariant min READ min CONSTANT) Q_PROPERTY(QVariant max READ max CONSTANT) + Q_PROPERTY(QString group READ group CONSTANT) Q_ENUMS(FactMetaData::ValueType_t) @@ -63,41 +64,19 @@ public: // Property system methods - /// Read accessor for name property QString name(void) const; - - /// Read accessor for componentId property int componentId(void) const; - - /// Read accessor for value property QVariant value(void) const; - - /// Read accessor for valueString property QString valueString(void) const; - - /// Write accessor for value property void setValue(const QVariant& value); - - /// Read accesor for defaultValue property QVariant defaultValue(void); - - /// Read accesor for type property FactMetaData::ValueType_t type(void); - - /// Read accesor for shortDescription property QString shortDescription(void); - - /// Read accesor for longDescription property QString longDescription(void); - - /// Read accesor for units property QString units(void); - - /// Read accesor for min property QVariant min(void); - - /// Read accesor for max property - QVariant max(void); + QVariant max(void); + QString group(void); /// Sets the meta data associated with the Fact. void setMetaData(FactMetaData* metaData); diff --git a/src/FactSystem/FactBinder.cc b/src/FactSystem/FactBinder.cc index a5d92b6251ce5681a9116a5522c5d8d5d5ae2a03..8c191259e60a9b2320e92047dbc42226cfa731d1 100644 --- a/src/FactSystem/FactBinder.cc +++ b/src/FactSystem/FactBinder.cc @@ -51,6 +51,11 @@ QString FactBinder::name(void) const } } +int FactBinder::componentId(void) const +{ + return _componentId; +} + void FactBinder::setName(const QString& name) { if (_fact) { @@ -59,13 +64,25 @@ void FactBinder::setName(const QString& name) } if (!name.isEmpty()) { - if (_autopilotPlugin->factExists(FactSystem::ParameterProvider, _componentId, name)) { - _fact = _autopilotPlugin->getFact(FactSystem::ParameterProvider, _componentId, name); + QString parsedName = name; + + // Component id + name combination? + if (name.contains(":")) { + QStringList parts = name.split(":"); + if (parts.count() == 2) { + parsedName = parts[0]; + _componentId = parts[1].toInt(); + } + } + + if (_autopilotPlugin->factExists(FactSystem::ParameterProvider, _componentId, parsedName)) { + _fact = _autopilotPlugin->getFact(FactSystem::ParameterProvider, _componentId, parsedName); connect(_fact, &Fact::valueChanged, this, &FactBinder::valueChanged); emit valueChanged(); emit nameChanged(); - } else { + emit metaDataChanged(); + } else { qWarning() << "FAILED BINDING PARAM" << name << ": PARAM DOES NOT EXIST ON SYSTEM!"; Q_ASSERT(false); } @@ -108,3 +125,66 @@ QString FactBinder::units(void) const return QString(); } } + +QVariant FactBinder::defaultValue(void) +{ + if (_fact) { + return _fact->defaultValue(); + } else { + return QVariant(0); + } +} + +FactMetaData::ValueType_t FactBinder::type(void) +{ + if (_fact) { + return _fact->type(); + } else { + return FactMetaData::valueTypeUint32; + } +} + +QString FactBinder::shortDescription(void) +{ + if (_fact) { + return _fact->shortDescription(); + } else { + return QString(); + } +} + +QString FactBinder::longDescription(void) +{ + if (_fact) { + return _fact->longDescription(); + } else { + return QString(); + } +} + +QVariant FactBinder::min(void) +{ + if (_fact) { + return _fact->min(); + } else { + return QVariant(0); + } +} + +QVariant FactBinder::max(void) +{ + if (_fact) { + return _fact->max(); + } else { + return QVariant(0); + } +} + +QString FactBinder::group(void) +{ + if (_fact) { + return _fact->group(); + } else { + return QString(); + } +} diff --git a/src/FactSystem/FactBinder.h b/src/FactSystem/FactBinder.h index a91db0d916593d990ab58787b2a4ea118c1f5e74..4cfb0c845ce1f508c951ed6200774e60b18b7a64 100644 --- a/src/FactSystem/FactBinder.h +++ b/src/FactSystem/FactBinder.h @@ -38,17 +38,23 @@ class FactBinder : public QObject { Q_OBJECT - Q_PROPERTY(int componentId MEMBER _componentId NOTIFY componentIdChanged) + Q_PROPERTY(int componentId READ componentId NOTIFY nameChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) Q_PROPERTY(QVariant valueString READ valueString NOTIFY valueChanged) - Q_PROPERTY(QString units READ units CONSTANT) - + Q_PROPERTY(QString units READ units NOTIFY metaDataChanged) + Q_PROPERTY(QVariant defaultValue READ defaultValue NOTIFY metaDataChanged) + Q_PROPERTY(FactMetaData::ValueType_t type READ type NOTIFY metaDataChanged) + Q_PROPERTY(QString shortDescription READ shortDescription NOTIFY metaDataChanged) + Q_PROPERTY(QString longDescription READ longDescription NOTIFY metaDataChanged) + Q_PROPERTY(QVariant min READ min NOTIFY metaDataChanged) + Q_PROPERTY(QVariant max READ max NOTIFY metaDataChanged) + Q_PROPERTY(QString group READ group NOTIFY metaDataChanged) + public: FactBinder(void); int componentId(void) const; - void setComponentId(int componentId); QString name(void) const; void setName(const QString& name); @@ -58,13 +64,19 @@ public: QString valueString(void) const; - /// Read accesor for units property QString units(void) const; - + QVariant defaultValue(void); + FactMetaData::ValueType_t type(void); + QString shortDescription(void); + QString longDescription(void); + QVariant min(void); + QVariant max(void); + QString group(void); + signals: - void componentIdChanged(void); void nameChanged(void); void valueChanged(void); + void metaDataChanged(void); private: AutoPilotPlugin* _autopilotPlugin; diff --git a/src/FactSystem/FactMetaData.h b/src/FactSystem/FactMetaData.h index 47924be5ee81e5a1fcde420f35c4f129874e9ac9..b7e2bfa4671179af383b80bf2cca41322c9045f8 100644 --- a/src/FactSystem/FactMetaData.h +++ b/src/FactSystem/FactMetaData.h @@ -57,7 +57,7 @@ public: /// Initialize the meta data given only the type. void initFromTypeOnly(ValueType_t initType); - // FIXME: This needs to switch over to Q_PROPERTY mechanism + QString group; ValueType_t type; QVariant defaultValue; QString shortDescription; diff --git a/src/FactSystem/FactSystem.cc b/src/FactSystem/FactSystem.cc index 2ff881016eee2e8bbd7000ff4bf3a6fef1820176..450b0b8e354e85a52fa35fd9f54c3c72f6b5257e 100644 --- a/src/FactSystem/FactSystem.cc +++ b/src/FactSystem/FactSystem.cc @@ -40,7 +40,7 @@ FactSystem::FactSystem(QObject* parent) : QGCSingleton(parent) { qmlRegisterType(_factSystemQmlUri, 1, 0, "Fact"); - qmlRegisterUncreatableType(_factSystemQmlUri, 1, 0, "VehicleComponent", "Can only reference VehicleComponent"); + qmlRegisterUncreatableType(_factSystemQmlUri, 1, 0, "VehicleComponent", "Can only reference, cannot create"); } FactSystem::~FactSystem() diff --git a/src/FactSystem/FactSystemTest.qml b/src/FactSystem/FactSystemTest.qml index b9e3d1fd7caab165dfb6c3753fcdd88760c731e4..885b4b22ff6f24d824777265d1684034a85c486b 100644 --- a/src/FactSystem/FactSystemTest.qml +++ b/src/FactSystem/FactSystemTest.qml @@ -37,7 +37,7 @@ Item { // Use specific component id TextInput { objectName: "testControl" - Fact { id: fact2; name: "COMPONENT_51"; componentId: 51 } + Fact { id: fact2; name: "COMPONENT_51:51" } text: fact2.value onAccepted: { fact2.value = text; } } diff --git a/src/FactSystem/ParameterLoader.cc b/src/FactSystem/ParameterLoader.cc index 5d66a9ccbec3101f10881505a6217968602d427c..c1c28e36bc5d7bdef4bc9ce30d10da1cff479a1e 100644 --- a/src/FactSystem/ParameterLoader.cc +++ b/src/FactSystem/ParameterLoader.cc @@ -80,9 +80,6 @@ void ParameterLoader::_parameterUpdate(int uas, int componentId, QString paramet } if (!_mapParameterName2Variant.contains(componentId) || !_mapParameterName2Variant[componentId].contains(parameterName)) { - // These should not get our of sync - Q_ASSERT(_mapParameterName2Variant.contains(componentId) == _mapFact2ParameterName.contains(componentId)); - qCDebug(ParameterLoaderLog) << "Adding new fact (component:" << componentId << "name:" << parameterName << ")"; FactMetaData::ValueType_t factType; @@ -121,7 +118,6 @@ void ParameterLoader::_parameterUpdate(int uas, int componentId, QString paramet setMetaData = true; _mapParameterName2Variant[componentId][parameterName] = QVariant::fromValue(fact); - _mapFact2ParameterName[componentId][fact] = parameterName; // We need to know when the fact changes from QML so that we can send the new value to the parameter manager connect(fact, &Fact::_containerValueChanged, this, &ParameterLoader::_valueUpdated); @@ -151,8 +147,6 @@ void ParameterLoader::_valueUpdated(const QVariant& value) int componentId = fact->componentId(); Q_ASSERT(_paramMgr); - Q_ASSERT(_mapFact2ParameterName.contains(componentId)); - Q_ASSERT(_mapFact2ParameterName[componentId].contains(fact)); QVariant typedValue; switch (fact->type()) { @@ -196,6 +190,7 @@ void ParameterLoader::_paramMgrParameterListUpToDate(void) qgcApp()->processEvents(); _determineDefaultComponentId(); + _setupGroupMap(); // We should have all parameters now so we can signal ready emit parametersReady(); @@ -254,7 +249,6 @@ void ParameterLoader::refreshParametersPrefix(int componentId, const QString& na Q_ASSERT(_paramMgr); componentId = _actualComponentId(componentId); - Q_ASSERT(_mapFact2ParameterName.contains(componentId)); foreach(QString name, _mapParameterName2Variant[componentId].keys()) { if (name.startsWith(namePrefix)) { refreshParameter(componentId, name); @@ -262,7 +256,7 @@ void ParameterLoader::refreshParametersPrefix(int componentId, const QString& na } } -bool ParameterLoader::factExists(int componentId, const QString& name) +bool ParameterLoader::parameterExists(int componentId, const QString& name) { componentId = _actualComponentId(componentId); if (_mapParameterName2Variant.contains(componentId)) { @@ -280,3 +274,29 @@ Fact* ParameterLoader::getFact(int componentId, const QString& name) Q_ASSERT(fact); return fact; } + +QStringList ParameterLoader::parameterNames(void) +{ + QStringList names; + + foreach(QString paramName, _mapParameterName2Variant[_defaultComponentId].keys()) { + names << paramName; + } + + return names; +} + +void ParameterLoader::_setupGroupMap(void) +{ + foreach (int componentId, _mapParameterName2Variant.keys()) { + foreach (QString name, _mapParameterName2Variant[componentId].keys()) { + Fact* fact = _mapParameterName2Variant[componentId][name].value(); + _mapGroup2ParameterName[componentId][fact->group()] += name; + } + } +} + +const QMap >& ParameterLoader::getGroupMap(void) +{ + return _mapGroup2ParameterName; +} diff --git a/src/FactSystem/ParameterLoader.h b/src/FactSystem/ParameterLoader.h index 6c1951059cd89a2db12670b9ed07c601d646e397..0237e757ea9e9b79da42fc525bbe3196d816c40b 100644 --- a/src/FactSystem/ParameterLoader.h +++ b/src/FactSystem/ParameterLoader.h @@ -60,16 +60,22 @@ public: /// Request a refresh on all parameters that begin with the specified prefix void refreshParametersPrefix(int componentId, const QString& namePrefix); - /// Returns true if the specifed fact exists - bool factExists(int componentId, ///< fact component, -1=default component - const QString& name); ///< fact name + /// Returns true if the specifed parameter exists + bool parameterExists(int componentId, ///< fact component, -1=default component + const QString& name); ///< fact name + + /// Returns all parameter names + /// FIXME: component id missing + QStringList parameterNames(void); /// Returns the specified Fact. - /// WARNING: Will assert if fact does not exists. If that possibily exists, check for existince first with - /// factExists. + /// WARNING: Will assert if parameter does not exists. If that possibily exists, check for existince first with + /// parameterExists. Fact* getFact(int componentId, ///< fact component, -1=default component const QString& name); ///< fact name + const QMap >& getGroupMap(void); + /// Return the parameter for which the default component id is derived from. Return an empty /// string is this is not available. virtual QString getDefaultComponentIdParam(void) const = 0; @@ -92,11 +98,8 @@ private: static QVariant _stringToTypedVariant(const QString& string, FactMetaData::ValueType_t type, bool failOk = false); int _actualComponentId(int componentId); void _determineDefaultComponentId(void); + void _setupGroupMap(void); - /// First mapping is by component id - /// Second mapping is parameter name, to Fact - QMap > _mapFact2ParameterName; - int _uasId; ///< Id for uas which this set of Facts are associated with QGCUASParamManagerInterface* _paramMgr; @@ -105,6 +108,10 @@ private: /// Second mapping is parameter name, to Fact* in QVariant QMap _mapParameterName2Variant; + /// First mapping is by component id + /// Second mapping is group name, to Fact + QMap > _mapGroup2ParameterName; + bool _parametersReady; ///< All params received from param mgr int _defaultComponentId; QString _defaultComponentIdParam; diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 7906ce6222ffad5cd01437ddf3ecd521aecf81af..0142643b69e31869050b7e62ed082bcdffb69305 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -28,7 +28,7 @@ import QtQuick.Controls.Styles 1.2 import QGroundControl.Controls 1.0 import QGroundControl.FactControls 1.0 import QGroundControl.Palette 1.0 -import QGroundControl.FirmwareUpgradeController 1.0 +import QGroundControl.Controllers 1.0 import QGroundControl.ScreenTools 1.0 Rectangle { diff --git a/src/VehicleSetup/ParameterEditor.cc b/src/VehicleSetup/ParameterEditor.cc deleted file mode 100644 index ed43081d2c03ced9d81cace5f896a937005e157f..0000000000000000000000000000000000000000 --- a/src/VehicleSetup/ParameterEditor.cc +++ /dev/null @@ -1,46 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - - ======================================================================*/ - -/// @file -/// @author Don Gagne - -#include "ParameterEditor.h" -#include "ui_ParameterEditor.h" - -ParameterEditor::ParameterEditor(UASInterface* uas, const QStringList& filterList, QWidget* parent) : - QWidget(parent), - _ui(new Ui::ParameterEditor) -{ - _ui->setupUi(this); - - _ui->paramTreeWidget->setFilterList(filterList); - _ui->paramTreeWidget->setUAS(uas); - _ui->paramTreeWidget->handleOnboardParameterListUpToDate(); - _ui->pendingCommitsWidget->setUAS(uas); - _ui->pendingCommitsWidget->update(); -} - -ParameterEditor::~ParameterEditor() -{ - delete _ui; -} diff --git a/src/VehicleSetup/ParameterEditor.qml b/src/VehicleSetup/ParameterEditor.qml new file mode 100644 index 0000000000000000000000000000000000000000..da3e113d46d0bf5b08f42c6ecfd3d63d4412999f --- /dev/null +++ b/src/VehicleSetup/ParameterEditor.qml @@ -0,0 +1,230 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2015 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 + +Rectangle { + QGCPalette { id: qgcPal; colorGroupEnabled: true } + ScreenTools { id: screenTools } + ParameterEditorController { id: controller } + QGCLabel { id: charWidth; text: "X"; visible: false } + + readonly property real leftMargin: 10 + readonly property real rightMargin: 20 + readonly property int maxParamChars: 16 + + color: qgcPal.window + + // We use an ExclusiveGroup to maintain the visibility of a single editing control at a time + ExclusiveGroup { + id: exclusiveEditorGroup + } + + Column { + anchors.fill:parent + + QGCLabel { + text: "PARAMETER EDITOR" + font.pointSize: screenTools.dpiAdjustedPointSize(20) + } + + Item { + height: 20 + width: 5 + } + + Row { + spacing: 10 + layoutDirection: Qt.RightToLeft + width: parent.width + + QGCButton { + text: "Clear RC to Param" + onClicked: controller.clearRCToParam() + } + QGCButton { + text: "Save to file" + onClicked: controller.saveToFile() + } + QGCButton { + text: "Load from file" + onClicked: controller.loadFromFile() + } + QGCButton { + id: firstButton + text: "Refresh" + onClicked: controller.refresh() + } + QGCLabel { + width: firstButton.x - parent.spacing + wrapMode: Text.WordWrap + text: "Click a parameter value to modify. Right-click to set an RC to Param mapping. Use caution when modifying parameters here since the values are not checked for validity." + } + } + + Item { + id: lastSpacer + height: 10 + width: 5 + } + + ScrollView { + id : scrollView + width: parent.width + height: parent.height - (lastSpacer.y + lastSpacer.height) + + Column { + Repeater { + model: controller.componentIds + + Column { + id: componentColumn + + property int componentId: parseInt(modelData) + + QGCLabel { + text: "Component #: " + componentId.toString() + font.pointSize: screenTools.dpiAdjustedPointSize(qgcPal.defaultFontPointSize + 4); + } + + Item { + height: 10 + width: 10 + } + + Repeater { + model: controller.getGroupsForComponent(componentColumn.componentId) + + Column { + Rectangle { + id: groupRect + color: qgcPal.windowShade + height: groupBlock.height + width: scrollView.viewport.width - rightMargin + + Column { + id: groupBlock + + Rectangle { + color: qgcPal.windowShadeDark + height: groupLabel.height + width: groupRect.width + + QGCLabel { + id: groupLabel + height: contentHeight + 5 + x: leftMargin + text: modelData + verticalAlignment: Text.AlignVCenter + font.pointSize: screenTools.dpiAdjustedPointSize(qgcPal.defaultFontPointSize + 2); + } + } + + Repeater { + model: controller.getFactsForGroup(componentColumn.componentId, modelData) + + Row { + spacing: 10 + x: leftMargin + + Fact { id: modelFact; name: modelData + ":" + componentColumn.componentId } + + QGCLabel { + text: modelFact.name + width: charWidth.contentWidth * (maxParamChars + 2) + } + + QGCLabel { + + text: modelFact.valueString + " " + modelFact.units + width: charWidth.contentWidth * 20 + height: contentHeight + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onClicked: { + if (mouse.button == Qt.LeftButton) { + editor.checked = true + editor.focus = true + } else if (mouse.button == Qt.RightButton) { + controller.setRCToParam(modelData) + } + } + } + + FactTextField { + id: editor + y: (parent.height - height) / 2 + width: parent.width + visible: checked + focus: true + fact: modelFact + showUnits: true + onEditingFinished: checked = false + + // We use an ExclusiveGroup to manage visibility + property bool checked: false + property ExclusiveGroup exclusiveGroup: exclusiveEditorGroup + onExclusiveGroupChanged: { + if (exclusiveGroup) + exclusiveGroup.bindCheckable(editor) + } + } + } + + QGCLabel { + text: modelFact.shortDescription + } + } // Row - Fact value + } // Repeater - Facts + } // Column - Fact rows + } // Rectangle - Group + + Item { + height: 10 + width: 10 + } + } // Column - Group + } // Repeater - Groups + + Item { + height: 10 + width: 10 + } + } // Column - Component + } // Repeater - Components + } // Column - Component + } // ScrollView + } // Column - Outer +} diff --git a/src/VehicleSetup/ParameterEditor.ui b/src/VehicleSetup/ParameterEditor.ui deleted file mode 100644 index ba61c7fa684f36aa3677ce9e608fe1fdf50dd3c8..0000000000000000000000000000000000000000 --- a/src/VehicleSetup/ParameterEditor.ui +++ /dev/null @@ -1,191 +0,0 @@ - - - ParameterEditor - - - - 0 - 0 - 750 - 600 - - - - - 0 - 0 - - - - - 802 - 471 - - - - Form - - - - - - - - - 3 - 1 - - - - Onboard Configuration - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 2 - 0 - - - - - 329 - 400 - - - - Changes Pending - - - - - - -1 - - - - - - 0 - 0 - - - - true - - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - - 0 - 0 - - - - Status - - - - - - - - QGCPendingParamWidget - QWidget -
ui/QGCPendingParamWidget.h
- 1 -
- - QGCParamWidget - QWidget -
ui/QGCParamWidget.h
- 1 -
-
- - -
diff --git a/src/VehicleSetup/ParameterEditorController.cc b/src/VehicleSetup/ParameterEditorController.cc new file mode 100644 index 0000000000000000000000000000000000000000..03e000f2bd46089b7ec30a5464d761e4f522a80e --- /dev/null +++ b/src/VehicleSetup/ParameterEditorController.cc @@ -0,0 +1,134 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009, 2015 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#include "ParameterEditorController.h" +#include "UASManager.h" +#include "AutoPilotPluginManager.h" +#include "QGCFileDialog.h" +#include "QGCMessageBox.h" +#include "QGCMapRCToParamDialog.h" +#include "MainWindow.h" + +/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens. +ParameterEditorController::ParameterEditorController(void) : + _uas(NULL), + _autopilot(NULL) +{ + _uas = UASManager::instance()->getActiveUAS(); + Q_ASSERT(_uas); + + _autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uas); + Q_ASSERT(_autopilot); + Q_ASSERT(_autopilot->pluginReady()); + + const QMap >& groupMap = _autopilot->getGroupMap(); + + foreach (int componentId, groupMap.keys()) { + _componentIds += QString("%1").arg(componentId); + } +} + +QStringList ParameterEditorController::getGroupsForComponent(int componentId) +{ + const QMap >& groupMap = _autopilot->getGroupMap(); + + return groupMap[componentId].keys(); +} + +QStringList ParameterEditorController::getFactsForGroup(int componentId, QString group) +{ + const QMap >& groupMap = _autopilot->getGroupMap(); + + return groupMap[componentId][group]; +} + +void ParameterEditorController::clearRCToParam(void) +{ + Q_ASSERT(_uas); + _uas->unsetRCToParameterMap(); +} + +void ParameterEditorController::saveToFile(void) +{ + Q_ASSERT(_autopilot); + + QString msgTitle("Save Parameters"); + + QString fileName = QGCFileDialog::getSaveFileName(NULL, + msgTitle, + qgcApp()->savedParameterFilesLocation(), + "Parameter Files (*.params)", + "params", + true); + if (!fileName.isEmpty()) { + QFile file(fileName); + + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QGCMessageBox::critical(msgTitle, "Unable to create file"); + return; + } + + QTextStream stream(&file); + _autopilot->writeParametersToStream(stream); + file.close(); + } +} + +void ParameterEditorController::loadFromFile(void) +{ + Q_ASSERT(_autopilot); + + QString msgTitle("Load Parameters"); + + QString fileName = QGCFileDialog::getOpenFileName(NULL, + msgTitle, + qgcApp()->savedParameterFilesLocation(), + "Parameter Files (*.params);;All Files (*)"); + if (!fileName.isEmpty()) { + QFile file(fileName); + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QGCMessageBox::critical(msgTitle, "Unable to open file"); + return; + } + + QTextStream stream(&file); + _autopilot->readParametersFromStream(stream); + file.close(); + } +} + +void ParameterEditorController::refresh(void) +{ + _autopilot->refreshAllParameters(); +} + +void ParameterEditorController::setRCToParam(const QString& paramName) +{ + Q_ASSERT(_uas); + QGCMapRCToParamDialog * d = new QGCMapRCToParamDialog(paramName, _uas, MainWindow::instance()); + d->exec(); +} diff --git a/src/VehicleSetup/ParameterEditor.h b/src/VehicleSetup/ParameterEditorController.h similarity index 54% rename from src/VehicleSetup/ParameterEditor.h rename to src/VehicleSetup/ParameterEditorController.h index 55d349265281f4d16deae0c70543f462444ceeeb..3f38266712e2a54576a32afd34fdc2f63940ec60 100644 --- a/src/VehicleSetup/ParameterEditor.h +++ b/src/VehicleSetup/ParameterEditorController.h @@ -2,7 +2,7 @@ QGroundControl Open Source Ground Control Station - (c) 2009 - 2014 QGROUNDCONTROL PROJECT + (c) 2009, 2015 QGROUNDCONTROL PROJECT This file is part of the QGROUNDCONTROL project @@ -21,31 +21,42 @@ ======================================================================*/ -#ifndef PARAMETEREDITOR_H -#define PARAMETEREDITOR_H - -#include - -#include "UASInterface.h" - /// @file -/// @brief This is the Parameter Editor widget which is used in the Parameters tab of Vehicle Setup. /// @author Don Gagne -namespace Ui { - class ParameterEditor; -} +#ifndef PARAMETEREDITORCONTROLLER_H +#define PARAMETEREDITORCONTROLLER_H + +#include +#include -class ParameterEditor : public QWidget +#include "AutoPilotPlugin.h" +#include "UASInterface.h" + +class ParameterEditorController : public QObject { Q_OBJECT - + public: - explicit ParameterEditor(UASInterface* uas, const QStringList& filterList, QWidget* parent = 0); - ~ParameterEditor(); - + ParameterEditorController(void); + + Q_PROPERTY(QStringList componentIds MEMBER _componentIds CONSTANT) + + Q_INVOKABLE QStringList getGroupsForComponent(int componentId); + Q_INVOKABLE QStringList getFactsForGroup(int componentId, QString group); + + Q_INVOKABLE void clearRCToParam(void); + Q_INVOKABLE void saveToFile(void); + Q_INVOKABLE void loadFromFile(void); + Q_INVOKABLE void refresh(void); + Q_INVOKABLE void setRCToParam(const QString& paramName); + + QList model(void); + private: - Ui::ParameterEditor* _ui; + UASInterface* _uas; + AutoPilotPlugin* _autopilot; + QStringList _componentIds; }; #endif diff --git a/src/VehicleSetup/SetupView.cc b/src/VehicleSetup/SetupView.cc index e90a46cc3610097d6fdad459750fa87a5cd14671..adefb4a73c53a9f4114f64203ab1e67a2331b831 100644 --- a/src/VehicleSetup/SetupView.cc +++ b/src/VehicleSetup/SetupView.cc @@ -30,11 +30,11 @@ #include "UASManager.h" #include "AutoPilotPluginManager.h" #include "VehicleComponent.h" -#include "ParameterEditor.h" #include "QGCQmlWidgetHolder.h" #include "MainWindow.h" #include "QGCMessageBox.h" #include "FirmwareUpgradeController.h" +#include "ParameterEditorController.h" #include #include @@ -54,8 +54,9 @@ SetupView::SetupView(QWidget* parent) : Q_UNUSED(fSucceeded); Q_ASSERT(fSucceeded); - qmlRegisterType("QGroundControl.FirmwareUpgradeController", 1, 0, "FirmwareUpgradeController"); - + qmlRegisterType("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController"); + qmlRegisterType("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); + _ui->buttonHolder->rootContext()->setContextProperty("controller", this); _ui->buttonHolder->setAutoPilot(NULL); _ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml")); @@ -131,8 +132,14 @@ void SetupView::firmwareButtonClicked(void) void SetupView::parametersButtonClicked(void) { - ParameterEditor* setup = new ParameterEditor(_uasCurrent, QStringList(), this); - _changeSetupWidget(setup); + QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder; + Q_CHECK_PTR(setup); + + Q_ASSERT(_autoPilotPlugin); + setup->setAutoPilot(_autoPilotPlugin); + setup->setSource(QUrl::fromUserInput("qrc:/qml/ParameterEditor.qml")); + + _changeSetupWidget(setup); } void SetupView::summaryButtonClicked(void) diff --git a/src/VehicleSetup/SetupView.h b/src/VehicleSetup/SetupView.h index 821bef72259182cf467bb14dfdaa18f2759c9193..0a931ca0390a69cfbc2a46df2a2281e8422acc80 100644 --- a/src/VehicleSetup/SetupView.h +++ b/src/VehicleSetup/SetupView.h @@ -25,7 +25,6 @@ #define SETUPVIEW_H #include "UASInterface.h" -#include "ParameterEditor.h" #include "VehicleComponent.h" #include "AutoPilotPlugin.h" diff --git a/src/qgcunittest/MockLink.cc b/src/qgcunittest/MockLink.cc index 7a75b81aed6da810d288101f252a95eda7feacc3..1265559a2b7e84e1dd5c7663b839f59ad4d72064 100644 --- a/src/qgcunittest/MockLink.cc +++ b/src/qgcunittest/MockLink.cc @@ -166,7 +166,7 @@ void MockLink::_run50HzTasks(void) void MockLink::_loadParams(void) { - QFile paramFile(":/unittest/MockLink.param"); + QFile paramFile(":/unittest/MockLink.params"); bool success = paramFile.open(QFile::ReadOnly); Q_UNUSED(success); diff --git a/src/qgcunittest/MockLink.param b/src/qgcunittest/MockLink.params similarity index 100% rename from src/qgcunittest/MockLink.param rename to src/qgcunittest/MockLink.params diff --git a/src/qgcunittest/MockQGCUASParamManager.cc b/src/qgcunittest/MockQGCUASParamManager.cc index 77b751b3d43ade3d3f341e6ca1ad964a74cc87b1..b10fdfe96602c588563a6115ddabb32da96edfda 100644 --- a/src/qgcunittest/MockQGCUASParamManager.cc +++ b/src/qgcunittest/MockQGCUASParamManager.cc @@ -58,7 +58,7 @@ void MockQGCUASParamManager::setParameter(int component, QString parameterName, void MockQGCUASParamManager::_loadParams(void) { - QFile paramFile(":/unittest/MockLink.param"); + QFile paramFile(":/unittest/MockLink.params"); bool success = paramFile.open(QFile::ReadOnly); Q_UNUSED(success); diff --git a/src/qgcunittest/PX4RCCalibrationTest.cc b/src/qgcunittest/PX4RCCalibrationTest.cc index 6a0d934d7011df9c173b9eb5a05e0613eb2de887..b74beb9588b0c82468e708b80304481a0164ef1c 100644 --- a/src/qgcunittest/PX4RCCalibrationTest.cc +++ b/src/qgcunittest/PX4RCCalibrationTest.cc @@ -392,7 +392,7 @@ void PX4RCCalibrationTest::_switchSelectAutoStep(const char* functionStr, PX4RCC void PX4RCCalibrationTest::_fullCalibration_test(void) { // IMPORTANT NOTE: We used channels 1-5 for attitude mapping in the test below. - // MockLink.param file cannot have flight mode switches mapped to those channels. + // MockLink.params file cannot have flight mode switches mapped to those channels. // If it does it will cause errors since the stick will not be detetected where MockQGCUASParamManager* paramMgr = _mockUAS->getMockQGCUASParamManager(); diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc index 008512085ce1bc79370a75ae58bfb08fb088a1b5..bec6cfae559024fa32d839bd9cb63ce057c558b0 100644 --- a/src/uas/QGCUASParamManager.cc +++ b/src/uas/QGCUASParamManager.cc @@ -21,9 +21,6 @@ QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas) { mav = uas; - // Load default values and tooltips for data model - loadParamMetaInfoCSV(); - paramDataModel.setUASID(mav->getUASID()); paramCommsMgr.initWithUAS(uas); @@ -143,30 +140,6 @@ void QGCUASParamManager::setPendingParam(int compId, const QString& paramName, -void QGCUASParamManager::loadParamMetaInfoCSV() -{ - // Load default values and tooltips - QString autopilot(mav->getAutopilotTypeName()); - - QDir appDir = QApplication::applicationDirPath(); - appDir.cd("files"); - QString fileName = QString("%1/%2/parameter_tooltips/tooltips.txt").arg(appDir.canonicalPath()).arg(autopilot.toLower()); - QFile paramMetaFile(fileName); - - qDebug() << "loadParamMetaInfoCSV for autopilot: " << autopilot << " from file: " << fileName; - - if (!paramMetaFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "loadParamMetaInfoCSV couldn't open:" << fileName; - return; - } - - QTextStream in(¶mMetaFile); - paramDataModel.loadParamMetaInfoFromStream(in); - paramMetaFile.close(); - -} - - UASInterface* QGCUASParamManager::getUAS() { return mav; diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h index 27853dd499349e515d35c44cca7c0d81f46c5f91..421f754ca8c54dc19098ffe55d7a8b036d5938ce 100644 --- a/src/uas/QGCUASParamManager.h +++ b/src/uas/QGCUASParamManager.h @@ -65,10 +65,6 @@ public: virtual bool parametersReady(void) { return _parametersReady; } protected: - - /** @brief Load parameter meta information from appropriate CSV file */ - virtual void loadParamMetaInfoCSV(); - void connectToModelAndComms(); diff --git a/src/uas/UASParameterCommsMgr.cc b/src/uas/UASParameterCommsMgr.cc index eba007b18b7b18e9455e3613a7d895cee6b6f33c..91d4ea4253e9311d723b0cbcdb80bddbb77b11c5 100644 --- a/src/uas/UASParameterCommsMgr.cc +++ b/src/uas/UASParameterCommsMgr.cc @@ -394,6 +394,7 @@ void UASParameterCommsMgr::updateSilenceTimer() else { //all parameters have been received, broadcast to UI qCDebug(UASParameterCommsMgrLog) << "emitting parameterListUpToDate"; + emit parameterListProgress(0.0f); emit parameterListUpToDate(); resetAfterListReceive(); emit _stopSilenceTimer(); // Stop timer on our thread;