diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.cpp deleted file mode 100644 index b745adaeb..000000000 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/** - ****************************************************************************** - * - * @file rebootpage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @addtogroup - * @{ - * @addtogroup RebootPage - * @{ - * @brief - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "rebootpage.h" -#include "ui_rebootpage.h" - -RebootPage::RebootPage(SetupWizard *wizard, QWidget *parent) : - AbstractWizardPage(wizard, parent), - ui(new Ui::RebootPage), m_toggl(false), m_isRebooting(false) -{ - ui->setupUi(this); - ui->yellowLabel->setVisible(false); - ui->redLabel->setVisible(true); - connect(ui->rebootButton, SIGNAL(clicked()), this, SLOT(reboot())); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Q_ASSERT(pm); - m_uploader = pm->getObject(); - Q_ASSERT(m_uploader); -} - -RebootPage::~RebootPage() -{ - disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel())); - m_timer.stop(); - delete ui; -} - -void RebootPage::initializePage() -{ - ui->messageLabel->setText(""); - ui->rebootProgress->setValue(0); - if (!m_timer.isActive()) { - connect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel())); - m_timer.setInterval(500); - m_timer.setSingleShot(false); - m_timer.start(); - } -} - -bool RebootPage::validatePage() -{ - return !m_isRebooting; -} - -void RebootPage::toggleLabel() -{ - m_toggl = !m_toggl; - ui->yellowLabel->setVisible(m_toggl); - ui->redLabel->setVisible(!m_toggl); -} - -void RebootPage::enableButtons(bool enable) -{ - getWizard()->button(QWizard::NextButton)->setEnabled(enable); - getWizard()->button(QWizard::CancelButton)->setEnabled(enable); - getWizard()->button(QWizard::BackButton)->setEnabled(enable); - getWizard()->button(QWizard::CustomButton1)->setEnabled(enable); - ui->rebootButton->setEnabled(enable); -} - -void RebootPage::reboot() -{ - enableButtons(false); - ui->rebootProgress->setValue(0); - QApplication::processEvents(); - connect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant))); - ui->messageLabel->setText(tr("Reboot in progress...")); - m_isRebooting = true; - m_uploader->reboot(); -} - -void RebootPage::progressUpdate(uploader::ProgressStep progress, QVariant message) -{ - Q_UNUSED(message); - if (progress == uploader::SUCCESS || progress == uploader::FAILURE) { - disconnect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant))); - if (progress == uploader::FAILURE) { - ui->messageLabel->setText(tr("Software reboot failed!

Please perform a manual reboot by power cycling the board. " - "To power cycle the controller remove all batteries and the USB cable for at least 30 seconds. " - "After 30 seconds, plug in the board again and wait for it to connect, this can take a few seconds. Then press Next.")); - } else { - ui->messageLabel->setText(tr("Reboot complete!")); - } - m_isRebooting= false; - enableButtons(true); - } else { - ui->rebootProgress->setValue(ui->rebootProgress->value() + 1); - } -} - - -bool RebootPage::isComplete() const -{ - return !m_isRebooting; -} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.ui deleted file mode 100644 index 190e14a48..000000000 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.ui +++ /dev/null @@ -1,137 +0,0 @@ - - - RebootPage - - - - 0 - 0 - 600 - 400 - - - - WizardPage - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:18pt; color:#ff0000;">PLEASE REBOOT YOUR CONTROLLER</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:18pt; color:#ffd500;">PLEASE REBOOT YOUR CONTROLLER</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; color:#000000;">The configuration created by the wizard contains settings that require a reboot of your controller. <br /><br />Press the button below to reboot board. Wait for the board to connect again and the Next button to be enabled before continuing. After board is connected press Next to continue wizard.</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - QProgressBar { - border: 2px solid grey; - border-radius: 5px; - text-align: center; - } -QProgressBar::chunk { - background-color: #3D6699; - width: 10px; - margin: 0.5px; - } - - - 6 - - - 0 - - - false - - - - - - - Reboot - - - - - yellowLabel - redLabel - infoLabel - rebootButton - verticalSpacer - messageLabel - rebootProgress - - - - diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 141877849..aace4fae1 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -44,7 +44,6 @@ #include "pages/summarypage.h" #include "pages/savepage.h" #include "pages/notyetimplementedpage.h" -#include "pages/rebootpage.h" #include "pages/outputcalibrationpage.h" #include "pages/revocalibrationpage.h" #include "pages/airframeinitialtuningpage.h" @@ -141,11 +140,8 @@ int SetupWizard::nextId() const case PAGE_INPUT: if (isRestartNeeded()) { saveHardwareSettings(); - return PAGE_REBOOT; - } else { - return PAGE_VEHICLES; + reboot(); } - case PAGE_REBOOT: return PAGE_VEHICLES; case PAGE_ESC: @@ -470,7 +466,6 @@ void SetupWizard::createPages() setPage(PAGE_OUTPUT_CALIBRATION, new OutputCalibrationPage(this)); setPage(PAGE_SUMMARY, new SummaryPage(this)); setPage(PAGE_SAVE, new SavePage(this)); - setPage(PAGE_REBOOT, new RebootPage(this)); setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this)); setPage(PAGE_AIRFRAME_INITIAL_TUNING, new AirframeInitialTuningPage(this)); setPage(PAGE_END, new OPEndPage(this)); @@ -500,6 +495,15 @@ void SetupWizard::pageChanged(int currId) button(QWizard::CancelButton)->setVisible(currId != PAGE_END); } +void SetupWizard::reboot() const +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); + UploaderGadgetFactory *uploader = pm->getObject(); + Q_ASSERT(uploader); + uploader->reboot(); +} + bool SetupWizard::saveHardwareSettings() const { VehicleConfigurationHelper helper(const_cast(this)); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h index 3a641d54d..10a34a5f3 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -192,6 +192,7 @@ private: void createPages(); bool saveHardwareSettings() const; bool canAutoUpdate() const; + void reboot() const; CONTROLLER_TYPE m_controllerType; VEHICLE_TYPE m_vehicleType; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index 6dee3e178..d2c6ffd74 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -31,7 +31,6 @@ HEADERS += setupwizardplugin.h \ connectiondiagram.h \ pages/outputcalibrationpage.h \ outputcalibrationutil.h \ - pages/rebootpage.h \ pages/savepage.h \ pages/autoupdatepage.h \ pages/revocalibrationpage.h \ @@ -65,7 +64,6 @@ SOURCES += setupwizardplugin.cpp \ connectiondiagram.cpp \ pages/outputcalibrationpage.cpp \ outputcalibrationutil.cpp \ - pages/rebootpage.cpp \ pages/savepage.cpp \ pages/autoupdatepage.cpp \ pages/revocalibrationpage.cpp \ @@ -92,7 +90,6 @@ FORMS += \ pages/summarypage.ui \ connectiondiagram.ui \ pages/outputcalibrationpage.ui \ - pages/rebootpage.ui \ pages/savepage.ui \ pages/autoupdatepage.ui \ pages/revocalibrationpage.ui \ diff --git a/ground/openpilotgcs/src/plugins/uploader/rebootdialog.cpp b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.cpp new file mode 100644 index 000000000..06f4c0423 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.cpp @@ -0,0 +1,76 @@ +/** + ****************************************************************************** + * + * @file rebootdialog.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup RebootDialog + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "rebootdialog.h" +#include "ui_rebootdialog.h" + +RebootDialog::RebootDialog(UploaderGadgetWidget *uploader, QWidget *parent) : + QDialog(parent), + ui(new Ui::RebootDialog), m_uploader(uploader) +{ + ui->setupUi(this); + connect(this, SIGNAL(reboot()), m_uploader, SLOT(systemReboot())); + ui->rebootProgressBar->setVisible(true); + ui->okButton->setVisible(false); +} + +RebootDialog::~RebootDialog() +{ + delete ui; +} + +void RebootDialog::on_okButton_clicked() +{ + reject(); +} + +int RebootDialog::exec() +{ + show(); + connect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant))); + emit reboot(); + return result(); +} + +void RebootDialog::progressUpdate(uploader::ProgressStep progress, QVariant message) +{ + Q_UNUSED(message); + if (progress == uploader::SUCCESS || progress == uploader::FAILURE) { + disconnect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant))); + if (progress == uploader::FAILURE) { + ui->rebootProgressBar->setVisible(false); + ui->okButton->setVisible(true); + ui->label->setText(tr("Reboot failed!

Please perform a manual reboot by power cycling the board.
" + "To power cycle the controller remove all batteries and the USB cable for at least 30 seconds.
" + "After 30 seconds, plug in the board again and wait for it to connect, this can take a few seconds.
" + "Then press Ok.")); + QDialog::exec(); + } else { + accept(); + } + } +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.h b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.h similarity index 61% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.h rename to ground/openpilotgcs/src/plugins/uploader/rebootdialog.h index dc1ba492c..9519d8931 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/rebootpage.h +++ b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.h @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file rebootpage.h + * @file rebootdialog.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @addtogroup + * @addtogroup [Group] * @{ - * @addtogroup RebootPage + * @addtogroup RebootDialog * @{ - * @brief + * @brief [Brief] *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -25,41 +25,37 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef REBOOTPAGE_H -#define REBOOTPAGE_H +#ifndef REBOOTDIALOG_H +#define REBOOTDIALOG_H -#include "abstractwizardpage.h" -#include -#include -#include "uploader/uploadergadgetfactory.h" +#include +#include "uploadergadgetwidget.h" namespace Ui { -class RebootPage; +class RebootDialog; } -class RebootPage : public AbstractWizardPage { +class RebootDialog : public QDialog +{ Q_OBJECT public: - explicit RebootPage(SetupWizard *wizard, QWidget *parent = 0); - ~RebootPage(); + explicit RebootDialog(UploaderGadgetWidget *uploader, QWidget *parent = 0); + ~RebootDialog(); - void initializePage(); - bool validatePage(); - bool isComplete() const; - - void enableButtons(bool enable); -private: - Ui::RebootPage *ui; - QTimer m_timer; - bool m_toggl; - UploaderGadgetFactory *m_uploader; - bool m_isRebooting; +signals: + void reboot(); private slots: - void toggleLabel(); - void reboot(); + void on_okButton_clicked(); void progressUpdate(uploader::ProgressStep progress, QVariant message); + +private: + Ui::RebootDialog *ui; + UploaderGadgetWidget *m_uploader; + +public slots: + int exec(); }; -#endif // REBOOTPAGE_H +#endif // REBOOTDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/uploader/rebootdialog.ui b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.ui new file mode 100644 index 000000000..274b56e7b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/rebootdialog.ui @@ -0,0 +1,84 @@ + + + RebootDialog + + + Qt::ApplicationModal + + + + 0 + 0 + 445 + 180 + + + + Reboot + + + + :/core/images/flight.png:/core/images/flight.png + + + true + + + + + + + 0 + 0 + + + + <html><head/><body><p>Please wait. Your controller is rebooting.<br/>This can take up to a minute.</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + false + + + + + + + QProgressBar { + border: 2px solid grey; + border-radius: 5px; + text-align: center; + } +QProgressBar::chunk { + background-color: #3D6699; + width: 10px; + margin: 0.5px; + } + + + 0 + + + -1 + + + + + + + Ok + + + true + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/uploader/uploader.pro b/ground/openpilotgcs/src/plugins/uploader/uploader.pro index 9dbdcc56b..934252c5f 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploader.pro +++ b/ground/openpilotgcs/src/plugins/uploader/uploader.pro @@ -30,7 +30,8 @@ HEADERS += uploadergadget.h \ SSP/common.h \ runningdevicewidget.h \ uploader_global.h \ - enums.h + enums.h \ + rebootdialog.h SOURCES += uploadergadget.cpp \ uploadergadgetconfiguration.cpp \ @@ -44,14 +45,16 @@ SOURCES += uploadergadget.cpp \ SSP/port.cpp \ SSP/qssp.cpp \ SSP/qsspt.cpp \ - runningdevicewidget.cpp + runningdevicewidget.cpp \ + rebootdialog.cpp OTHER_FILES += Uploader.pluginspec FORMS += \ uploader.ui \ devicewidget.ui \ - runningdevicewidget.ui + runningdevicewidget.ui \ + rebootdialog.ui RESOURCES += uploader.qrc diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp index 390369624..73029dc95 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp @@ -45,7 +45,7 @@ Core::IUAVGadget *UploaderGadgetFactory::createGadget(QWidget *parent) isautocapable = gadgetWidget->autoUpdateCapable(); connect(this, SIGNAL(autoUpdate(bool)), gadgetWidget, SLOT(autoUpdate(bool))); - connect(this, SIGNAL(reboot()), gadgetWidget, SLOT(systemReboot())); + connect(this, SIGNAL(reboot()), gadgetWidget, SLOT(rebootWithDialog())); connect(gadgetWidget, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant))); return new UploaderGadget(QString("Uploader"), gadgetWidget, parent); } diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index 213c678a5..46a1b6cb0 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -41,6 +41,7 @@ #include #include #include +#include "rebootdialog.h" #define DFU_DEBUG true @@ -548,6 +549,12 @@ void UploaderGadgetWidget::systemEraseBoot() } } +void UploaderGadgetWidget::rebootWithDialog() +{ + RebootDialog dialog(this); + dialog.exec(); +} + void UploaderGadgetWidget::systemReboot() { ResultEventLoop eventLoop; diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h index b40c79022..7ffec5d08 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h @@ -160,6 +160,7 @@ private slots: void systemBoot(); void systemSafeBoot(); void systemEraseBoot(); + void rebootWithDialog(); void systemReboot(); void commonSystemBoot(bool safeboot = false, bool erase = false); void systemRescue();