Commit c7d4af26 authored by tstellanova's avatar tstellanova

prelim extraction of read-only pending params widget

parent 16170648
...@@ -470,7 +470,8 @@ HEADERS += src/MG.h \ ...@@ -470,7 +470,8 @@ HEADERS += src/MG.h \
src/ui/configuration/ApmHighlighter.h \ src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h \ src/ui/configuration/ApmFirmwareConfig.h \
src/uas/UASParameterDataModel.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 # 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 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 \ ...@@ -687,7 +688,8 @@ SOURCES += src/main.cc \
src/ui/configuration/ApmHighlighter.cc \ src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc \ src/ui/configuration/ApmFirmwareConfig.cc \
src/uas/UASParameterDataModel.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 # 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 macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
...@@ -18,9 +18,6 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) : ...@@ -18,9 +18,6 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
// Load default values and tooltips // Load default values and tooltips
loadParamMetaInfoCSV(); loadParamMetaInfoCSV();
} }
...@@ -75,6 +72,11 @@ void QGCUASParamManager::sendPendingParameters() ...@@ -75,6 +72,11 @@ void QGCUASParamManager::sendPendingParameters()
paramCommsMgr->sendPendingParameters(); paramCommsMgr->sendPendingParameters();
} }
void QGCUASParamManager::setPendingParam(int compId, QString& paramName, const QVariant& value)
{
paramDataModel->setPendingParam(compId,paramName,value);
}
void QGCUASParamManager::loadParamMetaInfoCSV() void QGCUASParamManager::loadParamMetaInfoCSV()
......
...@@ -49,6 +49,8 @@ public slots: ...@@ -49,6 +49,8 @@ public slots:
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
virtual void requestParameterList(); virtual void requestParameterList();
virtual void setPendingParam(int componentId, QString& key, const QVariant& value);
/** @brief Request a single parameter by name from the MAV */ /** @brief Request a single parameter by name from the MAV */
virtual void requestParameterUpdate(int component, const QString& parameter); virtual void requestParameterUpdate(int component, const QString& parameter);
......
...@@ -98,6 +98,7 @@ void ParameterInterface::addUAS(UASInterface* uas) ...@@ -98,6 +98,7 @@ void ParameterInterface::addUAS(UASInterface* uas)
} }
QGCParamWidget* param = new QGCParamWidget(uas, this); QGCParamWidget* param = new QGCParamWidget(uas, this);
param->init();
QString ptrStr; QString ptrStr;
ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", param,this); ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", param,this);
qDebug() << "Created " << ptrStr << " for UAS id: " << uasId << " count: " << paramWidgets->count(); qDebug() << "Created " << ptrStr << " for UAS id: " << uasId << " count: " << paramWidgets->count();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "QGCPX4VehicleConfig.h" #include "QGCPX4VehicleConfig.h"
#include "QGC.h" #include "QGC.h"
#include "QGCPendingParamWidget.h"
#include "QGCToolWidget.h" #include "QGCToolWidget.h"
#include "UASManager.h" #include "UASManager.h"
#include "UASParameterCommsMgr.h" #include "UASParameterCommsMgr.h"
...@@ -82,7 +83,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ...@@ -82,7 +83,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
connect(ui->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int))); connect(ui->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int)));
//connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions())); //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 //TODO the following methods are not yet implemented
...@@ -301,7 +304,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) ...@@ -301,7 +304,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
} }
// Generate widgets for the Advanced tab. // Generate widgets for the Advanced tab.
left = true;
foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot)) foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
{ {
if (file.toLower().endsWith(".qgw")) { if (file.toLower().endsWith(".qgw")) {
...@@ -1232,8 +1234,6 @@ void QGCPX4VehicleConfig::handleRcParameterChange(QString parameterName, QVarian ...@@ -1232,8 +1234,6 @@ void QGCPX4VehicleConfig::handleRcParameterChange(QString parameterName, QVarian
void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value) void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{ {
Q_UNUSED(uas);
Q_UNUSED(component);
if (!doneLoadingConfig) { if (!doneLoadingConfig) {
//We do not want to attempt to generate any UI elements until loading of the config file is complete. //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. //We should re-request params later if needed, that is not implemented yet.
......
...@@ -187,6 +187,7 @@ protected: ...@@ -187,6 +187,7 @@ protected:
QTimer updateTimer; ///< Controls update intervals QTimer updateTimer; ///< Controls update intervals
enum RC_MODE rc_mode; ///< Mode of the remote control, according to usual convention enum RC_MODE rc_mode; ///< Mode of the remote control, according to usual convention
QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets
QMap<QString,QGCToolWidget*> toolWidgetsByName; ///<
bool calibrationEnabled; ///< calibration mode on / off bool calibrationEnabled; ///< calibration mode on / off
QMap<QString,QGCToolWidget*> paramToWidgetMap; ///< Holds the current active MAV's parameter widgets. QMap<QString,QGCToolWidget*> paramToWidgetMap; ///< Holds the current active MAV's parameter widgets.
......
...@@ -138,7 +138,7 @@ Config</string> ...@@ -138,7 +138,7 @@ Config</string>
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="rcTab"> <widget class="QWidget" name="rcTab">
<layout class="QVBoxLayout" name="verticalLayout_17"> <layout class="QVBoxLayout" name="verticalLayout_17">
...@@ -1035,8 +1035,8 @@ p, li { white-space: pre-wrap; } ...@@ -1035,8 +1035,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>16</width> <width>597</width>
<height>16</height> <height>569</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
...@@ -1168,7 +1168,17 @@ p, li { white-space: pre-wrap; } ...@@ -1168,7 +1168,17 @@ p, li { white-space: pre-wrap; }
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTreeView" name="pendingCommitsTreeView"/> <widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="setButton"> <widget class="QPushButton" name="setButton">
...@@ -1259,6 +1269,12 @@ p, li { white-space: pre-wrap; } ...@@ -1259,6 +1269,12 @@ p, li { white-space: pre-wrap; }
<header>ui/designer/QGCRadioChannelDisplay.h</header> <header>ui/designer/QGCRadioChannelDisplay.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QGCPendingParamWidget</class>
<extends>QWidget</extends>
<header>/ui/QGCPendingParamWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -55,9 +55,19 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : ...@@ -55,9 +55,19 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
updatingParamNameLock("") updatingParamNameLock("")
{ {
}
void QGCParamWidget::init()
{
layoutWidget(); layoutWidget();
connectSignalsAndSlots();
// Ensure we're receiving the list of params
requestAllParamsUpdate();
}
// Connect signals/slots void QGCParamWidget::connectSignalsAndSlots()
{
// Listen for edits to the tree UI // Listen for edits to the tree UI
connect(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), connect(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
...@@ -77,15 +87,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : ...@@ -77,15 +87,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
// Listen to communications status messages so we can display them // Listen to communications status messages so we can display them
connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int ))); this, SLOT(handleParamStatusMsgUpdate(QString , int )));
// Ensure we're receiving the list of params
requestAllParamsUpdate();
} }
void QGCParamWidget::layoutWidget() void QGCParamWidget::layoutWidget()
{ {
// Create tree widget // Create tree widget
......
...@@ -48,10 +48,12 @@ class QGCParamWidget : public QGCUASParamManager ...@@ -48,10 +48,12 @@ class QGCParamWidget : public QGCUASParamManager
Q_OBJECT Q_OBJECT
public: public:
QGCParamWidget(UASInterface* uas, QWidget *parent = 0); QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
virtual void init(); ///< Two-stage construction: initialize the object
protected: protected:
virtual void setParameterStatusMsg(const QString& msg); 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* getParentWidgetItemForParam(int compId, const QString& paramName);
virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName); virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName);
......
#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 )));
}
#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
...@@ -48,7 +48,7 @@ QGCComboBox::QGCComboBox(QWidget *parent) : ...@@ -48,7 +48,7 @@ QGCComboBox::QGCComboBox(QWidget *parent) :
connect(ui->editRemoveItemButton,SIGNAL(clicked()),this,SLOT(delButtonClicked())); connect(ui->editRemoveItemButton,SIGNAL(clicked()),this,SLOT(delButtonClicked()));
// Sending actions // 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->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectComponent(int)));
connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int))); connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int)));
//connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int))); //connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int)));
...@@ -233,24 +233,13 @@ void QGCComboBox::endEditMode() ...@@ -233,24 +233,13 @@ void QGCComboBox::endEditMode()
emit editingFinished(); emit editingFinished();
} }
void QGCComboBox::sendParameter() void QGCComboBox::setParamPending()
{ {
if (uas) if (uas) {
{ uas->getParamManager()->setPendingParam(component, parameterName, parameterValue);
// 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";
}
} }
else else {
{ qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
} }
} }
......
...@@ -23,8 +23,8 @@ public: ...@@ -23,8 +23,8 @@ public:
public slots: public slots:
void startEditMode(); void startEditMode();
void endEditMode(); void endEditMode();
/** @brief Send the parameter to the MAV */ /** @brief Queue parameter for sending to the MAV (add to pending list)*/
void sendParameter(); void setParamPending();
/** @brief Update the UI with the new parameter value */ /** @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 setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void writeSettings(QSettings& settings); void writeSettings(QSettings& settings);
......
...@@ -47,20 +47,31 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ...@@ -47,20 +47,31 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
// Sending actions // Sending actions
connect(ui->writeButton, SIGNAL(clicked()), this, SLOT(sendParameter())); connect(ui->writeButton, SIGNAL(clicked()),
connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectComponent(int))); this, SLOT(setParamPending()));
connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int))); connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)),
connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int))); this, SLOT(selectComponent(int)));
connect(ui->doubleValueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setParamValue(double))); connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)),
connect(ui->intValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setParamValue(int))); this, SLOT(selectParameter(int)));
connect(ui->editNameLabel, SIGNAL(textChanged(QString)), ui->nameLabel, SLOT(setText(QString))); 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->readButton, SIGNAL(clicked()), this, SLOT(requestParameter()));
connect(ui->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParamList())); connect(ui->editRefreshParamsButton, SIGNAL(clicked()),
connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(showInfo(bool))); this, SLOT(refreshParamList()));
connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)),
this, SLOT(showInfo(bool)));
// connect to self // 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 // 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() QGCParamSlider::~QGCParamSlider()
...@@ -83,8 +94,7 @@ void QGCParamSlider::refreshParamList() ...@@ -83,8 +94,7 @@ void QGCParamSlider::refreshParamList()
{ {
ui->editSelectParamComboBox->setEnabled(true); ui->editSelectParamComboBox->setEnabled(true);
ui->editSelectComponentComboBox->setEnabled(true); ui->editSelectComponentComboBox->setEnabled(true);
if (uas) if (uas) {
{
uas->getParamManager()->requestParameterList(); uas->getParamManager()->requestParameterList();
ui->editStatusLabel->setText(tr("Parameter list updating..")); ui->editStatusLabel->setText(tr("Parameter list updating.."));
} }
...@@ -122,9 +132,8 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas) ...@@ -122,9 +132,8 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
void QGCParamSlider::requestParameter() void QGCParamSlider::requestParameter()
{ {
if (!parameterName.isEmpty() && uas) if (uas && !parameterName.isEmpty()) {
{ uas->getParamManager()->requestParameterUpdate(component, parameterName);
uas->getParamManager()->requestParameterUpdate(this->component, this->parameterName);
} }
} }
...@@ -268,23 +277,13 @@ void QGCParamSlider::endEditMode() ...@@ -268,23 +277,13 @@ void QGCParamSlider::endEditMode()
emit editingFinished(); emit editingFinished();
} }
void QGCParamSlider::sendParameter() void QGCParamSlider::setParamPending()
{ {
if (uas) if (uas) {
{ uas->getParamManager()->setPendingParam(component, parameterName, parameterValue);
// Set value, param manager handles retransmission
if (uas->getParamManager())
{
uas->getParamManager()->setParameter(component, parameterName, parameterValue);
}
else
{
qDebug() << "UAS HAS NO PARAM MANAGER, DOING NOTHING";
}
} }
else else {
{ qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
} }
} }
...@@ -329,55 +328,48 @@ void QGCParamSlider::setSliderValue(int sliderValue) ...@@ -329,55 +328,48 @@ void QGCParamSlider::setSliderValue(int sliderValue)
* @brief parameterName Key/name of the parameter * @brief parameterName Key/name of the parameter
* @brief value Value 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); Q_UNUSED(paramCount);
if (ui->nameLabel->text() == "Name") if (uasId != this->uas->getUASID()) {
{ return;
ui->nameLabel->setText(parameterName); }
if (ui->nameLabel->text() == "Name") {
ui->nameLabel->setText(paramName);
} }
// Check if this component and parameter are part of the list // Check if this component and parameter are part of the list
bool found = false; bool found = false;
for (int i = 0; i< ui->editSelectComponentComboBox->count(); ++i) for (int i = 0; i< ui->editSelectComponentComboBox->count(); ++i) {
{ if (compId == ui->editSelectComponentComboBox->itemData(i).toInt()) {
if (component == ui->editSelectComponentComboBox->itemData(i).toInt())
{
found = true; found = true;
} }
} }
if (!found) if (!found) {
{ ui->editSelectComponentComboBox->addItem(tr("Component #%1").arg(compId), compId);
ui->editSelectComponentComboBox->addItem(tr("Component #%1").arg(component), component);
} }
// Parameter checking // Parameter checking
found = false; found = false;
for (int i = 0; i < ui->editSelectParamComboBox->count(); ++i) for (int i = 0; i < ui->editSelectParamComboBox->count(); ++i) {
{ if (paramName == ui->editSelectParamComboBox->itemText(i)) {
if (parameterName == ui->editSelectParamComboBox->itemText(i))
{
found = true; found = true;
} }
} }
if (!found) if (!found) {
{ ui->editSelectParamComboBox->addItem(paramName, paramIndex);
ui->editSelectParamComboBox->addItem(parameterName, paramIndex);
} }
if (visibleParam != "") if (visibleParam != "") {
{ if (paramName == visibleParam) {
if (parameterName == visibleParam) if (visibleVal == value.toInt()) {
{ uas->getParamManager()->requestParameterUpdate(compId,paramName);
if (visibleVal == value.toInt())
{
this->uas->requestParameter(this->component,this->parameterName);
visibleEnabled = true; visibleEnabled = true;
this->show(); this->show();
} }
else else {
{
//Disable the component here. //Disable the component here.
ui->valueSlider->setEnabled(false); ui->valueSlider->setEnabled(false);
ui->intValueSpinBox->setEnabled(false); ui->intValueSpinBox->setEnabled(false);
...@@ -388,10 +380,8 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i ...@@ -388,10 +380,8 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i
} }
} }
Q_UNUSED(uas); Q_UNUSED(uas);
if (component == this->component && parameterName == this->parameterName) if (compId == this->component && paramName == this->parameterName) {
{ if (!visibleEnabled) {
if (!visibleEnabled)
{
return; return;
} }
parameterValue = value; parameterValue = value;
...@@ -460,8 +450,7 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i ...@@ -460,8 +450,7 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i
parameterMin = ui->editMinSpinBox->value(); parameterMin = ui->editMinSpinBox->value();
} }
if (paramIndex == paramCount - 1) if (paramIndex == paramCount - 1) {
{
ui->editStatusLabel->setText(tr("Complete parameter list received.")); ui->editStatusLabel->setText(tr("Complete parameter list received."));
} }
} }
......
...@@ -23,8 +23,8 @@ public: ...@@ -23,8 +23,8 @@ public:
public slots: public slots:
void startEditMode(); void startEditMode();
void endEditMode(); void endEditMode();
/** @brief Send the parameter to the MAV */ /** @brief Queue parameter for sending to the MAV (add to pending list)*/
void sendParameter(); void setParamPending();
/** @brief Set the slider value as parameter value */ /** @brief Set the slider value as parameter value */
void setSliderValue(int sliderValue); void setSliderValue(int sliderValue);
/** @brief Update the UI with the new parameter value */ /** @brief Update the UI with the new parameter value */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment