From 4c8b3f0fcc2b9bf43568720355214f1a159b304b Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 9 Apr 2015 11:24:24 -0700 Subject: [PATCH 1/3] Click through all setup buttons --- src/VehicleSetup/SetupViewTest.cc | 29 +++++++++++++++++++++++++++-- src/ui/MainWindow.h | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/VehicleSetup/SetupViewTest.cc b/src/VehicleSetup/SetupViewTest.cc index 7a1ef75..93d6b23 100644 --- a/src/VehicleSetup/SetupViewTest.cc +++ b/src/VehicleSetup/SetupViewTest.cc @@ -27,6 +27,9 @@ #include "SetupViewTest.h" #include "MockLink.h" #include "QGCMessageBox.h" +#include "SetupView.h" +#include "UASManager.h" +#include "AutoPilotPluginManager.h" UT_REGISTER_TEST(SetupViewTest) @@ -72,9 +75,31 @@ void SetupViewTest::_clickThrough_test(void) _mainToolBar->onSetupView(); QTest::qWait(1000); - // Click through all the setup buttons - // FIXME: NYI + MainWindow* mainWindow = MainWindow::instance(); + Q_ASSERT(mainWindow); + QWidget* setupViewWidget = mainWindow->getCurrentViewWidget(); + Q_ASSERT(setupViewWidget); + SetupView* setupView = qobject_cast(setupViewWidget); + Q_ASSERT(setupView); + + // Click through fixed buttons + setupView->firmwareButtonClicked(); + QTest::qWait(1000); + setupView->parametersButtonClicked(); + QTest::qWait(1000); + setupView->summaryButtonClicked(); + QTest::qWait(1000); + // Click through component buttons + UASInterface* uas = UASManager::instance()->getActiveUAS(); + Q_ASSERT(uas); + AutoPilotPlugin* autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(uas); + Q_ASSERT(autopilot); + const QVariantList& components = autopilot->vehicleComponents(); + foreach(QVariant varComponent, components) { + setupView->setupButtonClicked(varComponent); + } + // On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop // the log file save dialog. diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4e9e38f..5421579 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -124,6 +124,8 @@ public: /// @brief Gets a pointer to the Main Tool Bar MainToolBar* getMainToolBar(void) { return _mainToolBar; } + + QWidget* getCurrentViewWidget(void) { return _currentViewWidget; } public slots: /** @brief Show the application settings */ From c74d545bf1d30f3d6a383c6725a257353ef4c310 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 9 Apr 2015 11:24:36 -0700 Subject: [PATCH 2/3] Switch to FactSystem for parameters --- src/AutoPilotPlugins/PX4/AirframeComponent.cc | 8 +------ src/AutoPilotPlugins/PX4/FlightModesComponent.cc | 8 +------ src/AutoPilotPlugins/PX4/PX4Component.cc | 6 +++++ src/AutoPilotPlugins/PX4/PX4Component.h | 3 +++ src/AutoPilotPlugins/PX4/PowerComponent.cc | 12 +++------- src/AutoPilotPlugins/PX4/RadioComponent.cc | 29 ++++-------------------- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 9 +------- src/VehicleSetup/VehicleComponent.cc | 3 --- src/VehicleSetup/VehicleComponent.h | 1 - 9 files changed, 19 insertions(+), 60 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index 576bff0..e9e4cd7 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -142,13 +142,7 @@ bool AirframeComponent::requiresSetup(void) const bool AirframeComponent::setupComplete(void) const { - QVariant value; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) { - return value.toInt() != 0; - } else { - Q_ASSERT(false); - return false; - } + return _autopilot->getParameterFact("SYS_AUTOSTART")->value().toInt() != 0; } QString AirframeComponent::setupStateDescription(void) const diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index e573a26..c03f66c 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -72,13 +72,7 @@ bool FlightModesComponent::requiresSetup(void) const bool FlightModesComponent::setupComplete(void) const { - QVariant value; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "RC_MAP_MODE_SW", value)) { - return value.toInt() != 0; - } else { - Q_ASSERT(false); - return false; - } + return _autopilot->getParameterFact("RC_MAP_MODE_SW")->value().toInt() != 0; } QString FlightModesComponent::setupStateDescription(void) const diff --git a/src/AutoPilotPlugins/PX4/PX4Component.cc b/src/AutoPilotPlugins/PX4/PX4Component.cc index d43a264..25cd36e 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.cc +++ b/src/AutoPilotPlugins/PX4/PX4Component.cc @@ -29,6 +29,12 @@ PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : VehicleComponent(uas, autopilot, parent) { + Q_ASSERT(uas); + Q_ASSERT(autopilot); + + _paramMgr = _uas->getParamManager(); + Q_ASSERT(_paramMgr); + bool fSuccess = connect(_paramMgr, SIGNAL(parameterUpdated(int, QString, QVariant)), this, SLOT(_parameterUpdated(int, QString, QVariant))); Q_ASSERT(fSuccess); Q_UNUSED(fSuccess); diff --git a/src/AutoPilotPlugins/PX4/PX4Component.h b/src/AutoPilotPlugins/PX4/PX4Component.h index c84ca2a..8efdb3f 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.h +++ b/src/AutoPilotPlugins/PX4/PX4Component.h @@ -47,6 +47,9 @@ private slots: /// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal /// setupCompleteChanged at appropriate times. void _parameterUpdated(int compId, QString paramName, QVariant value); + +private: + QGCUASParamManagerInterface* _paramMgr; }; #endif diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.cc b/src/AutoPilotPlugins/PX4/PowerComponent.cc index 5a3ff31..d1bf8fe 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.cc +++ b/src/AutoPilotPlugins/PX4/PowerComponent.cc @@ -58,15 +58,9 @@ bool PowerComponent::requiresSetup(void) const bool PowerComponent::setupComplete(void) const { QVariant cvalue, evalue, nvalue; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_CHARGED", cvalue)) { - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_EMPTY", evalue)) { - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_N_CELLS", nvalue)) { - return (cvalue.toFloat() > 0.1f) && (evalue.toFloat() > 0.1f) && (nvalue.toInt() > 0); - } - } - } - Q_ASSERT(false); - return false; + return _autopilot->getParameterFact("BAT_V_CHARGED")->value().toFloat() != 0.0f && + _autopilot->getParameterFact("BAT_V_EMPTY")->value().toFloat() != 0.0f && + _autopilot->getParameterFact("BAT_N_CELLS")->value().toInt() != 0; } QString PowerComponent::setupStateDescription(void) const diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.cc b/src/AutoPilotPlugins/PX4/RadioComponent.cc index 1a3536d..275cc81 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.cc +++ b/src/AutoPilotPlugins/PX4/RadioComponent.cc @@ -62,13 +62,7 @@ bool RadioComponent::setupComplete(void) const QStringList attitudeMappings; attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE"; foreach(QString mapParam, attitudeMappings) { - QVariant value; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), mapParam, value)) { - if (value.toInt() == 0) { - return false; - } - } else { - Q_ASSERT(false); + if (_autopilot->getParameterFact(mapParam)->value().toInt() == 0) { return false; } } @@ -86,28 +80,13 @@ bool RadioComponent::setupComplete(void) const QString param; param = QString("RC%1_MIN").arg(i); - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { - rcMin = value.toInt(); - } else { - Q_ASSERT(false); - return false; - } + rcMin = _autopilot->getParameterFact(param)->value().toInt(); param = QString("RC%1_MAX").arg(i); - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { - rcMax = value.toInt(); - } else { - Q_ASSERT(false); - return false; - } + rcMax = _autopilot->getParameterFact(param)->value().toInt(); param = QString("RC%1_TRIM").arg(i); - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { - rcTrim = value.toInt(); - } else { - Q_ASSERT(false); - return false; - } + rcTrim = _autopilot->getParameterFact(param)->value().toInt(); if (rcMin == rcMinDefault && rcMax == rcMaxDefault && rcTrim == rcTrimDefault) { return false; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 4c14ba7..60caa24 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -62,14 +62,7 @@ bool SensorsComponent::requiresSetup(void) const bool SensorsComponent::setupComplete(void) const { foreach(QString triggerParam, setupCompleteChangedTriggerList()) { - QVariant value; - - if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParam, value)) { - Q_ASSERT(false); - return false; - } - - if (value.toFloat() == 0.0f) { + if (_autopilot->getParameterFact(triggerParam)->value().toFloat() == 0.0f) { return false; } } diff --git a/src/VehicleSetup/VehicleComponent.cc b/src/VehicleSetup/VehicleComponent.cc index 956e607..d9cf5f0 100644 --- a/src/VehicleSetup/VehicleComponent.cc +++ b/src/VehicleSetup/VehicleComponent.cc @@ -34,9 +34,6 @@ VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* 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 397f3c6..5d928cf 100644 --- a/src/VehicleSetup/VehicleComponent.h +++ b/src/VehicleSetup/VehicleComponent.h @@ -75,7 +75,6 @@ signals: protected: UASInterface* _uas; AutoPilotPlugin* _autopilot; - QGCUASParamManagerInterface* _paramMgr; }; #endif From c4e18ecf2593c56ba9028e0f2adec10f63ba2bd9 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 10 Apr 2015 09:04:06 -0700 Subject: [PATCH 3/3] Fix new clang compiler warning --- src/ui/map/Waypoint2DIcon.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/map/Waypoint2DIcon.cc b/src/ui/map/Waypoint2DIcon.cc index 9a77643..5020477 100644 --- a/src/ui/map/Waypoint2DIcon.cc +++ b/src/ui/map/Waypoint2DIcon.cc @@ -307,7 +307,7 @@ void Waypoint2DIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *op penDash.setWidth(1); //penDash.setStyle(Qt::DotLine); // A negative radius indicates counter-clockwise rotation, but we still want to draw it positive - const int loiter = map->metersToPixels(fabsf(waypoint->getLoiterOrbit()), Coord()); + const int loiter = map->metersToPixels(fabs(waypoint->getLoiterOrbit()), Coord()); if (loiter > picture.width()/2) { painter->setPen(penBlack);