From 7177e77d2333e7b14eefceec0aee10ef1d11332e Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Mon, 9 Feb 2015 00:52:46 +0100 Subject: [PATCH] OP-1685 - Show a warning in output tab if config issues are found --- .../src/plugins/config/configgadget.qrc | 1 + .../src/plugins/config/configoutputwidget.cpp | 36 ++- .../src/plugins/config/configoutputwidget.h | 7 +- .../src/plugins/config/images/error.svg | 35 +++ .../openpilotgcs/src/plugins/config/output.ui | 223 ++++++++++++------ 5 files changed, 224 insertions(+), 78 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/images/error.svg diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index 01984a553..d89ac5bca 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -54,5 +54,6 @@ images/calibration/plane-swd.png images/calibration/board-swd.png images/gear.png + images/error.svg diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index 330911bf4..15163a142 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -32,7 +32,6 @@ #include "mixersettings.h" #include "actuatorcommand.h" #include "actuatorsettings.h" -#include "systemalarms.h" #include "systemsettings.h" #include "uavsettingsimportexport/uavsettingsimportexportfactory.h" #include @@ -53,6 +52,8 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren ui = new Ui_OutputWidget(); ui->setupUi(this); + ui->gvWarning->setScene(new QGraphicsScene(this)); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); if (!settings->useExpertMode()) { @@ -105,12 +106,16 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren addWidgetBinding("ActuatorSettings", "BankMode", ui->cb_outputMode5, 4, 0, true); addWidgetBinding("ActuatorSettings", "BankMode", ui->cb_outputMode6, 5, 0, true); + systemAlarmsObj = SystemAlarms::GetInstance(getObjectManager()); + connect(systemAlarmsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateWarnings(UAVObject *))); + disconnect(this, SLOT(refreshWidgetsValues(UAVObject *))); populateWidgets(); refreshWidgetsValues(); updateEnableControls(); + setWarning("PIppo"); } ConfigOutputWidget::~ConfigOutputWidget() @@ -145,7 +150,6 @@ void ConfigOutputWidget::sendAllChannelTests() */ void ConfigOutputWidget::runChannelTests(bool state) { - SystemAlarms *systemAlarmsObj = SystemAlarms::GetInstance(getObjectManager()); SystemAlarms::DataFields systemAlarms = systemAlarmsObj->getData(); if (state && systemAlarms.Alarm[SystemAlarms::ALARM_ACTUATOR] != SystemAlarms::ALARM_OK) { @@ -436,3 +440,31 @@ void ConfigOutputWidget::stopTests() { ui->channelOutTest->setChecked(false); } + +void ConfigOutputWidget::updateWarnings(UAVObject *) +{ + SystemAlarms::DataFields systemAlarms = systemAlarmsObj->getData(); + + if (systemAlarms.Alarm[SystemAlarms::ALARM_SYSTEMCONFIGURATION] > SystemAlarms::ALARM_WARNING) { + switch (systemAlarms.ExtendedAlarmStatus[SystemAlarms::EXTENDEDALARMSTATUS_SYSTEMCONFIGURATION]) { + case SystemAlarms::EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT: + setWarning(tr("OneShot only works with MainPort settings marked with \"+OneShot\"")); + return; + } + } + setWarning(NULL); +} + +void ConfigOutputWidget::setWarning(QString message) +{ + ui->gvWarning->scene()->clear(); + if (!message.isNull()) { + warningPic.load(":/configgadget/images/error.svg"); + } else { + warningPic.load(""); + } + ui->gvWarning->scene()->addPixmap(warningPic); + ui->gvWarning->setSceneRect(warningPic.rect()); + ui->gvWarning->fitInView(warningPic.rect(), Qt::KeepAspectRatio); + ui->txtWarning->setText(message); +} diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index 3b25fed69..c495bbd65 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -37,6 +37,8 @@ #include #include +#include "systemalarms.h" + class Ui_OutputWidget; class OutputChannelForm; @@ -50,11 +52,12 @@ public: protected: void enableControls(bool enable); + void setWarning(QString message); private: Ui_OutputWidget *ui; QList sliders; - + QPixmap warningPic; void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value); void assignOutputChannel(UAVDataObject *obj, QString &str); @@ -69,7 +72,9 @@ private: UAVObject::Metadata accInitialData; + SystemAlarms *systemAlarmsObj; private slots: + void updateWarnings(UAVObject *); void stopTests(); virtual void refreshWidgetsValues(UAVObject *obj = NULL); void updateObjectsFromWidgets(); diff --git a/ground/openpilotgcs/src/plugins/config/images/error.svg b/ground/openpilotgcs/src/plugins/config/images/error.svg new file mode 100644 index 000000000..8de454769 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/images/error.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/output.ui b/ground/openpilotgcs/src/plugins/config/output.ui index f804aab1d..4a9211f24 100644 --- a/ground/openpilotgcs/src/plugins/config/output.ui +++ b/ground/openpilotgcs/src/plugins/config/output.ui @@ -6,7 +6,7 @@ 0 0 - 698 + 765 754 @@ -122,8 +122,8 @@ 0 0 - 680 - 672 + 799 + 659 @@ -190,54 +190,83 @@ - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 5 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 5 - 20 - - - + + + + + + + 52 + 52 + + + + + 52 + 52 + + + + background: transparent + + + QFrame::NoFrame + + + QPainter::HighQualityAntialiasing + + + + + + + + 0 + 0 + + + + + 200 + 50 + + + + + 16777215 + 50 + + + + + 10 + 50 + false + + + + Calibration status + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustIgnored + + + Qt::NoTextInteraction + + + + - - + Qt::AlignCenter @@ -281,6 +310,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -350,6 +385,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -437,6 +478,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -502,6 +549,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -577,6 +630,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -642,6 +701,12 @@ 20 + + + 70 + 16777215 + + Setup PWM rate here: usual value is 490 Hz for multirotor airframes. OneShot and OneShot125 does not use this value @@ -690,34 +755,6 @@ - - - - - 0 - 0 - - - - - 0 - 20 - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 5 - 20 - - - - @@ -757,6 +794,12 @@ 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs. Several other ESCs like BLHeli 13+ can use the more advanced OneShot125. @@ -781,6 +824,12 @@ When using OneShot125 all values set in min/max and idle are divided by eight be 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs.\nSeveral other ESCs like BLHeli 13+ can use the more advanced OneShot125.\nWhen using OneShot125 all values set in min/max and idle are divided by eight before being sent to esc (i.e. 1000 = 125, 2000 = 250). @@ -803,6 +852,12 @@ When using OneShot125 all values set in min/max and idle are divided by eight be 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs.\nSeveral other ESCs like BLHeli 13+ can use the more advanced OneShot125.\nWhen using OneShot125 all values set in min/max and idle are divided by eight before being sent to esc (i.e. 1000 = 125, 2000 = 250). @@ -825,6 +880,12 @@ When using OneShot125 all values set in min/max and idle are divided by eight be 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs.\nSeveral other ESCs like BLHeli 13+ can use the more advanced OneShot125.\nWhen using OneShot125 all values set in min/max and idle are divided by eight before being sent to esc (i.e. 1000 = 125, 2000 = 250). @@ -847,6 +908,12 @@ When using OneShot125 all values set in min/max and idle are divided by eight be 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs.\nSeveral other ESCs like BLHeli 13+ can use the more advanced OneShot125.\nWhen using OneShot125 all values set in min/max and idle are divided by eight before being sent to esc (i.e. 1000 = 125, 2000 = 250). @@ -869,6 +936,12 @@ When using OneShot125 all values set in min/max and idle are divided by eight be 20 + + + 70 + 16777215 + + Setup output mode. Use PWM or OneShot with Standard ESCs.\nSeveral other ESCs like BLHeli 13+ can use the more advanced OneShot125.\nWhen using OneShot125 all values set in min/max and idle are divided by eight before being sent to esc (i.e. 1000 = 125, 2000 = 250).