diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc index beedd5c7414fe4c5ad4732f6ee7e852f7f3fd733..d62244e55279c77fc8d262dc373bbb6eda0d2cb1 100644 --- a/src/uas/QGCUASParamManager.cc +++ b/src/uas/QGCUASParamManager.cc @@ -1,6 +1,6 @@ #include "QGCUASParamManager.h" -#include > +#include #include #include @@ -27,28 +27,30 @@ QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas) paramCommsMgr = new UASParameterCommsMgr(this); paramCommsMgr->initWithUAS(uas); - connectToCommsMgr(); + connectToModelAndComms(); return this; } -void QGCUASParamManager::connectToCommsMgr() +void QGCUASParamManager::connectToModelAndComms() { - // Pass along comms mgr status msgs connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), this, SIGNAL(parameterStatusMsgUpdated(QString,int))); connect(paramCommsMgr, SIGNAL(parameterListUpToDate()), this, SIGNAL(parameterListUpToDate())); +} +void QGCUASParamManager::clearAllPendingParams() +{ + paramDataModel.clearAllPendingParams(); } - bool QGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const { return paramDataModel.getOnboardParamValue(component,parameter,value); diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h index 29c1150da46db69d8a1ad61665751767517a25ca..f4598db0afa85086e7d65b826eddb479e8cebd46 100644 --- a/src/uas/QGCUASParamManager.h +++ b/src/uas/QGCUASParamManager.h @@ -39,7 +39,7 @@ protected: /** @brief Load parameter meta information from appropriate CSV file */ virtual void loadParamMetaInfoCSV(); - void connectToCommsMgr(); + void connectToModelAndComms(); signals: @@ -49,6 +49,8 @@ signals: /** @brief We have received a complete list of all parameters onboard the MAV */ void parameterListUpToDate(); + + public slots: /** @brief Send one parameter to the MAV: changes value in transient memory of MAV */ virtual void setParameter(int component, QString parameterName, QVariant value); @@ -64,6 +66,9 @@ public slots: virtual void setPendingParam(int componentId, QString& key, const QVariant& value); + /** @brief remove all params from the pending list */ + virtual void clearAllPendingParams(); + /** @brief Request a single parameter by name from the MAV */ virtual void requestParameterUpdate(int component, const QString& parameter); diff --git a/src/uas/UASParameterDataModel.cc b/src/uas/UASParameterDataModel.cc index 012749f659aa8b583a27394630ab5334fe8a4d17..5ecb37db8981fca11b55f26e110e68796a224e7b 100644 --- a/src/uas/UASParameterDataModel.cc +++ b/src/uas/UASParameterDataModel.cc @@ -87,7 +87,7 @@ void UASParameterDataModel::setPendingParam(int compId, QString& key, const QVa } } -void UASParameterDataModel::removePendingParam(int compId, QString& key) +void UASParameterDataModel::removePendingParam(int compId, const QString& key) { qDebug() << "removePendingParam:" << key; @@ -197,6 +197,20 @@ void UASParameterDataModel::forgetAllOnboardParams() onboardParameters.clear(); } +void UASParameterDataModel::clearAllPendingParams() +{ + QList compIds = pendingParameters.keys(); + foreach (int compId , compIds) { + QMap* compParams = pendingParameters.value(compId); + QList paramNames = compParams->keys(); + foreach (QString paramName, paramNames) { + //remove this item from pending status and broadcast update + removePendingParam(compId,paramName); + } + } + +} + void UASParameterDataModel::readUpdateParamsFromStream( QTextStream& stream) { bool userWarned = false; diff --git a/src/uas/UASParameterDataModel.h b/src/uas/UASParameterDataModel.h index 40c6cead100c8c6695ca16f7c2e2c8b2c87b423a..738e9c36e56466c0af9d90c5b2656aa74b2ac05c 100644 --- a/src/uas/UASParameterDataModel.h +++ b/src/uas/UASParameterDataModel.h @@ -43,6 +43,7 @@ public: virtual void forgetAllOnboardParams(); + /** @brief add this parameter to pending list iff it has changed from onboard value * @return true if the parameter is now pending */ @@ -88,7 +89,7 @@ protected: /** @brief Write a new pending parameter value that may be eventually sent to the UAS */ virtual void setPendingParam(int componentId, QString& key, const QVariant& value); /** @brief remove a parameter from the pending list */ - virtual void removePendingParam(int compId, QString& key); + virtual void removePendingParam(int compId, const QString &key); signals: @@ -103,6 +104,7 @@ signals: public slots: + virtual void clearAllPendingParams(); protected: int uasId; ///< The UAS / MAV to which this data model pertains diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index 2a5772aee894d9605bce0231eea75cf6d62eb49e..c87306f9c5797e72858d7357b570b715e71ae72b 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -79,7 +79,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ui->rcCalibrationButton->setCheckable(true); connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool))); - connect(ui->setButton, SIGNAL(clicked()), this, SLOT(writeParameters())); + connect(ui->writeButton, SIGNAL(clicked()), + this, SLOT(writeParameters())); + connect(ui->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int))); //connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions())); @@ -816,14 +818,16 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) { // Hide items if NULL and abort if (!active) { - ui->setButton->setEnabled(false); ui->refreshButton->setEnabled(false); - ui->readButton->show(); + ui->refreshButton->show(); ui->readButton->setEnabled(false); - ui->writeButton->show(); + ui->readButton->show(); ui->writeButton->setEnabled(false); + ui->writeButton->show(); ui->loadFileButton->setEnabled(false); + ui->loadFileButton->show(); ui->saveFileButton->setEnabled(false); + ui->saveFileButton->show(); return; } @@ -918,12 +922,18 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) updateStatus(QString("Reading from system %1").arg(mav->getUASName())); // Since a system is now connected, enable the VehicleConfig UI. - ui->setButton->setEnabled(true); ui->refreshButton->setEnabled(true); + ui->refreshButton->show(); ui->readButton->setEnabled(true); + ui->readButton->show(); ui->writeButton->setEnabled(true); + ui->writeButton->show(); ui->loadFileButton->setEnabled(true); + ui->loadFileButton->show(); ui->saveFileButton->setEnabled(true); + ui->saveFileButton->show(); + + //TODO never true? if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA") { ui->readButton->hide(); ui->writeButton->hide(); diff --git a/src/ui/QGCPX4VehicleConfig.ui b/src/ui/QGCPX4VehicleConfig.ui index b153d7391a24c3a9b10e52664275eef2daed1935..fd13f905e204e51cb9d0f63559925dccd3bc4282 100644 --- a/src/ui/QGCPX4VehicleConfig.ui +++ b/src/ui/QGCPX4VehicleConfig.ui @@ -817,8 +817,8 @@ p, li { white-space: pre-wrap; } 0 0 - 26 - 26 + 98 + 28 @@ -906,8 +906,8 @@ p, li { white-space: pre-wrap; } 0 0 - 16 - 16 + 98 + 28 @@ -943,8 +943,8 @@ p, li { white-space: pre-wrap; } 0 0 - 16 - 16 + 98 + 28 @@ -1103,6 +1103,13 @@ p, li { white-space: pre-wrap; } + + + + Load File + + + @@ -1163,7 +1170,7 @@ p, li { white-space: pre-wrap; } 601 - + 0 @@ -1180,54 +1187,6 @@ p, li { white-space: pre-wrap; } - - - - false - - - Set current parameters in non-permanent onboard memory. - - - - - - Commit to UAS - - - - - - - false - - - Set current parameters in non-permanent onboard memory. - - - - - - Clear - - - - - - - false - - - Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them. - - - - - - Load from File - - - diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc index f01e526de31f21c4b155164bfcc4c536b2952bab..07cf8fdff935c73d3ba203cb140ef2df10780cb7 100644 --- a/src/ui/QGCParamWidget.cc +++ b/src/ui/QGCParamWidget.cc @@ -76,79 +76,81 @@ void QGCParamWidget::connectViewSignalsAndSlots() } -void QGCParamWidget::layoutWidget() +void QGCParamWidget::addActionButtonsToLayout(QGridLayout* layout) { - - statusLabel->setAutoFillBackground(true); - - // Set tree widget as widget onto this component - QGridLayout* horizontalLayout; - //form->setAutoFillBackground(false); - horizontalLayout = new QGridLayout(this); - horizontalLayout->setHorizontalSpacing(6); - horizontalLayout->setVerticalSpacing(6); - horizontalLayout->setMargin(0); - horizontalLayout->setSizeConstraint(QLayout::SetMinimumSize); - //horizontalLayout->setSizeConstraint( QLayout::SetFixedSize ); - - // Parameter tree - horizontalLayout->addWidget(tree, 0, 0, 1, 3); - - // Status line - statusLabel->setText(tr("Click refresh to download parameters")); - horizontalLayout->addWidget(statusLabel, 1, 0, 1, 3); - - // BUTTONS QPushButton* refreshButton = new QPushButton(tr("Get")); refreshButton->setToolTip(tr("Fetch parameters currently in volatile memory of aircraft.")); refreshButton->setWhatsThis(tr("Fetch parameters currently in volatile memory of aircraft.")); connect(refreshButton, SIGNAL(clicked()), this, SLOT(requestOnboardParamsUpdate())); - horizontalLayout->addWidget(refreshButton, 2, 0); + layout->addWidget(refreshButton, 2, 0); QPushButton* setButton = new QPushButton(tr("Set")); setButton->setToolTip(tr("Send pending parameters to volatile onboard memory")); setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory")); connect(setButton, SIGNAL(clicked()), paramMgr, SLOT(sendPendingParameters())); - horizontalLayout->addWidget(setButton, 2, 1); + layout->addWidget(setButton, 2, 1); QPushButton* writeButton = new QPushButton(tr("Write (ROM)")); writeButton->setToolTip(tr("Copy parameters in volatile memory of the aircraft to persistent memory. Transmit your parameters first to write these.")); writeButton->setWhatsThis(tr("Copy parameters in volatile memory of the aircraft to persistent memory. Transmit your parameters first to write these.")); connect(writeButton, SIGNAL(clicked()), paramMgr, SLOT(copyVolatileParamsToPersistent())); - horizontalLayout->addWidget(writeButton, 2, 2); + layout->addWidget(writeButton, 2, 2); QPushButton* loadFileButton = new QPushButton(tr("Load File")); loadFileButton->setToolTip(tr("Load parameters from a file into qgroundcontrol. To write these to the aircraft, use transmit after loading them.")); loadFileButton->setWhatsThis(tr("Load parameters from a file into qgroundcontrol. To write these to the aircraft, use transmit after loading them.")); connect(loadFileButton, SIGNAL(clicked()), this, SLOT(loadParametersFromFile())); - horizontalLayout->addWidget(loadFileButton, 3, 0); + layout->addWidget(loadFileButton, 3, 0); QPushButton* saveFileButton = new QPushButton(tr("Save File")); saveFileButton->setToolTip(tr("Save parameters in this view to a file on this computer.")); saveFileButton->setWhatsThis(tr("Save parameters in this view to a file on this computer.")); connect(saveFileButton, SIGNAL(clicked()), this, SLOT(saveParametersToFile())); - horizontalLayout->addWidget(saveFileButton, 3, 1); + layout->addWidget(saveFileButton, 3, 1); QPushButton* readButton = new QPushButton(tr("Read (ROM)")); readButton->setToolTip(tr("Copy parameters from persistent onboard memory to volatile onboard memory of aircraft. DOES NOT update the parameters in this view: click refresh after copying them to get them.")); readButton->setWhatsThis(tr("Copy parameters from persistent onboard memory to volatile onboard memory of aircraft. DOES NOT update the parameters in this view: click refresh after copying them to get them.")); connect(readButton, SIGNAL(clicked()), paramMgr, SLOT(copyPersistentParamsToVolatile())); - horizontalLayout->addWidget(readButton, 3, 2); + layout->addWidget(readButton, 3, 2); + +} + +void QGCParamWidget::layoutWidget() +{ + + statusLabel->setAutoFillBackground(true); + + QGridLayout* layout = new QGridLayout(this); + layout->setHorizontalSpacing(6); + layout->setVerticalSpacing(6); + layout->setMargin(0); + layout->setSizeConstraint(QLayout::SetMinimumSize); + + // Parameter tree + layout->addWidget(tree, 0, 0, 1, 3); + + // Status line + statusLabel->setText(tr("Click refresh to download parameters")); + layout->addWidget(statusLabel, 1, 0, 1, 3); + + // BUTTONS + addActionButtonsToLayout(layout); // Set correct vertical scaling - horizontalLayout->setRowStretch(0, 100); - horizontalLayout->setRowStretch(1, 10); - horizontalLayout->setRowStretch(2, 10); - horizontalLayout->setRowStretch(3, 10); + layout->setRowStretch(0, 100); + layout->setRowStretch(1, 10); + layout->setRowStretch(2, 10); + layout->setRowStretch(3, 10); // Set layout - this->setLayout(horizontalLayout); + this->setLayout(layout); // Set header QStringList headerItems; diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h index 3fc34214c0c2eac4a092414885d93987a2ba381a..83787de1d43193de0684c93972791865ed0c8216 100644 --- a/src/ui/QGCParamWidget.h +++ b/src/ui/QGCParamWidget.h @@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project //forward declarations +class QGridLayout; class UASInterface; /** @@ -67,6 +68,9 @@ protected: */ void addComponentItem(int compId, QString compName); + virtual void addActionButtonsToLayout(QGridLayout* layout); + + signals: diff --git a/src/ui/QGCPendingParamWidget.cc b/src/ui/QGCPendingParamWidget.cc index a37e20c7b44c774d9a291e8897985b0f517f5fc5..c5fb5a010f0dd57106413191ec5083697e1c17ef 100644 --- a/src/ui/QGCPendingParamWidget.cc +++ b/src/ui/QGCPendingParamWidget.cc @@ -1,5 +1,8 @@ #include "QGCPendingParamWidget.h" +#include +#include + #include "UASManager.h" #include "UASParameterCommsMgr.h" @@ -80,3 +83,22 @@ void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& } +void QGCPendingParamWidget::addActionButtonsToLayout(QGridLayout* layout) +{ + + QPushButton* setButton = new QPushButton(tr("Set")); + setButton->setToolTip(tr("Send pending parameters to volatile onboard memory")); + setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory")); + connect(setButton, SIGNAL(clicked()), + paramMgr, SLOT(sendPendingParameters())); + layout->addWidget(setButton, 2, 0); + + QPushButton* clearButton = new QPushButton(tr("Clear")); + clearButton->setToolTip(tr("Clear pending parameters without sending")); + clearButton->setWhatsThis(tr("Clear pending parameters without sending")); + connect(clearButton, SIGNAL(clicked()), + paramMgr, SLOT(clearAllPendingParams())); + layout->addWidget(clearButton, 2, 1); + + +} diff --git a/src/ui/QGCPendingParamWidget.h b/src/ui/QGCPendingParamWidget.h index 27e53f1d8496778deffe08dbc7e925837d144fa9..31b0d758d88c2b0e74a4bb8eb06c0d75f8c1b245 100644 --- a/src/ui/QGCPendingParamWidget.h +++ b/src/ui/QGCPendingParamWidget.h @@ -4,6 +4,8 @@ #include "QGCParamWidget.h" +class QGridLayout; + class QGCPendingParamWidget : public QGCParamWidget { Q_OBJECT @@ -18,6 +20,8 @@ protected: virtual void connectViewSignalsAndSlots(); virtual void disconnectViewSignalsAndSlots(); + virtual void addActionButtonsToLayout(QGridLayout* layout); + signals: