From f08d592f23c19d5d6f5a1460397a5da0b2fdb4de Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 23 Dec 2014 12:50:48 -0800 Subject: [PATCH] Added new _autopilot member --- src/AutoPilotPlugins/PX4/AirframeComponent.cc | 4 ++-- src/AutoPilotPlugins/PX4/AirframeComponent.h | 2 +- src/AutoPilotPlugins/PX4/FlightModesComponent.cc | 4 ++-- src/AutoPilotPlugins/PX4/FlightModesComponent.h | 2 +- src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc | 13 +++++++++---- src/AutoPilotPlugins/PX4/PX4Component.cc | 4 ++-- src/AutoPilotPlugins/PX4/PX4Component.h | 3 +-- src/AutoPilotPlugins/PX4/RadioComponent.cc | 4 ++-- src/AutoPilotPlugins/PX4/RadioComponent.h | 2 +- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 4 ++-- src/AutoPilotPlugins/PX4/SensorsComponent.h | 2 +- src/VehicleSetup/VehicleComponent.cc | 9 +++++++-- src/VehicleSetup/VehicleComponent.h | 15 +++++++++------ 13 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index c63f5334a..18cf67fd7 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -62,8 +62,8 @@ static const struct mavType mavTypeInfo[] = { }; static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]); -AirframeComponent::AirframeComponent(UASInterface* uas, QObject* parent) : - PX4Component(uas, parent), +AirframeComponent::AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + PX4Component(uas, autopilot, parent), _name(tr("Airframe")) { // Validate that our mavTypeInfo array hasn't gotten out of sync diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.h b/src/AutoPilotPlugins/PX4/AirframeComponent.h index 5891a18d8..c4d1143a8 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.h @@ -35,7 +35,7 @@ class AirframeComponent : public PX4Component Q_OBJECT public: - AirframeComponent(UASInterface* uas, QObject* parent = NULL); + AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component virtual const char** setupCompleteChangedTriggerList(void) const; diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index d797d8195..4d66d670f 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -45,8 +45,8 @@ static const SwitchListItem switchList[] = { }; static const size_t cSwitchList = sizeof(switchList) / sizeof(switchList[0]); -FlightModesComponent::FlightModesComponent(UASInterface* uas, QObject* parent) : - PX4Component(uas, parent), +FlightModesComponent::FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + PX4Component(uas, autopilot, parent), _name(tr("Flight Modes")) { } diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.h b/src/AutoPilotPlugins/PX4/FlightModesComponent.h index 079d2907c..ccae9b096 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.h +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.h @@ -35,7 +35,7 @@ class FlightModesComponent : public PX4Component Q_OBJECT public: - FlightModesComponent(UASInterface* uas, QObject* parent = NULL); + FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component virtual const char** setupCompleteChangedTriggerList(void) const; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 446a8c7ab..0a1ab924c 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -26,6 +26,7 @@ #include "RadioComponent.h" #include "SensorsComponent.h" #include "FlightModesComponent.h" +#include "SafetyComponent.h" #include "AutoPilotPluginManager.h" #include "UASManager.h" #include "QGCUASParamManagerInterface.h" @@ -196,19 +197,23 @@ const QVariantList& PX4AutoPilotPlugin::components(void) Q_ASSERT(_uas); - component = new AirframeComponent(_uas); + component = new AirframeComponent(_uas, this); Q_CHECK_PTR(component); _components.append(QVariant::fromValue(component)); - component = new RadioComponent(_uas); + component = new RadioComponent(_uas, this); Q_CHECK_PTR(component); _components.append(QVariant::fromValue(component)); - component = new FlightModesComponent(_uas); + component = new FlightModesComponent(_uas, this); Q_CHECK_PTR(component); _components.append(QVariant::fromValue(component)); - component = new SensorsComponent(_uas); + component = new SensorsComponent(_uas, this); + Q_CHECK_PTR(component); + _components.append(QVariant::fromValue(component)); + + component = new SafetyComponent(_uas, this); Q_CHECK_PTR(component); _components.append(QVariant::fromValue(component)); } diff --git a/src/AutoPilotPlugins/PX4/PX4Component.cc b/src/AutoPilotPlugins/PX4/PX4Component.cc index 2c551e496..6fea92ca7 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.cc +++ b/src/AutoPilotPlugins/PX4/PX4Component.cc @@ -26,8 +26,8 @@ #include "PX4Component.h" -PX4Component::PX4Component(UASInterface* uas, QObject* parent) : - VehicleComponent(uas, parent) +PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + VehicleComponent(uas, autopilot, parent) { bool fSuccess = connect(_paramMgr, SIGNAL(parameterUpdated(int, QString, QVariant)), this, SLOT(_parameterUpdated(int, QString, QVariant))); Q_ASSERT(fSuccess); diff --git a/src/AutoPilotPlugins/PX4/PX4Component.h b/src/AutoPilotPlugins/PX4/PX4Component.h index 70a58e17b..9bffafb9f 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.h +++ b/src/AutoPilotPlugins/PX4/PX4Component.h @@ -35,7 +35,7 @@ class PX4Component : public VehicleComponent Q_OBJECT public: - PX4Component(UASInterface* uas, QObject* parent = NULL); + PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); /// @brief Returns an array of parameter names for which a change should cause the setupCompleteChanged /// signal to be emitted. Last element is signalled by NULL. Must be implemented by upper level class. @@ -45,7 +45,6 @@ private slots: /// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal /// setupCompleteChanged at appropriate times. void _parameterUpdated(int compId, QString paramName, QVariant value); - }; #endif diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.cc b/src/AutoPilotPlugins/PX4/RadioComponent.cc index a071a6c57..0e6ca4346 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.cc +++ b/src/AutoPilotPlugins/PX4/RadioComponent.cc @@ -31,8 +31,8 @@ /// @brief Parameters which signal a change in setupComplete state static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL }; -RadioComponent::RadioComponent(UASInterface* uas, QObject* parent) : - PX4Component(uas, parent), +RadioComponent::RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + PX4Component(uas, autopilot, parent), _name(tr("Radio")) { } diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.h b/src/AutoPilotPlugins/PX4/RadioComponent.h index 8c6c948df..092e26530 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.h +++ b/src/AutoPilotPlugins/PX4/RadioComponent.h @@ -36,7 +36,7 @@ class RadioComponent : public PX4Component Q_OBJECT public: - RadioComponent(UASInterface* uas, QObject* parent = NULL); + RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component virtual const char** setupCompleteChangedTriggerList(void) const; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 2e2cd57fd..afeefc967 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -36,8 +36,8 @@ static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS /// @brief Used to translate from parameter name to user string static const char* triggerSensors[] = { "Compass", "Gyro", "Acceleromter", "Airspeed", NULL }; -SensorsComponent::SensorsComponent(UASInterface* uas, QObject* parent) : - PX4Component(uas, parent), +SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + PX4Component(uas, autopilot, parent), _name(tr("Sensors")) { } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index 52a68155a..7872f45b3 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -35,7 +35,7 @@ class SensorsComponent : public PX4Component Q_OBJECT public: - SensorsComponent(UASInterface* uas, QObject* parent = NULL); + SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component virtual const char** setupCompleteChangedTriggerList(void) const; diff --git a/src/VehicleSetup/VehicleComponent.cc b/src/VehicleSetup/VehicleComponent.cc index 0bb5eb923..956e6076f 100644 --- a/src/VehicleSetup/VehicleComponent.cc +++ b/src/VehicleSetup/VehicleComponent.cc @@ -25,13 +25,18 @@ /// @author Don Gagne #include "VehicleComponent.h" +#include "AutoPilotPlugin.h" -VehicleComponent::VehicleComponent(UASInterface* uas, QObject* parent) : +VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : QObject(parent), _uas(uas), - _paramMgr(_uas->getParamManager()) + _autopilot(autopilot) { + Q_ASSERT(uas); + Q_ASSERT(autopilot); + _paramMgr = _uas->getParamManager(); + Q_ASSERT(_paramMgr); } VehicleComponent::~VehicleComponent() diff --git a/src/VehicleSetup/VehicleComponent.h b/src/VehicleSetup/VehicleComponent.h index 48c5c6924..4c603b4d8 100644 --- a/src/VehicleSetup/VehicleComponent.h +++ b/src/VehicleSetup/VehicleComponent.h @@ -21,6 +21,9 @@ ======================================================================*/ +/// @file +/// @author Don Gagne + #ifndef VEHICLECOMPONENT_H #define VEHICLECOMPONENT_H @@ -30,11 +33,10 @@ #include "UASInterface.h" -/// @file -/// @brief Vehicle Component class. A vehicle component is an object which -/// abstracts the physical portion of a vehicle into a set of -/// configurable values and user interface. -/// @author Don Gagne +class AutoPilotPlugin; + +/// A vehicle component is an object which abstracts the physical portion of a vehicle into a set of +/// configurable values and user interface. class VehicleComponent : public QObject { @@ -50,7 +52,7 @@ class VehicleComponent : public QObject Q_PROPERTY(QVariantList summaryItems READ summaryItems CONSTANT); public: - VehicleComponent(UASInterface* uas, QObject* parent = NULL); + VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); ~VehicleComponent(); virtual QString name(void) const = 0; @@ -70,6 +72,7 @@ signals: protected: UASInterface* _uas; + AutoPilotPlugin* _autopilot; QGCUASParamManagerInterface* _paramMgr; }; -- 2.22.0