Commit 1487bf57 authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #347 from tstellanova/config_simplify

Migration to single parameter widget; ignore RC updates on unmapped channels 
parents c373ec74 c45feb28
...@@ -56,6 +56,8 @@ void QGCUASParamManager::connectToModelAndComms() ...@@ -56,6 +56,8 @@ void QGCUASParamManager::connectToModelAndComms()
void QGCUASParamManager::clearAllPendingParams() void QGCUASParamManager::clearAllPendingParams()
{ {
paramDataModel.clearAllPendingParams(); paramDataModel.clearAllPendingParams();
emit parameterStatusMsgUpdated(tr("Cleared all pending params"), UASParameterCommsMgr::ParamCommsStatusLevel_OK);
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#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"
...@@ -130,8 +129,6 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ...@@ -130,8 +129,6 @@ 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->writeButton, SIGNAL(clicked()),
this, SLOT(writeParameters()));
//TODO connect buttons here to save/clear actions? //TODO connect buttons here to save/clear actions?
UASInterface* tmpMav = UASManager::instance()->getActiveUAS(); UASInterface* tmpMav = UASManager::instance()->getActiveUAS();
...@@ -516,26 +513,29 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) ...@@ -516,26 +513,29 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
} }
} }
// Generate widgets for the Advanced tab.
foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
{
if (file.toLower().endsWith(".qgw")) {
QWidget* parent = ui->advanceColumnContents;
tool = new QGCToolWidget("", parent);
if (tool->loadSettings(vehicledir.absoluteFilePath(file), false))
{
toolWidgets.append(tool);
QGroupBox *box = new QGroupBox(parent);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);
ui->advancedColumnLayout->addWidget(box);
} else { //TODO fix and reintegrate the Advanced parameter editor
delete tool; // // Generate widgets for the Advanced tab.
} // foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
} // {
} // if (file.toLower().endsWith(".qgw")) {
// QWidget* parent = ui->advanceColumnContents;
// tool = new QGCToolWidget("", parent);
// if (tool->loadSettings(vehicledir.absoluteFilePath(file), false))
// {
// toolWidgets.append(tool);
// QGroupBox *box = new QGroupBox(parent);
// box->setTitle(tool->objectName());
// box->setLayout(new QVBoxLayout(box));
// box->layout()->addWidget(tool);
// ui->advancedColumnLayout->addWidget(box);
// } else {
// delete tool;
// }
// }
// }
// Load tabs for general configuration // Load tabs for general configuration
foreach (QString dir,generaldir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) foreach (QString dir,generaldir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
...@@ -1023,17 +1023,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1023,17 +1023,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
{ {
// Hide items if NULL and abort // Hide items if NULL and abort
if (!active) { if (!active) {
ui->refreshButton->setEnabled(false);
ui->refreshButton->show();
ui->readButton->setEnabled(false);
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; return;
} }
...@@ -1051,8 +1040,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1051,8 +1040,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
//TODO use paramCommsMgr instead //TODO use paramCommsMgr instead
disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant))); SLOT(parameterChanged(int,int,QString,QVariant)));
disconnect(ui->refreshButton,SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
// Delete all children from all fixed tabs. // Delete all children from all fixed tabs.
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) { foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) {
...@@ -1093,6 +1080,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1093,6 +1080,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
paramMgr = mav->getParamManager(); paramMgr = mav->getParamManager();
ui->pendingCommitsWidget->setUAS(mav); ui->pendingCommitsWidget->setUAS(mav);
ui->paramTreeWidget->setUAS(mav);
// Reset current state // Reset current state
resetCalibrationRC(); resetCalibrationRC();
...@@ -1106,8 +1094,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1106,8 +1094,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
SLOT(remoteControlChannelRawChanged(int,float))); SLOT(remoteControlChannelRawChanged(int,float)));
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant))); SLOT(parameterChanged(int,int,QString,QVariant)));
connect(ui->refreshButton, SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
if (systemTypeToParamMap.contains(mav->getSystemTypeName())) { if (systemTypeToParamMap.contains(mav->getSystemTypeName())) {
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()]; paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
...@@ -1131,22 +1118,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1131,22 +1118,7 @@ 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->refreshButton->setEnabled(true); //TODO anything?
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();
}
} }
void QGCPX4VehicleConfig::resetCalibrationRC() void QGCPX4VehicleConfig::resetCalibrationRC()
...@@ -1222,8 +1194,13 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval) ...@@ -1222,8 +1194,13 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval)
} }
// Raw value // Raw value
int delta = abs(fval - rcMappedValue[rcToFunctionMapping[chan]]); float mappedVal = rcMappedValue[rcToFunctionMapping[chan]];
if (!configEnabled && !calibrationEnabled && delta < 12 && delta >= 0 && rcValue[chan] > 800 && rcValue[chan] < 2200) { bool isMapped = (((float)UINT16_MAX) != mappedVal);
float delta = fabsf(fval - mappedVal);
if (!configEnabled && !calibrationEnabled &&
(!isMapped ||
(delta < 12.0f && rcValue[chan] > 800 && rcValue[chan] < 2200) )
) {
//ignore tiny jitter values //ignore tiny jitter values
return; return;
} }
...@@ -1690,33 +1667,33 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param ...@@ -1690,33 +1667,33 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param
break; break;
} }
} }
if (!found) { // if (!found) {
//New param type, create a QGroupBox for it. // //New param type, create a QGroupBox for it.
QWidget* parent = ui->advanceColumnContents; // QWidget* parent = ui->advanceColumnContents;
// Create the tool, attaching it to the QGroupBox // // Create the tool, attaching it to the QGroupBox
QGCToolWidget *tool = new QGCToolWidget("", parent); // QGCToolWidget *tool = new QGCToolWidget("", parent);
QString tooltitle = parameterName; // QString tooltitle = parameterName;
if (parameterName.split("_").size() > 1) { // if (parameterName.split("_").size() > 1) {
tooltitle = parameterName.split("_")[0] + "_"; // tooltitle = parameterName.split("_")[0] + "_";
} // }
tool->setTitle(tooltitle); // tool->setTitle(tooltitle);
tool->setObjectName(tooltitle); // tool->setObjectName(tooltitle);
//tool->setSettings(set); // //tool->setSettings(set);
libParamToWidgetMap.insert(parameterName,tool); // libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool); // toolWidgets.append(tool);
tool->addParam(uas, component, parameterName, value); // tool->addParam(uas, component, parameterName, value);
QGroupBox *box = new QGroupBox(parent); // QGroupBox *box = new QGroupBox(parent);
box->setTitle(tool->objectName()); // box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box)); // box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool); // box->layout()->addWidget(tool);
libParamToWidgetMap.insert(parameterName,tool); // libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool); // toolWidgets.append(tool);
ui->advancedColumnLayout->addWidget(box); // ui->advancedColumnLayout->addWidget(box);
toolToBoxMap[tool] = box; // toolToBoxMap[tool] = box;
} // }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1256</width> <width>1256</width>
<height>889</height> <height>912</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>133</width> <width>133</width>
<height>863</height> <height>886</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="verticalLayout_12">
...@@ -154,7 +154,7 @@ Config</string> ...@@ -154,7 +154,7 @@ Config</string>
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="firmwareTab"> <widget class="QWidget" name="firmwareTab">
<layout class="QVBoxLayout" name="firmwareLayout"> <layout class="QVBoxLayout" name="firmwareLayout">
...@@ -932,8 +932,8 @@ Config</string> ...@@ -932,8 +932,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>39</width>
<height>28</height> <height>26</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
...@@ -1020,8 +1020,8 @@ Config</string> ...@@ -1020,8 +1020,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>16</width>
<height>28</height> <height>16</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
...@@ -1057,8 +1057,8 @@ Config</string> ...@@ -1057,8 +1057,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>16</width>
<height>28</height> <height>16</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
...@@ -1149,8 +1149,8 @@ Config</string> ...@@ -1149,8 +1149,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>597</width>
<height>28</height> <height>740</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
...@@ -1158,90 +1158,20 @@ Config</string> ...@@ -1158,90 +1158,20 @@ Config</string>
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QVBoxLayout" name="advancedColumnLayout"/> <layout class="QVBoxLayout" name="advancedColumnLayout">
<item>
<widget class="QGCParamWidget" name="paramTreeWidget" native="true">
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="refreshButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Load parameters currently in non-permanent memory of aircraft.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Copy parameters from permanent memory to non-permanent current memory of aircraft. DOES NOT update the parameters in this view, click refresh after copying them to get them.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Read ROM</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="writeButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Copy current parameters in non-permanent memory of the aircraft to permanent memory. Transmit your parameters first to write these.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Write ROM</string>
</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">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Save parameters in this view to a file on this computer.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Save to File</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -1275,34 +1205,28 @@ Config</string> ...@@ -1275,34 +1205,28 @@ Config</string>
<property name="title"> <property name="title">
<string>Changes Pending</string> <string>Changes Pending</string>
</property> </property>
<widget class="QWidget" name="verticalLayoutWidget"> <layout class="QVBoxLayout" name="verticalLayout_8">
<property name="geometry"> <item>
<rect> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<x>10</x> <property name="spacing">
<y>30</y> <number>-1</number>
<width>381</width> </property>
<height>601</height> <item>
</rect> <widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true">
</property> <property name="minimumSize">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0"> <size>
<property name="spacing"> <width>0</width>
<number>0</number> <height>0</height>
</property> </size>
<item> </property>
<widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true"> <property name="autoFillBackground">
<property name="minimumSize"> <bool>true</bool>
<size> </property>
<width>0</width> </widget>
<height>30</height> </item>
</size> </layout>
</property> </item>
<property name="autoFillBackground"> </layout>
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
...@@ -1354,6 +1278,12 @@ Config</string> ...@@ -1354,6 +1278,12 @@ Config</string>
<header location="global">QGCMessageView.h</header> <header location="global">QGCMessageView.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QGCParamWidget</class>
<extends>QWidget</extends>
<header>ui/QGCParamWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) : QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) :
QGCParamWidget((QWidget*)parent) QGCParamWidget((QWidget*)parent)
{ {
//this subclass doesn't display status updates
statusLabel->hide();
} }
...@@ -20,10 +22,6 @@ void QGCPendingParamWidget::connectToParamManager() ...@@ -20,10 +22,6 @@ void QGCPendingParamWidget::connectToParamManager()
// Listen to updated param signals from the data model // Listen to updated param signals from the data model
connect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), connect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen to communications status messages so we can display them
connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
} }
...@@ -33,10 +31,6 @@ void QGCPendingParamWidget::disconnectFromParamManager() ...@@ -33,10 +31,6 @@ void QGCPendingParamWidget::disconnectFromParamManager()
disconnect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )), disconnect(paramMgr, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool ))); this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen to communications status messages so we can display them
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL; paramMgr = NULL;
} }
......
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