Commit 4646c681 authored by tstellanova's avatar tstellanova

Cleanup buttons in px4config; impl clearing pending list

parent d6801ac6
#include "QGCUASParamManager.h"
#include <QApplication>>
#include <QApplication>
#include <QDir>
#include <QMessageBox>
......@@ -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);
......
......@@ -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);
......
......@@ -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<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)
{
bool userWarned = false;
......
......@@ -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
......
......@@ -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();
......
......@@ -817,8 +817,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>26</width>
<height>26</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
......@@ -906,8 +906,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>16</width>
<height>16</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -943,8 +943,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>16</width>
<height>16</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
......@@ -1103,6 +1103,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="text">
<string>Load File</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveFileButton">
<property name="enabled">
......@@ -1163,7 +1170,7 @@ p, li { white-space: pre-wrap; }
<height>601</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1,1">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing">
<number>0</number>
</property>
......@@ -1180,54 +1187,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</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>
</widget>
</widget>
......
......@@ -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;
......
......@@ -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:
......
#include "QGCPendingParamWidget.h"
#include <QGridLayout>
#include <QPushButton>
#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);
}
......@@ -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:
......
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