From 3e5cd8981a8b0e11b1e1c87f1facc21943597dbe Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Mon, 1 Feb 2016 16:14:42 -0500 Subject: [PATCH] Making the ESP8266 component "common" instead of APM/PX4 only. --- qgroundcontrol.pro | 8 +-- .../APM/APMAirframeComponent.cc | 2 +- .../APM/APMAirframeComponent.h | 6 +-- .../APM/APMAutoPilotPlugin.cc | 12 ++++- src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h | 3 ++ .../APM/APMCameraComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMCameraComponent.h | 6 +-- src/AutoPilotPlugins/APM/APMComponent.cc | 51 ------------------ src/AutoPilotPlugins/APM/APMComponent.h | 54 ------------------- .../APM/APMFlightModesComponent.cc | 2 +- .../APM/APMFlightModesComponent.h | 6 +-- src/AutoPilotPlugins/APM/APMPowerComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMPowerComponent.h | 6 +-- src/AutoPilotPlugins/APM/APMRadioComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMRadioComponent.h | 6 +-- .../APM/APMSafetyComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMSafetyComponent.h | 6 +-- .../APM/APMSensorsComponent.cc | 2 +- .../APM/APMSensorsComponent.h | 6 +-- .../APM/APMTuningComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMTuningComponent.h | 6 +-- .../ESP8266Component.cc} | 26 ++++----- .../ESP8266Component.h} | 12 ++--- src/AutoPilotPlugins/PX4/AirframeComponent.cc | 2 +- src/AutoPilotPlugins/PX4/AirframeComponent.h | 6 +-- .../PX4/FlightModesComponent.cc | 2 +- .../PX4/FlightModesComponent.h | 6 +-- .../PX4/PX4AutoPilotPlugin.cc | 2 +- src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h | 6 +-- src/AutoPilotPlugins/PX4/PX4Component.cc | 53 ------------------ src/AutoPilotPlugins/PX4/PX4Component.h | 54 ------------------- src/AutoPilotPlugins/PX4/PX4RadioComponent.cc | 2 +- src/AutoPilotPlugins/PX4/PX4RadioComponent.h | 6 +-- .../PX4/PX4TuningComponent.cc | 2 +- src/AutoPilotPlugins/PX4/PX4TuningComponent.h | 6 +-- src/AutoPilotPlugins/PX4/PowerComponent.cc | 2 +- src/AutoPilotPlugins/PX4/PowerComponent.h | 6 +-- src/AutoPilotPlugins/PX4/SafetyComponent.cc | 2 +- src/AutoPilotPlugins/PX4/SafetyComponent.h | 6 +-- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 2 +- src/AutoPilotPlugins/PX4/SensorsComponent.h | 6 +-- src/VehicleSetup/VehicleComponent.cc | 14 +++++ src/VehicleSetup/VehicleComponent.h | 13 ++++- 43 files changed, 125 insertions(+), 303 deletions(-) delete mode 100644 src/AutoPilotPlugins/APM/APMComponent.cc delete mode 100644 src/AutoPilotPlugins/APM/APMComponent.h rename src/AutoPilotPlugins/{PX4/PX4ESP8266Component.cc => Common/ESP8266Component.cc} (66%) rename src/AutoPilotPlugins/{PX4/PX4ESP8266Component.h => Common/ESP8266Component.h} (86%) delete mode 100644 src/AutoPilotPlugins/PX4/PX4Component.cc delete mode 100644 src/AutoPilotPlugins/PX4/PX4Component.h diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 728d8b500..6d60e1221 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -562,7 +562,6 @@ HEADERS+= \ src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.h \ src/AutoPilotPlugins/APM/APMCameraComponent.h \ src/AutoPilotPlugins/APM/APMCompassCal.h \ - src/AutoPilotPlugins/APM/APMComponent.h \ src/AutoPilotPlugins/APM/APMFlightModesComponent.h \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \ src/AutoPilotPlugins/APM/APMPowerComponent.h \ @@ -573,6 +572,7 @@ HEADERS+= \ src/AutoPilotPlugins/APM/APMTuningComponent.h \ src/AutoPilotPlugins/Common/RadioComponentController.h \ src/AutoPilotPlugins/Common/ESP8266ComponentController.h \ + src/AutoPilotPlugins/Common/ESP8266Component.h \ src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \ src/AutoPilotPlugins/PX4/AirframeComponent.h \ src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \ @@ -582,9 +582,7 @@ HEADERS+= \ src/AutoPilotPlugins/PX4/PowerComponent.h \ src/AutoPilotPlugins/PX4/PowerComponentController.h \ src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \ - src/AutoPilotPlugins/PX4/PX4Component.h \ src/AutoPilotPlugins/PX4/PX4RadioComponent.h \ - src/AutoPilotPlugins/PX4/PX4ESP8266Component.h \ src/AutoPilotPlugins/PX4/SafetyComponent.h \ src/AutoPilotPlugins/PX4/SensorsComponent.h \ src/AutoPilotPlugins/PX4/SensorsComponentController.h \ @@ -620,7 +618,6 @@ SOURCES += \ src/AutoPilotPlugins/APM/APMAirframeComponentController.cc \ src/AutoPilotPlugins/APM/APMCameraComponent.cc \ src/AutoPilotPlugins/APM/APMCompassCal.cc \ - src/AutoPilotPlugins/APM/APMComponent.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \ src/AutoPilotPlugins/APM/APMPowerComponent.cc \ @@ -631,6 +628,7 @@ SOURCES += \ src/AutoPilotPlugins/APM/APMTuningComponent.cc \ src/AutoPilotPlugins/Common/RadioComponentController.cc \ src/AutoPilotPlugins/Common/ESP8266ComponentController.cc \ + src/AutoPilotPlugins/Common/ESP8266Component.cc \ src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.cc \ src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \ src/AutoPilotPlugins/PX4/AirframeComponent.cc \ @@ -641,9 +639,7 @@ SOURCES += \ src/AutoPilotPlugins/PX4/PowerComponent.cc \ src/AutoPilotPlugins/PX4/PowerComponentController.cc \ src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \ - src/AutoPilotPlugins/PX4/PX4Component.cc \ src/AutoPilotPlugins/PX4/PX4RadioComponent.cc \ - src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc \ src/AutoPilotPlugins/PX4/SafetyComponent.cc \ src/AutoPilotPlugins/PX4/SensorsComponent.cc \ src/AutoPilotPlugins/PX4/SensorsComponentController.cc \ diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc index 7813515aa..c9e3b464d 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc @@ -28,7 +28,7 @@ #include "ArduCopterFirmwarePlugin.h" APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : APMComponent(vehicle, autopilot, parent) + : VehicleComponent(vehicle, autopilot, parent) , _requiresFrameSetup(false) , _name("Airframe") { diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.h b/src/AutoPilotPlugins/APM/APMAirframeComponent.h index de6b7e128..d023c0516 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.h +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.h @@ -24,16 +24,16 @@ #ifndef APMAirframeComponent_H #define APMAirframeComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMAirframeComponent : public APMComponent +class APMAirframeComponent : public VehicleComponent { Q_OBJECT public: APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from APMComponent + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 97ae76277..157f03bcd 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -27,7 +27,7 @@ #include "FirmwarePlugin/APM/APMParameterMetaData.h" // FIXME: Hack #include "FirmwarePlugin/APM/APMFirmwarePlugin.h" // FIXME: Hack #include "FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h" -#include "APMComponent.h" +#include "VehicleComponent.h" #include "APMAirframeComponent.h" #include "APMAirframeComponentAirframes.h" #include "APMAirframeComponentController.h" @@ -40,6 +40,7 @@ #include "APMSensorsComponent.h" #include "APMPowerComponent.h" #include "APMCameraComponent.h" +#include "ESP8266Component.h" /// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type. APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) @@ -54,6 +55,7 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) , _sensorsComponent(NULL) , _tuningComponent(NULL) , _airframeFacts(new APMAirframeLoader(this, vehicle->uas(), this)) + , _esp8266Component(NULL) { APMAirframeLoader::loadAirframeFactMetaData(); } @@ -89,6 +91,13 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) _radioComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_radioComponent)); + //-- Is there an ESP8266 Connected? + if(factExists(FactSystem::ParameterProvider, MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) { + _esp8266Component = new ESP8266Component(_vehicle, this); + _esp8266Component->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_esp8266Component)); + } + _sensorsComponent = new APMSensorsComponent(_vehicle, this); _sensorsComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent)); @@ -100,6 +109,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) _tuningComponent = new APMTuningComponent(_vehicle, this); _tuningComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent)); + } else { qWarning() << "Call to vehicleCompenents prior to parametersReady"; } diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h index 52d92ab45..32bc82b6d 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h @@ -36,6 +36,7 @@ class APMSafetyComponent; class APMSensorsComponent; class APMPowerComponent; class APMCameraComponent; +class ESP8266Component; /// This is the APM specific implementation of the AutoPilot class. class APMAutoPilotPlugin : public AutoPilotPlugin @@ -57,6 +58,7 @@ public: APMSafetyComponent* safetyComponent (void) const { return _safetyComponent; } APMSensorsComponent* sensorsComponent (void) const { return _sensorsComponent; } APMTuningComponent* tuningComponent (void) const { return _tuningComponent; } + ESP8266Component* esp8266Component (void) const { return _esp8266Component; } public slots: // FIXME: This is public until we restructure AutoPilotPlugin/FirmwarePlugin/Vehicle @@ -75,6 +77,7 @@ private: APMSensorsComponent* _sensorsComponent; APMTuningComponent* _tuningComponent; APMAirframeLoader* _airframeFacts; + ESP8266Component* _esp8266Component; }; #endif diff --git a/src/AutoPilotPlugins/APM/APMCameraComponent.cc b/src/AutoPilotPlugins/APM/APMCameraComponent.cc index 03c26492f..2acfbc303 100644 --- a/src/AutoPilotPlugins/APM/APMCameraComponent.cc +++ b/src/AutoPilotPlugins/APM/APMCameraComponent.cc @@ -30,7 +30,7 @@ #include "APMAirframeComponent.h" APMCameraComponent::APMCameraComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : APMComponent(vehicle, autopilot, parent) + : VehicleComponent(vehicle, autopilot, parent) , _name(tr("Camera")) { } diff --git a/src/AutoPilotPlugins/APM/APMCameraComponent.h b/src/AutoPilotPlugins/APM/APMCameraComponent.h index 7c59c9cc8..5d7ff62ad 100644 --- a/src/AutoPilotPlugins/APM/APMCameraComponent.h +++ b/src/AutoPilotPlugins/APM/APMCameraComponent.h @@ -24,16 +24,16 @@ #ifndef APMCameraComponent_H #define APMCameraComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMCameraComponent : public APMComponent +class APMCameraComponent : public VehicleComponent { Q_OBJECT public: APMCameraComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMComponent.cc b/src/AutoPilotPlugins/APM/APMComponent.cc deleted file mode 100644 index e5b745b31..000000000 --- a/src/AutoPilotPlugins/APM/APMComponent.cc +++ /dev/null @@ -1,51 +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 "APMComponent.h" -#include "Fact.h" -#include "AutoPilotPlugin.h" - -APMComponent::APMComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - VehicleComponent(vehicle, autopilot, parent) -{ - Q_ASSERT(vehicle); - Q_ASSERT(autopilot); -} - -void APMComponent::setupTriggerSignals(void) -{ - foreach (const QString& paramName, setupCompleteChangedTriggerList()) { - Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName); - connect(fact, &Fact::valueChanged, this, &APMComponent::_triggerUpdated); - } -} - - -void APMComponent::_triggerUpdated(QVariant value) -{ - Q_UNUSED(value); - emit setupCompleteChanged(setupComplete()); -} diff --git a/src/AutoPilotPlugins/APM/APMComponent.h b/src/AutoPilotPlugins/APM/APMComponent.h deleted file mode 100644 index 558c8d99f..000000000 --- a/src/AutoPilotPlugins/APM/APMComponent.h +++ /dev/null @@ -1,54 +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 . - - ======================================================================*/ - -#ifndef APMComponent_H -#define APMComponent_H - -#include "VehicleComponent.h" - -#include - -/// @file -/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects. -/// @author Don Gagne - -class APMComponent : public VehicleComponent -{ - Q_OBJECT - -public: - APMComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - - /// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged - /// signal to be emitted. Last element is signalled by NULL. - virtual QStringList setupCompleteChangedTriggerList(void) const = 0; - - /// Should be called after the component is created (but not in constructor) to setup the - /// signals which are used to track parameter changes which affect setupComplete state. - void setupTriggerSignals(void); - -private slots: - void _triggerUpdated(QVariant value); -}; - -#endif diff --git a/src/AutoPilotPlugins/APM/APMFlightModesComponent.cc b/src/AutoPilotPlugins/APM/APMFlightModesComponent.cc index 21cdfc1fa..29473b0d7 100644 --- a/src/AutoPilotPlugins/APM/APMFlightModesComponent.cc +++ b/src/AutoPilotPlugins/APM/APMFlightModesComponent.cc @@ -27,7 +27,7 @@ #include "APMRadioComponent.h" APMFlightModesComponent::APMFlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - APMComponent(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Flight Modes")) { } diff --git a/src/AutoPilotPlugins/APM/APMFlightModesComponent.h b/src/AutoPilotPlugins/APM/APMFlightModesComponent.h index 688321fdd..e5c2a53fc 100644 --- a/src/AutoPilotPlugins/APM/APMFlightModesComponent.h +++ b/src/AutoPilotPlugins/APM/APMFlightModesComponent.h @@ -24,16 +24,16 @@ #ifndef APMFlightModesComponent_H #define APMFlightModesComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMFlightModesComponent : public APMComponent +class APMFlightModesComponent : public VehicleComponent { Q_OBJECT public: APMFlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMPowerComponent.cc b/src/AutoPilotPlugins/APM/APMPowerComponent.cc index 54954dceb..6324ffe85 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponent.cc +++ b/src/AutoPilotPlugins/APM/APMPowerComponent.cc @@ -26,7 +26,7 @@ #include "APMAirframeComponent.h" APMPowerComponent::APMPowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : APMComponent(vehicle, autopilot, parent), + : VehicleComponent(vehicle, autopilot, parent), _name("Power") { } diff --git a/src/AutoPilotPlugins/APM/APMPowerComponent.h b/src/AutoPilotPlugins/APM/APMPowerComponent.h index c69553315..f1514f2f4 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponent.h +++ b/src/AutoPilotPlugins/APM/APMPowerComponent.h @@ -24,16 +24,16 @@ #ifndef APMPowerComponent_H #define APMPowerComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMPowerComponent : public APMComponent +class APMPowerComponent : public VehicleComponent { Q_OBJECT public: APMPowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMRadioComponent.cc b/src/AutoPilotPlugins/APM/APMRadioComponent.cc index 0e19bf648..400424f54 100644 --- a/src/AutoPilotPlugins/APM/APMRadioComponent.cc +++ b/src/AutoPilotPlugins/APM/APMRadioComponent.cc @@ -26,7 +26,7 @@ #include "APMAirframeComponent.h" APMRadioComponent::APMRadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - APMComponent(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Radio")) { _mapParams << QStringLiteral("RCMAP_ROLL") << QStringLiteral("RCMAP_PITCH") << QStringLiteral("RCMAP_YAW") << QStringLiteral("RCMAP_THROTTLE"); diff --git a/src/AutoPilotPlugins/APM/APMRadioComponent.h b/src/AutoPilotPlugins/APM/APMRadioComponent.h index 429eee9a4..9d217e27f 100644 --- a/src/AutoPilotPlugins/APM/APMRadioComponent.h +++ b/src/AutoPilotPlugins/APM/APMRadioComponent.h @@ -24,17 +24,17 @@ #ifndef APMRadioComponent_H #define APMRadioComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" #include "Fact.h" -class APMRadioComponent : public APMComponent +class APMRadioComponent : public VehicleComponent { Q_OBJECT public: APMRadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc index 9b7e18bce..86815e674 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc +++ b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc @@ -30,7 +30,7 @@ #include "APMAirframeComponent.h" APMSafetyComponent::APMSafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : APMComponent(vehicle, autopilot, parent) + : VehicleComponent(vehicle, autopilot, parent) , _name(tr("Safety")) { } diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponent.h b/src/AutoPilotPlugins/APM/APMSafetyComponent.h index 01c17502c..805e97ea3 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponent.h +++ b/src/AutoPilotPlugins/APM/APMSafetyComponent.h @@ -24,16 +24,16 @@ #ifndef APMSafetyComponent_H #define APMSafetyComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMSafetyComponent : public APMComponent +class APMSafetyComponent : public VehicleComponent { Q_OBJECT public: APMSafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponent.cc b/src/AutoPilotPlugins/APM/APMSensorsComponent.cc index 5b95ac541..9e25a1831 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponent.cc +++ b/src/AutoPilotPlugins/APM/APMSensorsComponent.cc @@ -29,7 +29,7 @@ // These two list must be kept in sync APMSensorsComponent::APMSensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - APMComponent(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Sensors")) { diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponent.h b/src/AutoPilotPlugins/APM/APMSensorsComponent.h index cf5999b76..754345036 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponent.h +++ b/src/AutoPilotPlugins/APM/APMSensorsComponent.h @@ -24,9 +24,9 @@ #ifndef APMSensorsComponent_H #define APMSensorsComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMSensorsComponent : public APMComponent +class APMSensorsComponent : public VehicleComponent { Q_OBJECT @@ -36,7 +36,7 @@ public: bool compassSetupNeeded(void) const; bool accelSetupNeeded(void) const; - // Virtuals from APMComponent + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/APM/APMTuningComponent.cc b/src/AutoPilotPlugins/APM/APMTuningComponent.cc index 833e54ba3..15177f306 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponent.cc +++ b/src/AutoPilotPlugins/APM/APMTuningComponent.cc @@ -26,7 +26,7 @@ #include "APMAirframeComponent.h" APMTuningComponent::APMTuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : APMComponent(vehicle, autopilot, parent) + : VehicleComponent(vehicle, autopilot, parent) , _name("Tuning") { } diff --git a/src/AutoPilotPlugins/APM/APMTuningComponent.h b/src/AutoPilotPlugins/APM/APMTuningComponent.h index 8e7ec4e2d..90fcfe508 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponent.h +++ b/src/AutoPilotPlugins/APM/APMTuningComponent.h @@ -24,16 +24,16 @@ #ifndef APMTuningComponent_H #define APMTuningComponent_H -#include "APMComponent.h" +#include "VehicleComponent.h" -class APMTuningComponent : public APMComponent +class APMTuningComponent : public VehicleComponent { Q_OBJECT public: APMTuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList(void) const final; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc b/src/AutoPilotPlugins/Common/ESP8266Component.cc similarity index 66% rename from src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc rename to src/AutoPilotPlugins/Common/ESP8266Component.cc index 39e79b2b8..650841be2 100644 --- a/src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc +++ b/src/AutoPilotPlugins/Common/ESP8266Component.cc @@ -21,57 +21,57 @@ ======================================================================*/ -#include "PX4ESP8266Component.h" -#include "PX4AutoPilotPlugin.h" +#include "ESP8266Component.h" +#include "AutoPilotPlugin.h" -PX4ESP8266Component::PX4ESP8266Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : PX4Component(vehicle, autopilot, parent) +ESP8266Component::ESP8266Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : VehicleComponent(vehicle, autopilot, parent) , _name(tr("WiFi Bridge")) { } -QString PX4ESP8266Component::name(void) const +QString ESP8266Component::name(void) const { return _name; } -QString PX4ESP8266Component::description(void) const +QString ESP8266Component::description(void) const { return tr("The ESP8266 WiFi Bridge Component is used to setup the WiFi link."); } -QString PX4ESP8266Component::iconResource(void) const +QString ESP8266Component::iconResource(void) const { return "/qmlimages/wifi.svg"; } -bool PX4ESP8266Component::requiresSetup(void) const +bool ESP8266Component::requiresSetup(void) const { return false; } -bool PX4ESP8266Component::setupComplete(void) const +bool ESP8266Component::setupComplete(void) const { return true; } -QStringList PX4ESP8266Component::setupCompleteChangedTriggerList(void) const +QStringList ESP8266Component::setupCompleteChangedTriggerList(void) const { return QStringList(); } -QUrl PX4ESP8266Component::setupSource(void) const +QUrl ESP8266Component::setupSource(void) const { return QUrl::fromUserInput("qrc:/qml/ESP8266Component.qml"); } -QUrl PX4ESP8266Component::summaryQmlSource(void) const +QUrl ESP8266Component::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/ESP8266ComponentSummary.qml"); } -QString PX4ESP8266Component::prerequisiteSetup(void) const +QString ESP8266Component::prerequisiteSetup(void) const { return QString(); } diff --git a/src/AutoPilotPlugins/PX4/PX4ESP8266Component.h b/src/AutoPilotPlugins/Common/ESP8266Component.h similarity index 86% rename from src/AutoPilotPlugins/PX4/PX4ESP8266Component.h rename to src/AutoPilotPlugins/Common/ESP8266Component.h index 220b0ab4f..3a09e23b5 100644 --- a/src/AutoPilotPlugins/PX4/PX4ESP8266Component.h +++ b/src/AutoPilotPlugins/Common/ESP8266Component.h @@ -21,18 +21,18 @@ ======================================================================*/ -#ifndef PX4ESP8266Component_H -#define PX4ESP8266Component_H +#ifndef ESP8266Component_H +#define ESP8266Component_H -#include "PX4Component.h" +#include "VehicleComponent.h" -class PX4ESP8266Component : public PX4Component +class ESP8266Component : public VehicleComponent { Q_OBJECT public: - PX4ESP8266Component (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); + ESP8266Component (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent QStringList setupCompleteChangedTriggerList() const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index 44b0ebdb5..87c8a0fb2 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -69,7 +69,7 @@ static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]); #endif AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Airframe")) { #if 0 diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.h b/src/AutoPilotPlugins/PX4/AirframeComponent.h index a31e5b7b6..6ee80a578 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.h @@ -24,20 +24,20 @@ #ifndef AIRFRAMECOMPONENT_H #define AIRFRAMECOMPONENT_H -#include "PX4Component.h" +#include "VehicleComponent.h" /// @file /// @brief The Airframe VehicleComponent is used to set the SYS_AUTOSTART airframe id. /// @author Don Gagne -class AirframeComponent : public PX4Component +class AirframeComponent : public VehicleComponent { Q_OBJECT public: AirframeComponent(Vehicle* vehicles, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index 66ad52af8..5825147a2 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -34,7 +34,7 @@ struct SwitchListItem { }; FlightModesComponent::FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Flight Modes")) { } diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.h b/src/AutoPilotPlugins/PX4/FlightModesComponent.h index c8502fdd7..f61254dc0 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.h +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.h @@ -24,20 +24,20 @@ #ifndef FLIGHTMODESCOMPONENT_H #define FLIGHTMODESCOMPONENT_H -#include "PX4Component.h" +#include "VehicleComponent.h" /// @file /// @brief The FlightModes VehicleComponent is used to set the associated Flight Mode switches. /// @author Don Gagne -class FlightModesComponent : public PX4Component +class FlightModesComponent : public VehicleComponent { Q_OBJECT public: FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 6e96c18fa..ce32581b5 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -105,7 +105,7 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) //-- Is there an ESP8266 Connected? if(factExists(FactSystem::ParameterProvider, MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) { - _esp8266Component = new PX4ESP8266Component(_vehicle, this); + _esp8266Component = new ESP8266Component(_vehicle, this); _esp8266Component->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_esp8266Component)); } diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h index 836c3c1cc..134fd4761 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h @@ -28,7 +28,7 @@ #include "PX4AirframeLoader.h" #include "AirframeComponent.h" #include "PX4RadioComponent.h" -#include "PX4ESP8266Component.h" +#include "ESP8266Component.h" #include "FlightModesComponent.h" #include "SensorsComponent.h" #include "SafetyComponent.h" @@ -56,7 +56,7 @@ public: // These methods should only be used by objects within the plugin AirframeComponent* airframeComponent(void) { return _airframeComponent; } PX4RadioComponent* radioComponent(void) { return _radioComponent; } - PX4ESP8266Component* esp8266Component(void) { return _esp8266Component; } + ESP8266Component* esp8266Component(void) { return _esp8266Component; } FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; } SensorsComponent* sensorsComponent(void) { return _sensorsComponent; } SafetyComponent* safetyComponent(void) { return _safetyComponent; } @@ -72,7 +72,7 @@ private: QVariantList _components; AirframeComponent* _airframeComponent; PX4RadioComponent* _radioComponent; - PX4ESP8266Component* _esp8266Component; + ESP8266Component* _esp8266Component; FlightModesComponent* _flightModesComponent; SensorsComponent* _sensorsComponent; SafetyComponent* _safetyComponent; diff --git a/src/AutoPilotPlugins/PX4/PX4Component.cc b/src/AutoPilotPlugins/PX4/PX4Component.cc deleted file mode 100644 index a3ea75a91..000000000 --- a/src/AutoPilotPlugins/PX4/PX4Component.cc +++ /dev/null @@ -1,53 +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 "PX4Component.h" -#include "Fact.h" -#include "AutoPilotPlugin.h" - -PX4Component::PX4Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - VehicleComponent(vehicle, autopilot, parent) -{ - Q_ASSERT(vehicle); - Q_ASSERT(autopilot); -} - -void PX4Component::setupTriggerSignals(void) -{ - // Watch for changed on trigger list params - foreach (const QString ¶mName, setupCompleteChangedTriggerList()) { - Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName); - - connect(fact, &Fact::valueChanged, this, &PX4Component::_triggerUpdated); - } -} - - -void PX4Component::_triggerUpdated(QVariant value) -{ - Q_UNUSED(value); - emit setupCompleteChanged(setupComplete()); -} diff --git a/src/AutoPilotPlugins/PX4/PX4Component.h b/src/AutoPilotPlugins/PX4/PX4Component.h deleted file mode 100644 index 0283506e8..000000000 --- a/src/AutoPilotPlugins/PX4/PX4Component.h +++ /dev/null @@ -1,54 +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 . - - ======================================================================*/ - -#ifndef PX4COMPONENT_H -#define PX4COMPONENT_H - -#include "VehicleComponent.h" - -#include - -/// @file -/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects. -/// @author Don Gagne - -class PX4Component : public VehicleComponent -{ - Q_OBJECT - -public: - PX4Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - - /// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged - /// signal to be emitted. Last element is signalled by NULL. - virtual QStringList setupCompleteChangedTriggerList(void) const = 0; - - /// Should be called after the component is created (but not in constructor) to setup the - /// signals which are used to track parameter changes which affect setupComplete state. - void setupTriggerSignals(void); - -private slots: - void _triggerUpdated(QVariant value); -}; - -#endif diff --git a/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc b/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc index b8d6d6cca..8a500f018 100644 --- a/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc +++ b/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc @@ -25,7 +25,7 @@ #include "PX4AutoPilotPlugin.h" PX4RadioComponent::PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Radio")) { } diff --git a/src/AutoPilotPlugins/PX4/PX4RadioComponent.h b/src/AutoPilotPlugins/PX4/PX4RadioComponent.h index e8d147875..95cd83419 100644 --- a/src/AutoPilotPlugins/PX4/PX4RadioComponent.h +++ b/src/AutoPilotPlugins/PX4/PX4RadioComponent.h @@ -24,16 +24,16 @@ #ifndef PX4RadioComponent_H #define PX4RadioComponent_H -#include "PX4Component.h" +#include "VehicleComponent.h" -class PX4RadioComponent : public PX4Component +class PX4RadioComponent : public VehicleComponent { Q_OBJECT public: PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc index e808f8a34..5d7f5d53b 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc @@ -26,7 +26,7 @@ #include "AirframeComponent.h" PX4TuningComponent::PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) - : PX4Component(vehicle, autopilot, parent) + : VehicleComponent(vehicle, autopilot, parent) , _name("Tuning") { } diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.h b/src/AutoPilotPlugins/PX4/PX4TuningComponent.h index a86a65abe..89aeb4097 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponent.h +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.h @@ -24,16 +24,16 @@ #ifndef PX4TuningComponent_H #define PX4TuningComponent_H -#include "PX4Component.h" +#include "VehicleComponent.h" -class PX4TuningComponent : public PX4Component +class PX4TuningComponent : public VehicleComponent { Q_OBJECT public: PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.cc b/src/AutoPilotPlugins/PX4/PowerComponent.cc index 0b07f2466..357bfde03 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.cc +++ b/src/AutoPilotPlugins/PX4/PowerComponent.cc @@ -29,7 +29,7 @@ #include "PX4AutoPilotPlugin.h" PowerComponent::PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Power")) { } diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.h b/src/AutoPilotPlugins/PX4/PowerComponent.h index 3bddfa3e6..68436de17 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.h +++ b/src/AutoPilotPlugins/PX4/PowerComponent.h @@ -24,20 +24,20 @@ #ifndef PowerComponent_H #define PowerComponent_H -#include "PX4Component.h" +#include "VehicleComponent.h" /// @file /// @brief Battery, propeller and magnetometer settings /// @author Gus Grubba -class PowerComponent : public PX4Component +class PowerComponent : public VehicleComponent { Q_OBJECT public: PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.cc b/src/AutoPilotPlugins/PX4/SafetyComponent.cc index 26ab7c440..05d62d754 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.cc +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.cc @@ -28,7 +28,7 @@ #include "PX4AutoPilotPlugin.h" SafetyComponent::SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Safety")) { } diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.h b/src/AutoPilotPlugins/PX4/SafetyComponent.h index b6f9c1857..9cbf37e2b 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.h +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.h @@ -24,21 +24,21 @@ #ifndef SafetyComponent_H #define SafetyComponent_H -#include "PX4Component.h" +#include "VehicleComponent.h" /// @file /// @brief The Radio VehicleComponent is used to calibrate the trasmitter and assign function mapping /// to channels. /// @author Don Gagne -class SafetyComponent : public PX4Component +class SafetyComponent : public VehicleComponent { Q_OBJECT public: SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 0a712c74e..c47d3b2ed 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -32,7 +32,7 @@ // These two list must be kept in sync SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - PX4Component(vehicle, autopilot, parent), + VehicleComponent(vehicle, autopilot, parent), _name(tr("Sensors")) { diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index 5e5349fcf..a0557b443 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -24,20 +24,20 @@ #ifndef SENSORSCOMPONENT_H #define SENSORSCOMPONENT_H -#include "PX4Component.h" +#include "VehicleComponent.h" /// @file /// @brief The Sensors VehicleComponent is used to calibrate the the various sensors associated with the board. /// @author Don Gagne -class SensorsComponent : public PX4Component +class SensorsComponent : public VehicleComponent { Q_OBJECT public: SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); - // Virtuals from PX4Component + // Virtuals from VehicleComponent virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent diff --git a/src/VehicleSetup/VehicleComponent.cc b/src/VehicleSetup/VehicleComponent.cc index 16df91fe2..de7a4835a 100644 --- a/src/VehicleSetup/VehicleComponent.cc +++ b/src/VehicleSetup/VehicleComponent.cc @@ -57,3 +57,17 @@ void VehicleComponent::addSummaryQmlComponent(QQmlContext* context, QQuickItem* item->setParentItem(parent); item->setProperty("vehicleComponent", QVariant::fromValue(this)); } + +void VehicleComponent::setupTriggerSignals(void) +{ + // Watch for changed on trigger list params + foreach (const QString ¶mName, setupCompleteChangedTriggerList()) { + Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName); + connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated); + } +} + +void VehicleComponent::_triggerUpdated(QVariant /*value*/) +{ + emit setupCompleteChanged(setupComplete()); +} diff --git a/src/VehicleSetup/VehicleComponent.h b/src/VehicleSetup/VehicleComponent.h index dcc3ea114..3e4fba293 100644 --- a/src/VehicleSetup/VehicleComponent.h +++ b/src/VehicleSetup/VehicleComponent.h @@ -66,9 +66,20 @@ public: virtual void addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent); + /// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged + /// signal to be emitted. Last element is signalled by NULL. + virtual QStringList setupCompleteChangedTriggerList(void) const = 0; + + /// Should be called after the component is created (but not in constructor) to setup the + /// signals which are used to track parameter changes which affect setupComplete state. + virtual void setupTriggerSignals(void); + signals: void setupCompleteChanged(bool setupComplete); - + +protected slots: + void _triggerUpdated(QVariant value); + protected: Vehicle* _vehicle; AutoPilotPlugin* _autopilot; -- 2.22.0