Commit 4646c681 authored by tstellanova's avatar tstellanova

Cleanup buttons in px4config; impl clearing pending list

parent d6801ac6
#include "QGCUASParamManager.h" #include "QGCUASParamManager.h"
#include <QApplication>> #include <QApplication>
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
...@@ -27,28 +27,30 @@ QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas) ...@@ -27,28 +27,30 @@ QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas)
paramCommsMgr = new UASParameterCommsMgr(this); paramCommsMgr = new UASParameterCommsMgr(this);
paramCommsMgr->initWithUAS(uas); paramCommsMgr->initWithUAS(uas);
connectToCommsMgr(); connectToModelAndComms();
return this; return this;
} }
void QGCUASParamManager::connectToCommsMgr() void QGCUASParamManager::connectToModelAndComms()
{ {
// Pass along comms mgr status msgs // Pass along comms mgr status msgs
connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)), connect(paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SIGNAL(parameterStatusMsgUpdated(QString,int))); this, SIGNAL(parameterStatusMsgUpdated(QString,int)));
connect(paramCommsMgr, SIGNAL(parameterListUpToDate()), connect(paramCommsMgr, SIGNAL(parameterListUpToDate()),
this, SIGNAL(parameterListUpToDate())); this, SIGNAL(parameterListUpToDate()));
}
void QGCUASParamManager::clearAllPendingParams()
{
paramDataModel.clearAllPendingParams();
} }
bool QGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const bool QGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const
{ {
return paramDataModel.getOnboardParamValue(component,parameter,value); return paramDataModel.getOnboardParamValue(component,parameter,value);
......
...@@ -39,7 +39,7 @@ protected: ...@@ -39,7 +39,7 @@ protected:
/** @brief Load parameter meta information from appropriate CSV file */ /** @brief Load parameter meta information from appropriate CSV file */
virtual void loadParamMetaInfoCSV(); virtual void loadParamMetaInfoCSV();
void connectToCommsMgr(); void connectToModelAndComms();
signals: signals:
...@@ -49,6 +49,8 @@ signals: ...@@ -49,6 +49,8 @@ signals:
/** @brief We have received a complete list of all parameters onboard the MAV */ /** @brief We have received a complete list of all parameters onboard the MAV */
void parameterListUpToDate(); void parameterListUpToDate();
public slots: public slots:
/** @brief Send one parameter to the MAV: changes value in transient memory of MAV */ /** @brief Send one parameter to the MAV: changes value in transient memory of MAV */
virtual void setParameter(int component, QString parameterName, QVariant value); virtual void setParameter(int component, QString parameterName, QVariant value);
...@@ -64,6 +66,9 @@ public slots: ...@@ -64,6 +66,9 @@ public slots:
virtual void setPendingParam(int componentId, QString& key, const QVariant& value); 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 */ /** @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);
......
...@@ -87,7 +87,7 @@ void UASParameterDataModel::setPendingParam(int compId, QString& key, const QVa ...@@ -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; qDebug() << "removePendingParam:" << key;
...@@ -197,6 +197,20 @@ void UASParameterDataModel::forgetAllOnboardParams() ...@@ -197,6 +197,20 @@ void UASParameterDataModel::forgetAllOnboardParams()
onboardParameters.clear(); onboardParameters.clear();
} }
void UASParameterDataModel::clearAllPendingParams()
{
QList<int> compIds = pendingParameters.keys();
foreach (int compId , compIds) {
QMap<QString, QVariant>* compParams = pendingParameters.value(compId);
QList<QString> paramNames = compParams->keys();
foreach (QString paramName, paramNames) {
//remove this item from pending status and broadcast update
removePendingParam(compId,paramName);
}
}
}
void UASParameterDataModel::readUpdateParamsFromStream( QTextStream& stream) void UASParameterDataModel::readUpdateParamsFromStream( QTextStream& stream)
{ {
bool userWarned = false; bool userWarned = false;
......
...@@ -43,6 +43,7 @@ public: ...@@ -43,6 +43,7 @@ public:
virtual void forgetAllOnboardParams(); virtual void forgetAllOnboardParams();
/** @brief add this parameter to pending list iff it has changed from onboard value /** @brief add this parameter to pending list iff it has changed from onboard value
* @return true if the parameter is now pending * @return true if the parameter is now pending
*/ */
...@@ -88,7 +89,7 @@ protected: ...@@ -88,7 +89,7 @@ protected:
/** @brief Write a new pending parameter value that may be eventually sent to the UAS */ /** @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); virtual void setPendingParam(int componentId, QString& key, const QVariant& value);
/** @brief remove a parameter from the pending list */ /** @brief remove a parameter from the pending list */
virtual void removePendingParam(int compId, QString& key); virtual void removePendingParam(int compId, const QString &key);
signals: signals:
...@@ -103,6 +104,7 @@ signals: ...@@ -103,6 +104,7 @@ signals:
public slots: public slots:
virtual void clearAllPendingParams();
protected: protected:
int uasId; ///< The UAS / MAV to which this data model pertains int uasId; ///< The UAS / MAV to which this data model pertains
......
...@@ -79,7 +79,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ...@@ -79,7 +79,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
ui->rcCalibrationButton->setCheckable(true); ui->rcCalibrationButton->setCheckable(true);
connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool))); 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->rcModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRCModeIndex(int)));
//connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions())); //connect(ui->setTrimButton, SIGNAL(clicked()), this, SLOT(setTrimPositions()));
...@@ -816,14 +818,16 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -816,14 +818,16 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
{ {
// Hide items if NULL and abort // Hide items if NULL and abort
if (!active) { if (!active) {
ui->setButton->setEnabled(false);
ui->refreshButton->setEnabled(false); ui->refreshButton->setEnabled(false);
ui->readButton->show(); ui->refreshButton->show();
ui->readButton->setEnabled(false); ui->readButton->setEnabled(false);
ui->writeButton->show(); ui->readButton->show();
ui->writeButton->setEnabled(false); ui->writeButton->setEnabled(false);
ui->writeButton->show();
ui->loadFileButton->setEnabled(false); ui->loadFileButton->setEnabled(false);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(false); ui->saveFileButton->setEnabled(false);
ui->saveFileButton->show();
return; return;
} }
...@@ -918,12 +922,18 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -918,12 +922,18 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
updateStatus(QString("Reading from system %1").arg(mav->getUASName())); updateStatus(QString("Reading from system %1").arg(mav->getUASName()));
// Since a system is now connected, enable the VehicleConfig UI. // Since a system is now connected, enable the VehicleConfig UI.
ui->setButton->setEnabled(true);
ui->refreshButton->setEnabled(true); ui->refreshButton->setEnabled(true);
ui->refreshButton->show();
ui->readButton->setEnabled(true); ui->readButton->setEnabled(true);
ui->readButton->show();
ui->writeButton->setEnabled(true); ui->writeButton->setEnabled(true);
ui->writeButton->show();
ui->loadFileButton->setEnabled(true); ui->loadFileButton->setEnabled(true);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(true); ui->saveFileButton->setEnabled(true);
ui->saveFileButton->show();
//TODO never true?
if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA") { if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA") {
ui->readButton->hide(); ui->readButton->hide();
ui->writeButton->hide(); ui->writeButton->hide();
......
...@@ -817,8 +817,8 @@ p, li { white-space: pre-wrap; } ...@@ -817,8 +817,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>26</width> <width>98</width>
<height>26</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
...@@ -906,8 +906,8 @@ p, li { white-space: pre-wrap; } ...@@ -906,8 +906,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>98</width>
<height>16</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
...@@ -943,8 +943,8 @@ p, li { white-space: pre-wrap; } ...@@ -943,8 +943,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>98</width>
<height>16</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
...@@ -1103,6 +1103,13 @@ p, li { white-space: pre-wrap; } ...@@ -1103,6 +1103,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="text">
<string>Load File</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="saveFileButton"> <widget class="QPushButton" name="saveFileButton">
<property name="enabled"> <property name="enabled">
...@@ -1163,7 +1170,7 @@ p, li { white-space: pre-wrap; } ...@@ -1163,7 +1170,7 @@ p, li { white-space: pre-wrap; }
<height>601</height> <height>601</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1,1"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
...@@ -1180,54 +1187,6 @@ p, li { white-space: pre-wrap; } ...@@ -1180,54 +1187,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="setButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Set current parameters in non-permanent onboard memory.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Commit to UAS</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Set current parameters in non-permanent onboard memory.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Load from File</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
......
...@@ -76,79 +76,81 @@ void QGCParamWidget::connectViewSignalsAndSlots() ...@@ -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")); QPushButton* refreshButton = new QPushButton(tr("Get"));
refreshButton->setToolTip(tr("Fetch parameters currently in volatile memory of aircraft.")); refreshButton->setToolTip(tr("Fetch parameters currently in volatile memory of aircraft."));
refreshButton->setWhatsThis(tr("Fetch parameters currently in volatile memory of aircraft.")); refreshButton->setWhatsThis(tr("Fetch parameters currently in volatile memory of aircraft."));
connect(refreshButton, SIGNAL(clicked()), connect(refreshButton, SIGNAL(clicked()),
this, SLOT(requestOnboardParamsUpdate())); this, SLOT(requestOnboardParamsUpdate()));
horizontalLayout->addWidget(refreshButton, 2, 0); layout->addWidget(refreshButton, 2, 0);
QPushButton* setButton = new QPushButton(tr("Set")); QPushButton* setButton = new QPushButton(tr("Set"));
setButton->setToolTip(tr("Send pending parameters to volatile onboard memory")); setButton->setToolTip(tr("Send pending parameters to volatile onboard memory"));
setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory")); setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory"));
connect(setButton, SIGNAL(clicked()), connect(setButton, SIGNAL(clicked()),
paramMgr, SLOT(sendPendingParameters())); paramMgr, SLOT(sendPendingParameters()));
horizontalLayout->addWidget(setButton, 2, 1); layout->addWidget(setButton, 2, 1);
QPushButton* writeButton = new QPushButton(tr("Write (ROM)")); 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->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.")); 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()), connect(writeButton, SIGNAL(clicked()),
paramMgr, SLOT(copyVolatileParamsToPersistent())); paramMgr, SLOT(copyVolatileParamsToPersistent()));
horizontalLayout->addWidget(writeButton, 2, 2); layout->addWidget(writeButton, 2, 2);
QPushButton* loadFileButton = new QPushButton(tr("Load File")); 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->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.")); 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()), connect(loadFileButton, SIGNAL(clicked()),
this, SLOT(loadParametersFromFile())); this, SLOT(loadParametersFromFile()));
horizontalLayout->addWidget(loadFileButton, 3, 0); layout->addWidget(loadFileButton, 3, 0);
QPushButton* saveFileButton = new QPushButton(tr("Save File")); QPushButton* saveFileButton = new QPushButton(tr("Save File"));
saveFileButton->setToolTip(tr("Save parameters in this view to a file on this computer.")); 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.")); saveFileButton->setWhatsThis(tr("Save parameters in this view to a file on this computer."));
connect(saveFileButton, SIGNAL(clicked()), connect(saveFileButton, SIGNAL(clicked()),
this, SLOT(saveParametersToFile())); this, SLOT(saveParametersToFile()));
horizontalLayout->addWidget(saveFileButton, 3, 1); layout->addWidget(saveFileButton, 3, 1);
QPushButton* readButton = new QPushButton(tr("Read (ROM)")); 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->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.")); 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()), connect(readButton, SIGNAL(clicked()),
paramMgr, SLOT(copyPersistentParamsToVolatile())); 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 // Set correct vertical scaling
horizontalLayout->setRowStretch(0, 100); layout->setRowStretch(0, 100);
horizontalLayout->setRowStretch(1, 10); layout->setRowStretch(1, 10);
horizontalLayout->setRowStretch(2, 10); layout->setRowStretch(2, 10);
horizontalLayout->setRowStretch(3, 10); layout->setRowStretch(3, 10);
// Set layout // Set layout
this->setLayout(horizontalLayout); this->setLayout(layout);
// Set header // Set header
QStringList headerItems; QStringList headerItems;
......
...@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project
//forward declarations //forward declarations
class QGridLayout;
class UASInterface; class UASInterface;
/** /**
...@@ -67,6 +68,9 @@ protected: ...@@ -67,6 +68,9 @@ protected:
*/ */
void addComponentItem(int compId, QString compName); void addComponentItem(int compId, QString compName);
virtual void addActionButtonsToLayout(QGridLayout* layout);
signals: signals:
......
#include "QGCPendingParamWidget.h" #include "QGCPendingParamWidget.h"
#include <QGridLayout>
#include <QPushButton>
#include "UASManager.h" #include "UASManager.h"
#include "UASParameterCommsMgr.h" #include "UASParameterCommsMgr.h"
...@@ -80,3 +83,22 @@ void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& ...@@ -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);
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "QGCParamWidget.h" #include "QGCParamWidget.h"
class QGridLayout;
class QGCPendingParamWidget : public QGCParamWidget class QGCPendingParamWidget : public QGCParamWidget
{ {
Q_OBJECT Q_OBJECT
...@@ -18,6 +20,8 @@ protected: ...@@ -18,6 +20,8 @@ protected:
virtual void connectViewSignalsAndSlots(); virtual void connectViewSignalsAndSlots();
virtual void disconnectViewSignalsAndSlots(); virtual void disconnectViewSignalsAndSlots();
virtual void addActionButtonsToLayout(QGridLayout* layout);
signals: signals:
......
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