From b887cbd9cddf776473af20f9d0f09d3e1ead0d7a Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 20 Dec 2015 10:26:45 -0800 Subject: [PATCH] Airframe component is always created --- qgroundcontrol.pro | 4 ++- src/AutoPilotPlugins/APM/APMAirframeComponent.cc | 40 +++++++++++++++++------- src/AutoPilotPlugins/APM/APMAirframeComponent.h | 2 +- src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc | 14 ++++----- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index e6f7fcd..167a06a 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -544,10 +544,12 @@ SOURCES += \ # INCLUDEPATH += \ + src/AutoPilotPlugins/APM \ src/AutoPilotPlugins/Common \ src/AutoPilotPlugins/PX4 \ - src/AutoPilotPlugins/APM \ src/FirmwarePlugin \ + src/FirmwarePlugin/APM \ + src/FirmwarePlugin/PX4 \ src/Vehicle \ src/VehicleSetup \ diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc index 19899f1..12fb5df 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc @@ -25,13 +25,14 @@ /// @author Don Gagne #include "APMAirframeComponent.h" -#include "QGCQmlWidgetHolder.h" +#include "ArduCopterFirmwarePlugin.h" -APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - APMComponent(vehicle, autopilot, parent), - _name(tr("Airframe")) +APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : APMComponent(vehicle, autopilot, parent) + , _copterFirmware(false) + , _name("Airframe") { - + _copterFirmware = qobject_cast(_vehicle->firmwarePlugin()) != NULL; } QString APMAirframeComponent::name(void) const @@ -52,28 +53,45 @@ QString APMAirframeComponent::iconResource(void) const bool APMAirframeComponent::requiresSetup(void) const { - return true; + return _copterFirmware; } bool APMAirframeComponent::setupComplete(void) const { - //: Not the correct one, but it works for the moment. - return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() != -1; + if (_copterFirmware) { + return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() >= 0; + } else { + return true; + } } QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const { - return QStringList(); + QStringList list; + + if (_copterFirmware) { + list << "FRAME"; + } + + return list; } QUrl APMAirframeComponent::setupSource(void) const { - return QUrl::fromUserInput("qrc:/qml/APMAirframeComponent.qml"); + if (_copterFirmware) { + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponent.qml"); + } else { + return QUrl(); + } } QUrl APMAirframeComponent::summaryQmlSource(void) const { - return QUrl::fromUserInput("qrc:/qml/APMAirframeComponentSummary.qml"); + if (_copterFirmware) { + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponentSummary.qml"); + } else { + return QUrl(); + } } QString APMAirframeComponent::prerequisiteSetup(void) const diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.h b/src/AutoPilotPlugins/APM/APMAirframeComponent.h index a37f9d3..7741938 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.h +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.h @@ -47,8 +47,8 @@ public: virtual QString prerequisiteSetup(void) const; private: + bool _copterFirmware; const QString _name; - QVariantList _summaryItems; }; #endif diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 338ce0d..e0bdf16 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -67,14 +67,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) Q_ASSERT(_vehicle); if (parametersReady()) { - if (dynamic_cast(_vehicle->firmwarePlugin())){ - _airframeComponent = new APMAirframeComponent(_vehicle, this); - if(_airframeComponent) { - _airframeComponent->setupTriggerSignals(); - _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); - } else { - qWarning() << "new APMAirframeComponent failed"; - } + _airframeComponent = new APMAirframeComponent(_vehicle, this); + if(_airframeComponent) { + _airframeComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); + } else { + qWarning() << "new APMAirframeComponent failed"; } _flightModesComponent = new APMFlightModesComponent(_vehicle, this);