diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 6f0f51ca488c79ca9411c2dff946f03d7d5ae09c..cf714d579cebe5cdffb54d27365344a2b40e85c9 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -470,7 +470,8 @@ HEADERS += src/MG.h \ src/ui/configuration/ApmHighlighter.h \ src/ui/configuration/ApmFirmwareConfig.h \ src/uas/UASParameterDataModel.h \ - src/uas/UASParameterCommsMgr.h + src/uas/UASParameterCommsMgr.h \ + src/ui/QGCPendingParamWidget.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -687,7 +688,8 @@ SOURCES += src/main.cc \ src/ui/configuration/ApmHighlighter.cc \ src/ui/configuration/ApmFirmwareConfig.cc \ src/uas/UASParameterDataModel.cc \ - src/uas/UASParameterCommsMgr.cc + src/uas/UASParameterCommsMgr.cc \ + src/ui/QGCPendingParamWidget.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc index fcc78a6cb669391de11a8245515ac321b4a6f16c..f1fd085bff87d2552484aba7042afb60e152eb25 100644 --- a/src/uas/QGCUASParamManager.cc +++ b/src/uas/QGCUASParamManager.cc @@ -18,9 +18,6 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) : // Load default values and tooltips loadParamMetaInfoCSV(); - - - } @@ -75,6 +72,11 @@ void QGCUASParamManager::sendPendingParameters() paramCommsMgr->sendPendingParameters(); } +void QGCUASParamManager::setPendingParam(int compId, QString& paramName, const QVariant& value) +{ + paramDataModel->setPendingParam(compId,paramName,value); +} + void QGCUASParamManager::loadParamMetaInfoCSV() diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h index 5612334e6e987690f58e57653b2a6ed3789bb6ee..6c910509cd7f74375ae335731d4894d02ff9a58c 100644 --- a/src/uas/QGCUASParamManager.h +++ b/src/uas/QGCUASParamManager.h @@ -49,6 +49,8 @@ public slots: /** @brief Request list of parameters from MAV */ virtual void requestParameterList(); + virtual void setPendingParam(int componentId, QString& key, const QVariant& value); + /** @brief Request a single parameter by name from the MAV */ virtual void requestParameterUpdate(int component, const QString& parameter); diff --git a/src/ui/ParameterInterface.cc b/src/ui/ParameterInterface.cc index c7d5f811b3ab8b23c29d623bb49b3a77d6425b09..93624d50ea6b871f87277d651bc76816092b2683 100644 --- a/src/ui/ParameterInterface.cc +++ b/src/ui/ParameterInterface.cc @@ -98,6 +98,7 @@ void ParameterInterface::addUAS(UASInterface* uas) } QGCParamWidget* param = new QGCParamWidget(uas, this); + param->init(); QString ptrStr; ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", param,this); qDebug() << "Created " << ptrStr << " for UAS id: " << uasId << " count: " << paramWidgets->count(); diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index 177a5e0660ea149044c107782fd8d2edd3b49e9e..e28569335bbe26f23be31d767acb388a65235954 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -15,6 +15,7 @@ #include "QGCPX4VehicleConfig.h" #include "QGC.h" +#include "QGCPendingParamWidget.h" #include "QGCToolWidget.h" #include "UASManager.h" #include "UASParameterCommsMgr.h" @@ -82,7 +83,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : connect(ui->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int))); //connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions())); - + //TODO connect buttons here to save/clear actions? + ui->pendingCommitsWidget->init(); + ui->pendingCommitsWidget->update(); //TODO the following methods are not yet implemented @@ -301,7 +304,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) } // Generate widgets for the Advanced tab. - left = true; foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { @@ -1232,8 +1234,6 @@ void QGCPX4VehicleConfig::handleRcParameterChange(QString parameterName, QVarian void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value) { - Q_UNUSED(uas); - Q_UNUSED(component); if (!doneLoadingConfig) { //We do not want to attempt to generate any UI elements until loading of the config file is complete. //We should re-request params later if needed, that is not implemented yet. diff --git a/src/ui/QGCPX4VehicleConfig.h b/src/ui/QGCPX4VehicleConfig.h index 93761d52f2aeb43a3fbe1571a868dc981e906582..a242fcf9d3d4b9c210b9dcb83edef26a7225f717 100644 --- a/src/ui/QGCPX4VehicleConfig.h +++ b/src/ui/QGCPX4VehicleConfig.h @@ -187,6 +187,7 @@ protected: QTimer updateTimer; ///< Controls update intervals enum RC_MODE rc_mode; ///< Mode of the remote control, according to usual convention QList toolWidgets; ///< Configurable widgets + QMap toolWidgetsByName; ///< bool calibrationEnabled; ///< calibration mode on / off QMap paramToWidgetMap; ///< Holds the current active MAV's parameter widgets. diff --git a/src/ui/QGCPX4VehicleConfig.ui b/src/ui/QGCPX4VehicleConfig.ui index 8607a55643c540d831a7b0290ace9a4f673e7e58..da0ddfd9b14f9b30ad3c3eb374727e2d1a4551db 100644 --- a/src/ui/QGCPX4VehicleConfig.ui +++ b/src/ui/QGCPX4VehicleConfig.ui @@ -138,7 +138,7 @@ Config - 0 + 3 @@ -1035,8 +1035,8 @@ p, li { white-space: pre-wrap; } 0 0 - 16 - 16 + 597 + 569 @@ -1168,7 +1168,17 @@ p, li { white-space: pre-wrap; } 0 - + + + + 0 + 30 + + + + true + + @@ -1259,6 +1269,12 @@ p, li { white-space: pre-wrap; }
ui/designer/QGCRadioChannelDisplay.h
1 + + QGCPendingParamWidget + QWidget +
/ui/QGCPendingParamWidget.h
+ 1 +
diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc index ab8624c64f7d2a3c26dae6af774a7ecdcb765914..1f4889603d14fc343ad8f6bd5dc4bd3605f209ad 100644 --- a/src/ui/QGCParamWidget.cc +++ b/src/ui/QGCParamWidget.cc @@ -55,9 +55,19 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : updatingParamNameLock("") { +} + +void QGCParamWidget::init() +{ layoutWidget(); + connectSignalsAndSlots(); + + // Ensure we're receiving the list of params + requestAllParamsUpdate(); +} - // Connect signals/slots +void QGCParamWidget::connectSignalsAndSlots() +{ // Listen for edits to the tree UI connect(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), @@ -77,15 +87,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : // Listen to communications status messages so we can display them connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), this, SLOT(handleParamStatusMsgUpdate(QString , int ))); - - // Ensure we're receiving the list of params - requestAllParamsUpdate(); - } - - - void QGCParamWidget::layoutWidget() { // Create tree widget diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h index 3578ed04ba5fe36dcd6b9ce1c3d1a1c738d6be70..f23a627d339ac20cd5dc1d4310f736365e4ce2b3 100644 --- a/src/ui/QGCParamWidget.h +++ b/src/ui/QGCParamWidget.h @@ -48,10 +48,12 @@ class QGCParamWidget : public QGCUASParamManager Q_OBJECT public: QGCParamWidget(UASInterface* uas, QWidget *parent = 0); + virtual void init(); ///< Two-stage construction: initialize the object protected: virtual void setParameterStatusMsg(const QString& msg); - virtual void layoutWidget(); + virtual void layoutWidget();///< Layout the appearance of this widget + virtual void connectSignalsAndSlots();///< Connect signals/slots as needed virtual QTreeWidgetItem* getParentWidgetItemForParam(int compId, const QString& paramName); virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName); diff --git a/src/ui/QGCPendingParamWidget.cc b/src/ui/QGCPendingParamWidget.cc new file mode 100644 index 0000000000000000000000000000000000000000..800ca354e0cca9744f12a91e43b8e550ad9318fd --- /dev/null +++ b/src/ui/QGCPendingParamWidget.cc @@ -0,0 +1,33 @@ +#include "QGCPendingParamWidget.h" + +#include "UASManager.h" +#include "UASParameterCommsMgr.h" + + +QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) : + QGCParamWidget(UASManager::instance()->getActiveUAS(),(QWidget*)parent) +{ +} + + +void QGCPendingParamWidget::init() +{ + //we override a lot of the super's init methods + layoutWidget(); + connectSignalsAndSlots(); + + //don't request update params here...assume that everything we need is in the data model +} + +void QGCPendingParamWidget::connectSignalsAndSlots() +{ + // Listing for pending list update + connect(paramDataModel, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), + this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); + + // Listen to communications status messages so we can display them + connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), + this, SLOT(handleParamStatusMsgUpdate(QString , int ))); +} + + diff --git a/src/ui/QGCPendingParamWidget.h b/src/ui/QGCPendingParamWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..91f08a522fd982ef675c77c784e5063349cbf6e2 --- /dev/null +++ b/src/ui/QGCPendingParamWidget.h @@ -0,0 +1,26 @@ +#ifndef QGCPENDINGPARAMWIDGET_H +#define QGCPENDINGPARAMWIDGET_H + + +#include "QGCParamWidget.h" + +class QGCPendingParamWidget : public QGCParamWidget +{ + Q_OBJECT + +public: + explicit QGCPendingParamWidget(QObject* parent); + virtual void init(); ///< Two-stage construction: initialize the object + +protected: + virtual void connectSignalsAndSlots(); + + + +signals: + +public slots: + +}; + +#endif // QGCPENDINGPARAMWIDGET_H diff --git a/src/ui/designer/QGCComboBox.cc b/src/ui/designer/QGCComboBox.cc index 91f9dfc21bd0c68a63ca1c6120f108516f079d95..01ca3881b888730de03ab424bcfd9dce6f3a8269 100644 --- a/src/ui/designer/QGCComboBox.cc +++ b/src/ui/designer/QGCComboBox.cc @@ -48,7 +48,7 @@ QGCComboBox::QGCComboBox(QWidget *parent) : connect(ui->editRemoveItemButton,SIGNAL(clicked()),this,SLOT(delButtonClicked())); // Sending actions - connect(ui->writeButton, SIGNAL(clicked()), this, SLOT(sendParameter())); + connect(ui->writeButton, SIGNAL(clicked()), this, SLOT(setParamPending())); connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectComponent(int))); connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int))); //connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int))); @@ -233,24 +233,13 @@ void QGCComboBox::endEditMode() emit editingFinished(); } -void QGCComboBox::sendParameter() +void QGCComboBox::setParamPending() { - if (uas) - { - // Set value, param manager handles retransmission - if (uas->getParamManager()) - { - qDebug() << "Sending param:" << parameterName << "to component" << component << "with a value of" << parameterValue; - uas->getParamManager()->setParameter(component, parameterName, parameterValue); - } - else - { - qDebug() << "UAS HAS NO PARAM MANAGER, DOING NOTHING"; - } + if (uas) { + uas->getParamManager()->setPendingParam(component, parameterName, parameterValue); } - else - { - qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; + else { + qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; } } diff --git a/src/ui/designer/QGCComboBox.h b/src/ui/designer/QGCComboBox.h index 4c5491580e5c7da5af777354a7a4e03bb675bdb8..ecc71126b5b3bdc976e22abe40979582da5546a7 100644 --- a/src/ui/designer/QGCComboBox.h +++ b/src/ui/designer/QGCComboBox.h @@ -23,8 +23,8 @@ public: public slots: void startEditMode(); void endEditMode(); - /** @brief Send the parameter to the MAV */ - void sendParameter(); + /** @brief Queue parameter for sending to the MAV (add to pending list)*/ + void setParamPending(); /** @brief Update the UI with the new parameter value */ void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, const QVariant value); void writeSettings(QSettings& settings); diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index 32b236a4b853e3cb6a55f4fb60ad587b1605be1b..54b3bd723ee827c814505ab81ad82a4ae89284f0 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -47,20 +47,31 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); // Sending actions - connect(ui->writeButton, SIGNAL(clicked()), this, SLOT(sendParameter())); - connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectComponent(int))); - connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int))); - connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int))); - connect(ui->doubleValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setParamValue(double))); - connect(ui->intValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setParamValue(int))); - connect(ui->editNameLabel, SIGNAL(textChanged(QString)), ui->nameLabel, SLOT(setText(QString))); + connect(ui->writeButton, SIGNAL(clicked()), + this, SLOT(setParamPending())); + connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(selectComponent(int))); + connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(selectParameter(int))); + connect(ui->valueSlider, SIGNAL(valueChanged(int)), + this, SLOT(setSliderValue(int))); + connect(ui->doubleValueSpinBox, SIGNAL(valueChanged(double)), + this, SLOT(setParamValue(double))); + connect(ui->intValueSpinBox, SIGNAL(valueChanged(int)), + this, SLOT(setParamValue(int))); + connect(ui->editNameLabel, SIGNAL(textChanged(QString)), + ui->nameLabel, SLOT(setText(QString))); connect(ui->readButton, SIGNAL(clicked()), this, SLOT(requestParameter())); - connect(ui->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParamList())); - connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(showInfo(bool))); + connect(ui->editRefreshParamsButton, SIGNAL(clicked()), + this, SLOT(refreshParamList())); + connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), + this, SLOT(showInfo(bool))); // connect to self - connect(ui->infoLabel, SIGNAL(released()), this, SLOT(showTooltip())); + connect(ui->infoLabel, SIGNAL(released()), + this, SLOT(showTooltip())); // Set the current UAS if present - connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), + this, SLOT(setActiveUAS(UASInterface*))); } QGCParamSlider::~QGCParamSlider() @@ -83,8 +94,7 @@ void QGCParamSlider::refreshParamList() { ui->editSelectParamComboBox->setEnabled(true); ui->editSelectComponentComboBox->setEnabled(true); - if (uas) - { + if (uas) { uas->getParamManager()->requestParameterList(); ui->editStatusLabel->setText(tr("Parameter list updating..")); } @@ -122,9 +132,8 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas) void QGCParamSlider::requestParameter() { - if (!parameterName.isEmpty() && uas) - { - uas->getParamManager()->requestParameterUpdate(this->component, this->parameterName); + if (uas && !parameterName.isEmpty()) { + uas->getParamManager()->requestParameterUpdate(component, parameterName); } } @@ -268,23 +277,13 @@ void QGCParamSlider::endEditMode() emit editingFinished(); } -void QGCParamSlider::sendParameter() +void QGCParamSlider::setParamPending() { - if (uas) - { - // Set value, param manager handles retransmission - if (uas->getParamManager()) - { - uas->getParamManager()->setParameter(component, parameterName, parameterValue); - } - else - { - qDebug() << "UAS HAS NO PARAM MANAGER, DOING NOTHING"; - } + if (uas) { + uas->getParamManager()->setPendingParam(component, parameterName, parameterValue); } - else - { - qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; + else { + qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; } } @@ -329,55 +328,48 @@ void QGCParamSlider::setSliderValue(int sliderValue) * @brief parameterName Key/name of the parameter * @brief value Value of the parameter */ -void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, QVariant value) +void QGCParamSlider::setParameterValue(int uasId, int compId, int paramCount, int paramIndex, QString paramName, QVariant value) { Q_UNUSED(paramCount); - if (ui->nameLabel->text() == "Name") - { - ui->nameLabel->setText(parameterName); + if (uasId != this->uas->getUASID()) { + return; + } + + if (ui->nameLabel->text() == "Name") { + ui->nameLabel->setText(paramName); } // Check if this component and parameter are part of the list bool found = false; - for (int i = 0; i< ui->editSelectComponentComboBox->count(); ++i) - { - if (component == ui->editSelectComponentComboBox->itemData(i).toInt()) - { + for (int i = 0; i< ui->editSelectComponentComboBox->count(); ++i) { + if (compId == ui->editSelectComponentComboBox->itemData(i).toInt()) { found = true; } } - if (!found) - { - ui->editSelectComponentComboBox->addItem(tr("Component #%1").arg(component), component); + if (!found) { + ui->editSelectComponentComboBox->addItem(tr("Component #%1").arg(compId), compId); } // Parameter checking found = false; - for (int i = 0; i < ui->editSelectParamComboBox->count(); ++i) - { - if (parameterName == ui->editSelectParamComboBox->itemText(i)) - { + for (int i = 0; i < ui->editSelectParamComboBox->count(); ++i) { + if (paramName == ui->editSelectParamComboBox->itemText(i)) { found = true; } } - if (!found) - { - ui->editSelectParamComboBox->addItem(parameterName, paramIndex); + if (!found) { + ui->editSelectParamComboBox->addItem(paramName, paramIndex); } - if (visibleParam != "") - { - if (parameterName == visibleParam) - { - if (visibleVal == value.toInt()) - { - this->uas->requestParameter(this->component,this->parameterName); + if (visibleParam != "") { + if (paramName == visibleParam) { + if (visibleVal == value.toInt()) { + uas->getParamManager()->requestParameterUpdate(compId,paramName); visibleEnabled = true; this->show(); } - else - { + else { //Disable the component here. ui->valueSlider->setEnabled(false); ui->intValueSpinBox->setEnabled(false); @@ -388,10 +380,8 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i } } Q_UNUSED(uas); - if (component == this->component && parameterName == this->parameterName) - { - if (!visibleEnabled) - { + if (compId == this->component && paramName == this->parameterName) { + if (!visibleEnabled) { return; } parameterValue = value; @@ -460,8 +450,7 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i parameterMin = ui->editMinSpinBox->value(); } - if (paramIndex == paramCount - 1) - { + if (paramIndex == paramCount - 1) { ui->editStatusLabel->setText(tr("Complete parameter list received.")); } } diff --git a/src/ui/designer/QGCParamSlider.h b/src/ui/designer/QGCParamSlider.h index 7160cd937ef5e48f7930ab3cb99e448936d68429..3ef78fdf714d26e50b1f2a6e9cbd683b1c876a0c 100644 --- a/src/ui/designer/QGCParamSlider.h +++ b/src/ui/designer/QGCParamSlider.h @@ -23,8 +23,8 @@ public: public slots: void startEditMode(); void endEditMode(); - /** @brief Send the parameter to the MAV */ - void sendParameter(); + /** @brief Queue parameter for sending to the MAV (add to pending list)*/ + void setParamPending(); /** @brief Set the slider value as parameter value */ void setSliderValue(int sliderValue); /** @brief Update the UI with the new parameter value */