Commit 4b128fba authored by Don Gagne's avatar Don Gagne

Update for FactLoader->ParameterLoader changes

parent 59856660
...@@ -34,7 +34,7 @@ GenericAutoPilotPlugin::GenericAutoPilotPlugin(UASInterface* uas, QObject* paren ...@@ -34,7 +34,7 @@ GenericAutoPilotPlugin::GenericAutoPilotPlugin(UASInterface* uas, QObject* paren
_parameterFacts = new GenericParameterFacts(uas, this); _parameterFacts = new GenericParameterFacts(uas, this);
Q_CHECK_PTR(_parameterFacts); Q_CHECK_PTR(_parameterFacts);
connect(_parameterFacts, &GenericParameterFacts::factsReady, this, &GenericAutoPilotPlugin::_factsReady); connect(_parameterFacts, &GenericParameterFacts::parametersReady, this, &GenericAutoPilotPlugin::_parametersReady);
} }
QList<AutoPilotPluginManager::FullMode_t> GenericAutoPilotPlugin::getModes(void) QList<AutoPilotPluginManager::FullMode_t> GenericAutoPilotPlugin::getModes(void)
...@@ -87,24 +87,14 @@ void GenericAutoPilotPlugin::clearStaticData(void) ...@@ -87,24 +87,14 @@ void GenericAutoPilotPlugin::clearStaticData(void)
// No Static data yet // No Static data yet
} }
const QVariantList& GenericAutoPilotPlugin::components(void) const QVariantList& GenericAutoPilotPlugin::vehicleComponents(void)
{ {
static QVariantList emptyList; static QVariantList emptyList;
return emptyList; return emptyList;
} }
const QVariantMap& GenericAutoPilotPlugin::parameters(void) void GenericAutoPilotPlugin::_parametersReady(void)
{
return _parameterFacts->factMap();
}
QUrl GenericAutoPilotPlugin::setupBackgroundImage(void)
{
return QUrl::fromUserInput("qrc:/qml/px4fmu_2.x.png");
}
void GenericAutoPilotPlugin::_factsReady(void)
{ {
_pluginReady = true; _pluginReady = true;
emit pluginReadyChanged(_pluginReady); emit pluginReadyChanged(_pluginReady);
......
...@@ -41,16 +41,15 @@ public: ...@@ -41,16 +41,15 @@ public:
GenericAutoPilotPlugin(UASInterface* uas, QObject* parent = NULL); GenericAutoPilotPlugin(UASInterface* uas, QObject* parent = NULL);
// Overrides from AutoPilotPlugin // Overrides from AutoPilotPlugin
virtual QUrl setupBackgroundImage(void); virtual const QVariantList& vehicleComponents(void);
virtual const QVariantList& components(void); virtual ParameterLoader* getParameterLoader(void) { return _parameterFacts; }
virtual const QVariantMap& parameters(void);
static QList<AutoPilotPluginManager::FullMode_t> getModes(void); static QList<AutoPilotPluginManager::FullMode_t> getModes(void);
static QString getShortModeText(uint8_t baseMode, uint32_t customMode); static QString getShortModeText(uint8_t baseMode, uint32_t customMode);
static void clearStaticData(void); static void clearStaticData(void);
private slots: private slots:
void _factsReady(void); void _parametersReady(void);
private: private:
GenericParameterFacts* _parameterFacts; GenericParameterFacts* _parameterFacts;
......
...@@ -25,13 +25,11 @@ ...@@ -25,13 +25,11 @@
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
#include "GenericParameterFacts.h" #include "GenericParameterFacts.h"
#include "QGCApplication.h"
#include <QFile>
#include <QDebug> #include <QDebug>
GenericParameterFacts::GenericParameterFacts(UASInterface* uas, QObject* parent) : GenericParameterFacts::GenericParameterFacts(UASInterface* uas, QObject* parent) :
FactLoader(uas, parent) ParameterLoader(uas, parent)
{ {
Q_ASSERT(uas); Q_ASSERT(uas);
} }
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
#define GenericParameterFacts_h #define GenericParameterFacts_h
#include <QObject> #include <QObject>
#include <QMap>
#include <QXmlStreamReader>
#include <QLoggingCategory>
#include "FactSystem.h" #include "ParameterLoader.h"
#include "UASInterface.h" #include "UASInterface.h"
/// @file /// @file
...@@ -37,13 +34,16 @@ ...@@ -37,13 +34,16 @@
/// Collection of Parameter Facts for Generic AutoPilot /// Collection of Parameter Facts for Generic AutoPilot
class GenericParameterFacts : public FactLoader class GenericParameterFacts : public ParameterLoader
{ {
Q_OBJECT Q_OBJECT
public: public:
/// @param uas Uas which this set of facts is associated with /// @param uas Uas which this set of facts is associated with
GenericParameterFacts(UASInterface* uas, QObject* parent = NULL); GenericParameterFacts(UASInterface* uas, QObject* parent = NULL);
/// Override from ParameterLoader
virtual QString getDefaultComponentIdParam(void) const { return QString(); }
}; };
#endif #endif
\ No newline at end of file
...@@ -80,7 +80,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) : ...@@ -80,7 +80,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
_parameterFacts = new PX4ParameterFacts(uas, this); _parameterFacts = new PX4ParameterFacts(uas, this);
Q_CHECK_PTR(_parameterFacts); Q_CHECK_PTR(_parameterFacts);
connect(_parameterFacts, &PX4ParameterFacts::factsReady, this, &PX4AutoPilotPlugin::_pluginReadyPreChecks); connect(_parameterFacts, &PX4ParameterFacts::parametersReady, this, &PX4AutoPilotPlugin::_pluginReadyPreChecks);
PX4ParameterFacts::loadParameterFactMetaData(); PX4ParameterFacts::loadParameterFactMetaData();
} }
...@@ -189,7 +189,7 @@ void PX4AutoPilotPlugin::clearStaticData(void) ...@@ -189,7 +189,7 @@ void PX4AutoPilotPlugin::clearStaticData(void)
PX4ParameterFacts::clearStaticData(); PX4ParameterFacts::clearStaticData();
} }
const QVariantList& PX4AutoPilotPlugin::components(void) const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
{ {
if (_components.count() == 0 && !_incorrectParameterVersion) { if (_components.count() == 0 && !_incorrectParameterVersion) {
Q_ASSERT(_uas); Q_ASSERT(_uas);
...@@ -222,29 +222,19 @@ const QVariantList& PX4AutoPilotPlugin::components(void) ...@@ -222,29 +222,19 @@ const QVariantList& PX4AutoPilotPlugin::components(void)
return _components; return _components;
} }
const QVariantMap& PX4AutoPilotPlugin::parameters(void)
{
return _parameterFacts->factMap();
}
QUrl PX4AutoPilotPlugin::setupBackgroundImage(void)
{
return QUrl::fromUserInput("qrc:/qml/px4fmu_2.x.png");
}
/// This will perform various checks prior to signalling that the plug in ready /// This will perform various checks prior to signalling that the plug in ready
void PX4AutoPilotPlugin::_pluginReadyPreChecks(void) void PX4AutoPilotPlugin::_pluginReadyPreChecks(void)
{ {
// Check for older parameter version set // Check for older parameter version set
// FIXME: Firmware is moving to version stamp parameter set. Once that is complete the version stamp // FIXME: Firmware is moving to version stamp parameter set. Once that is complete the version stamp
// should be used instead. // should be used instead.
if (parameters().contains("SENS_GYRO_XOFF")) { if (parameterExists("SENS_GYRO_XOFF")) {
_incorrectParameterVersion = true; _incorrectParameterVersion = true;
QGCMessageBox::warning(tr("Setup"), tr("This version of GroundControl can only perform vehicle setup on a newer version of firmware. " QGCMessageBox::warning(tr("Setup"), tr("This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup.")); "Please perform a Firmware Upgrade if you wish to use Vehicle Setup."));
} else { } else {
// Check for missing setup complete // Check for missing setup complete
foreach(const QVariant componentVariant, components()) { foreach(const QVariant componentVariant, vehicleComponents()) {
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant));
Q_ASSERT(component); Q_ASSERT(component);
......
...@@ -50,21 +50,20 @@ public: ...@@ -50,21 +50,20 @@ public:
~PX4AutoPilotPlugin(); ~PX4AutoPilotPlugin();
// Overrides from AutoPilotPlugin // Overrides from AutoPilotPlugin
virtual const QVariantList& components(void); virtual const QVariantList& vehicleComponents(void);
virtual const QVariantMap& parameters(void); virtual ParameterLoader* getParameterLoader(void) { return _parameterFacts; }
virtual QUrl setupBackgroundImage(void);
static QList<AutoPilotPluginManager::FullMode_t> getModes(void); static QList<AutoPilotPluginManager::FullMode_t> getModes(void);
static QString getShortModeText(uint8_t baseMode, uint32_t customMode); static QString getShortModeText(uint8_t baseMode, uint32_t customMode);
static void clearStaticData(void); static void clearStaticData(void);
// These methods should only be used by objects within the plugin // These methods should only be used by objects within the plugin
AirframeComponent* airframeComponent(void) { return _airframeComponent; } AirframeComponent* airframeComponent(void) { return _airframeComponent; }
RadioComponent* radioComponent(void) { return _radioComponent; } RadioComponent* radioComponent(void) { return _radioComponent; }
FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; } FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; } SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; } SafetyComponent* safetyComponent(void) { return _safetyComponent; }
PowerComponent* powerComponent(void) { return _powerComponent; } PowerComponent* powerComponent(void) { return _powerComponent; }
private slots: private slots:
void _pluginReadyPreChecks(void); void _pluginReadyPreChecks(void);
......
...@@ -37,7 +37,7 @@ bool PX4ParameterFacts::_parameterMetaDataLoaded = false; ...@@ -37,7 +37,7 @@ bool PX4ParameterFacts::_parameterMetaDataLoaded = false;
QMap<QString, FactMetaData*> PX4ParameterFacts::_mapParameterName2FactMetaData; QMap<QString, FactMetaData*> PX4ParameterFacts::_mapParameterName2FactMetaData;
PX4ParameterFacts::PX4ParameterFacts(UASInterface* uas, QObject* parent) : PX4ParameterFacts::PX4ParameterFacts(UASInterface* uas, QObject* parent) :
FactLoader(uas, parent) ParameterLoader(uas, parent)
{ {
Q_ASSERT(uas); Q_ASSERT(uas);
} }
...@@ -273,6 +273,6 @@ void PX4ParameterFacts::_addMetaDataToFact(Fact* fact) ...@@ -273,6 +273,6 @@ void PX4ParameterFacts::_addMetaDataToFact(Fact* fact)
fact->setMetaData(_mapParameterName2FactMetaData[fact->name()]); fact->setMetaData(_mapParameterName2FactMetaData[fact->name()]);
} else { } else {
// Use generic meta data // Use generic meta data
FactLoader::_addMetaDataToFact(fact); ParameterLoader::_addMetaDataToFact(fact);
} }
} }
...@@ -21,14 +21,15 @@ ...@@ -21,14 +21,15 @@
======================================================================*/ ======================================================================*/
#ifndef PX4ParameterFacts_h #ifndef PX4PARAMETERFACTS_H
#define PX4ParameterFacts_h #define PX4PARAMETERFACTS_H
#include <QObject> #include <QObject>
#include <QMap> #include <QMap>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QLoggingCategory> #include <QLoggingCategory>
#include "ParameterLoader.h"
#include "FactSystem.h" #include "FactSystem.h"
#include "UASInterface.h" #include "UASInterface.h"
...@@ -39,13 +40,16 @@ Q_DECLARE_LOGGING_CATEGORY(PX4ParameterFactsMetaDataLog) ...@@ -39,13 +40,16 @@ Q_DECLARE_LOGGING_CATEGORY(PX4ParameterFactsMetaDataLog)
/// Collection of Parameter Facts for PX4 AutoPilot /// Collection of Parameter Facts for PX4 AutoPilot
class PX4ParameterFacts : public FactLoader class PX4ParameterFacts : public ParameterLoader
{ {
Q_OBJECT Q_OBJECT
public: public:
/// @param uas Uas which this set of facts is associated with /// @param uas Uas which this set of facts is associated with
PX4ParameterFacts(UASInterface* uas, QObject* parent = NULL); PX4ParameterFacts(UASInterface* uas, QObject* parent = NULL);
/// Override from ParameterLoader
virtual QString getDefaultComponentIdParam(void) const { return QString("SYS_AUTOSTART"); }
static void loadParameterFactMetaData(void); static void loadParameterFactMetaData(void);
static void deleteParameterFactMetaData(void); static void deleteParameterFactMetaData(void);
......
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