Commit c45feb28 authored by tstellanova's avatar tstellanova
Browse files

Begin migration to integrated param widget

don't process updates to unmapped rc channels when we're not in
calibration mode
parent c373ec74
......@@ -56,6 +56,8 @@ void QGCUASParamManager::connectToModelAndComms()
void QGCUASParamManager::clearAllPendingParams()
{
paramDataModel.clearAllPendingParams();
emit parameterStatusMsgUpdated(tr("Cleared all pending params"), UASParameterCommsMgr::ParamCommsStatusLevel_OK);
}
......
......@@ -16,7 +16,6 @@
#include "QGCPX4VehicleConfig.h"
#include "QGC.h"
//#include "QGCPendingParamWidget.h"
#include "QGCToolWidget.h"
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
......@@ -130,8 +129,6 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
ui->rcCalibrationButton->setCheckable(true);
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?
UASInterface* tmpMav = UASManager::instance()->getActiveUAS();
......@@ -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 {
delete tool;
}
}
}
//TODO fix and reintegrate the Advanced parameter editor
// // 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
foreach (QString dir,generaldir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
......@@ -1023,17 +1023,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
{
// Hide items if NULL and abort
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;
}
......@@ -1051,8 +1040,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
//TODO use paramCommsMgr instead
disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
disconnect(ui->refreshButton,SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
// Delete all children from all fixed tabs.
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) {
......@@ -1093,6 +1080,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
paramMgr = mav->getParamManager();
ui->pendingCommitsWidget->setUAS(mav);
ui->paramTreeWidget->setUAS(mav);
// Reset current state
resetCalibrationRC();
......@@ -1106,8 +1094,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
SLOT(remoteControlChannelRawChanged(int,float)));
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
connect(ui->refreshButton, SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));
if (systemTypeToParamMap.contains(mav->getSystemTypeName())) {
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
......@@ -1131,22 +1118,7 @@ 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->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();
}
//TODO anything?
}
void QGCPX4VehicleConfig::resetCalibrationRC()
......@@ -1222,8 +1194,13 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval)
}
// Raw value
int delta = abs(fval - rcMappedValue[rcToFunctionMapping[chan]]);
if (!configEnabled && !calibrationEnabled && delta < 12 && delta >= 0 && rcValue[chan] > 800 && rcValue[chan] < 2200) {
float mappedVal = rcMappedValue[rcToFunctionMapping[chan]];
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
return;
}
......@@ -1690,33 +1667,33 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param
break;
}
}
if (!found) {
//New param type, create a QGroupBox for it.
QWidget* parent = ui->advanceColumnContents;
// if (!found) {
// //New param type, create a QGroupBox for it.
// QWidget* parent = ui->advanceColumnContents;
// Create the tool, attaching it to the QGroupBox
QGCToolWidget *tool = new QGCToolWidget("", parent);
QString tooltitle = parameterName;
if (parameterName.split("_").size() > 1) {
tooltitle = parameterName.split("_")[0] + "_";
}
tool->setTitle(tooltitle);
tool->setObjectName(tooltitle);
//tool->setSettings(set);
libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool);
tool->addParam(uas, component, parameterName, value);
QGroupBox *box = new QGroupBox(parent);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);
libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool);
ui->advancedColumnLayout->addWidget(box);
toolToBoxMap[tool] = box;
}
// // Create the tool, attaching it to the QGroupBox
// QGCToolWidget *tool = new QGCToolWidget("", parent);
// QString tooltitle = parameterName;
// if (parameterName.split("_").size() > 1) {
// tooltitle = parameterName.split("_")[0] + "_";
// }
// tool->setTitle(tooltitle);
// tool->setObjectName(tooltitle);
// //tool->setSettings(set);
// libParamToWidgetMap.insert(parameterName,tool);
// toolWidgets.append(tool);
// tool->addParam(uas, component, parameterName, value);
// QGroupBox *box = new QGroupBox(parent);
// box->setTitle(tool->objectName());
// box->setLayout(new QVBoxLayout(box));
// box->layout()->addWidget(tool);
// libParamToWidgetMap.insert(parameterName,tool);
// toolWidgets.append(tool);
// ui->advancedColumnLayout->addWidget(box);
// toolToBoxMap[tool] = box;
// }
}
}
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1256</width>
<height>889</height>
<height>912</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -43,7 +43,7 @@
<x>0</x>
<y>0</y>
<width>133</width>
<height>863</height>
<height>886</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
......@@ -154,7 +154,7 @@ Config</string>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
<number>5</number>
</property>
<widget class="QWidget" name="firmwareTab">
<layout class="QVBoxLayout" name="firmwareLayout">
......@@ -932,8 +932,8 @@ Config</string>
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>39</width>
<height>26</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
......@@ -1020,8 +1020,8 @@ Config</string>
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -1057,8 +1057,8 @@ Config</string>
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
......@@ -1149,8 +1149,8 @@ Config</string>
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>597</width>
<height>740</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
......@@ -1158,91 +1158,21 @@ Config</string>
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="advancedColumnLayout"/>
</item>
</layout>
</widget>
</widget>
</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>
<layout class="QVBoxLayout" name="advancedColumnLayout">
<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>
<widget class="QGCParamWidget" name="paramTreeWidget" native="true">
<property name="autoFillBackground">
<bool>true</bool>
</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>
</layout>
</item>
<item>
<widget class="QPushButton" name="loadFileButton">
<property name="text">
<string>Load File</string>
</property>
</layout>
</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>
</widget>
</item>
<item>
......@@ -1275,25 +1205,18 @@ Config</string>
<property name="title">
<string>Changes Pending</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>381</width>
<height>601</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing">
<number>0</number>
<number>-1</number>
</property>
<item>
<widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
......@@ -1302,7 +1225,8 @@ Config</string>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
......@@ -1354,6 +1278,12 @@ Config</string>
<header location="global">QGCMessageView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QGCParamWidget</class>
<extends>QWidget</extends>
<header>ui/QGCParamWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -10,6 +10,8 @@
QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) :
QGCParamWidget((QWidget*)parent)
{
//this subclass doesn't display status updates
statusLabel->hide();
}
......@@ -20,10 +22,6 @@ void QGCPendingParamWidget::connectToParamManager()
// Listen to updated param signals from the data model
connect(paramMgr, 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(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}
......@@ -33,10 +31,6 @@ void QGCPendingParamWidget::disconnectFromParamManager()
disconnect(paramMgr, 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
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL;
}
......
Supports Markdown
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