diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index 576bff02797989e09f4d55db7d570738ca9ee560..e9e4cd7db6dc503bae186d8f5663f02be3ebd705 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 e573a26c218d3e67d923c3286a144ef755459a54..c03f66c1b7b9979f1be166d9a553c20304b086a1 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 d43a2644ad3708287a1f91eb9a9e9181a8e0cdd8..25cd36eb6bfc05546abb9915372d41303e3bd038 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 c84ca2ab1d1f7561eb7edf49b21dadfa7aec19c7..8efdb3f3354bcebdf271c78236d09e499c364970 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 5a3ff31f173892e51f9835a106a3c6d1dac26ca1..d1bf8fef201d5dcaf588073ebc3f7d2eefdce2a3 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 1a3536d8827dff5f7421945bd2a8ae79aa878ed0..275cc813968df5b093299d3c468e99763a655370 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 4c14ba7c32bf97e85f298913c7bb505fb38de232..60caa24922d363f8fab50804b43c8ffc9cf04566 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 956e6076fbc56a5a72049c6bf2f5103a2ea23810..d9cf5f0d205f1df730a0811d19a18886a996d906 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 397f3c6c882ee0a2756bcf2e28c18eb07ccbf119..5d928cfc43d54df7b8f71694fd255b494d5dfeb7 100644 --- a/src/VehicleSetup/VehicleComponent.h +++ b/src/VehicleSetup/VehicleComponent.h @@ -75,7 +75,6 @@ signals: protected: UASInterface* _uas; AutoPilotPlugin* _autopilot; - QGCUASParamManagerInterface* _paramMgr; }; #endif