mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-19 04:52:12 +01:00
OP-1628 Added software reboot to wizard.
This commit is contained in:
parent
a1e8d7efed
commit
82c65b6b3f
@ -27,10 +27,6 @@
|
||||
|
||||
#include "rebootpage.h"
|
||||
#include "ui_rebootpage.h"
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <uavobjectutil/uavobjectutilmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include "uploader/uploadergadgetfactory.h"
|
||||
|
||||
RebootPage::RebootPage(SetupWizard *wizard, QWidget *parent) :
|
||||
AbstractWizardPage(wizard, parent),
|
||||
@ -39,11 +35,11 @@ RebootPage::RebootPage(SetupWizard *wizard, QWidget *parent) :
|
||||
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);
|
||||
UploaderGadgetFactory *uploader = pm->getObject<UploaderGadgetFactory>();
|
||||
Q_ASSERT(uploader);
|
||||
connect(ui->rebootButton, SIGNAL(clicked()), uploader, SIGNAL(reboot()));
|
||||
m_uploader = pm->getObject<UploaderGadgetFactory>();
|
||||
Q_ASSERT(m_uploader);
|
||||
}
|
||||
|
||||
RebootPage::~RebootPage()
|
||||
@ -55,6 +51,8 @@ RebootPage::~RebootPage()
|
||||
|
||||
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);
|
||||
@ -74,3 +72,40 @@ void RebootPage::toggleLabel()
|
||||
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_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("<font color='red'>Software reboot failed!</font><p> 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("<font color='green'>Reboot complete!</font>"));
|
||||
}
|
||||
enableButtons(true);
|
||||
} else {
|
||||
ui->rebootProgress->setValue(ui->rebootProgress->value() + 1);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,9 @@
|
||||
#define REBOOTPAGE_H
|
||||
|
||||
#include "abstractwizardpage.h"
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include "uploader/uploadergadgetfactory.h"
|
||||
|
||||
namespace Ui {
|
||||
class RebootPage;
|
||||
@ -44,13 +47,17 @@ public:
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
|
||||
void enableButtons(bool enable);
|
||||
private:
|
||||
Ui::RebootPage *ui;
|
||||
QTimer m_timer;
|
||||
bool m_toggl;
|
||||
UploaderGadgetFactory *m_uploader;
|
||||
|
||||
private slots:
|
||||
void toggleLabel();
|
||||
void reboot();
|
||||
void progressUpdate(uploader::ProgressStep progress, QVariant message);
|
||||
};
|
||||
|
||||
#endif // REBOOTPAGE_H
|
||||
|
@ -49,15 +49,13 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="infoLabel">
|
||||
<property name="text">
|
||||
<string><!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. </span></p>
|
||||
<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;">There are two ways to reboot your board:</span></p>
|
||||
<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; font-weight:600; color:#000000;">1. Software Reboot</span><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; color:#000000;"><br />Press the button below to reboot board. Wait for the board to connect again before pressing Next. After board is connected press Next to continue wizard.<br /><br /></span><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600; color:#000000;">2. Power Cycle </span><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; color:#000000;"><br />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.</span></p></body></html></string>
|
||||
<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></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
@ -67,6 +65,45 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="messageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="rebootProgress">
|
||||
<property name="maximum">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QPushButton" name="rebootButton">
|
||||
<property name="text">
|
||||
@ -77,8 +114,11 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
<zorder>yellowLabel</zorder>
|
||||
<zorder>redLabel</zorder>
|
||||
<zorder>label_3</zorder>
|
||||
<zorder>infoLabel</zorder>
|
||||
<zorder>rebootButton</zorder>
|
||||
<zorder>verticalSpacer</zorder>
|
||||
<zorder>messageLabel</zorder>
|
||||
<zorder>rebootProgress</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -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(systemReset()));
|
||||
connect(this, SIGNAL(reboot()), gadgetWidget, SLOT(systemReboot()));
|
||||
connect(gadgetWidget, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)));
|
||||
return new UploaderGadget(QString("Uploader"), gadgetWidget, parent);
|
||||
}
|
||||
|
@ -548,6 +548,47 @@ void UploaderGadgetWidget::systemEraseBoot()
|
||||
}
|
||||
}
|
||||
|
||||
void UploaderGadgetWidget::systemReboot()
|
||||
{
|
||||
ResultEventLoop eventLoop;
|
||||
|
||||
connect(this, SIGNAL(bootloaderSuccess()), &eventLoop, SLOT(success()));
|
||||
connect(this, SIGNAL(bootloaderFailed()), &eventLoop, SLOT(fail()));
|
||||
|
||||
goToBootloader();
|
||||
|
||||
if (eventLoop.run(AUTOUPDATE_TIMEOUT) != 0) {
|
||||
emit progressUpdate(FAILURE, QVariant());
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(this, SIGNAL(bootloaderSuccess()), &eventLoop, SLOT(success()));
|
||||
disconnect(this, SIGNAL(bootloaderFailed()), &eventLoop, SLOT(fail()));
|
||||
|
||||
commonSystemBoot(false, false);
|
||||
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pluginManager);
|
||||
TelemetryManager *telemetryManager = pluginManager->getObject<TelemetryManager>();
|
||||
Q_ASSERT(telemetryManager);
|
||||
|
||||
if (!telemetryManager->isConnected()) {
|
||||
progressUpdate(BOOTING, QVariant());
|
||||
ResultEventLoop eventLoop;
|
||||
|
||||
connect(telemetryManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
|
||||
if (eventLoop.run(AUTOUPDATE_TIMEOUT) != 0) {
|
||||
emit progressUpdate(FAILURE, QVariant());
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(telemetryManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
}
|
||||
|
||||
emit progressUpdate(SUCCESS, QVariant());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the system to boot (from Bootloader state)
|
||||
* @param[in] safeboot Indicates whether the firmware should use the stock HWSettings
|
||||
|
@ -160,6 +160,7 @@ private slots:
|
||||
void systemBoot();
|
||||
void systemSafeBoot();
|
||||
void systemEraseBoot();
|
||||
void systemReboot();
|
||||
void commonSystemBoot(bool safeboot = false, bool erase = false);
|
||||
void systemRescue();
|
||||
void getSerialPorts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user