Commit 4c53a1de authored by Don Gagne's avatar Don Gagne

Merge pull request #1437 from DonLakeFlyer/FactSystem

Cut over more code fully to FactSystem, plus setup view unit test click through
parents a8d4af86 c4e18ecf
...@@ -142,13 +142,7 @@ bool AirframeComponent::requiresSetup(void) const ...@@ -142,13 +142,7 @@ bool AirframeComponent::requiresSetup(void) const
bool AirframeComponent::setupComplete(void) const bool AirframeComponent::setupComplete(void) const
{ {
QVariant value; return _autopilot->getParameterFact("SYS_AUTOSTART")->value().toInt() != 0;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) {
return value.toInt() != 0;
} else {
Q_ASSERT(false);
return false;
}
} }
QString AirframeComponent::setupStateDescription(void) const QString AirframeComponent::setupStateDescription(void) const
......
...@@ -72,13 +72,7 @@ bool FlightModesComponent::requiresSetup(void) const ...@@ -72,13 +72,7 @@ bool FlightModesComponent::requiresSetup(void) const
bool FlightModesComponent::setupComplete(void) const bool FlightModesComponent::setupComplete(void) const
{ {
QVariant value; return _autopilot->getParameterFact("RC_MAP_MODE_SW")->value().toInt() != 0;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "RC_MAP_MODE_SW", value)) {
return value.toInt() != 0;
} else {
Q_ASSERT(false);
return false;
}
} }
QString FlightModesComponent::setupStateDescription(void) const QString FlightModesComponent::setupStateDescription(void) const
......
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(uas, autopilot, 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))); bool fSuccess = connect(_paramMgr, SIGNAL(parameterUpdated(int, QString, QVariant)), this, SLOT(_parameterUpdated(int, QString, QVariant)));
Q_ASSERT(fSuccess); Q_ASSERT(fSuccess);
Q_UNUSED(fSuccess); Q_UNUSED(fSuccess);
......
...@@ -47,6 +47,9 @@ private slots: ...@@ -47,6 +47,9 @@ private slots:
/// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal /// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal
/// setupCompleteChanged at appropriate times. /// setupCompleteChanged at appropriate times.
void _parameterUpdated(int compId, QString paramName, QVariant value); void _parameterUpdated(int compId, QString paramName, QVariant value);
private:
QGCUASParamManagerInterface* _paramMgr;
}; };
#endif #endif
...@@ -58,15 +58,9 @@ bool PowerComponent::requiresSetup(void) const ...@@ -58,15 +58,9 @@ bool PowerComponent::requiresSetup(void) const
bool PowerComponent::setupComplete(void) const bool PowerComponent::setupComplete(void) const
{ {
QVariant cvalue, evalue, nvalue; QVariant cvalue, evalue, nvalue;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_CHARGED", cvalue)) { return _autopilot->getParameterFact("BAT_V_CHARGED")->value().toFloat() != 0.0f &&
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_EMPTY", evalue)) { _autopilot->getParameterFact("BAT_V_EMPTY")->value().toFloat() != 0.0f &&
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_N_CELLS", nvalue)) { _autopilot->getParameterFact("BAT_N_CELLS")->value().toInt() != 0;
return (cvalue.toFloat() > 0.1f) && (evalue.toFloat() > 0.1f) && (nvalue.toInt() > 0);
}
}
}
Q_ASSERT(false);
return false;
} }
QString PowerComponent::setupStateDescription(void) const QString PowerComponent::setupStateDescription(void) const
......
...@@ -62,13 +62,7 @@ bool RadioComponent::setupComplete(void) const ...@@ -62,13 +62,7 @@ bool RadioComponent::setupComplete(void) const
QStringList attitudeMappings; QStringList attitudeMappings;
attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE"; attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
foreach(QString mapParam, attitudeMappings) { foreach(QString mapParam, attitudeMappings) {
QVariant value; if (_autopilot->getParameterFact(mapParam)->value().toInt() == 0) {
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), mapParam, value)) {
if (value.toInt() == 0) {
return false;
}
} else {
Q_ASSERT(false);
return false; return false;
} }
} }
...@@ -86,28 +80,13 @@ bool RadioComponent::setupComplete(void) const ...@@ -86,28 +80,13 @@ bool RadioComponent::setupComplete(void) const
QString param; QString param;
param = QString("RC%1_MIN").arg(i); param = QString("RC%1_MIN").arg(i);
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { rcMin = _autopilot->getParameterFact(param)->value().toInt();
rcMin = value.toInt();
} else {
Q_ASSERT(false);
return false;
}
param = QString("RC%1_MAX").arg(i); param = QString("RC%1_MAX").arg(i);
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { rcMax = _autopilot->getParameterFact(param)->value().toInt();
rcMax = value.toInt();
} else {
Q_ASSERT(false);
return false;
}
param = QString("RC%1_TRIM").arg(i); param = QString("RC%1_TRIM").arg(i);
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), param, value)) { rcTrim = _autopilot->getParameterFact(param)->value().toInt();
rcTrim = value.toInt();
} else {
Q_ASSERT(false);
return false;
}
if (rcMin == rcMinDefault && rcMax == rcMaxDefault && rcTrim == rcTrimDefault) { if (rcMin == rcMinDefault && rcMax == rcMaxDefault && rcTrim == rcTrimDefault) {
return false; return false;
......
...@@ -62,14 +62,7 @@ bool SensorsComponent::requiresSetup(void) const ...@@ -62,14 +62,7 @@ bool SensorsComponent::requiresSetup(void) const
bool SensorsComponent::setupComplete(void) const bool SensorsComponent::setupComplete(void) const
{ {
foreach(QString triggerParam, setupCompleteChangedTriggerList()) { foreach(QString triggerParam, setupCompleteChangedTriggerList()) {
QVariant value; if (_autopilot->getParameterFact(triggerParam)->value().toFloat() == 0.0f) {
if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParam, value)) {
Q_ASSERT(false);
return false;
}
if (value.toFloat() == 0.0f) {
return false; return false;
} }
} }
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#include "SetupViewTest.h" #include "SetupViewTest.h"
#include "MockLink.h" #include "MockLink.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "SetupView.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h"
UT_REGISTER_TEST(SetupViewTest) UT_REGISTER_TEST(SetupViewTest)
...@@ -72,9 +75,31 @@ void SetupViewTest::_clickThrough_test(void) ...@@ -72,9 +75,31 @@ void SetupViewTest::_clickThrough_test(void)
_mainToolBar->onSetupView(); _mainToolBar->onSetupView();
QTest::qWait(1000); QTest::qWait(1000);
// Click through all the setup buttons MainWindow* mainWindow = MainWindow::instance();
// FIXME: NYI Q_ASSERT(mainWindow);
QWidget* setupViewWidget = mainWindow->getCurrentViewWidget();
Q_ASSERT(setupViewWidget);
SetupView* setupView = qobject_cast<SetupView*>(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 // On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop
// the log file save dialog. // the log file save dialog.
......
...@@ -34,9 +34,6 @@ VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot ...@@ -34,9 +34,6 @@ VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot
{ {
Q_ASSERT(uas); Q_ASSERT(uas);
Q_ASSERT(autopilot); Q_ASSERT(autopilot);
_paramMgr = _uas->getParamManager();
Q_ASSERT(_paramMgr);
} }
VehicleComponent::~VehicleComponent() VehicleComponent::~VehicleComponent()
......
...@@ -75,7 +75,6 @@ signals: ...@@ -75,7 +75,6 @@ signals:
protected: protected:
UASInterface* _uas; UASInterface* _uas;
AutoPilotPlugin* _autopilot; AutoPilotPlugin* _autopilot;
QGCUASParamManagerInterface* _paramMgr;
}; };
#endif #endif
...@@ -124,6 +124,8 @@ public: ...@@ -124,6 +124,8 @@ public:
/// @brief Gets a pointer to the Main Tool Bar /// @brief Gets a pointer to the Main Tool Bar
MainToolBar* getMainToolBar(void) { return _mainToolBar; } MainToolBar* getMainToolBar(void) { return _mainToolBar; }
QWidget* getCurrentViewWidget(void) { return _currentViewWidget; }
public slots: public slots:
/** @brief Show the application settings */ /** @brief Show the application settings */
......
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