mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-690 Added flight status check on system Reset similar to the check on Halt. Re-factored method to get hold of current FlightStatus UAVO from UAVOManager.
This commit is contained in:
parent
4a16909cb3
commit
f1590a4f66
@ -121,6 +121,18 @@ void UploaderGadgetWidget::connectSignalSlot(QWidget *widget)
|
||||
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(uploadStarted()),this,SLOT(uploadStarted()));
|
||||
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(uploadEnded(bool)),this,SLOT(uploadEnded(bool)));
|
||||
}
|
||||
|
||||
FlightStatus *UploaderGadgetWidget::getFlightStatus()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
FlightStatus *status = dynamic_cast<FlightStatus*>(objManager->getObject(QString("FlightStatus")));
|
||||
Q_ASSERT(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
void UploaderGadgetWidget::onPhisicalHWConnect()
|
||||
{
|
||||
m_config->bootButton->setEnabled(false);
|
||||
@ -351,12 +363,7 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
|
||||
|
||||
void UploaderGadgetWidget::systemHalt()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
FlightStatus *status = dynamic_cast<FlightStatus*>(objManager->getObject(QString("FlightStatus")));
|
||||
Q_ASSERT(status);
|
||||
FlightStatus* status = getFlightStatus();
|
||||
|
||||
// The board can not be halted when in armed state.
|
||||
// If board is armed, or arming. Show message with notice.
|
||||
@ -366,7 +373,9 @@ void UploaderGadgetWidget::systemHalt()
|
||||
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.")));
|
||||
"Please make sure the board is not armed and then press halt again to proceed.\n"
|
||||
"Or.\n"
|
||||
"Use the rescue option to force a firmware upgrade.")));
|
||||
mbox.setStandardButtons(QMessageBox::Ok);
|
||||
mbox.setIcon(QMessageBox::Warning);
|
||||
mbox.exec();
|
||||
@ -380,14 +389,30 @@ void UploaderGadgetWidget::systemHalt()
|
||||
*/
|
||||
void UploaderGadgetWidget::systemReset()
|
||||
{
|
||||
resetOnly = true;
|
||||
if (dfu) {
|
||||
delete dfu;
|
||||
dfu = NULL;
|
||||
FlightStatus* status = getFlightStatus();
|
||||
|
||||
// The board can not be reset when in armed state.
|
||||
// If board is armed, or arming. Show message with notice.
|
||||
if (status->getArmed() == FlightStatus::ARMED_DISARMED) {
|
||||
resetOnly = true;
|
||||
if (dfu) {
|
||||
delete dfu;
|
||||
dfu = NULL;
|
||||
}
|
||||
m_config->textBrowser->clear();
|
||||
log("Board Reset initiated.");
|
||||
goToBootloader();
|
||||
}
|
||||
else {
|
||||
QMessageBox mbox(this);
|
||||
mbox.setText(QString(tr("The controller board is armed and can not be reset.\n"
|
||||
"Please make sure the board is not armed and then press reset again to proceed.\n"
|
||||
"Or.\n"
|
||||
"Use the rescue option to force a firmware upgrade.")));
|
||||
mbox.setStandardButtons(QMessageBox::Ok);
|
||||
mbox.setIcon(QMessageBox::Warning);
|
||||
mbox.exec();
|
||||
}
|
||||
m_config->textBrowser->clear();
|
||||
log("Board Reset initiated.");
|
||||
goToBootloader();
|
||||
}
|
||||
|
||||
void UploaderGadgetWidget::systemBoot()
|
||||
|
@ -61,6 +61,8 @@
|
||||
using namespace OP_DFU;
|
||||
using namespace uploader;
|
||||
|
||||
class FlightStatus;
|
||||
|
||||
class UPLOADER_EXPORT UploaderGadgetWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -94,6 +96,7 @@ private:
|
||||
QErrorMessage * msg;
|
||||
void connectSignalSlot(QWidget * widget);
|
||||
int autoUpdateConnectTimeout;
|
||||
FlightStatus * getFlightStatus();
|
||||
private slots:
|
||||
void onPhisicalHWConnect();
|
||||
void versionMatchCheck();
|
||||
|
Loading…
x
Reference in New Issue
Block a user