Commit 8691d1e1 authored by Lorenz Meier's avatar Lorenz Meier

Merged config changes from upstream

parents 97d2bf45 2db1d024
......@@ -473,7 +473,8 @@ HEADERS += src/MG.h \
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h \
src/ui/QGCPendingParamWidget.h \
src/ui/px4_configuration/QGCPX4AirframeConfig.h
src/ui/px4_configuration/QGCPX4AirframeConfig.h \
src/ui/QGCBaseParamWidget.h
# 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
......@@ -692,7 +693,8 @@ SOURCES += src/main.cc \
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc \
src/ui/QGCPendingParamWidget.cc \
src/ui/px4_configuration/QGCPX4AirframeConfig.cc
src/ui/px4_configuration/QGCPX4AirframeConfig.cc \
src/ui/QGCBaseParamWidget.cc
# 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
......
#include "QGCUASParamManager.h"
#include <QApplication>>
#include <QApplication>
#include <QDir>
#include <QMessageBox>
#include "UASInterface.h"
#include "UASParameterCommsMgr.h"
QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
QWidget(parent),
mav(uas),
paramDataModel(NULL),
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent),
mav(NULL),
paramDataModel(this),
paramCommsMgr(NULL)
{
paramDataModel = uas->getParamDataModel();
paramCommsMgr = uas->getParamCommsMgr();
mav->setParamManager(this);
// Load default values and tooltips
}
QGCUASParamManager* QGCUASParamManager::initWithUAS(UASInterface* uas)
{
mav = uas;
// Load default values and tooltips for data model
loadParamMetaInfoCSV();
paramCommsMgr = new UASParameterCommsMgr(this);
paramCommsMgr->initWithUAS(uas);
connectToModelAndComms();
return this;
}
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);
return paramDataModel.getOnboardParamValue(component,parameter,value);
}
......@@ -42,29 +72,31 @@ void QGCUASParamManager::requestParameterUpdate(int component, const QString& pa
*/
void QGCUASParamManager::requestParameterList()
{
if (!mav) {
return;
if (mav) {
emit parameterStatusMsgUpdated(tr("Requested param list.. waiting"), UASParameterCommsMgr::ParamCommsStatusLevel_OK);
paramCommsMgr->requestParameterList();
}
setParameterStatusMsg(tr("Requested param list.. waiting"));
paramCommsMgr->requestParameterList();
}
void QGCUASParamManager::setParameterStatusMsg(const QString& msg)
void QGCUASParamManager::requestParameterListIfEmpty()
{
qDebug() << "parameterStatusMsg: " << msg;
parameterStatusMsg = msg;
if (mav) {
int totalOnboard = paramDataModel.countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
requestParameterList();
}
}
}
void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& paramInfo) {
paramDataModel->setParamDescriptions(paramInfo);
paramDataModel.setParamDescriptions(paramInfo);
}
void QGCUASParamManager::setParameter(int compId, QString paramName, QVariant value)
{
//paramCommsMgr->setParameter(compId,paramName,value);
paramDataModel->updatePendingParamWithValue(compId,paramName,value);
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
void QGCUASParamManager::sendPendingParameters()
......@@ -74,7 +106,7 @@ void QGCUASParamManager::sendPendingParameters()
void QGCUASParamManager::setPendingParam(int compId, QString& paramName, const QVariant& value)
{
paramDataModel->updatePendingParamWithValue(compId,paramName,value);
paramDataModel.updatePendingParamWithValue(compId,paramName,value);
}
......@@ -97,16 +129,59 @@ void QGCUASParamManager::loadParamMetaInfoCSV()
}
QTextStream in(&paramMetaFile);
paramDataModel->loadParamMetaInfoFromStream(in);
paramDataModel.loadParamMetaInfoFromStream(in);
paramMetaFile.close();
}
/**
* @return The MAV of this mgr. Unless the MAV object has been destroyed, this
* pointer is never zero.
*/
UASInterface* QGCUASParamManager::getUAS()
{
return mav;
}
UASParameterDataModel* QGCUASParamManager::dataModel()
{
return &paramDataModel;
}
void QGCUASParamManager::writeOnboardParamsToStream(QTextStream &stream, const QString& uasName)
{
paramDataModel.writeOnboardParamsToStream(stream,uasName);
}
void QGCUASParamManager::readPendingParamsFromStream(QTextStream &stream)
{
paramDataModel.readUpdateParamsFromStream(stream);
}
void QGCUASParamManager::copyVolatileParamsToPersistent()
{
int changedParamCount = paramDataModel.countPendingParams();
if (changedParamCount > 0) {
QMessageBox msgBox;
msgBox.setText(tr("There are locally changed parameters. Please transmit them first (<TRANSMIT>) or update them with the onboard values (<REFRESH>) before storing onboard from RAM to ROM."));
msgBox.exec();
}
else {
paramCommsMgr->writeParamsToPersistentStorage();
}
}
void QGCUASParamManager::copyPersistentParamsToVolatile()
{
if (mav) {
mav->readParametersFromStorage(); //TODO use comms mgr instead?
}
}
void QGCUASParamManager::requestRcCalibrationParamsUpdate() {
paramCommsMgr->requestRcCalibrationParamsUpdate();
}
......@@ -6,16 +6,19 @@
#include <QTimer>
#include <QVariant>
#include "UASParameterDataModel.h"
//forward declarations
class QTextStream;
class UASInterface;
class UASParameterCommsMgr;
class UASParameterDataModel;
class QGCUASParamManager : public QWidget
class QGCUASParamManager : public QObject
{
Q_OBJECT
public:
QGCUASParamManager(UASInterface* uas, QWidget *parent = 0);
QGCUASParamManager(QObject* parent = 0);
QGCUASParamManager* initWithUAS(UASInterface* uas);
/** @brief Get the known, confirmed value of a parameter */
virtual bool getParameterValue(int component, const QString& parameter, QVariant& value) const;
......@@ -28,16 +31,25 @@ public:
*/
UASInterface* getUAS();
/** @return The data model managed by this class */
virtual UASParameterDataModel* dataModel();
protected:
//TODO decouple this UI message display further?
virtual void setParameterStatusMsg(const QString& msg);
/** @brief Load parameter meta information from appropriate CSV file */
virtual void loadParamMetaInfoCSV();
void connectToModelAndComms();
signals:
void parameterChanged(int component, QString parameter, QVariant value);
void parameterChanged(int component, int parameterIndex, QVariant value);
/** @brief We updated the parameter status message */
void parameterStatusMsgUpdated(QString msg, int level);
/** @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 */
......@@ -49,25 +61,35 @@ public slots:
/** @brief Request list of parameters from MAV */
virtual void requestParameterList();
/** @brief Request a list of params onboard the MAV if the onboard param list we have is empty */
virtual void requestParameterListIfEmpty();
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);
virtual void handleParameterUpdate(int component, const QString& parameterName, QVariant value) = 0;
virtual void handleParameterListUpToDate() = 0;
virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName);
virtual void readPendingParamsFromStream(QTextStream &stream);
virtual void requestRcCalibrationParamsUpdate();
/** @brief Copy the current parameters in volatile RAM to persistent storage (EEPROM/HDD) */
virtual void copyVolatileParamsToPersistent();
/** @brief Copy the parameters from persistent storage to volatile RAM */
virtual void copyPersistentParamsToVolatile();
protected:
// Parameter data model
UASInterface* mav; ///< The MAV this manager is controlling
UASParameterDataModel* paramDataModel;///< Shared data model of parameters
UASParameterDataModel paramDataModel;///< Shared data model of parameters
UASParameterCommsMgr* paramCommsMgr; ///< Shared comms mgr for parameters
// Status
QString parameterStatusMsg;
};
#endif // QGCUASPARAMMANAGER_H
This diff is collapsed.
......@@ -492,9 +492,7 @@ protected: //COMMENTS FOR TEST UNIT
/// PARAMETERS
QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
bool paramsOnceRequested; ///< If the parameter list has been read at least once
QGCUASParamManager* paramManager; ///< Parameter manager class
UASParameterDataModel* paramDataModel; ///< The parameter data model for this UAS
UASParameterCommsMgr* paramCommsMgr;
QGCUASParamManager paramMgr; ///< Parameter manager for this UAS
/// SIMULATION
QGCHilLink* simulation; ///< Hardware in the loop simulation link
......@@ -515,36 +513,22 @@ public:
/** @brief Check if vehicle is armed */
bool isArmed() const { return systemIsArmed; }
/** @brief Get reference to the waypoint manager **/
UASWaypointManager* getWaypointManager() {
return &waypointManager;
}
/** @brief Get reference to the param manager **/
QGCUASParamManager* getParamManager() const {
return paramManager;
}
/** @brief Get reference to the parameter data model (same one shared with the parameter manager) **/
UASParameterDataModel* getParamDataModel() {
return paramDataModel;
}
UASParameterCommsMgr* getParamCommsMgr() {
return paramCommsMgr;
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() {
return &paramMgr;
}
/** @brief Get the HIL simulation */
QGCHilLink* getHILSimulation() const {
return simulation;
}
// TODO Will be removed
/** @brief Set reference to the param manager **/
void setParamManager(QGCUASParamManager* manager) {
paramManager = manager;
}
int getSystemType();
/**
......@@ -953,6 +937,8 @@ protected:
/** @brief Get the UNIX timestamp in milliseconds, ignore attitudeStamped mode */
quint64 getUnixReferenceTime(quint64 time);
virtual void processParamValueMsg(mavlink_message_t& msg, const QString& paramName,const mavlink_param_value_t& rawValue, mavlink_param_union_t& paramValue);
int componentID[256];
bool componentMulti[256];
bool connectionLost; ///< Flag indicates a timed out connection
......
......@@ -154,18 +154,8 @@ public:
/** @brief Get reference to the waypoint manager **/
virtual UASWaypointManager* getWaypointManager(void) = 0;
/** @brief Access the parameter data model for this UAS (sans widget). This is the same parameter data model used by the parameter manager. **/
virtual UASParameterDataModel* getParamDataModel() = 0;
virtual UASParameterCommsMgr* getParamCommsMgr() = 0;
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() const = 0;
// TODO Will be removed
/** @brief Set reference to the param manager **/
virtual void setParamManager(QGCUASParamManager* manager) = 0;
virtual QGCUASParamManager* getParamManager() = 0;
/* COMMUNICATION FLAGS */
......
......@@ -7,9 +7,9 @@
#define RC_CAL_CHAN_MAX 8
UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent, UASInterface *uas) :
UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent) :
QObject(parent),
mav(uas),
mav(NULL),
paramDataModel(NULL),
transmissionListMode(false),
transmissionActive(false),
......@@ -18,10 +18,16 @@ UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent, UASInterface *uas) :
rewriteTimeout(1000),
retransmissionBurstRequestSize(5)
{
paramDataModel = mav->getParamDataModel();
loadParamCommsSettings();
}
UASParameterCommsMgr* UASParameterCommsMgr::initWithUAS(UASInterface* uas)
{
mav = uas;
paramDataModel = mav->getParamManager()->dataModel();
loadParamCommsSettings();
//Requesting parameters one-by-one from mav
connect(this, SIGNAL(parameterUpdateRequestedById(int,int)),
mav, SLOT(requestParameter(int,int)));
......@@ -34,10 +40,11 @@ UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent, UASInterface *uas) :
connect(mav, SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)),
this, SLOT(receivedParameterUpdate(int,int,int,int,QString,QVariant)));
//connecto retransmissionTimer
//connect to retransmissionTimer
connect(&retransmissionTimer, SIGNAL(timeout()),
this, SLOT(retransmissionGuardTick()));
return this;
}
......@@ -60,15 +67,6 @@ void UASParameterCommsMgr::loadParamCommsSettings()
}
void UASParameterCommsMgr::requestParameterListIfEmpty()
{
int totalOnboard = paramDataModel->countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
requestParameterList();
}
}
/**
* Send a request to deliver the list of onboard parameters
......
......@@ -18,7 +18,9 @@ class UASParameterCommsMgr : public QObject
public:
explicit UASParameterCommsMgr(QObject *parent = 0, UASInterface* uas = NULL);
explicit UASParameterCommsMgr(QObject *parent = 0);
UASParameterCommsMgr* initWithUAS(UASInterface* model);///< Two-stage constructor
~UASParameterCommsMgr();
typedef enum ParamCommsStatusLevel {
......@@ -72,8 +74,6 @@ public slots:
/** @brief Request list of parameters from MAV */
virtual void requestParameterList();
/** @brief Request a list of params onboard the MAV if the onboard param list we have is empty */
virtual void requestParameterListIfEmpty();
/** @brief Check for missing parameters */
virtual void retransmissionGuardTick();
......
......@@ -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
......
......@@ -97,14 +97,15 @@ void ParameterInterface::addUAS(UASInterface* uas)
return;
}
QGCParamWidget* param = new QGCParamWidget(uas, this);
param->init();
QGCParamWidget* paramWidget = new QGCParamWidget(this);
paramWidget = (QGCParamWidget*)paramWidget->initWithUAS(uas);
QString ptrStr;
ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", param,this);
ptrStr.sprintf("QGCParamWidget %8p (parent %8p)", paramWidget,this);
qDebug() << "Created " << ptrStr << " for UAS id: " << uasId << " count: " << paramWidgets->count();
paramWidgets->insert(uasId, param);
m_ui->stackedWidget->addWidget(param);
paramWidgets->insert(uasId, paramWidget);
m_ui->stackedWidget->addWidget(paramWidget);
QGCSensorSettingsWidget* sensor = NULL;
......@@ -119,7 +120,7 @@ void ParameterInterface::addUAS(UASInterface* uas)
// Clear
if (m_ui->sensorSettings && sensor)
m_ui->sensorSettings->setCurrentWidget(sensor);
m_ui->stackedWidget->setCurrentWidget(param);
m_ui->stackedWidget->setCurrentWidget(paramWidget);
curr = 0;
}
}
......
#include "QGCBaseParamWidget.h"
#include <QFileDialog>
#include <QFile>
#include <QVariant>
#include <QTextStream>>
#include "QGCUASParamManager.h"
#include "UASInterface.h"
QGCBaseParamWidget::QGCBaseParamWidget(QWidget *parent) :
QWidget(parent),
mav(NULL),
paramMgr(NULL),
updatingParamNameLock("")
{
}
QGCBaseParamWidget* QGCBaseParamWidget::initWithUAS(UASInterface *uas)
{
setUAS(uas);
return this;
}
void QGCBaseParamWidget::setUAS(UASInterface* uas)
{
if (uas != mav) {
if (mav) {
//TODO disconnect any connections as needed
disconnectViewSignalsAndSlots();
disconnectFromParamManager();
clearOnboardParamDisplay();
clearPendingParamDisplay();
}
mav = uas;
if (mav) {
connectToParamManager();
connectViewSignalsAndSlots();
layoutWidget();
paramMgr->requestParameterListIfEmpty();
}
}
}
void QGCBaseParamWidget::connectToParamManager()
{
paramMgr = mav->getParamManager();
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
connect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )),
this, SLOT(handleOnboardParamUpdate(int,QString,QVariant)));
connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
// Listen for param list reload finished
connect(paramMgr, SIGNAL(parameterListUpToDate()),
this, SLOT(handleOnboardParameterListUpToDate()));
// Listen to communications status messages so we can display them
connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}
void QGCBaseParamWidget::disconnectFromParamManager()
{
disconnect(paramMgr->dataModel(), SIGNAL(parameterUpdated(int, QString , QVariant )),
this, SLOT(handleOnboardParamUpdate(int,QString,QVariant)));
disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
disconnect(paramMgr, SIGNAL(parameterListUpToDate()),
this, SLOT(handleOnboardParameterListUpToDate()));
// Listen to communications status messages so we can display them
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL;
}
void QGCBaseParamWidget::requestOnboardParamsUpdate()
{
paramMgr->requestParameterList();
}
void QGCBaseParamWidget::saveParametersToFile()
{
if (!mav)
return;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "./parameters.txt", tr("Parameter File (*.txt)"));
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}
QTextStream outstream(&file);
paramMgr->writeOnboardParamsToStream(outstream,mav->getUASName());
file.close();
}
void QGCBaseParamWidget::loadParametersFromFile()
{
if (!mav)
return;
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), ".", tr("Parameter file (*.txt)"));
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in(&file);
paramMgr->readPendingParamsFromStream(in);
file.close();
}
#ifndef QGCBASEPARAMWIDGET_H
#define QGCBASEPARAMWIDGET_H
#include <QVariant>
#include <QWidget>
//forward declarations
class QGCUASParamManager;
class UASInterface;
class QGCBaseParamWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCBaseParamWidget(QWidget *parent = 0);
virtual QGCBaseParamWidget* initWithUAS(UASInterface* uas);///< Two-stage construction: initialize this object
virtual void setUAS(UASInterface* uas);///< Allows swapping the underlying UAS
protected:
virtual void setParameterStatusMsg(const QString& msg) = 0;
virtual void layoutWidget() = 0;///< Layout the appearance of this widget
virtual void connectViewSignalsAndSlots() = 0;///< Connect view signals/slots as needed
virtual void disconnectViewSignalsAndSlots() = 0;///< Disconnect view signals/slots as needed
virtual void connectToParamManager(); ///>Connect to any required param manager signals
virtual void disconnectFromParamManager(); ///< Disconnect from any connected param manager signals
signals:
public slots:
virtual void handleOnboardParamUpdate(int component,const QString& parameterName, QVariant value) = 0;
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending) = 0;
virtual void handleOnboardParameterListUpToDate() = 0;
virtual void handleParamStatusMsgUpdate(QString msg, int level) = 0;
/** @brief Clear the rendering of onboard parameters */
virtual void clearOnboardParamDisplay() = 0;
/** @brief Clear the rendering of pending parameters */
virtual void clearPendingParamDisplay() = 0;
/** @brief Request list of parameters from MAV */
virtual void requestOnboardParamsUpdate();
/** @brief Store parameters to a file */
virtual void saveParametersToFile();
/** @brief Load parameters from a file */
virtual void loadParametersFromFile();
protected:
QGCUASParamManager* paramMgr;
UASInterface* mav;
QString updatingParamNameLock; ///< Name of param currently being updated-- used for reducing echo on param change
};
#endif // QGCBASEPARAMWIDGET_H
......@@ -79,13 +79,22 @@ 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()));
//TODO connect buttons here to save/clear actions?
ui->pendingCommitsWidget->init();
ui->pendingCommitsWidget->update();
UASInterface* tmpMav = UASManager::instance()->getActiveUAS();
if (tmpMav) {
ui->pendingCommitsWidget->initWithUAS(tmpMav);
ui->pendingCommitsWidget->update();
setActiveUAS(tmpMav);
}
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
//TODO the following methods are not yet implemented
......@@ -109,9 +118,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
// connect(ui->invertCheckBox_7, SIGNAL(clicked(bool)), this, SLOT(setAux2Inverted(bool)));
// connect(ui->invertCheckBox_8, SIGNAL(clicked(bool)), this, SLOT(setAux3Inverted(bool)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
setActiveUAS(UASManager::instance()->getActiveUAS());
for (unsigned int i = 0; i < chanMax; i++) {
rcValue[i] = UINT16_MAX;
......@@ -798,25 +807,27 @@ void QGCPX4VehicleConfig::loadConfig()
}
if (!paramTooltips.isEmpty()) {
mav->getParamManager()->setParamDescriptions(paramTooltips);
paramMgr->setParamDescriptions(paramTooltips);
}
doneLoadingConfig = true;
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
paramCommsMgr->requestParameterListIfEmpty();
paramMgr->requestParameterListIfEmpty();
}
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;
}
......@@ -828,6 +839,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
if (mav)
{
// Disconnect old system
disconnect(mav, SIGNAL(remoteControlChannelRawChanged(int,float)), this,
SLOT(remoteControlChannelRawChanged(int,float)));
......@@ -835,7 +847,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
disconnect(ui->refreshButton,SIGNAL(clicked()),
paramCommsMgr,SLOT(requestParameterList()));
paramMgr,SLOT(requestParameterList()));
// Delete all children from all fixed tabs.
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) {
......@@ -868,22 +880,25 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
// Connect new system
mav = active;
paramCommsMgr = mav->getParamCommsMgr();
paramMgr = mav->getParamManager();
ui->pendingCommitsWidget->setUAS(mav);
// Reset current state
resetCalibrationRC();
requestCalibrationRC();
//TODO eliminate the separate RC_TYPE call
mav->requestParameter(0, "RC_TYPE");
chanCount = 0;
//TODO get parameter changes via Param Mgr instead
// Connect new system
connect(mav, SIGNAL(remoteControlChannelRawChanged(int,float)), this,
SLOT(remoteControlChannelRawChanged(int,float)));
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
connect(ui->refreshButton, SIGNAL(clicked()),
paramCommsMgr,SLOT(requestParameterList()));
paramMgr,SLOT(requestParameterList()));
if (systemTypeToParamMap.contains(mav->getSystemTypeName())) {
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
......@@ -907,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();
......@@ -978,9 +999,7 @@ void QGCPX4VehicleConfig::writeCalibrationRC()
void QGCPX4VehicleConfig::requestCalibrationRC()
{
if (paramCommsMgr) {
paramCommsMgr->requestRcCalibrationParamsUpdate();
}
paramMgr->requestRcCalibrationParamsUpdate();
}
void QGCPX4VehicleConfig::writeParameters()
......@@ -1240,6 +1259,7 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param
return;
}
//TODO this may introduce a bug with param editor widgets not receiving param updates
if (parameterName.startsWith("RC")) {
handleRcParameterChange(parameterName,value);
return;
......
......@@ -161,7 +161,7 @@ protected slots:
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
UASParameterCommsMgr* paramCommsMgr; ///< param comms mgr for the mav
QGCUASParamManager* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
......
......@@ -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>
......
This diff is collapsed.
......@@ -37,72 +37,65 @@ This file is part of the QGROUNDCONTROL project
#include <QLabel>
#include <QTimer>
#include "QGCUASParamManager.h"
#include "UASInterface.h"
#include "QGCBaseParamWidget.h"
//forward declarations
class QGridLayout;
class UASInterface;
/**
* @brief Widget to read/set onboard parameters
*/
class QGCParamWidget : public QGCUASParamManager
class QGCParamWidget : public QGCBaseParamWidget
{
Q_OBJECT
public:
QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
virtual void init(); ///< Two-stage construction: initialize the object
QGCParamWidget(QWidget *parent = 0);
protected:
virtual void setParameterStatusMsg(const QString& msg);
virtual void layoutWidget();///< Layout the appearance of this widget
virtual void connectSignalsAndSlots();///< Connect signals/slots as needed
virtual void connectViewSignalsAndSlots();///< Connect view signals/slots as needed
virtual void disconnectViewSignalsAndSlots();///< Connect view signals/slots as needed
virtual QTreeWidgetItem* getParentWidgetItemForParam(int compId, const QString& paramName);
virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName);
signals:
public slots:
/** @brief Add a component to the list
/** @brief Add a component item as a child of this widget
* @param compId Component id of the component
* @param compName Human friendly name of the component
*/
void addComponentItem(int compId, QString compName);
virtual void addActionButtonsToLayout(QGridLayout* layout);
virtual void handleParameterUpdate(int component,const QString& parameterName, QVariant value);
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
virtual void handleParameterListUpToDate();
signals:
public slots:
virtual void handleOnboardParamUpdate(int component,const QString& parameterName, QVariant value);
virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
virtual void handleOnboardParameterListUpToDate();
virtual void handleParamStatusMsgUpdate(QString msg, int level);
virtual void clearOnboardParamDisplay();
virtual void clearPendingParamDisplay();
/** @brief Ensure that view of parameter matches data in the model */
QTreeWidgetItem* updateParameterDisplay(int component, QString parameterName, QVariant value);
/** @brief Request list of parameters from MAV */
void requestAllParamsUpdate();
/** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
void writeParameters();
/** @brief Read the parameters from permanent storage to RAM */
void readParameters();
/** @brief Clear the parameter list */
void clear();
/** @brief Update when user changes parameters */
void parameterItemChanged(QTreeWidgetItem* prev, int column);
/** @brief Store parameters to a file */
void saveParametersToFile();
/** @brief Load parameters from a file */
void loadParametersFromFile();
/** @brief Update when user changes parameters */
void parameterItemChanged(QTreeWidgetItem* prev, int column);
protected:
QTreeWidget* tree; ///< The parameter tree
QLabel* statusLabel; ///< User-facing parameter status label
QMap<int, QTreeWidgetItem*>* componentItems; ///< The tree of component items, stored by component ID
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
QString updatingParamNameLock; ///< Name of param currently being updated-- used for reducing echo on param change
QLabel* statusLabel; ///< User-facing parameter status label
QTreeWidget* tree; ///< The parameter tree
};
......
#include "QGCPendingParamWidget.h"
#include <QGridLayout>
#include <QPushButton>
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) :
QGCParamWidget(UASManager::instance()->getActiveUAS(),(QWidget*)parent)
QGCParamWidget((QWidget*)parent)
{
}
void QGCPendingParamWidget::init()
void QGCPendingParamWidget::connectToParamManager()
{
//we override a lot of the super's init methods
layoutWidget();
connectSignalsAndSlots();
paramMgr = mav->getParamManager();
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
this, SLOT(handlePendingParamUpdate(int , const QString& , QVariant, bool )));
//don't request update params here...assume that everything we need is in the data model
// Listen to communications status messages so we can display them
connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}
void QGCPendingParamWidget::connectSignalsAndSlots()
void QGCPendingParamWidget::disconnectFromParamManager()
{
// Listing for pending list update
connect(paramDataModel, SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
//TODO route via paramManager instead?
// Listen to updated param signals from the data model
disconnect(paramMgr->dataModel(), 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)),
disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SLOT(handleParamStatusMsgUpdate(QString , int )));
paramMgr = NULL;
}
void QGCPendingParamWidget::disconnectViewSignalsAndSlots()
{
//we ignore edits from the tree view
}
void QGCPendingParamWidget::connectViewSignalsAndSlots()
{
//we ignore edits from the tree view
}
void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)
......@@ -60,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,17 +4,23 @@
#include "QGCParamWidget.h"
class QGridLayout;
class QGCPendingParamWidget : public QGCParamWidget
{
Q_OBJECT
public:
explicit QGCPendingParamWidget(QObject* parent);
virtual void init(); ///< Two-stage construction: initialize the object
protected:
virtual void connectSignalsAndSlots();
virtual void connectToParamManager();
virtual void disconnectFromParamManager();
virtual void connectViewSignalsAndSlots();
virtual void disconnectViewSignalsAndSlots();
virtual void addActionButtonsToLayout(QGridLayout* layout);
signals:
......
......@@ -4,18 +4,18 @@ QGCTabbedInfoView::QGCTabbedInfoView(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
messageView = new QGCMessageView(this);
actionsWidget = new UASActionsWidget(this);
//actionsWidget = new UASActionsWidget(this);
quickView = new UASQuickView(this);
rawView = new UASRawStatusView(this);
//rawView = new UASRawStatusView(this);
ui.tabWidget->addTab(quickView,"Quick");
ui.tabWidget->addTab(actionsWidget,"Actions");
ui.tabWidget->addTab(rawView,"Status");
//ui.tabWidget->addTab(actionsWidget,"Actions");
//ui.tabWidget->addTab(rawView,"Status");
ui.tabWidget->addTab(messageView,"Messages");
}
void QGCTabbedInfoView::addSource(MAVLinkDecoder *decoder)
{
m_decoder = decoder;
rawView->addSource(decoder);
//rawView->addSource(decoder);
quickView->addSource(decoder);
}
......
......@@ -788,10 +788,12 @@ void QGCVehicleConfig::loadConfig()
xml.readNext();
}
mav->getParamManager()->setParamDescriptions(paramTooltips);
if (!paramTooltips.isEmpty()) {
paramMgr->setParamDescriptions(paramTooltips);
}
doneLoadingConfig = true;
//Config is finished, lets do a parameter request to ensure none are missed if someone else started requesting before we were finished.
mav->getParamCommsMgr()->requestParameterListIfEmpty();
paramMgr->requestParameterListIfEmpty();
}
void QGCVehicleConfig::setActiveUAS(UASInterface* active)
......@@ -862,6 +864,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active)
// Connect new system
mav = active;
paramMgr = mav->getParamManager();
// Reset current state
resetCalibrationRC();
......@@ -977,15 +980,14 @@ void QGCVehicleConfig::writeCalibrationRC()
void QGCVehicleConfig::requestCalibrationRC()
{
if (mav) {
mav->getParamCommsMgr()->requestRcCalibrationParamsUpdate();
}
paramMgr->requestRcCalibrationParamsUpdate();
}
void QGCVehicleConfig::writeParameters()
{
updateStatus(tr("Writing all onboard parameters."));
writeCalibrationRC();
mav->writeParametersToStorage();
}
......
......@@ -158,6 +158,7 @@ protected slots:
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
QGCUASParamManager* paramMgr; ///< params mgr for the mav
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
......
......@@ -17,7 +17,7 @@ QGCComboBox::QGCComboBox(QWidget *parent) :
parameterScalingFactor(0.0),
parameterMin(0.0f),
parameterMax(0.0f),
component(0),
componentId(0),
ui(new Ui::QGCComboBox)
{
ui->setupUi(this);
......@@ -56,7 +56,7 @@ QGCComboBox::QGCComboBox(QWidget *parent) :
//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->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParamList()));
connect(ui->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParameter()));
connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(showInfo(bool)));
// connect to self
connect(ui->infoLabel, SIGNAL(released()), this, SLOT(showTooltip()));
......@@ -82,14 +82,13 @@ void QGCComboBox::showTooltip()
}
}
void QGCComboBox::refreshParamList()
void QGCComboBox::refreshParameter()
{
ui->editSelectParamComboBox->setEnabled(true);
ui->editSelectComponentComboBox->setEnabled(true);
if (uas)
{
uas->getParamManager()->requestParameterList();
ui->editStatusLabel->setText(tr("Parameter list updating.."));
if (uas && !parameterName.isEmpty()) {
uas->getParamManager()->requestParameterUpdate(componentId,parameterName);
ui->editStatusLabel->setText(tr("Requesting refresh..."));
}
}
......@@ -105,11 +104,12 @@ void QGCComboBox::setActiveUAS(UASInterface* activeUas)
// Connect buttons and signals
connect(activeUas, SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)), this, SLOT(setParameterValue(int,int,int,int,QString,QVariant)), Qt::UniqueConnection);
uas = activeUas;
paramMgr = uas->getParamManager();
// Update current param value
//requestParameter();
// Set param info
QString text = uas->getParamDataModel()->getParamDescription(parameterName);
QString text = paramMgr->dataModel()->getParamDescription(parameterName);
if (!text.isEmpty()) {
ui->infoLabel->setToolTip(text);
ui->infoLabel->show();
......@@ -125,7 +125,7 @@ void QGCComboBox::requestParameter()
{
if (!parameterName.isEmpty() && uas)
{
uas->getParamManager()->requestParameterUpdate(this->component, this->parameterName);
paramMgr->requestParameterUpdate(this->componentId, this->parameterName);
}
}
......@@ -137,7 +137,7 @@ void QGCComboBox::showInfo(bool enable)
void QGCComboBox::selectComponent(int componentIndex)
{
this->component = ui->editSelectComponentComboBox->itemData(componentIndex).toInt();
this->componentId = ui->editSelectComponentComboBox->itemData(componentIndex).toInt();
}
void QGCComboBox::selectParameter(int paramIndex)
......@@ -147,7 +147,7 @@ void QGCComboBox::selectParameter(int paramIndex)
// Update min and max values if available
if (uas) {
UASParameterDataModel* dataModel = uas->getParamDataModel();
UASParameterDataModel* dataModel = paramMgr->dataModel();
if (dataModel) {
// Minimum
if (dataModel->isParamMinKnown(parameterName)) {
......@@ -236,7 +236,7 @@ void QGCComboBox::endEditMode()
void QGCComboBox::setParamPending()
{
if (uas) {
uas->getParamManager()->setPendingParam(component, parameterName, parameterValue);
uas->getParamManager()->setPendingParam(componentId, parameterName, parameterValue);
}
else {
qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
......@@ -292,7 +292,7 @@ void QGCComboBox::setParameterValue(int uas, int component, int paramCount, int
{
if (visibleVal == value.toInt())
{
this->uas->requestParameter(this->component,this->parameterName);
this->uas->requestParameter(this->componentId,this->parameterName);
visibleEnabled = true;
this->show();
}
......@@ -307,7 +307,7 @@ void QGCComboBox::setParameterValue(int uas, int component, int paramCount, int
}
}
}
if (component == this->component && parameterName == this->parameterName)
if (component == this->componentId && parameterName == this->parameterName)
{
if (!visibleEnabled)
{
......@@ -350,7 +350,7 @@ void QGCComboBox::writeSettings(QSettings& settings)
settings.setValue("QGC_PARAM_COMBOBOX_DESCRIPTION", ui->nameLabel->text());
//settings.setValue("QGC_PARAM_COMBOBOX_BUTTONTEXT", ui->actionButton->text());
settings.setValue("QGC_PARAM_COMBOBOX_PARAMID", parameterName);
settings.setValue("QGC_PARAM_COMBOBOX_COMPONENTID", component);
settings.setValue("QGC_PARAM_COMBOBOX_COMPONENTID", componentId);
settings.setValue("QGC_PARAM_COMBOBOX_DISPLAY_INFO", ui->editInfoCheckBox->isChecked());
settings.setValue("QGC_PARAM_COMBOBOX_COUNT", ui->editOptionComboBox->count());
......@@ -364,7 +364,7 @@ void QGCComboBox::writeSettings(QSettings& settings)
void QGCComboBox::readSettings(const QString& pre,const QVariantMap& settings)
{
parameterName = settings.value(pre + "QGC_PARAM_COMBOBOX_PARAMID").toString();
component = settings.value(pre + "QGC_PARAM_COMBOBOX_COMPONENTID").toInt();
componentId = settings.value(pre + "QGC_PARAM_COMBOBOX_COMPONENTID").toInt();
ui->nameLabel->setText(settings.value(pre + "QGC_PARAM_COMBOBOX_DESCRIPTION").toString());
ui->editNameLabel->setText(settings.value(pre + "QGC_PARAM_COMBOBOX_DESCRIPTION").toString());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
......
......@@ -7,6 +7,8 @@
#include "QGCToolWidgetItem.h"
class QGCUASParamManager;
namespace Ui
{
class QGCComboBox;
......@@ -26,11 +28,12 @@ public slots:
/** @brief Queue parameter for sending to the MAV (add to pending list)*/
void setParamPending();
/** @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 componentId, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void writeSettings(QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
void readSettings(const QSettings& settings);
void refreshParamList();
/** @brief request that the parameter for this widget be refreshed */
void refreshParameter();
void setActiveUAS(UASInterface *uas);
void selectComponent(int componentIndex);
void selectParameter(int paramIndex);
......@@ -49,6 +52,7 @@ protected slots:
/** @brief Updates current parameter based on new combobox value */
void comboBoxIndexChanged(QString val);
protected:
QGCUASParamManager *paramMgr; ///< Access to parameter manager
bool visibleEnabled;
QString visibleParam;
int visibleVal;
......@@ -61,7 +65,7 @@ protected:
float parameterMin;
bool isDisabled;
float parameterMax;
int component; ///< ID of the MAV component to address
int componentId; ///< ID of the MAV component to address
//double scaledInt;
void changeEvent(QEvent *e);
......
......@@ -17,7 +17,7 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
parameterScalingFactor(0.0),
parameterMin(0.0f),
parameterMax(0.0f),
component(0),
componentId(0),
ui(new Ui::QGCParamSlider)
{
valueModLock = false;
......@@ -116,7 +116,7 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
}
if (uas && !parameterName.isEmpty()) {
QString text = uas->getParamDataModel()->getParamDescription(parameterName);
QString text = uas->getParamManager()->dataModel()->getParamDescription(parameterName);
if (!text.isEmpty()) {
ui->infoLabel->setToolTip(text);
ui->infoLabel->show();
......@@ -133,7 +133,7 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
void QGCParamSlider::requestParameter()
{
if (uas && !parameterName.isEmpty()) {
uas->getParamManager()->requestParameterUpdate(component, parameterName);
uas->getParamManager()->requestParameterUpdate(componentId, parameterName);
}
}
......@@ -177,7 +177,7 @@ void QGCParamSlider::setParamValue(int value)
void QGCParamSlider::selectComponent(int componentIndex)
{
this->component = ui->editSelectComponentComboBox->itemData(componentIndex).toInt();
this->componentId = ui->editSelectComponentComboBox->itemData(componentIndex).toInt();
}
void QGCParamSlider::selectParameter(int paramIndex)
......@@ -190,7 +190,7 @@ void QGCParamSlider::selectParameter(int paramIndex)
// Update min and max values if available
if (uas) {
UASParameterDataModel* dataModel = uas->getParamDataModel();
UASParameterDataModel* dataModel = uas->getParamManager()->dataModel();
if (dataModel) {
// Minimum
if (dataModel->isParamMinKnown(parameterName)) {
......@@ -280,7 +280,7 @@ void QGCParamSlider::endEditMode()
void QGCParamSlider::setParamPending()
{
if (uas) {
uas->getParamManager()->setPendingParam(component, parameterName, parameterValue);
uas->getParamManager()->setPendingParam(componentId, parameterName, parameterValue);
}
else {
qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
......@@ -380,7 +380,7 @@ void QGCParamSlider::setParameterValue(int uasId, int compId, int paramCount, in
}
}
Q_UNUSED(uas);
if (compId == this->component && paramName == this->parameterName) {
if (compId == this->componentId && paramName == this->parameterName) {
if (!visibleEnabled) {
return;
}
......@@ -487,7 +487,7 @@ void QGCParamSlider::writeSettings(QSettings& settings)
settings.setValue("QGC_PARAM_SLIDER_DESCRIPTION", ui->nameLabel->text());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
settings.setValue("QGC_PARAM_SLIDER_PARAMID", parameterName);
settings.setValue("QGC_PARAM_SLIDER_COMPONENTID", component);
settings.setValue("QGC_PARAM_SLIDER_COMPONENTID", componentId);
settings.setValue("QGC_PARAM_SLIDER_MIN", ui->editMinSpinBox->value());
settings.setValue("QGC_PARAM_SLIDER_MAX", ui->editMaxSpinBox->value());
settings.setValue("QGC_PARAM_SLIDER_DISPLAY_INFO", ui->editInfoCheckBox->isChecked());
......@@ -496,7 +496,7 @@ void QGCParamSlider::writeSettings(QSettings& settings)
void QGCParamSlider::readSettings(const QString& pre,const QVariantMap& settings)
{
parameterName = settings.value(pre + "QGC_PARAM_SLIDER_PARAMID").toString();
component = settings.value(pre + "QGC_PARAM_SLIDER_COMPONENTID").toInt();
componentId = settings.value(pre + "QGC_PARAM_SLIDER_COMPONENTID").toInt();
ui->nameLabel->setText(settings.value(pre + "QGC_PARAM_SLIDER_DESCRIPTION").toString());
ui->editNameLabel->setText(settings.value(pre + "QGC_PARAM_SLIDER_DESCRIPTION").toString());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
......@@ -516,9 +516,6 @@ void QGCParamSlider::readSettings(const QString& pre,const QVariantMap& settings
ui->editSelectComponentComboBox->setEnabled(true);
setActiveUAS(UASManager::instance()->getActiveUAS());
// Get param value after settings have been loaded
//requestParameter();
}
void QGCParamSlider::readSettings(const QSettings& settings)
......@@ -532,7 +529,7 @@ void QGCParamSlider::readSettings(const QSettings& settings)
readSettings("",map);
return;
parameterName = settings.value("QGC_PARAM_SLIDER_PARAMID").toString();
component = settings.value("QGC_PARAM_SLIDER_COMPONENTID").toInt();
componentId = settings.value("QGC_PARAM_SLIDER_COMPONENTID").toInt();
ui->nameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString());
ui->editNameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
......@@ -552,6 +549,4 @@ void QGCParamSlider::readSettings(const QSettings& settings)
setActiveUAS(UASManager::instance()->getActiveUAS());
// Get param value after settings have been loaded
//requestParameter();
}
......@@ -28,7 +28,7 @@ public slots:
/** @brief Set the slider value as parameter value */
void setSliderValue(int sliderValue);
/** @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 componentId, int paramCount, int paramIndex, QString parameterName, const QVariant value);
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
......@@ -62,7 +62,7 @@ protected:
double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
float parameterMin;
float parameterMax;
int component; ///< ID of the MAV component to address
int componentId; ///< ID of the MAV component to address
double scaledInt;
void changeEvent(QEvent *e);
......
......@@ -25,7 +25,7 @@ public slots:
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
void textMessageReceived(int uasid, int component, int severity, QString message);
void textMessageReceived(int uasid, int componentId, int severity, QString message);
private:
int enabledNum;
Ui::QGCTextLabel *ui;
......
......@@ -14,7 +14,7 @@ public:
QGCToolWidgetItem(const QString& name, QWidget *parent = 0);
~QGCToolWidgetItem();
int component() {
int componentId() {
return _component;
}
......
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