Commit 36b702a8 authored by Don Gagne's avatar Don Gagne

Merge pull request #1465 from DonLakeFlyer/Setup

Lead the user through fixing setup problems
parents 72760033 5f5aea84
......@@ -26,15 +26,21 @@
#include "AutoPilotPlugin.h"
#include "QGCUASParamManagerInterface.h"
#include "SetupView.h"
#include "QGCApplication.h"
#include "QGCMessageBox.h"
#include "MainWindow.h"
AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) :
QObject(parent),
_uas(uas),
_pluginReady(false)
_pluginReady(false),
_setupComplete(false)
{
Q_ASSERT(_uas);
connect(_uas, &UASInterface::disconnected, this, &AutoPilotPlugin::_uasDisconnected);
connect(this, &AutoPilotPlugin::pluginReadyChanged, this, &AutoPilotPlugin::_pluginReadyChanged);
}
void AutoPilotPlugin::_uasDisconnected(void)
......@@ -43,6 +49,54 @@ void AutoPilotPlugin::_uasDisconnected(void)
emit pluginReadyChanged(_pluginReady);
}
void AutoPilotPlugin::_pluginReadyChanged(bool pluginReady)
{
if (pluginReady) {
_recalcSetupComplete();
if (!_setupComplete) {
QGCMessageBox::warning("Setup", "One or more vehicle components require setup prior to flight.");
// Take the user to Vehicle Summary
MainWindow* mainWindow = MainWindow::instance();
Q_ASSERT(mainWindow);
mainWindow->getMainToolBar()->onSetupView();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QWidget* setupViewWidget = mainWindow->getCurrentViewWidget();
Q_ASSERT(setupViewWidget);
SetupView* setupView = qobject_cast<SetupView*>(setupViewWidget);
Q_ASSERT(setupView);
setupView->summaryButtonClicked();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
}
}
}
void AutoPilotPlugin::_recalcSetupComplete(void)
{
bool newSetupComplete = true;
foreach(const QVariant componentVariant, vehicleComponents()) {
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant));
Q_ASSERT(component);
if (!component->setupComplete()) {
newSetupComplete = false;
break;
}
}
if (_setupComplete != newSetupComplete) {
_setupComplete = newSetupComplete;
emit setupCompleteChanged(_setupComplete);
}
}
bool AutoPilotPlugin::setupComplete(void)
{
Q_ASSERT(_pluginReady);
return _setupComplete;
}
void AutoPilotPlugin::refreshAllParameters(void)
{
_getParameterLoader()->refreshAllParameters();
......
......@@ -56,7 +56,10 @@ public:
/// List of VehicleComponent objects
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT)
/// false: One or more vehicle components require setup
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged)
/// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(void);
......@@ -103,12 +106,15 @@ public:
static void clearStaticData(void);
// Property accessors
bool pluginReady(void) { return _pluginReady; }
bool setupComplete(void);
UASInterface* uas(void) { return _uas; }
signals:
/// Signalled when plugin is ready for use
void pluginReadyChanged(bool pluginReady);
void setupCompleteChanged(bool setupComplete);
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
......@@ -119,9 +125,14 @@ protected:
UASInterface* _uas;
bool _pluginReady;
bool _setupComplete;
private slots:
void _uasDisconnected(void);
void _pluginReadyChanged(bool pluginReady);
private:
void _recalcSetupComplete(void);
};
#endif
......@@ -231,22 +231,10 @@ void PX4AutoPilotPlugin::_pluginReadyPreChecks(void)
// should be used instead.
if (parameterExists("SENS_GYRO_XOFF")) {
_incorrectParameterVersion = true;
QGCMessageBox::warning(tr("Setup"), tr("This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup."));
} else {
// Check for missing setup complete
foreach(const QVariant componentVariant, vehicleComponents()) {
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant));
Q_ASSERT(component);
if (!component->setupComplete()) {
QGCMessageBox::warning(tr("Setup"), tr("One or more vehicle components require setup prior to flight. "
"Please correct these by going to the Setup view."));
break;
}
}
}
QGCMessageBox::warning("Setup", "This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup.");
}
_pluginReady = true;
emit pluginReadyChanged(_pluginReady);
}
......@@ -57,8 +57,15 @@ Rectangle {
}
QGCLabel {
width: parent.width
text: "If any of the setup indicators below are shown as red YOU SHOULD NOT FLY until you complete the setup of those components."
width: parent.width
wrapMode: Text.WordWrap
color: autopilot.setupComplete ? qgcPal.text : "red"
font.pointSize: autopilot.setupComplete ? qgcPal.dpiAdjustedDefaultFontPointSize : screenTools.dpiAdjustedPointSize(20)
text: autopilot.setupComplete ?
"Below you will find a summary of the settings for your vehicle. To the left are the setup buttons for deatiled settings for each component." :
"WARNING: One or more of your vehicle's components require setup prior to flight. It will be shown with a red circular indicator below. " +
"Find the matching setup button to the left and click it to get to the setup screen you need to complete. " +
"Once all indicators go green you will be ready to fly."
}
Item {
......
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