Commit a0bb4bbb authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #1561 from DonLakeFlyer/AirframeConfig

Airframe Config: No longer tries to reconnect after reboot
parents bc71d49d 2fa21491
...@@ -51,7 +51,7 @@ QGCView { ...@@ -51,7 +51,7 @@ QGCView {
onCompleted: { onCompleted: {
if (controller.showCustomConfigPanel) { if (controller.showCustomConfigPanel) {
panel.showDialog(customConfigDialog, "Custom Airframe Config", 50, StandardButton.Reset) panel.showDialog(customConfigDialogComponent, "Custom Airframe Config", 50, StandardButton.Reset)
} }
} }
} }
...@@ -62,23 +62,45 @@ QGCView { ...@@ -62,23 +62,45 @@ QGCView {
} }
Component { Component {
id: customConfigDialog id: customConfigDialogComponent
QGCLabel { QGCViewDialog {
id: customConfigPanel id: customConfigDialog
anchors.fill: parent
wrapMode: Text.WordWrap
text: "Your vehicle is using a custom airframe configuration. " +
"This configuration can only be modified through the Parameter Editor.\n\n" +
"If you want to Reset your airframe configuration and select a standard configuration, click 'Reset' above."
signal hideDialog
Fact { id: sys_autostart; name: "SYS_AUTOSTART" } Fact { id: sys_autostart; name: "SYS_AUTOSTART" }
function accept() { function accept() {
sys_autostart.value = 0 sys_autostart.value = 0
customConfigPanel.hideDialog() customConfigDialog.hideDialog()
}
QGCLabel {
anchors.fill: parent
wrapMode: Text.WordWrap
text: "Your vehicle is using a custom airframe configuration. " +
"This configuration can only be modified through the Parameter Editor.\n\n" +
"If you want to Reset your airframe configuration and select a standard configuration, click 'Reset' above."
}
}
}
Component {
id: applyRestartDialogComponent
QGCViewDialog {
id: applyRestartDialog
function accept() {
controller.changeAutostart()
applyRestartDialog.hideDialog()
}
QGCLabel {
anchors.fill: parent
wrapMode: Text.WordWrap
text: "Clicking Apply will save the changes you have made to your aiframe configuration. " +
"Your vehicle will also be rebooted in order to complete the process. " +
"After your vehicle reboots, you can reconnect it to QGroundControl."
} }
} }
} }
...@@ -117,7 +139,7 @@ QGCView { ...@@ -117,7 +139,7 @@ QGCView {
anchors.right: parent.right anchors.right: parent.right
text: "Apply and Restart" text: "Apply and Restart"
onClicked: { controller.changeAutostart() } onClicked: panel.showDialog(applyRestartDialogComponent, "Apply and Restart", 50, StandardButton.Apply | StandardButton.Cancel)
} }
Item { Item {
......
...@@ -101,24 +101,26 @@ void AirframeComponentController::changeAutostart(void) ...@@ -101,24 +101,26 @@ void AirframeComponentController::changeAutostart(void)
return; return;
} }
qgcApp()->setOverrideCursor(Qt::WaitCursor);
_autopilot->getParameterFact("SYS_AUTOSTART")->setValue(_autostartId); _autopilot->getParameterFact("SYS_AUTOSTART")->setValue(_autostartId);
_autopilot->getParameterFact("SYS_AUTOCONFIG")->setValue(1); _autopilot->getParameterFact("SYS_AUTOCONFIG")->setValue(1);
qgcApp()->setOverrideCursor(Qt::WaitCursor);
// Wait for the parameters to flow through system // Wait for the parameters to flow through system
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QGC::SLEEP::sleep(1); QGC::SLEEP::sleep(1);
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
// Reboot board and reconnect // Reboot board
_uas->executeCommand(MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); _uas->executeCommand(MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QGC::SLEEP::sleep(1); QGC::SLEEP::sleep(1);
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
LinkManager::instance()->disconnectAll();
qgcApp()->reconnectAfterWait(5); qgcApp()->restoreOverrideCursor();
} }
AirframeType::AirframeType(const QString& name, const QString& imageResource, QObject* parent) : AirframeType::AirframeType(const QString& name, const QString& imageResource, QObject* parent) :
......
...@@ -655,32 +655,6 @@ void QGCApplication::_loadCurrentStyle(void) ...@@ -655,32 +655,6 @@ void QGCApplication::_loadCurrentStyle(void)
restoreOverrideCursor(); restoreOverrideCursor();
} }
void QGCApplication::reconnectAfterWait(int waitSeconds)
{
LinkManager* linkManager = LinkManager::instance();
Q_ASSERT(linkManager);
Q_ASSERT(linkManager->getLinks().count() == 1);
LinkInterface* link = linkManager->getLinks()[0];
// Save the link configuration so we can restart the link laster
_reconnectLinkConfig = LinkConfiguration::duplicateSettings(linkManager->getLinks()[0]->getLinkConfiguration());
// Disconnect and wait
linkManager->disconnectLink(link);
QTimer::singleShot(waitSeconds * 1000, this, &QGCApplication::_reconnect);
}
void QGCApplication::_reconnect(void)
{
Q_ASSERT(_reconnectLinkConfig);
qgcApp()->restoreOverrideCursor();
LinkManager::instance()->createConnectedLink(_reconnectLinkConfig);
_reconnectLinkConfig = NULL;
}
void QGCApplication::reportMissingFact(const QString& name) void QGCApplication::reportMissingFact(const QString& name)
{ {
_missingFacts += name; _missingFacts += name;
......
...@@ -96,9 +96,6 @@ public: ...@@ -96,9 +96,6 @@ public:
/// Set the current UI style /// Set the current UI style
void setStyle(bool styleIsDark); void setStyle(bool styleIsDark);
/// Disconnects the current link and waits for the specified number of seconds before reconnecting.
void reconnectAfterWait(int waitSeconds);
/// Used to report a missing Fact. Warning will be displayed to user. Method may be called /// Used to report a missing Fact. Warning will be displayed to user. Method may be called
/// multiple times. /// multiple times.
void reportMissingFact(const QString& name); void reportMissingFact(const QString& name);
...@@ -143,7 +140,6 @@ public: ...@@ -143,7 +140,6 @@ public:
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
private slots: private slots:
void _reconnect(void);
void _missingFactsDisplay(void); void _missingFactsDisplay(void);
private: private:
...@@ -167,8 +163,6 @@ private: ...@@ -167,8 +163,6 @@ private:
static const char* _lightStyleFile; static const char* _lightStyleFile;
bool _styleIsDark; ///< true: dark style, false: light style bool _styleIsDark; ///< true: dark style, false: light style
LinkConfiguration* _reconnectLinkConfig; ///< Configuration to reconnect for reconnectAfterWait
static const int _missingFactDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display static const int _missingFactDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingFactDelayedDisplayTimer; ///< Timer use to delay missing fact display QTimer _missingFactDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingFacts; ///< List of missing facts to be displayed QStringList _missingFacts; ///< List of missing facts to be displayed
......
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