From f8e704451852373865b688fdc4411afe99325be0 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 1 Mar 2015 10:34:06 -0800 Subject: [PATCH] Trigger list now QStringList --- src/AutoPilotPlugins/PX4/AirframeComponent.cc | 9 +++---- src/AutoPilotPlugins/PX4/AirframeComponent.h | 2 +- .../PX4/FlightModesComponent.cc | 9 +++---- .../PX4/FlightModesComponent.h | 2 +- src/AutoPilotPlugins/PX4/PX4Component.cc | 9 +++---- src/AutoPilotPlugins/PX4/PX4Component.h | 8 ++++--- src/AutoPilotPlugins/PX4/RadioComponent.h | 2 +- src/AutoPilotPlugins/PX4/SafetyComponent.cc | 7 ++---- src/AutoPilotPlugins/PX4/SafetyComponent.h | 2 +- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 24 +++++++++---------- src/AutoPilotPlugins/PX4/SensorsComponent.h | 2 +- 11 files changed, 32 insertions(+), 44 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index 223765f99..04b757afc 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -27,9 +27,6 @@ #include "AirframeComponent.h" #include "QGCPX4AirframeConfig.h" -/// @brief Parameters which signal a change in setupComplete state -static const char* triggerParams[] = { "SYS_AUTOSTART", NULL }; - #if 0 // Broken by latest mavlink module changes. Not used yet. Comment out for now. // Discussing mavlink fix. @@ -146,7 +143,7 @@ bool AirframeComponent::requiresSetup(void) const bool AirframeComponent::setupComplete(void) const { QVariant value; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) { + if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) { return value.toInt() != 0; } else { Q_ASSERT(false); @@ -166,9 +163,9 @@ QString AirframeComponent::setupStateDescription(void) const return QString(stateDescription); } -const char** AirframeComponent::setupCompleteChangedTriggerList(void) const +QStringList AirframeComponent::setupCompleteChangedTriggerList(void) const { - return triggerParams; + return QStringList("SYS_AUTOSTART"); } QStringList AirframeComponent::paramFilterList(void) const diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.h b/src/AutoPilotPlugins/PX4/AirframeComponent.h index 1b5247491..9a25d80ba 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.h @@ -38,7 +38,7 @@ public: AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component - virtual const char** setupCompleteChangedTriggerList(void) const; + virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent virtual QString name(void) const; diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index 629295295..14b64315c 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -28,9 +28,6 @@ #include "FlightModeConfig.h" #include "PX4AutoPilotPlugin.h" -/// @brief Parameters which signal a change in setupComplete state -static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL }; - struct SwitchListItem { const char* param; const char* name; @@ -76,7 +73,7 @@ bool FlightModesComponent::requiresSetup(void) const bool FlightModesComponent::setupComplete(void) const { QVariant value; - if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) { + if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "RC_MAP_MODE_SW", value)) { return value.toInt() != 0; } else { Q_ASSERT(false); @@ -96,9 +93,9 @@ QString FlightModesComponent::setupStateDescription(void) const return QString(stateDescription); } -const char** FlightModesComponent::setupCompleteChangedTriggerList(void) const +QStringList FlightModesComponent::setupCompleteChangedTriggerList(void) const { - return triggerParams; + return QStringList("RC_MAP_MODE_SW"); } QStringList FlightModesComponent::paramFilterList(void) const diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.h b/src/AutoPilotPlugins/PX4/FlightModesComponent.h index da97c5565..097bb1171 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.h +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.h @@ -38,7 +38,7 @@ public: FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component - virtual const char** setupCompleteChangedTriggerList(void) const; + virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent virtual QString name(void) const; diff --git a/src/AutoPilotPlugins/PX4/PX4Component.cc b/src/AutoPilotPlugins/PX4/PX4Component.cc index bcf264028..d43a2644a 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.cc +++ b/src/AutoPilotPlugins/PX4/PX4Component.cc @@ -39,15 +39,12 @@ void PX4Component::_parameterUpdated(int compId, QString paramName, QVariant val Q_UNUSED(value); if (compId == _paramMgr->getDefaultComponentId()) { - const char** prgTriggers = setupCompleteChangedTriggerList(); - Q_ASSERT(prgTriggers); - - while (*prgTriggers != NULL) { - if (paramName == *prgTriggers) { + QStringList triggerList = setupCompleteChangedTriggerList(); + foreach(QString triggerParam, triggerList) { + if (paramName == triggerParam) { emit setupCompleteChanged(setupComplete()); return; } - prgTriggers++; } } } diff --git a/src/AutoPilotPlugins/PX4/PX4Component.h b/src/AutoPilotPlugins/PX4/PX4Component.h index 9bffafb9f..c84ca2ab1 100644 --- a/src/AutoPilotPlugins/PX4/PX4Component.h +++ b/src/AutoPilotPlugins/PX4/PX4Component.h @@ -26,6 +26,8 @@ #include "VehicleComponent.h" +#include + /// @file /// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects. /// @author Don Gagne @@ -37,9 +39,9 @@ class PX4Component : public VehicleComponent public: 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. - virtual const char** setupCompleteChangedTriggerList(void) const = 0; + /// @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; private slots: /// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.h b/src/AutoPilotPlugins/PX4/RadioComponent.h index 0d00db325..9ed4ff1cd 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.h +++ b/src/AutoPilotPlugins/PX4/RadioComponent.h @@ -39,7 +39,7 @@ public: RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component - virtual const char** setupCompleteChangedTriggerList(void) const; + virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent virtual QString name(void) const; diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.cc b/src/AutoPilotPlugins/PX4/SafetyComponent.cc index 4f9fbee04..f530f4fd0 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.cc +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.cc @@ -29,9 +29,6 @@ #include "QGCQmlWidgetHolder.h" #include "PX4AutoPilotPlugin.h" -/// @brief Parameters which signal a change in setupComplete state -static const char* triggerParams[] = { NULL }; - SafetyComponent::SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : PX4Component(uas, autopilot, parent), _name(tr("Safety")) @@ -76,9 +73,9 @@ QString SafetyComponent::setupStateDescription(void) const return QString(stateDescription); } -const char** SafetyComponent::setupCompleteChangedTriggerList(void) const +QStringList SafetyComponent::setupCompleteChangedTriggerList(void) const { - return triggerParams; + return QStringList(); } QStringList SafetyComponent::paramFilterList(void) const diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.h b/src/AutoPilotPlugins/PX4/SafetyComponent.h index 4102b4a33..b915f02f7 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.h +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.h @@ -39,7 +39,7 @@ public: SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component - virtual const char** setupCompleteChangedTriggerList(void) const; + virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent virtual QString name(void) const; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index e11b02229..4c14ba7c3 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -31,10 +31,6 @@ // These two list must be kept in sync -/// @brief Parameters which signal a change in setupComplete state -static const char* triggerParams[] = { "CAL_MAG0_ID", "CAL_GYRO0_ID", "CAL_ACC0_ID", NULL }; -static const char* triggerParamsFixedWing[] = { "CAL_MAG0_ID", "CAL_GYRO0_ID", "CAL_ACC0_ID", "SENS_DPRES_OFF", NULL }; - SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : PX4Component(uas, autopilot, parent), _name(tr("Sensors")) @@ -65,13 +61,10 @@ bool SensorsComponent::requiresSetup(void) const bool SensorsComponent::setupComplete(void) const { - const char** prgTriggers = setupCompleteChangedTriggerList(); - Q_ASSERT(prgTriggers); - - while (*prgTriggers != NULL) { + foreach(QString triggerParam, setupCompleteChangedTriggerList()) { QVariant value; - if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), *prgTriggers, value)) { + if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParam, value)) { Q_ASSERT(false); return false; } @@ -79,8 +72,6 @@ bool SensorsComponent::setupComplete(void) const if (value.toFloat() == 0.0f) { return false; } - - prgTriggers++; } return true; @@ -98,9 +89,16 @@ QString SensorsComponent::setupStateDescription(void) const return QString(stateDescription); } -const char** SensorsComponent::setupCompleteChangedTriggerList(void) const +QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const { - return _uas->getSystemType() == MAV_TYPE_FIXED_WING ? triggerParamsFixedWing : triggerParams; + QStringList triggers; + + triggers << "CAL_MAG0_ID" << "CAL_GYRO0_ID" << "CAL_ACC0_ID"; + if (_uas->getSystemType() == MAV_TYPE_FIXED_WING) { + triggers << "SENS_DPRES_OFF"; + } + + return triggers; } QStringList SensorsComponent::paramFilterList(void) const diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index 00b0d6e97..699822e15 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -38,7 +38,7 @@ public: SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Virtuals from PX4Component - virtual const char** setupCompleteChangedTriggerList(void) const; + virtual QStringList setupCompleteChangedTriggerList(void) const; // Virtuals from VehicleComponent virtual QString name(void) const; -- 2.22.0