Commit 1b1e0f50 authored by tstellanova's avatar tstellanova

fix one-stage constructor problem

parent 5a69605a
......@@ -7,19 +7,29 @@
#include "UASInterface.h"
#include "UASParameterCommsMgr.h"
QGCUASParamManager::QGCUASParamManager(QObject *parent, UASInterface* uas) :
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent),
mav(uas),
mav(NULL),
paramDataModel(this),
paramCommsMgr(NULL)
{
paramCommsMgr = new UASParameterCommsMgr(this,mav);
// 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);
connectToCommsMgr();
return this;
}
void QGCUASParamManager::connectToCommsMgr()
......
......@@ -17,7 +17,8 @@ class QGCUASParamManager : public QObject
{
Q_OBJECT
public:
QGCUASParamManager(QObject* parent = 0,UASInterface* uas = 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;
......
......@@ -115,8 +115,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
nedPosGlobalOffset(0,0,0),
nedAttGlobalOffset(0,0,0),
waypointManager(this),
paramMgr(this),
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
receivedOverlayTimestamp(0.0),
......@@ -131,8 +131,6 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
lastAttitude(0),
paramsOnceRequested(false),
paramManager(this,this),
simulation(0),
// The protected members.
......@@ -217,6 +215,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
connect(this, SIGNAL(systemSpecsChanged(int)), this, SLOT(writeSettings()));
statusTimeout->start(500);
readSettings();
//need to init paramMgr after readSettings have been loaded, to properly set autopilot and so forth
paramMgr.initWithUAS(this);
// Initial signals
emit disarmed();
emit armingChanged(false);
......
......@@ -492,7 +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 for this UAS
QGCUASParamManager paramMgr; ///< Parameter manager for this UAS
/// SIMULATION
QGCHilLink* simulation; ///< Hardware in the loop simulation link
......@@ -520,7 +520,7 @@ public:
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() {
return &paramManager;
return &paramMgr;
}
/** @brief Get the HIL simulation */
......
......@@ -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)
{
}
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;
}
......
......@@ -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 {
......
......@@ -100,29 +100,29 @@ void QGCParamWidget::layoutWidget()
// BUTTONS
QPushButton* refreshButton = new QPushButton(tr("Get"));
refreshButton->setToolTip(tr("Load parameters currently in non-permanent memory of aircraft."));
refreshButton->setWhatsThis(tr("Load parameters currently in non-permanent memory of aircraft."));
refreshButton->setToolTip(tr("Fetch parameters currently in volatile memory of aircraft."));
refreshButton->setWhatsThis(tr("Fetch parameters currently in volatile memory of aircraft."));
connect(refreshButton, SIGNAL(clicked()),
this, SLOT(requestOnboardParamsUpdate()));
horizontalLayout->addWidget(refreshButton, 2, 0);
QPushButton* setButton = new QPushButton(tr("Set"));
setButton->setToolTip(tr("Set current parameters in non-permanent onboard memory"));
setButton->setWhatsThis(tr("Set current parameters in non-permanent onboard memory"));
setButton->setToolTip(tr("Send pending parameters to volatile onboard memory"));
setButton->setWhatsThis(tr("Send pending parameters to volatile onboard memory"));
connect(setButton, SIGNAL(clicked()),
this, SLOT(sendPendingParameters()));
paramMgr, SLOT(sendPendingParameters()));
horizontalLayout->addWidget(setButton, 2, 1);
QPushButton* writeButton = new QPushButton(tr("Write (ROM)"));
writeButton->setToolTip(tr("Copy current parameters in non-permanent memory of the aircraft to permanent memory. Transmit your parameters first to write these."));
writeButton->setWhatsThis(tr("Copy current parameters in non-permanent memory of the aircraft to permanent memory. Transmit your parameters first to write these."));
writeButton->setToolTip(tr("Copy parameters in volatile memory of the aircraft to persistent memory. Transmit your parameters first to write these."));
writeButton->setWhatsThis(tr("Copy parameters in volatile memory of the aircraft to persistent memory. Transmit your parameters first to write these."));
connect(writeButton, SIGNAL(clicked()),
paramMgr, SLOT(copyVolatileParamsToPersistent()));
horizontalLayout->addWidget(writeButton, 2, 2);
QPushButton* loadFileButton = new QPushButton(tr("Load File"));
loadFileButton->setToolTip(tr("Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them."));
loadFileButton->setWhatsThis(tr("Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them."));
loadFileButton->setToolTip(tr("Load parameters from a file into qgroundcontrol. To write these to the aircraft, use transmit after loading them."));
loadFileButton->setWhatsThis(tr("Load parameters from a file into qgroundcontrol. To write these to the aircraft, use transmit after loading them."));
connect(loadFileButton, SIGNAL(clicked()),
this, SLOT(loadParametersFromFile()));
horizontalLayout->addWidget(loadFileButton, 3, 0);
......@@ -135,8 +135,8 @@ void QGCParamWidget::layoutWidget()
horizontalLayout->addWidget(saveFileButton, 3, 1);
QPushButton* readButton = new QPushButton(tr("Read (ROM)"));
readButton->setToolTip(tr("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."));
readButton->setWhatsThis(tr("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."));
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);
......
......@@ -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;
......@@ -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)
......@@ -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