Commit f8e70445 authored by Don Gagne's avatar Don Gagne

Trigger list now QStringList

parent a7c79618
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include "AirframeComponent.h" #include "AirframeComponent.h"
#include "QGCPX4AirframeConfig.h" #include "QGCPX4AirframeConfig.h"
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SYS_AUTOSTART", NULL };
#if 0 #if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now. // Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix. // Discussing mavlink fix.
...@@ -146,7 +143,7 @@ bool AirframeComponent::requiresSetup(void) const ...@@ -146,7 +143,7 @@ bool AirframeComponent::requiresSetup(void) const
bool AirframeComponent::setupComplete(void) const bool AirframeComponent::setupComplete(void) const
{ {
QVariant value; QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) { if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) {
return value.toInt() != 0; return value.toInt() != 0;
} else { } else {
Q_ASSERT(false); Q_ASSERT(false);
...@@ -166,9 +163,9 @@ QString AirframeComponent::setupStateDescription(void) const ...@@ -166,9 +163,9 @@ QString AirframeComponent::setupStateDescription(void) const
return QString(stateDescription); 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 QStringList AirframeComponent::paramFilterList(void) const
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component // Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const; virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent // Virtuals from VehicleComponent
virtual QString name(void) const; virtual QString name(void) const;
......
...@@ -28,9 +28,6 @@ ...@@ -28,9 +28,6 @@
#include "FlightModeConfig.h" #include "FlightModeConfig.h"
#include "PX4AutoPilotPlugin.h" #include "PX4AutoPilotPlugin.h"
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL };
struct SwitchListItem { struct SwitchListItem {
const char* param; const char* param;
const char* name; const char* name;
...@@ -76,7 +73,7 @@ bool FlightModesComponent::requiresSetup(void) const ...@@ -76,7 +73,7 @@ bool FlightModesComponent::requiresSetup(void) const
bool FlightModesComponent::setupComplete(void) const bool FlightModesComponent::setupComplete(void) const
{ {
QVariant value; QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) { if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "RC_MAP_MODE_SW", value)) {
return value.toInt() != 0; return value.toInt() != 0;
} else { } else {
Q_ASSERT(false); Q_ASSERT(false);
...@@ -96,9 +93,9 @@ QString FlightModesComponent::setupStateDescription(void) const ...@@ -96,9 +93,9 @@ QString FlightModesComponent::setupStateDescription(void) const
return QString(stateDescription); 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 QStringList FlightModesComponent::paramFilterList(void) const
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component // Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const; virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent // Virtuals from VehicleComponent
virtual QString name(void) const; virtual QString name(void) const;
......
...@@ -39,15 +39,12 @@ void PX4Component::_parameterUpdated(int compId, QString paramName, QVariant val ...@@ -39,15 +39,12 @@ void PX4Component::_parameterUpdated(int compId, QString paramName, QVariant val
Q_UNUSED(value); Q_UNUSED(value);
if (compId == _paramMgr->getDefaultComponentId()) { if (compId == _paramMgr->getDefaultComponentId()) {
const char** prgTriggers = setupCompleteChangedTriggerList(); QStringList triggerList = setupCompleteChangedTriggerList();
Q_ASSERT(prgTriggers); foreach(QString triggerParam, triggerList) {
if (paramName == triggerParam) {
while (*prgTriggers != NULL) {
if (paramName == *prgTriggers) {
emit setupCompleteChanged(setupComplete()); emit setupCompleteChanged(setupComplete());
return; return;
} }
prgTriggers++;
} }
} }
} }
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "VehicleComponent.h" #include "VehicleComponent.h"
#include <QStringList>
/// @file /// @file
/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects. /// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
...@@ -37,9 +39,9 @@ class PX4Component : public VehicleComponent ...@@ -37,9 +39,9 @@ class PX4Component : public VehicleComponent
public: public:
PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, 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 /// @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. Must be implemented by upper level class. /// signal to be emitted. Last element is signalled by NULL.
virtual const char** setupCompleteChangedTriggerList(void) const = 0; virtual QStringList setupCompleteChangedTriggerList(void) const = 0;
private slots: private slots:
/// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal /// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component // Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const; virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent // Virtuals from VehicleComponent
virtual QString name(void) const; virtual QString name(void) const;
......
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include "QGCQmlWidgetHolder.h" #include "QGCQmlWidgetHolder.h"
#include "PX4AutoPilotPlugin.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) : SafetyComponent::SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent), PX4Component(uas, autopilot, parent),
_name(tr("Safety")) _name(tr("Safety"))
...@@ -76,9 +73,9 @@ QString SafetyComponent::setupStateDescription(void) const ...@@ -76,9 +73,9 @@ QString SafetyComponent::setupStateDescription(void) const
return QString(stateDescription); return QString(stateDescription);
} }
const char** SafetyComponent::setupCompleteChangedTriggerList(void) const QStringList SafetyComponent::setupCompleteChangedTriggerList(void) const
{ {
return triggerParams; return QStringList();
} }
QStringList SafetyComponent::paramFilterList(void) const QStringList SafetyComponent::paramFilterList(void) const
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component // Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const; virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent // Virtuals from VehicleComponent
virtual QString name(void) const; virtual QString name(void) const;
......
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
// These two list must be kept in sync // 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) : SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent), PX4Component(uas, autopilot, parent),
_name(tr("Sensors")) _name(tr("Sensors"))
...@@ -65,13 +61,10 @@ bool SensorsComponent::requiresSetup(void) const ...@@ -65,13 +61,10 @@ bool SensorsComponent::requiresSetup(void) const
bool SensorsComponent::setupComplete(void) const bool SensorsComponent::setupComplete(void) const
{ {
const char** prgTriggers = setupCompleteChangedTriggerList(); foreach(QString triggerParam, setupCompleteChangedTriggerList()) {
Q_ASSERT(prgTriggers);
while (*prgTriggers != NULL) {
QVariant value; QVariant value;
if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), *prgTriggers, value)) { if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParam, value)) {
Q_ASSERT(false); Q_ASSERT(false);
return false; return false;
} }
...@@ -79,8 +72,6 @@ bool SensorsComponent::setupComplete(void) const ...@@ -79,8 +72,6 @@ bool SensorsComponent::setupComplete(void) const
if (value.toFloat() == 0.0f) { if (value.toFloat() == 0.0f) {
return false; return false;
} }
prgTriggers++;
} }
return true; return true;
...@@ -98,9 +89,16 @@ QString SensorsComponent::setupStateDescription(void) const ...@@ -98,9 +89,16 @@ QString SensorsComponent::setupStateDescription(void) const
return QString(stateDescription); 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 QStringList SensorsComponent::paramFilterList(void) const
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component // Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const; virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent // Virtuals from VehicleComponent
virtual QString name(void) const; virtual QString name(void) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment