diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index c3d855ba44007b31536337a95d84eb7022d40797..708438c4e4cad4c9efb0d735210356d8b2daada7 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -169,3 +169,8 @@ QUrl AirframeComponent::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/AirframeComponentSummary.qml"); } + +QString AirframeComponent::prerequisiteSetup(void) const +{ + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.h b/src/AutoPilotPlugins/PX4/AirframeComponent.h index 67d24011336f7f577369296ea23110faa0554d6f..98b04484a4da88be219d5e35a82a431c262461b6 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.h @@ -49,7 +49,8 @@ public: virtual QString setupStateDescription(void) const; virtual QWidget* setupWidget(void) const; virtual QStringList paramFilterList(void) const; - virtual QUrl summaryQmlSource(void) const; + virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; private: const QString _name; diff --git a/src/AutoPilotPlugins/PX4/FlightModeConfig.cc b/src/AutoPilotPlugins/PX4/FlightModeConfig.cc index 78cd1fda4b4d22859d82bb2f45f5db33b5882d57..792b067b86d954344d02e1156e695e8395af8695 100644 --- a/src/AutoPilotPlugins/PX4/FlightModeConfig.cc +++ b/src/AutoPilotPlugins/PX4/FlightModeConfig.cc @@ -104,12 +104,6 @@ void FlightModeConfig::_initUi(void) { } _updateAllSwitches(); - - // Finally if RC Calibration has not been performed disable the entire widget and inform user - if (_getChannelMapForParam(_modeSwitchParam) == 0) { - // FIXME: Do something more than disable - setEnabled(false); - } } void FlightModeConfig::_updateAllSwitches(void) diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index 18c49bddf4c6c9f469d8aba2128eafc2b1fee023..8c0084532d8017654ccdade68c8e5733236fc433 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -27,6 +27,7 @@ #include "FlightModesComponent.h" #include "FlightModeConfig.h" #include "VehicleComponentSummaryItem.h" +#include "PX4AutoPilotPlugin.h" /// @brief Parameters which signal a change in setupComplete state static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL }; @@ -121,3 +122,17 @@ QUrl FlightModesComponent::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/FlightModesComponentSummary.qml"); } + +QString FlightModesComponent::prerequisiteSetup(void) const +{ + PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot); + Q_ASSERT(plugin); + + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } else if (!plugin->radioComponent()->setupComplete()) { + return plugin->radioComponent()->name(); + } + + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.h b/src/AutoPilotPlugins/PX4/FlightModesComponent.h index e284859da2420bf0552027221885a737cf77d212..74c0a37b3160b4b46f5be6c9ef3e2d9cdb12efef 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.h +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.h @@ -50,6 +50,7 @@ public: virtual QWidget* setupWidget(void) const; virtual QStringList paramFilterList(void) const; virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; private: const QString _name; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 0a1ab924cf384b37f2e053328694d1a3f25e2414..183af85137c6aa139fc7902a0560f1f74b467ecf 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -22,11 +22,6 @@ ======================================================================*/ #include "PX4AutoPilotPlugin.h" -#include "AirframeComponent.h" -#include "RadioComponent.h" -#include "SensorsComponent.h" -#include "FlightModesComponent.h" -#include "SafetyComponent.h" #include "AutoPilotPluginManager.h" #include "UASManager.h" #include "QGCUASParamManagerInterface.h" @@ -36,7 +31,6 @@ /// @brief This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_PX4 type. /// @author Don Gagne - enum PX4_CUSTOM_MAIN_MODE { PX4_CUSTOM_MAIN_MODE_MANUAL = 1, PX4_CUSTOM_MAIN_MODE_ALTCTL, @@ -69,7 +63,12 @@ union px4_custom_mode { PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) : AutoPilotPlugin(parent), _uas(uas), - _parameterFacts(NULL) + _parameterFacts(NULL), + _airframeComponent(NULL), + _radioComponent(NULL), + _flightModesComponent(NULL), + _sensorsComponent(NULL), + _safetyComponent(NULL) { Q_ASSERT(uas); @@ -193,29 +192,27 @@ bool PX4AutoPilotPlugin::pluginIsReady(void) const const QVariantList& PX4AutoPilotPlugin::components(void) { if (_components.count() == 0) { - VehicleComponent* component; - Q_ASSERT(_uas); - component = new AirframeComponent(_uas, this); - Q_CHECK_PTR(component); - _components.append(QVariant::fromValue(component)); + _airframeComponent = new AirframeComponent(_uas, this); + Q_CHECK_PTR(_airframeComponent); + _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); - component = new RadioComponent(_uas, this); - Q_CHECK_PTR(component); - _components.append(QVariant::fromValue(component)); + _radioComponent = new RadioComponent(_uas, this); + Q_CHECK_PTR(_radioComponent); + _components.append(QVariant::fromValue((VehicleComponent*)_radioComponent)); - component = new FlightModesComponent(_uas, this); - Q_CHECK_PTR(component); - _components.append(QVariant::fromValue(component)); + _flightModesComponent = new FlightModesComponent(_uas, this); + Q_CHECK_PTR(_flightModesComponent); + _components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent)); - component = new SensorsComponent(_uas, this); - Q_CHECK_PTR(component); - _components.append(QVariant::fromValue(component)); + _sensorsComponent = new SensorsComponent(_uas, this); + Q_CHECK_PTR(_sensorsComponent); + _components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent)); - component = new SafetyComponent(_uas, this); - Q_CHECK_PTR(component); - _components.append(QVariant::fromValue(component)); + _safetyComponent = new SafetyComponent(_uas, this); + Q_CHECK_PTR(_safetyComponent); + _components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent)); } return _components; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h index abb65c45d1bf130dcfc8b553a1f197971333541f..83f571b9ccee9e346b3692d4b48ddd90018cb110 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h @@ -28,6 +28,11 @@ #include "AutoPilotPluginManager.h" #include "UASInterface.h" #include "PX4ParameterFacts.h" +#include "AirframeComponent.h" +#include "RadioComponent.h" +#include "FlightModesComponent.h" +#include "SensorsComponent.h" +#include "SafetyComponent.h" #include @@ -53,10 +58,22 @@ public: static QString getShortModeText(uint8_t baseMode, uint32_t customMode); static void clearStaticData(void); + // These methods should only be used by objects within the plugin + AirframeComponent* airframeComponent(void) { return _airframeComponent; } + RadioComponent* radioComponent(void) { return _radioComponent; } + FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; } + SensorsComponent* sensorsComponent(void) { return _sensorsComponent; } + SafetyComponent* safetyComponent(void) { return _safetyComponent; } + private: - UASInterface* _uas; - PX4ParameterFacts* _parameterFacts; - QVariantList _components; + UASInterface* _uas; + PX4ParameterFacts* _parameterFacts; + QVariantList _components; + AirframeComponent* _airframeComponent; + RadioComponent* _radioComponent; + FlightModesComponent* _flightModesComponent; + SensorsComponent* _sensorsComponent; + SafetyComponent* _safetyComponent; }; #endif diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.cc b/src/AutoPilotPlugins/PX4/RadioComponent.cc index b9b15155487d315cb7aa4a459cb93651dbf480b5..31e555f82228f8a9c801786c7268244e5c66fb14 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.cc +++ b/src/AutoPilotPlugins/PX4/RadioComponent.cc @@ -27,6 +27,7 @@ #include "RadioComponent.h" #include "PX4RCCalibration.h" #include "VehicleComponentSummaryItem.h" +#include "PX4AutoPilotPlugin.h" /// @brief Parameters which signal a change in setupComplete state static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL }; @@ -105,3 +106,15 @@ QUrl RadioComponent::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/RadioComponentSummary.qml"); } + +QString RadioComponent::prerequisiteSetup(void) const +{ + PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot); + Q_ASSERT(plugin); + + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } + + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.h b/src/AutoPilotPlugins/PX4/RadioComponent.h index 06dbe0cc5868d624bf73583ac7349d89900e1cc0..5f91a27d0aaca82c086843f7bb1c645ea095b5a1 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.h +++ b/src/AutoPilotPlugins/PX4/RadioComponent.h @@ -51,6 +51,7 @@ public: virtual QWidget* setupWidget(void) const; virtual QStringList paramFilterList(void) const; virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; private: const QString _name; diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.cc b/src/AutoPilotPlugins/PX4/SafetyComponent.cc index e9bfc540cf47bc0d2be07e971c014e72994b16cf..fab464197d8abfba01635ccd5053c825173a13d8 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.cc +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.cc @@ -28,6 +28,7 @@ #include "PX4RCCalibration.h" #include "VehicleComponentSummaryItem.h" #include "QGCQmlWidgetHolder.h" +#include "PX4AutoPilotPlugin.h" /// @brief Parameters which signal a change in setupComplete state static const char* triggerParams[] = { NULL }; @@ -104,3 +105,15 @@ QUrl SafetyComponent::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/SafetyComponentSummary.qml"); } + +QString SafetyComponent::prerequisiteSetup(void) const +{ + PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot); + Q_ASSERT(plugin); + + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } + + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.h b/src/AutoPilotPlugins/PX4/SafetyComponent.h index 853394f8a135b1c37b8eeecad4a08384ace3026a..8211a871e10eca4ce6d09d36bdc3d15cd42d992b 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.h +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.h @@ -51,6 +51,7 @@ public: virtual QWidget* setupWidget(void) const; virtual QStringList paramFilterList(void) const; virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; private: const QString _name; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index bd3710a1b71cd06eee47300402ec1420c14ad362..d97a957d1807e5df9965688c4ea8d9d9e7e446db 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -27,6 +27,7 @@ #include "SensorsComponent.h" #include "QGCPX4SensorCalibration.h" #include "VehicleComponentSummaryItem.h" +#include "PX4AutoPilotPlugin.h" // These two list must be kept in sync @@ -118,3 +119,15 @@ QUrl SensorsComponent::summaryQmlSource(void) const { return QUrl::fromUserInput("qrc:/qml/SensorsComponentSummary.qml"); } + +QString SensorsComponent::prerequisiteSetup(void) const +{ + PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot); + Q_ASSERT(plugin); + + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } + + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index 5fae18b00f99c3e17856471c512afc4a62a8652e..a58874986ac71c26ee156635504ee0761273b305 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -50,6 +50,7 @@ public: virtual QWidget* setupWidget(void) const; virtual QStringList paramFilterList(void) const; virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; private: const QString _name;