From 3bf7dbd7e5388e822b5d22cde2fe3b241082137e Mon Sep 17 00:00:00 2001 From: zedamota Date: Tue, 19 Jul 2011 14:50:42 +0100 Subject: [PATCH 1/5] Added new hw config tab to the config gadget. Created new helper class for update/save buttons which creates a visual feedback of the op result. --- .../src/plugins/config/cc_hw_settings.ui | 201 ++ .../src/plugins/config/config.pro | 20 +- .../plugins/config/config_cc_hw_widget.cpp | 126 + .../src/plugins/config/config_cc_hw_widget.h | 58 + ...trywidget.cpp => config_pro_hw_widget.cpp} | 16 +- ...lemetrywidget.h => config_pro_hw_widget.h} | 16 +- .../src/plugins/config/configgadget.qrc | 34 +- .../src/plugins/config/configgadgetwidget.cpp | 30 +- .../src/plugins/config/defaulthwsettings.ui | 77 + .../config/defaulthwsettingswidget.cpp | 44 + .../plugins/config/defaulthwsettingswidget.h | 55 + .../plugins/config/images/coptercontrol.svg | 2647 +++++++++++++++++ .../src/plugins/config/images/hw_config.svg | 88 + .../{telemetry.ui => pro_hw_settings.ui} | 4 +- .../src/plugins/config/smartsavebutton.cpp | 113 + .../src/plugins/config/smartsavebutton.h | 44 + 16 files changed, 3524 insertions(+), 49 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui create mode 100644 ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h rename ground/openpilotgcs/src/plugins/config/{configtelemetrywidget.cpp => config_pro_hw_widget.cpp} (89%) rename ground/openpilotgcs/src/plugins/config/{configtelemetrywidget.h => config_pro_hw_widget.h} (83%) create mode 100644 ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui create mode 100644 ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h create mode 100644 ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg create mode 100644 ground/openpilotgcs/src/plugins/config/images/hw_config.svg rename ground/openpilotgcs/src/plugins/config/{telemetry.ui => pro_hw_settings.ui} (98%) create mode 100644 ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/smartsavebutton.h diff --git a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui new file mode 100644 index 000000000..188706190 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui @@ -0,0 +1,201 @@ + + + CC_HW_Widget + + + + 0 + 0 + 517 + 487 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + :/configgadget/images/coptercontrol.svg + + + true + + + + + + + + + + + + + MainPort + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + + + + + Flexiport + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + dkwtc + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 11 + 75 + true + + + + Telemetry speed: + + + + + + + Select the speed here. + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Send to OpenPilot but don't write in SD. +Beware of not locking yourself out! + + + true + + + + + + Apply + + + false + + + + + + + Applies and Saves all settings to SD. +Beware of not locking yourself out! + + + false + + + + + + Save + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 4918feb53..79ddea046 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -24,7 +24,8 @@ HEADERS += configplugin.h \ configoutputwidget.h \ configtaskwidget.h \ configairframewidget.h \ - configtelemetrywidget.h \ + config_pro_hw_widget.h \ + config_cc_hw_widget.h \ configahrswidget.h \ configccattitudewidget.h \ mixercurvewidget.h \ @@ -34,7 +35,9 @@ HEADERS += configplugin.h \ configstabilizationwidget.h \ assertions.h \ calibration.h \ - defaultattitudewidget.h + defaultattitudewidget.h \ + smartsavebutton.h \ + defaulthwsettingswidget.h SOURCES += configplugin.cpp \ configgadgetconfiguration.cpp \ @@ -47,7 +50,8 @@ SOURCES += configplugin.cpp \ configinputwidget.cpp \ configoutputwidget.cpp \ configairframewidget.cpp \ - configtelemetrywidget.cpp \ + config_pro_hw_widget.cpp \ + config_cc_hw_widget.cpp \ configahrswidget.cpp \ configccattitudewidget.cpp \ mixercurvewidget.cpp \ @@ -59,17 +63,21 @@ SOURCES += configplugin.cpp \ legacy-calibration.cpp \ gyro-calibration.cpp \ alignment-calibration.cpp \ - defaultattitudewidget.cpp + defaultattitudewidget.cpp \ + smartsavebutton.cpp \ + defaulthwsettingswidget.cpp FORMS += \ airframe.ui \ - telemetry.ui \ + cc_hw_settings.ui \ + pro_hw_settings.ui \ ahrs.ui \ ccpm.ui \ stabilization.ui \ input.ui \ output.ui \ ccattitude.ui \ - defaultattitude.ui + defaultattitude.ui \ + defaulthwsettings.ui RESOURCES += configgadget.qrc diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp new file mode 100644 index 000000000..f1c9122fb --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -0,0 +1,126 @@ +/** + ****************************************************************************** + * + * @file configtelemetrywidget.h + * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief The Configuration Gadget used to update settings in the firmware + *****************************************************************************/ +/* + * 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 "config_cc_hw_widget.h" + +#include +#include +#include +#include +#include +#include + + +ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) +{ + m_telemetry = new Ui_CC_HW_Widget(); + m_telemetry->setupUi(this); + smartsave=new smartSaveButton(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); + // Now connect the widget to the ManualControlCommand / Channel UAVObject + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + + UAVObject *obj = objManager->getObject(QString("TelemetrySettings")); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); + smartsave->addObject(obj); + UAVObjectField *field = obj->getField(QString("Speed")); + m_telemetry->telemetrySpeed->addItems(field->getOptions()); + + obj = objManager->getObject(QString("HwSettings")); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); + smartsave->addObject(obj); + field = obj->getField(QString("CC_FlexiPort")); + m_telemetry->cbFlexi->addItems(field->getOptions()); + + field = obj->getField(QString("CC_MainPort")); + m_telemetry->cbTele->addItems(field->getOptions()); + + connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(saveTelemetryUpdate())); + + enableControls(false); + refreshValues(); + connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); + connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); +} + +ConfigCCHWWidget::~ConfigCCHWWidget() +{ + // Do nothing +} + + +/******************************* + * Telemetry Settings + *****************************/ + +void ConfigCCHWWidget::enableControls(bool enable) +{ + m_telemetry->saveTelemetryToSD->setEnabled(enable); + //m_telemetry->saveTelemetryToRAM->setEnabled(enable); +} + +/** + Request telemetry settings from the board + */ +void ConfigCCHWWidget::refreshValues() +{ + qDebug()<<"refreshvalues"; + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("TelemetrySettings"))); + Q_ASSERT(obj); + UAVObjectField *field = obj->getField(QString("Speed")); + m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString())); + qDebug()<getValue().toString(); + obj = dynamic_cast(objManager->getObject(QString("HwSettings"))); + Q_ASSERT(obj); + field = obj->getField(QString("CC_FlexiPort")); + m_telemetry->cbFlexi->setCurrentIndex(m_telemetry->cbFlexi->findText(field->getValue().toString())); + qDebug()<getValue().toString(); + field = obj->getField(QString("CC_MainPort")); + m_telemetry->cbTele->setCurrentIndex(m_telemetry->cbTele->findText(field->getValue().toString())); + qDebug()<getValue().toString(); +} + + +/** + Send telemetry settings to the board and request saving to SD card + */ +void ConfigCCHWWidget::saveTelemetryUpdate() +{ + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); + Q_ASSERT(obj); + UAVObjectField* field = obj->getField(QString("Speed")); + field->setValue(m_telemetry->telemetrySpeed->currentText()); + obj = dynamic_cast(getObjectManager()->getObject(QString("HwSettings"))); + Q_ASSERT(obj); + field = obj->getField(QString("CC_FlexiPort")); + field->setValue(m_telemetry->cbFlexi->currentText()); + field = obj->getField(QString("CC_MainPort")); + field->setValue(m_telemetry->cbTele->currentText()); + + +} diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h new file mode 100644 index 000000000..9ad52d9bc --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h @@ -0,0 +1,58 @@ +/** + ****************************************************************************** + * + * @file configtelemetrytwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Telemetry configuration panel + *****************************************************************************/ +/* + * 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 + */ +#ifndef CONFIGCCHWWIDGET_H +#define CONFIGCCHWWIDGET_H + +#include "ui_cc_hw_settings.h" +#include "configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include "smartsavebutton.h" + +class ConfigCCHWWidget: public ConfigTaskWidget +{ + Q_OBJECT + +public: + ConfigCCHWWidget(QWidget *parent = 0); + ~ConfigCCHWWidget(); + +private: + Ui_CC_HW_Widget *m_telemetry; + void enableControls(bool enable); + smartSaveButton *smartsave; + +private slots: + virtual void refreshValues(); + void saveTelemetryUpdate(); + +}; + +#endif // CONFIGCCHWWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp similarity index 89% rename from ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp rename to ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp index 2b1a8e873..149f92b73 100644 --- a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp @@ -24,7 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "configtelemetrywidget.h" +#include "config_pro_hw_widget.h" #include #include @@ -34,9 +34,9 @@ #include -ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget(parent) +ConfigProHWWidget::ConfigProHWWidget(QWidget *parent) : ConfigTaskWidget(parent) { - m_telemetry = new Ui_TelemetryWidget(); + m_telemetry = new Ui_PRO_HW_Widget(); m_telemetry->setupUi(this); // Now connect the widget to the ManualControlCommand / Channel UAVObject @@ -57,7 +57,7 @@ ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); } -ConfigTelemetryWidget::~ConfigTelemetryWidget() +ConfigProHWWidget::~ConfigProHWWidget() { // Do nothing } @@ -67,7 +67,7 @@ ConfigTelemetryWidget::~ConfigTelemetryWidget() * Telemetry Settings *****************************/ -void ConfigTelemetryWidget::enableControls(bool enable) +void ConfigProHWWidget::enableControls(bool enable) { m_telemetry->saveTelemetryToSD->setEnabled(enable); //m_telemetry->saveTelemetryToRAM->setEnabled(enable); @@ -76,7 +76,7 @@ void ConfigTelemetryWidget::enableControls(bool enable) /** Request telemetry settings from the board */ -void ConfigTelemetryWidget::refreshValues() +void ConfigProHWWidget::refreshValues() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); @@ -89,7 +89,7 @@ void ConfigTelemetryWidget::refreshValues() /** Send telemetry settings to the board */ -void ConfigTelemetryWidget::sendTelemetryUpdate() +void ConfigProHWWidget::sendTelemetryUpdate() { UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); Q_ASSERT(obj); @@ -101,7 +101,7 @@ void ConfigTelemetryWidget::sendTelemetryUpdate() /** Send telemetry settings to the board and request saving to SD card */ -void ConfigTelemetryWidget::saveTelemetryUpdate() +void ConfigProHWWidget::saveTelemetryUpdate() { // Send update so that the latest value is saved sendTelemetryUpdate(); diff --git a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h similarity index 83% rename from ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h rename to ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h index f36ba1a4e..254cf7af0 100644 --- a/ground/openpilotgcs/src/plugins/config/configtelemetrywidget.h +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h @@ -24,10 +24,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CONFIGTELEMETRYWIDGET_H -#define CONFIGTELEMETRYWIDGET_H +#ifndef CONFIGPROHWWIDGET_H +#define CONFIGPROHWWIDGET_H -#include "ui_telemetry.h" +#include "ui_pro_hw_settings.h" #include "configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" @@ -36,16 +36,16 @@ #include -class ConfigTelemetryWidget: public ConfigTaskWidget +class ConfigProHWWidget: public ConfigTaskWidget { Q_OBJECT public: - ConfigTelemetryWidget(QWidget *parent = 0); - ~ConfigTelemetryWidget(); + ConfigProHWWidget(QWidget *parent = 0); + ~ConfigProHWWidget(); private: - Ui_TelemetryWidget *m_telemetry; + Ui_PRO_HW_Widget *m_telemetry; void enableControls(bool enable); private slots: @@ -55,4 +55,4 @@ private slots: }; -#endif // ConfigTelemetryWidget_H +#endif // CONFIGPROHWWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index 30f9431e3..f53d5811f 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -1,18 +1,20 @@ - - images/help2.png - images/XBee.svg - images/Airframe.png - images/Servo.png - images/ahrs-calib.svg - images/AHRS-v1.3.png - images/paper-plane.svg - images/curve-bg.svg - images/quad-shapes.svg - images/ccpm_setup.svg - images/PipXtreme.png - images/gyroscope.svg - images/Transmitter.png - images/help.png - + + images/help2.png + images/XBee.svg + images/Airframe.png + images/Servo.png + images/ahrs-calib.svg + images/AHRS-v1.3.png + images/paper-plane.svg + images/curve-bg.svg + images/quad-shapes.svg + images/ccpm_setup.svg + images/PipXtreme.png + images/gyroscope.svg + images/Transmitter.png + images/help.png + images/coptercontrol.svg + images/hw_config.svg + diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp index f19b414c4..d424385c5 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp @@ -33,9 +33,10 @@ #include "configinputwidget.h" #include "configoutputwidget.h" #include "configstabilizationwidget.h" -#include "configtelemetrywidget.h" +#include "config_pro_hw_widget.h" +#include "config_cc_hw_widget.h" #include "defaultattitudewidget.h" - +#include "defaulthwsettingswidget.h" #include "uavobjectutilmanager.h" #include @@ -62,23 +63,26 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) // ********************* QWidget *qwd; + qwd = new DefaultHwSettingsWidget(this); + ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + qwd = new ConfigAirframeWidget(this); - ftw->insertTab(0, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); + ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); qwd = new ConfigInputWidget(this); - ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); + ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); qwd = new ConfigOutputWidget(this); - ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); + ftw->insertTab(3, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); qwd = new DefaultAttitudeWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->insertTab(4, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); qwd = new ConfigStabilizationWidget(this); - ftw->insertTab(4, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); + ftw->insertTab(5, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); - qwd = new ConfigTelemetryWidget(this); - ftw->insertTab(5, qwd, QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry")); + qwd = new ConfigProHWWidget(this); + ftw->insertTab(6, qwd, QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry")); // qwd = new ConfigPipXtremeWidget(this); @@ -132,12 +136,20 @@ void ConfigGadgetWidget::onAutopilotConnect() { ftw->removeTab(3); QWidget *qwd = new ConfigCCAttitudeWidget(this); ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude")); + ftw->removeTab(0); + qwd = new ConfigCCHWWidget(this); + ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(0); } else if ((board & 0xff00) == 256 ) { // Mainboard family ftw->setCurrentIndex(0); ftw->removeTab(3); QWidget *qwd = new ConfigAHRSWidget(this); ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->removeTab(0); + qwd = new ConfigProHWWidget(this); + ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(0); } } emit autopilotConnected(); diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui b/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui new file mode 100644 index 000000000..d1ef7d913 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettings.ui @@ -0,0 +1,77 @@ + + + defaulthwsettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt; font-weight:600;">Hardware Configuration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt; font-weight:600;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">This panel will be updated to provide the relevant controls to let you configure your hardware once telemetry is connected and running.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p></body></html> + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp new file mode 100644 index 000000000..a6d0c10e7 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * + * @file DefaultHwSettingsWidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Placeholder for attitude panel until board is connected. + *****************************************************************************/ +/* + * 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 "DefaultHwSettingsWidget.h" +#include "ui_defaultattitude.h" +#include +#include +#include + +DefaultHwSettingsWidget::DefaultHwSettingsWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui_defaulthwsettings) +{ + ui->setupUi(this); +} + +DefaultHwSettingsWidget::~DefaultHwSettingsWidget() +{ + delete ui; +} + diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h new file mode 100644 index 000000000..e94435f8d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.h @@ -0,0 +1,55 @@ +/** + ****************************************************************************** + * + * @file defaultccattitudewidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Placeholder for attitude settings widget until board connected. + *****************************************************************************/ +/* + * 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 + */ +#ifndef DEFAULTHWSETTINGSt_H +#define DEFAULTHWSETTINGSt_H + +#include "ui_defaulthwsettings.h" +#include "configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include + +class Ui_Widget; + +class DefaultHwSettingsWidget : public QWidget +{ + Q_OBJECT + +public: + explicit DefaultHwSettingsWidget(QWidget *parent = 0); + ~DefaultHwSettingsWidget(); + +private slots: + +private: + Ui_defaulthwsettings *ui; +}; + +#endif // DEFAULTHWSETTINGSt_H diff --git a/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg b/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg new file mode 100644 index 000000000..669199ef6 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/images/coptercontrol.svg @@ -0,0 +1,2647 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/config/images/hw_config.svg b/ground/openpilotgcs/src/plugins/config/images/hw_config.svg new file mode 100644 index 000000000..a40c3c3f3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/images/hw_config.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/telemetry.ui b/ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui similarity index 98% rename from ground/openpilotgcs/src/plugins/config/telemetry.ui rename to ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui index 0db9c9299..6e6751b87 100644 --- a/ground/openpilotgcs/src/plugins/config/telemetry.ui +++ b/ground/openpilotgcs/src/plugins/config/pro_hw_settings.ui @@ -1,7 +1,7 @@ - TelemetryWidget - + PRO_HW_Widget + 0 diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp new file mode 100644 index 000000000..f9771f1a1 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -0,0 +1,113 @@ +#include "smartsavebutton.h" + +smartSaveButton::smartSaveButton(QPushButton * update, QPushButton * save):bupdate(update),bsave(save) +{ + connect(bsave,SIGNAL(clicked()),this,SLOT(processClick())); + connect(bupdate,SIGNAL(clicked()),this,SLOT(processClick())); + +} +void smartSaveButton::processClick() +{ + bool save=false; + QPushButton *button=bupdate; + if(sender()==bsave) + { + save=true; + button=bsave; + } + emit preProcessOperations(); + button->setEnabled(false); + button->setIcon(QIcon(":/uploader/images/system-run.svg")); + QTimer timer; + timer.setSingleShot(true); + bool error=false; + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager* utilMngr = pm->getObject(); + foreach(UAVObject * obj,objects) + { + up_result=false; + current_object=obj; + for(int i=0;i<3;++i) + { + + connect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool))); + connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + obj->updated(); + timer.start(1000); + loop.exec(); + timer.stop(); + disconnect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool))); + disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + if(up_result) + break; + } + if(up_result==false) + { + error=true; + continue; + } + sv_result=false; + current_objectID=obj->getObjID(); + if(save) + { + for(int i=0;i<3;++i) + { + connect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); + connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + utilMngr->saveObjectToSD(obj); + timer.start(1000); + loop.exec(); + timer.stop(); + disconnect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool))); + disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit())); + if(sv_result) + break; + } + if(sv_result==false) + { + error=true; + } + } + } + button->setEnabled(true); + if(!error) + { + button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); + } + else + { + button->setIcon(QIcon(":/uploader/images/process-stop.svg")); + } +} + +void smartSaveButton::setObjects(QList list) +{ + objects=list; +} + +void smartSaveButton::addObject(UAVObject * obj) +{ + objects.append(obj); +} + +void smartSaveButton::clearObjects() +{ + objects.clear(); +} +void smartSaveButton::transaction_finished(UAVObject* obj, bool result) +{ + if(current_object==obj) + { + up_result=result; + loop.quit(); + } +} + +void smartSaveButton::saving_finished(int id, bool result) +{ + if(id==current_objectID) + { + sv_result=result; + loop.quit(); + } +} diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h new file mode 100644 index 000000000..b086a04f1 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h @@ -0,0 +1,44 @@ +#ifndef SMARTSAVEBUTTON_H +#define SMARTSAVEBUTTON_H + +#include "uavtalk/telemetrymanager.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include +#include +#include +#include "uavobjectutilmanager.h" +#include +class smartSaveButton:public QObject +{ +public: + Q_OBJECT +public: + smartSaveButton(QPushButton * update,QPushButton * save); + void setObjects(QList); + void addObject(UAVObject *); + void clearObjects(); +signals: + void preProcessOperations(); +private slots: + void processClick(); + void transaction_finished(UAVObject* obj, bool result); + void saving_finished(int,bool); + +private: + QPushButton *bupdate; + QPushButton *bsave; + quint32 current_objectID; + UAVObject * current_object; + bool up_result; + bool sv_result; + QEventLoop loop; + QList objects; +protected: + + +}; + + +#endif // SMARTSAVEBUTTON_H From 05f6904e09f319aeec6cca300b3aeadf2eeceeb3 Mon Sep 17 00:00:00 2001 From: zedamota Date: Thu, 21 Jul 2011 15:35:59 +0100 Subject: [PATCH 2/5] Fix tab order. Switch to using unum for tabs. --- .../plugins/config/config_cc_hw_widget.cpp | 1 + .../src/plugins/config/configgadgetwidget.cpp | 38 +++++++++---------- .../src/plugins/config/configgadgetwidget.h | 1 + 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index f1c9122fb..6caf32d09 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -69,6 +69,7 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) ConfigCCHWWidget::~ConfigCCHWWidget() { // Do nothing + delete smartsave; } diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp index d424385c5..f1f93c9d7 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp @@ -64,25 +64,23 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent) QWidget *qwd; qwd = new DefaultHwSettingsWidget(this); - ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); qwd = new ConfigAirframeWidget(this); - ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); + ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft")); qwd = new ConfigInputWidget(this); - ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); + ftw->insertTab(ConfigGadgetWidget::input, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input")); qwd = new ConfigOutputWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); + ftw->insertTab(ConfigGadgetWidget::output, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output")); qwd = new DefaultAttitudeWidget(this); - ftw->insertTab(4, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); qwd = new ConfigStabilizationWidget(this); - ftw->insertTab(5, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); + ftw->insertTab(ConfigGadgetWidget::stabilization, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization")); - qwd = new ConfigProHWWidget(this); - ftw->insertTab(6, qwd, QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry")); // qwd = new ConfigPipXtremeWidget(this); @@ -132,24 +130,24 @@ void ConfigGadgetWidget::onAutopilotConnect() { if ((board & 0xff00) == 1024) { // CopterControl family // Delete the INS panel, replace with CC Panel: - ftw->setCurrentIndex(0); - ftw->removeTab(3); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + ftw->removeTab(ConfigGadgetWidget::ins); QWidget *qwd = new ConfigCCAttitudeWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude")); - ftw->removeTab(0); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude")); + ftw->removeTab(ConfigGadgetWidget::hardware); qwd = new ConfigCCHWWidget(this); - ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); - ftw->setCurrentIndex(0); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); } else if ((board & 0xff00) == 256 ) { // Mainboard family - ftw->setCurrentIndex(0); - ftw->removeTab(3); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); + ftw->removeTab(ConfigGadgetWidget::ins); QWidget *qwd = new ConfigAHRSWidget(this); - ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); - ftw->removeTab(0); + ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS")); + ftw->removeTab(ConfigGadgetWidget::hardware); qwd = new ConfigProHWWidget(this); - ftw->insertTab(0, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); - ftw->setCurrentIndex(0); + ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.svg"), QString("HW Settings")); + ftw->setCurrentIndex(ConfigGadgetWidget::hardware); } } emit autopilotConnected(); diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h index 43db58429..84d65b383 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h @@ -49,6 +49,7 @@ class ConfigGadgetWidget: public QWidget public: ConfigGadgetWidget(QWidget *parent = 0); ~ConfigGadgetWidget(); + enum widgetTabs {hardware=0, aircraft, input, output, ins, stabilization}; public slots: void onAutopilotConnect(); From 4dc5e7ea651faaface7d8a6f68fff1746760f64e Mon Sep 17 00:00:00 2001 From: zedamota Date: Mon, 25 Jul 2011 14:18:09 +0100 Subject: [PATCH 3/5] Fixed included file case. Changed "throttle curve 1/2" to "curve 1/2". --- ground/openpilotgcs/src/plugins/config/airframe.ui | 12 ++++++------ .../src/plugins/config/defaulthwsettingswidget.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 4b2b44ce8..1f3c6446a 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -74,7 +74,7 @@ - 1 + 3 @@ -1138,7 +1138,7 @@ Typical value is 50% for + or X configuration on quads. - Throtle Curve 1 + Curve 1 @@ -1208,7 +1208,7 @@ Typical value is 50% for + or X configuration on quads. - Throtle Curve 2 + Curve 2 @@ -2082,14 +2082,14 @@ p, li { white-space: pre-wrap; } <!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:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</p></td></tr></table></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</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:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> diff --git a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp index a6d0c10e7..69eef9117 100644 --- a/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/defaulthwsettingswidget.cpp @@ -24,7 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "DefaultHwSettingsWidget.h" +#include "defaulthwsettingswidget.h" #include "ui_defaultattitude.h" #include #include From 79404ab80edc4cb5c4c5c72e0ba4a4ca189293c1 Mon Sep 17 00:00:00 2001 From: zedamota Date: Mon, 25 Jul 2011 23:18:41 +0100 Subject: [PATCH 4/5] Moved input type to hw config tab. Created error message for unsupported configs. --- .../src/plugins/config/cc_hw_settings.ui | 23 +++- .../plugins/config/config_cc_hw_widget.cpp | 110 ++++++------------ .../src/plugins/config/config_cc_hw_widget.h | 10 +- .../plugins/config/config_pro_hw_widget.cpp | 59 +--------- .../src/plugins/config/config_pro_hw_widget.h | 3 - .../src/plugins/config/configinputwidget.cpp | 11 +- .../src/plugins/config/configtaskwidget.cpp | 90 +++++++++++++- .../src/plugins/config/configtaskwidget.h | 29 ++++- .../openpilotgcs/src/plugins/config/input.ui | 106 ++++++++--------- .../src/plugins/config/smartsavebutton.cpp | 6 + .../src/plugins/config/smartsavebutton.h | 3 +- 11 files changed, 233 insertions(+), 217 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui index 188706190..ecabe8de1 100644 --- a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui +++ b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui @@ -31,7 +31,7 @@ - :/configgadget/images/coptercontrol.svg + :/configgadget/images/coptercontrol.svg true @@ -87,7 +87,7 @@ - dkwtc + Receiver type Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -95,7 +95,7 @@ - + @@ -139,6 +139,19 @@ + + + + + + + Qt::AutoText + + + true + + + @@ -196,6 +209,8 @@ Beware of not locking yourself out! - + + + diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index 6caf32d09..eb11b872f 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -38,90 +38,52 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_telemetry = new Ui_CC_HW_Widget(); m_telemetry->setupUi(this); - smartsave=new smartSaveButton(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); - // Now connect the widget to the ManualControlCommand / Channel UAVObject - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - - UAVObject *obj = objManager->getObject(QString("TelemetrySettings")); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); - smartsave->addObject(obj); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->addItems(field->getOptions()); - - obj = objManager->getObject(QString("HwSettings")); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); - smartsave->addObject(obj); - field = obj->getField(QString("CC_FlexiPort")); - m_telemetry->cbFlexi->addItems(field->getOptions()); - - field = obj->getField(QString("CC_MainPort")); - m_telemetry->cbTele->addItems(field->getOptions()); - - connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(saveTelemetryUpdate())); - + setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); + addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addObjectToWidget("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); + addObjectToWidget("HwSettings","CC_MainPort",m_telemetry->cbTele); + addObjectToWidget("ManualControlSettings","InputMode",m_telemetry->receiverType); enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); + populateWidgets(); + refreshWidgetsValues(); } ConfigCCHWWidget::~ConfigCCHWWidget() { - // Do nothing - delete smartsave; + // Do nothing } - -/******************************* - * Telemetry Settings - *****************************/ - -void ConfigCCHWWidget::enableControls(bool enable) -{ - m_telemetry->saveTelemetryToSD->setEnabled(enable); - //m_telemetry->saveTelemetryToRAM->setEnabled(enable); -} - -/** - Request telemetry settings from the board - */ void ConfigCCHWWidget::refreshValues() { - qDebug()<<"refreshvalues"; - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString())); - qDebug()<getValue().toString(); - obj = dynamic_cast(objManager->getObject(QString("HwSettings"))); - Q_ASSERT(obj); - field = obj->getField(QString("CC_FlexiPort")); - m_telemetry->cbFlexi->setCurrentIndex(m_telemetry->cbFlexi->findText(field->getValue().toString())); - qDebug()<getValue().toString(); - field = obj->getField(QString("CC_MainPort")); - m_telemetry->cbTele->setCurrentIndex(m_telemetry->cbTele->findText(field->getValue().toString())); - qDebug()<getValue().toString(); } - -/** - Send telemetry settings to the board and request saving to SD card - */ -void ConfigCCHWWidget::saveTelemetryUpdate() +void ConfigCCHWWidget::widgetsContentsChanged() { - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField* field = obj->getField(QString("Speed")); - field->setValue(m_telemetry->telemetrySpeed->currentText()); - obj = dynamic_cast(getObjectManager()->getObject(QString("HwSettings"))); - Q_ASSERT(obj); - field = obj->getField(QString("CC_FlexiPort")); - field->setValue(m_telemetry->cbFlexi->currentText()); - field = obj->getField(QString("CC_MainPort")); - field->setValue(m_telemetry->cbTele->currentText()); - - + enableControls(false); + if((m_telemetry->cbFlexi->currentText()==m_telemetry->cbTele->currentText()) && m_telemetry->cbTele->currentText()!="Disabled") + { + m_telemetry->problems->setText("Warning-You have configured the main port and the flexi port for the same function, this is currently not suported"); + } + else if((m_telemetry->cbTele->currentText()=="Spektrum" ||m_telemetry->cbFlexi->currentText()=="Spektrum") && m_telemetry->receiverType->currentText()!="Spektrum") + { + m_telemetry->problems->setText("Warning-You have at least one port configured as 'Spektrum' however thats not your selected input type"); + } + else if(m_telemetry->cbTele->currentText()=="S.Bus" && m_telemetry->receiverType->currentText()!="S.Bus") + { + m_telemetry->problems->setText("Warning-You have at least one port configured as 'S.Bus' however thats not your selected input type"); + } + else if(m_telemetry->cbTele->currentText()!="S.Bus" && m_telemetry->receiverType->currentText()=="S.Bus") + { + m_telemetry->problems->setText("Warning-You have at selected 'S.Bus' as your input type however you have no port configured for that protocol"); + } + else if((m_telemetry->cbTele->currentText()!="Spektrum" && m_telemetry->cbFlexi->currentText()!="Spektrum") && m_telemetry->receiverType->currentText()=="Spektrum") + { + m_telemetry->problems->setText("Warning-You have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); + } + else + { + m_telemetry->problems->setText(""); + enableControls(true); + } } + diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h index 9ad52d9bc..32c8a6988 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.h @@ -43,16 +43,12 @@ class ConfigCCHWWidget: public ConfigTaskWidget public: ConfigCCHWWidget(QWidget *parent = 0); ~ConfigCCHWWidget(); +private slots: + void refreshValues(); + void widgetsContentsChanged(); private: Ui_CC_HW_Widget *m_telemetry; - void enableControls(bool enable); - smartSaveButton *smartsave; - -private slots: - virtual void refreshValues(); - void saveTelemetryUpdate(); - }; #endif // CONFIGCCHWWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp index 149f92b73..cfe0741e4 100644 --- a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp @@ -39,22 +39,11 @@ ConfigProHWWidget::ConfigProHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry = new Ui_PRO_HW_Widget(); m_telemetry->setupUi(this); - // Now connect the widget to the ManualControlCommand / Channel UAVObject - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - - UAVObject *obj = objManager->getObject(QString("TelemetrySettings")); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->addItems(field->getOptions()); - - connect(m_telemetry->saveTelemetryToSD, SIGNAL(clicked()), this, SLOT(saveTelemetryUpdate())); - connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate())); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues())); - + setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); + addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); + populateWidgets(); + refreshWidgetsValues(); } ConfigProHWWidget::~ConfigProHWWidget() @@ -63,49 +52,9 @@ ConfigProHWWidget::~ConfigProHWWidget() } -/******************************* - * Telemetry Settings - *****************************/ - -void ConfigProHWWidget::enableControls(bool enable) -{ - m_telemetry->saveTelemetryToSD->setEnabled(enable); - //m_telemetry->saveTelemetryToRAM->setEnabled(enable); -} - /** Request telemetry settings from the board */ void ConfigProHWWidget::refreshValues() { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField *field = obj->getField(QString("Speed")); - m_telemetry->telemetrySpeed->setCurrentIndex(m_telemetry->telemetrySpeed->findText(field->getValue().toString())); -} - -/** - Send telemetry settings to the board - */ -void ConfigProHWWidget::sendTelemetryUpdate() -{ - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - UAVObjectField* field = obj->getField(QString("Speed")); - field->setValue(m_telemetry->telemetrySpeed->currentText()); - obj->updated(); -} - -/** - Send telemetry settings to the board and request saving to SD card - */ -void ConfigProHWWidget::saveTelemetryUpdate() -{ - // Send update so that the latest value is saved - sendTelemetryUpdate(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("TelemetrySettings"))); - Q_ASSERT(obj); - saveObjectToSD(obj); } diff --git a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h index 254cf7af0..fbf35b9bd 100644 --- a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.h @@ -46,12 +46,9 @@ public: private: Ui_PRO_HW_Widget *m_telemetry; - void enableControls(bool enable); private slots: virtual void refreshValues(); - void sendTelemetryUpdate(); - void saveTelemetryUpdate(); }; diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 88579c78c..e0c0e7e45 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -112,10 +112,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent) obj = dynamic_cast(objManager->getObject(QString("ManualControlSettings"))); QString fieldName = QString("InputMode"); UAVObjectField *field = obj->getField(fieldName); - m_config->receiverType->addItems(field->getOptions()); - m_config->receiverType->setDisabled(true); // This option does not work for now, it is a compile-time option. - - // Fill in the dropdown menus for the channel RC Input assignement. + // Fill in the dropdown menus for the channel RC Input assignement. QStringList channelsList; channelsList << "None"; QList fieldList = obj->getFields(); @@ -264,7 +261,7 @@ void ConfigInputWidget::refreshValues() // Update receiver type field = obj->getField(QString("InputMode")); - m_config->receiverType->setCurrentIndex(m_config->receiverType->findText(field->getValue().toString())); + m_config->receiverType->setText(field->getValue().toString()); // Reset all channel assignement dropdowns: foreach (QComboBox *combo, inChannelAssign) { @@ -332,10 +329,6 @@ void ConfigInputWidget::sendRCInputUpdate() for (int i = 0; i < 8; i++) field->setValue(inSliders[i]->value(), i); - // Set RC Receiver type: - fieldName = QString("InputMode"); - field = obj->getField(fieldName); - field->setValue(m_config->receiverType->currentText()); // Set Roll/Pitch/Yaw/Etc assignement: // Rule: if two channels have the same setting (which is wrong!) the higher channel diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index bb598cba0..15c79aa74 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -28,13 +28,34 @@ #include -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL) { + pm = ExtensionSystem::PluginManager::instance(); + objManager = pm->getObject(); + connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); + connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); +} +void ConfigTaskWidget::addObjectToWidget(QString object, QString field, QWidget * widget) +{ + UAVObject *obj = objManager->getObject(QString(object)); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + //smartsave->addObject(obj); + UAVObjectField *_field = obj->getField(QString(field)); + objectToWidget * ow=new objectToWidget(); + ow->field=_field; + ow->object=obj; + ow->widget=widget; + objOfInterest.append(ow); + smartsave->addObject(obj); + if(QComboBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(currentIndexChanged(int)),this,SLOT(widgetsContentsChanged())); + } } ConfigTaskWidget::~ConfigTaskWidget() { - // Do nothing + delete smartsave; } void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) @@ -73,9 +94,72 @@ void ConfigTaskWidget::onAutopilotDisconnect() void ConfigTaskWidget::onAutopilotConnect() { enableControls(true); - refreshValues(); + refreshWidgetsValues(); } +void ConfigTaskWidget::populateWidgets() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(QComboBox * cb=qobject_cast(ow->widget)) + { + cb->addItems(ow->field->getOptions()); + cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + cb->setText(ow->field->getValue().toString()); + } + } +} + +void ConfigTaskWidget::refreshWidgetsValues() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(QComboBox * cb=qobject_cast(ow->widget)) + { + cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + cb->setText(ow->field->getValue().toString()); + } + } +} + +void ConfigTaskWidget::updateObjectsFromWidgets() +{ + foreach(objectToWidget * ow,objOfInterest) + { + if(QComboBox * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->currentText()); + } + else if(QLabel * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->text()); + } + } +} + +void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save) +{ + smartsave=new smartSaveButton(update,save); + connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); +} + +void ConfigTaskWidget::enableControls(bool enable) +{ + if(smartsave) + smartsave->enableControls(enable); +} + +void ConfigTaskWidget::widgetsContentsChanged() +{ +} + + /** diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h index 6ffe15b70..0f439f3d1 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h @@ -35,28 +35,45 @@ #include #include #include - - +#include +#include "smartsavebutton.h" class ConfigTaskWidget: public QWidget { Q_OBJECT public: + struct objectToWidget + { + UAVObject * object; + UAVObjectField * field; + QWidget * widget; + }; + ConfigTaskWidget(QWidget *parent = 0); ~ConfigTaskWidget(); void saveObjectToSD(UAVObject *obj); UAVObjectManager* getObjectManager(); static double listMean(QList list); - + void addObjectToWidget(QString object,QString field,QWidget * widget); + void setupButtons(QPushButton * update,QPushButton * save); public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); private slots: - virtual void refreshValues() = 0; - + virtual void refreshValues()=0; + virtual void updateObjectsFromWidgets(); private: - virtual void enableControls(bool enable) = 0; + QList objOfInterest; + ExtensionSystem::PluginManager *pm; + UAVObjectManager *objManager; + smartSaveButton *smartsave; +protected slots: + virtual void widgetsContentsChanged(); + virtual void populateWidgets(); + virtual void refreshWidgetsValues(); +protected: + virtual void enableControls(bool enable); }; diff --git a/ground/openpilotgcs/src/plugins/config/input.ui b/ground/openpilotgcs/src/plugins/config/input.ui index cef9c9abe..8d22b281b 100644 --- a/ground/openpilotgcs/src/plugins/config/input.ui +++ b/ground/openpilotgcs/src/plugins/config/input.ui @@ -40,17 +40,7 @@ - - - - Select the receiver type here: -- PWM is the most usual type -- PPM is connected to input XXX -- Spektrum is used with Spektrum 'satellite' receivers - - - - + @@ -80,7 +70,7 @@ - + Rev. @@ -100,7 +90,7 @@ - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -114,7 +104,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -132,7 +122,7 @@ p, li { white-space: pre-wrap; } - + true @@ -151,7 +141,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -166,7 +156,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -181,7 +171,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -195,7 +185,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -213,7 +203,7 @@ p, li { white-space: pre-wrap; } - + true @@ -232,7 +222,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -247,7 +237,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -262,7 +252,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -276,7 +266,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -294,7 +284,7 @@ p, li { white-space: pre-wrap; } - + true @@ -313,7 +303,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -328,7 +318,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -343,7 +333,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -357,7 +347,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -375,7 +365,7 @@ p, li { white-space: pre-wrap; } - + true @@ -394,7 +384,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -409,7 +399,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -424,7 +414,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -438,7 +428,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -456,7 +446,7 @@ p, li { white-space: pre-wrap; } - + true @@ -475,7 +465,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -490,7 +480,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -505,7 +495,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -519,7 +509,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -537,7 +527,7 @@ p, li { white-space: pre-wrap; } - + true @@ -556,7 +546,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -571,7 +561,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -586,7 +576,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -600,7 +590,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -618,7 +608,7 @@ p, li { white-space: pre-wrap; } - + true @@ -637,7 +627,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -652,7 +642,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -667,7 +657,7 @@ reversal capabilities). - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -681,7 +671,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -699,7 +689,7 @@ p, li { white-space: pre-wrap; } - + true @@ -718,7 +708,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -733,7 +723,7 @@ p, li { white-space: pre-wrap; } - + Check this to reverse the channel. @@ -745,7 +735,7 @@ reversal capabilities). - + @@ -759,7 +749,7 @@ reversal capabilities). - + @@ -792,6 +782,13 @@ Neutral should be put at the bottom of the slider for the throttle. + + + + + + + @@ -1252,7 +1249,6 @@ Applies and Saves all settings to SD ch5Assign ch6Assign ch7Assign - receiverType fmsSlider fmsModePos3 fmsSsPos3Roll diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp index f9771f1a1..f86c01b7e 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -111,3 +111,9 @@ void smartSaveButton::saving_finished(int id, bool result) loop.quit(); } } + +void smartSaveButton::enableControls(bool value) +{ + bupdate->setEnabled(value); + bsave->setEnabled(value); +} diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h index b086a04f1..dd77967dd 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h @@ -36,7 +36,8 @@ private: QEventLoop loop; QList objects; protected: - +public slots: + void enableControls(bool value); }; From b9f1532598cc577238fd925b2811e1f683c240d5 Mon Sep 17 00:00:00 2001 From: zedamota Date: Tue, 26 Jul 2011 20:35:38 +0100 Subject: [PATCH 5/5] Refractured the Airframe config widget. Corrected some language mistakes. --- .../src/plugins/config/airframe.ui | 181 +++++++----------- .../src/plugins/config/cc_hw_settings.ui | 31 ++- .../plugins/config/config_cc_hw_widget.cpp | 19 +- .../plugins/config/config_pro_hw_widget.cpp | 2 +- .../plugins/config/configairframewidget.cpp | 94 ++++----- .../src/plugins/config/configairframewidget.h | 7 +- .../src/plugins/config/configinputwidget.cpp | 2 +- .../src/plugins/config/configtaskwidget.cpp | 111 ++++++++++- .../src/plugins/config/configtaskwidget.h | 15 +- .../src/plugins/config/smartsavebutton.cpp | 4 + .../src/plugins/config/smartsavebutton.h | 4 + 11 files changed, 269 insertions(+), 201 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 1f3c6446a..fd039a906 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -23,7 +23,7 @@ Mixer Settings - + 5 @@ -74,7 +74,7 @@ - 3 + 1 @@ -1731,75 +1731,6 @@ Typical value is 50% for + or X configuration on quads. - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - - - - :/core/images/helpicon.svg:/core/images/helpicon.svg - - - - 32 - 32 - - - - true - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - @@ -1808,7 +1739,7 @@ Typical value is 50% for + or X configuration on quads. - + @@ -2106,49 +2037,81 @@ p, li { white-space: pre-wrap; } - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 32 + 32 + + + + true + + + + + + + Send to board, but don't save permanently (flash or SD). + + + Apply + + + + + + + Applies and Saves all settings to flash or SD depending on board. + + + Save + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui index ecabe8de1..b0ffec294 100644 --- a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui +++ b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui @@ -64,7 +64,7 @@ - Flexiport + FlexiPort Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -124,6 +124,25 @@ + + + + + 75 + true + + + + + + + Qt::AutoText + + + true + + + @@ -140,15 +159,9 @@ - + - - - - Qt::AutoText - - - true + Changes on this page require an Hw reboot to be applied diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index eb11b872f..03296210b 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -39,10 +39,10 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry = new Ui_CC_HW_Widget(); m_telemetry->setupUi(this); setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); - addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); - addObjectToWidget("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); - addObjectToWidget("HwSettings","CC_MainPort",m_telemetry->cbTele); - addObjectToWidget("ManualControlSettings","InputMode",m_telemetry->receiverType); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addUAVObjectToWidgetRelation("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); + addUAVObjectToWidgetRelation("HwSettings","CC_MainPort",m_telemetry->cbTele); + addUAVObjectToWidgetRelation("ManualControlSettings","InputMode",m_telemetry->receiverType); enableControls(false); populateWidgets(); refreshWidgetsValues(); @@ -59,26 +59,27 @@ void ConfigCCHWWidget::refreshValues() void ConfigCCHWWidget::widgetsContentsChanged() { + ConfigTaskWidget::widgetsContentsChanged(); enableControls(false); if((m_telemetry->cbFlexi->currentText()==m_telemetry->cbTele->currentText()) && m_telemetry->cbTele->currentText()!="Disabled") { - m_telemetry->problems->setText("Warning-You have configured the main port and the flexi port for the same function, this is currently not suported"); + m_telemetry->problems->setText("Warning: you have configured the MainPort and the FlexiPort for the same function, this is currently not suported"); } else if((m_telemetry->cbTele->currentText()=="Spektrum" ||m_telemetry->cbFlexi->currentText()=="Spektrum") && m_telemetry->receiverType->currentText()!="Spektrum") { - m_telemetry->problems->setText("Warning-You have at least one port configured as 'Spektrum' however thats not your selected input type"); + m_telemetry->problems->setText("Warning: you have at least one port configured as 'Spektrum' however that is not your selected input type"); } else if(m_telemetry->cbTele->currentText()=="S.Bus" && m_telemetry->receiverType->currentText()!="S.Bus") { - m_telemetry->problems->setText("Warning-You have at least one port configured as 'S.Bus' however thats not your selected input type"); + m_telemetry->problems->setText("Warning: you have at least one port configured as 'S.Bus' however that is not your selected input type"); } else if(m_telemetry->cbTele->currentText()!="S.Bus" && m_telemetry->receiverType->currentText()=="S.Bus") { - m_telemetry->problems->setText("Warning-You have at selected 'S.Bus' as your input type however you have no port configured for that protocol"); + m_telemetry->problems->setText("Warning: you have selected 'S.Bus' as your input type however you have no port configured for that protocol"); } else if((m_telemetry->cbTele->currentText()!="Spektrum" && m_telemetry->cbFlexi->currentText()!="Spektrum") && m_telemetry->receiverType->currentText()=="Spektrum") { - m_telemetry->problems->setText("Warning-You have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); + m_telemetry->problems->setText("Warning: you have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); } else { diff --git a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp index cfe0741e4..b3f562acd 100644 --- a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp @@ -40,7 +40,7 @@ ConfigProHWWidget::ConfigProHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry->setupUi(this); setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); - addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); enableControls(false); populateWidgets(); refreshWidgetsValues(); diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp index 0044afa62..dcf743915 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp @@ -91,6 +91,32 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft = new Ui_AircraftWidget(); m_aircraft->setupUi(this); + setupButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD); + addWidget(m_aircraft->customMixerTable); + addWidget(m_aircraft->customThrottle2Curve); + addWidget(m_aircraft->customThrottle1Curve); + addWidget(m_aircraft->multiThrottleCurve); + addWidget(m_aircraft->fixedWingThrottle); + addWidget(m_aircraft->fixedWingType); + addWidget(m_aircraft->feedForwardSlider); + addWidget(m_aircraft->accelTime); + addWidget(m_aircraft->decelTime); + addWidget(m_aircraft->maxAccelSlider); + addWidget(m_aircraft->multirotorFrameType); + addWidget(m_aircraft->multiMotor1); + addWidget(m_aircraft->multiMotor2); + addWidget(m_aircraft->multiMotor3); + addWidget(m_aircraft->multiMotor4); + addWidget(m_aircraft->multiMotor5); + addWidget(m_aircraft->multiMotor6); + addWidget(m_aircraft->multiMotor7); + addWidget(m_aircraft->multiMotor8); + addWidget(m_aircraft->triYawChannel); + addUAVObject("SystemSettings"); + addUAVObject("MixerSettings"); + addUAVObject("ActuatorSettings"); + + ffTuningInProgress = false; ffTuningPhase = false; @@ -164,11 +190,6 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } - connect(m_aircraft->saveAircraftToSD, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->saveAircraftToRAM, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); - - connect(m_aircraft->ffSave, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->ffApply, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -191,17 +212,8 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); + refreshWidgetsValues(); - // Register for ManualControlSettings changes: - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); // Connect the help button connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); @@ -213,18 +225,6 @@ ConfigAirframeWidget::~ConfigAirframeWidget() // Do nothing } -/** - Enable or disable controls depending on whether we're ronnected or not - */ -void ConfigAirframeWidget::enableControls(bool enable) -{ - //m_aircraft->saveAircraftToRAM->setEnabled(enable); - m_aircraft->saveAircraftToSD->setEnabled(enable); - //m_aircraft->ffApply->setEnabled(enable); - m_aircraft->ffSave->setEnabled(enable); -} - - /** Slot for switching the airframe type. We do it explicitely rather than a signal in the UI, because we want to force a fitInView of the quad shapes. @@ -460,7 +460,7 @@ void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList list, d /** Refreshes the current value of the SystemSettings which holds the aircraft type */ -void ConfigAirframeWidget::refreshValues() +void ConfigAirframeWidget::refreshWidgetsValues() { // Get the Airframe type from the system settings: UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -665,10 +665,13 @@ void ConfigAirframeWidget::refreshValues() val = floor(-field->getDouble(i)/1.27); m_aircraft->mrYawMixLevel->setValue(val); eng = m_aircraft->multiMotor2->currentIndex()-1; - field = obj->getField(mixerVectors.at(eng)); - i = field->getElementNames().indexOf("Roll"); - val = floor(1-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); + if(eng>-1) + { + field = obj->getField(mixerVectors.at(eng)); + i = field->getElementNames().indexOf("Roll"); + val = floor(1-field->getDouble(i)/1.27); + m_aircraft->mrRollMixLevel->setValue(val); + } } } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW @@ -1817,8 +1820,9 @@ void ConfigAirframeWidget::updateCustomAirframeUI() we call additional methods for specific frames, so that we do not have a code that is too heavy. */ -void ConfigAirframeWidget::sendAircraftUpdate() +void ConfigAirframeWidget::updateObjectsFromWidgets() { + qDebug()<<"updateObjectsFromWidgets"; QString airframeType = "Custom"; if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { // Save the curve (common to all Fixed wing frames) @@ -2123,31 +2127,9 @@ void ConfigAirframeWidget::sendAircraftUpdate() } } - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); UAVObjectField* field = obj->getField(QString("AirframeType")); field->setValue(airframeType); - obj->updated(); -} - -/** - Send airframe type to the board and request saving to SD card - */ -void ConfigAirframeWidget::saveAircraftUpdate() -{ - // Send update so that the latest value is saved - sendAircraftUpdate(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(obj); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - saveObjectToSD(obj); } diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.h b/ground/openpilotgcs/src/plugins/config/configairframewidget.h index 5d9bfecc8..234a114c1 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.h @@ -58,7 +58,6 @@ private: void updateCustomAirframeUI(); bool setupMixer(double mixerFactors[8][3]); void setupMotors(QList motorList); - virtual void enableControls(bool enable); void resetField(UAVObjectField * field); void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue); @@ -74,9 +73,9 @@ private: UAVObject::Metadata accInitialData; private slots: - virtual void refreshValues(); - void sendAircraftUpdate(); - void saveAircraftUpdate(); + virtual void refreshWidgetsValues(); + void updateObjectsFromWidgets(); + // void saveAircraftUpdate(); void setupAirframeUI(QString type); void toggleAileron2(int index); void toggleElevator2(int index); diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index e0c0e7e45..80d36e46b 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -700,7 +700,7 @@ void ConfigInputWidget::receiverHelp() unassigned.append("FlightMode"); } if(unassigned.length()>0) - m_config->lblMissingInputs->setText(QString("Channels left to assign:")+unassigned); + m_config->lblMissingInputs->setText(QString("Channels left to assign: ")+unassigned); else m_config->lblMissingInputs->setText(""); } diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index 15c79aa74..8fd35c596 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -28,31 +28,69 @@ #include -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); } -void ConfigTaskWidget::addObjectToWidget(QString object, QString field, QWidget * widget) +void ConfigTaskWidget::addWidget(QWidget * widget) { - UAVObject *obj = objManager->getObject(QString(object)); + addUAVObjectToWidgetRelation("","",widget); +} +void ConfigTaskWidget::addUAVObject(QString objectName) +{ + addUAVObjectToWidgetRelation(objectName,"",NULL); +} +void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget * widget) +{ + UAVObject *obj=NULL; + UAVObjectField *_field=NULL; + if(!object.isEmpty()) + obj = objManager->getObject(QString(object)); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); //smartsave->addObject(obj); - UAVObjectField *_field = obj->getField(QString(field)); + if(!field.isEmpty() && obj) + _field = obj->getField(QString(field)); objectToWidget * ow=new objectToWidget(); ow->field=_field; ow->object=obj; ow->widget=widget; objOfInterest.append(ow); - smartsave->addObject(obj); - if(QComboBox * cb=qobject_cast(widget)) + if(obj) + smartsave->addObject(obj); + if(widget==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(widget)) { connect(cb,SIGNAL(currentIndexChanged(int)),this,SLOT(widgetsContentsChanged())); } + else if(QSlider * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(sliderMoved(int)),this,SLOT(widgetsContentsChanged())); + } + else if(MixerCurveWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(curveUpdated(QList,double)),this,SLOT(widgetsContentsChanged())); + } + else if(QTableWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(cellChanged(int,int)),this,SLOT(widgetsContentsChanged())); + } + else if(QSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(int)),this,SLOT(widgetsContentsChanged())); + } + else if(QDoubleSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(double)),this,SLOT(widgetsContentsChanged())); + } } + ConfigTaskWidget::~ConfigTaskWidget() { delete smartsave; @@ -101,7 +139,11 @@ void ConfigTaskWidget::populateWidgets() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) { cb->addItems(ow->field->getOptions()); cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); @@ -111,13 +153,18 @@ void ConfigTaskWidget::populateWidgets() cb->setText(ow->field->getValue().toString()); } } + dirty=false; } void ConfigTaskWidget::refreshWidgetsValues() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) + { + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) { cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); } @@ -132,9 +179,13 @@ void ConfigTaskWidget::updateObjectsFromWidgets() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) { - ow->field->setValue(cb->currentText()); + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->currentText()); } else if(QLabel * cb=qobject_cast(ow->widget)) { @@ -147,6 +198,9 @@ void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save) { smartsave=new smartSaveButton(update,save); connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); + connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty())); + connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates())); + connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates())); } void ConfigTaskWidget::enableControls(bool enable) @@ -157,8 +211,45 @@ void ConfigTaskWidget::enableControls(bool enable) void ConfigTaskWidget::widgetsContentsChanged() { + dirty=true; } +void ConfigTaskWidget::clearDirty() +{ + dirty=false; +} + +bool ConfigTaskWidget::isDirty() +{ + return dirty; +} + +void ConfigTaskWidget::refreshValues() +{ +} + +void ConfigTaskWidget::disableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + +void ConfigTaskWidget::enableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h index 0f439f3d1..bd293ce5f 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h @@ -37,6 +37,10 @@ #include #include #include "smartsavebutton.h" +#include "mixercurvewidget.h" +#include +#include +#include class ConfigTaskWidget: public QWidget { Q_OBJECT @@ -54,21 +58,28 @@ public: void saveObjectToSD(UAVObject *obj); UAVObjectManager* getObjectManager(); static double listMean(QList list); - void addObjectToWidget(QString object,QString field,QWidget * widget); + void addUAVObject(QString objectName); + void addWidget(QWidget * widget); + void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget); void setupButtons(QPushButton * update,QPushButton * save); + bool isDirty(); public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); private slots: - virtual void refreshValues()=0; + virtual void refreshValues(); virtual void updateObjectsFromWidgets(); private: QList objOfInterest; ExtensionSystem::PluginManager *pm; UAVObjectManager *objManager; smartSaveButton *smartsave; + bool dirty; protected slots: + virtual void disableObjUpdates(); + virtual void enableObjUpdates(); + virtual void clearDirty(); virtual void widgetsContentsChanged(); virtual void populateWidgets(); virtual void refreshWidgetsValues(); diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp index f86c01b7e..720e06c15 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -8,6 +8,7 @@ smartSaveButton::smartSaveButton(QPushButton * update, QPushButton * save):bupda } void smartSaveButton::processClick() { + emit beginOp(); bool save=false; QPushButton *button=bupdate; if(sender()==bsave) @@ -23,6 +24,7 @@ void smartSaveButton::processClick() bool error=false; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectUtilManager* utilMngr = pm->getObject(); + qDebug()<<"smartbutton:save"; foreach(UAVObject * obj,objects) { up_result=false; @@ -73,11 +75,13 @@ void smartSaveButton::processClick() if(!error) { button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); + emit saveSuccessfull(); } else { button->setIcon(QIcon(":/uploader/images/process-stop.svg")); } + emit endOp(); } void smartSaveButton::setObjects(QList list) diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h index dd77967dd..d0238d034 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h @@ -10,6 +10,7 @@ #include #include "uavobjectutilmanager.h" #include +#include class smartSaveButton:public QObject { public: @@ -21,6 +22,9 @@ public: void clearObjects(); signals: void preProcessOperations(); + void saveSuccessfull(); + void beginOp(); + void endOp(); private slots: void processClick(); void transaction_finished(UAVObject* obj, bool result);