From 4a16909cb3fdc6bf9f0e4a8c5a04dd4c3842b803 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 18 Nov 2012 22:40:05 +0100 Subject: [PATCH] OP-690 Show dialog if halt is invoked and the board is armed or arming (not disarmed). --- .../plugins/uploader/uploadergadgetwidget.cpp | 29 +++++++++++++++++-- .../plugins/uploader/uploadergadgetwidget.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index 715b237b7..cd4fb199e 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -28,6 +28,7 @@ #include "../../../../../build/ground/openpilotgcs/gcsversioninfo.h" #include #include +#include "flightstatus.h" #define DFU_DEBUG true @@ -49,7 +50,7 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); - connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader())); + connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->safeBootButton, SIGNAL(clicked()), this, SLOT(systemSafeBoot())); @@ -348,6 +349,30 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success) } +void UploaderGadgetWidget::systemHalt() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); + UAVObjectManager *objManager = pm->getObject(); + Q_ASSERT(objManager); + FlightStatus *status = dynamic_cast(objManager->getObject(QString("FlightStatus"))); + Q_ASSERT(status); + + // The board can not be halted when in armed state. + // If board is armed, or arming. Show message with notice. + if (status->getArmed() == FlightStatus::ARMED_DISARMED) { + goToBootloader(); + } + else { + QMessageBox mbox(this); + mbox.setText(QString(tr("The controller board is armed and can not be halted.\n" + "Please make sure the board is not armed and then press halt again to proceed."))); + mbox.setStandardButtons(QMessageBox::Ok); + mbox.setIcon(QMessageBox::Warning); + mbox.exec(); + } +} + /** Tell the mainboard to reset: - Send the relevant IAP commands @@ -381,7 +406,6 @@ void UploaderGadgetWidget::systemSafeBoot() */ void UploaderGadgetWidget::commonSystemBoot(bool safeboot) { - clearLog(); m_config->bootButton->setEnabled(false); m_config->safeBootButton->setEnabled(false); @@ -828,6 +852,5 @@ void UploaderGadgetWidget::versionMatchCheck() void UploaderGadgetWidget::openHelp() { - QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/AoBZ", QUrl::StrictMode) ); } diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h index 67b988a38..a492a857f 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h @@ -100,6 +100,7 @@ private slots: void error(QString errorString,int errorNumber); void info(QString infoString,int infoNumber); void goToBootloader(UAVObject* = NULL, bool = false); + void systemHalt(); void systemReset(); void systemBoot(); void systemSafeBoot();