Commit 28e1ad82 authored by Don Gagne's avatar Don Gagne

Support for new parametersReady method

This allows you to determine if full parameter list is ready if you
missed the parameterListUpToDate signal.
parent 92e8b048
......@@ -53,6 +53,7 @@ public slots:
{ Q_UNUSED(forceSend); setParameter(componentId, key, value); }
virtual void sendPendingParameters(bool persistAfterSend = false, bool forceSend = false)
{ Q_UNUSED(persistAfterSend); Q_UNUSED(forceSend); }
virtual bool parametersReady(void) { return false; }
public:
// MockQGCUASParamManager methods
......
......@@ -244,12 +244,16 @@ void PX4RCCalibrationTest::_minRCChannels_test(void)
}
_multiSpyNextButtonMessageBox->clearAllSignals();
// The following test code no longer works since view update doesn't happens until parameters are received.
// Leaving code here because RC Cal could be restructured to handle this case at some point.
#if 0
// Only available channels should have visible widget. A ui update cycle needs to have passed so we wait a little.
QTest::qWait(PX4RCCalibration::_updateInterval * 2);
for (int chanWidget=0; chanWidget<PX4RCCalibration::_chanMax; chanWidget++) {
//qDebug() << _rgValueWidget[chanWidget]->objectName() << chanWidget << chan;
QCOMPARE(_rgValueWidget[chanWidget]->isVisible(), !!(chanWidget <= chan));
}
#endif
}
}
......
......@@ -9,7 +9,8 @@
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QGCUASParamManagerInterface(parent),
mav(NULL),
paramDataModel(this)
paramDataModel(this),
_parametersReady(false)
{
......@@ -36,8 +37,7 @@ void QGCUASParamManager::connectToModelAndComms()
connect(&paramCommsMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
this, SIGNAL(parameterStatusMsgUpdated(QString,int)));
connect(&paramCommsMgr, SIGNAL(parameterListUpToDate()),
this, SIGNAL(parameterListUpToDate()));
connect(&paramCommsMgr, SIGNAL(parameterListUpToDate()), this, SLOT(_parameterListUpToDate()));
// Pass along data model updates
connect(&paramDataModel, SIGNAL(parameterUpdated(int, QString , QVariant )),
......@@ -214,3 +214,9 @@ void QGCUASParamManager::copyPersistentParamsToVolatile()
void QGCUASParamManager::requestRcCalibrationParamsUpdate() {
paramCommsMgr.requestRcCalibrationParamsUpdate();
}
void QGCUASParamManager::_parameterListUpToDate(void)
{
_parametersReady = true;
emit parameterListUpToDate();
}
......@@ -60,6 +60,9 @@ public:
/** @return The data model managed by this class */
virtual UASParameterDataModel* dataModel();
/// @return true: first full set of parameters received
virtual bool parametersReady(void) { return _parametersReady; }
protected:
......@@ -119,6 +122,9 @@ public slots:
virtual void copyVolatileParamsToPersistent();
/** @brief Copy the parameters from persistent storage to volatile RAM */
virtual void copyPersistentParamsToVolatile();
private slots:
void _parameterListUpToDate(void);
protected:
......@@ -126,6 +132,8 @@ protected:
UASInterface* mav; ///< The MAV this manager is controlling
UASParameterDataModel paramDataModel;///< Shared data model of parameters
UASParameterCommsMgr paramCommsMgr; ///< Shared comms mgr for parameters
bool _parametersReady;
};
......
......@@ -33,6 +33,7 @@ public:
virtual int countPendingParams() = 0;
virtual int countOnboardParams() = 0;
virtual UASParameterDataModel* dataModel() = 0;
virtual bool parametersReady(void) = 0;
public slots:
virtual void setParameter(int component, QString parameterName, QVariant value) = 0;
......
......@@ -133,7 +133,6 @@ PX4RCCalibration::PX4RCCalibration(QWidget *parent) :
_updateTimer.setInterval(150);
_updateTimer.start();
connect(&_updateTimer, &QTimer::timeout, this, &PX4RCCalibration::_updateView);
connect(_ui->rcCalCancel, &QPushButton::clicked, this, &PX4RCCalibration::_stopCalibration);
connect(_ui->rcCalSkip, &QPushButton::clicked, this, &PX4RCCalibration::_skipButton);
......@@ -835,6 +834,10 @@ void PX4RCCalibration::_setActiveUAS(UASInterface* active)
fSucceeded = connect(_paramMgr, SIGNAL(parameterListUpToDate()), this, SLOT(_parameterListUpToDate()));
Q_ASSERT(fSucceeded);
if (_paramMgr->parametersReady()) {
_parameterListUpToDate();
}
}
setEnabled(_mav ? true : false);
......@@ -1074,6 +1077,9 @@ void PX4RCCalibration::_parameterListUpToDate(void)
{
_parameterListUpToDateSignalled = true;
// Don't start updating the view until we have parameters
connect(&_updateTimer, &QTimer::timeout, this, &PX4RCCalibration::_updateView);
if (_currentStep == -1) {
_setInternalCalibrationValuesFromParameters();
}
......
......@@ -110,9 +110,9 @@ QGCPX4AirframeConfig::QGCPX4AirframeConfig(QWidget *parent) :
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
setActiveUAS(UASManager::instance()->getActiveUAS());
uncheckAll();
setActiveUAS(UASManager::instance()->getActiveUAS());
}
void QGCPX4AirframeConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
......@@ -148,6 +148,19 @@ void QGCPX4AirframeConfig::setActiveUAS(UASInterface* uas)
paramMgr = mav->getParamManager();
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, SLOT(parameterChanged(int,int,QString,QVariant)));
// If the parameters are ready, we aren't going to get paramterChanged signals. So fake them in order to make the UI work.
if (uas->getParamManager()->parametersReady()) {
QVariant value;
static const char* param = "SYS_AUTOSTART";
QGCUASParamManagerInterface* paramMgr = uas->getParamManager();
QList<int> compIds = paramMgr->getComponentForParam(param);
Q_ASSERT(compIds.count() == 1);
paramMgr->getParameterValue(compIds[0], param, value);
parameterChanged(uas->getUASID(), compIds[0], param, value);
}
}
void QGCPX4AirframeConfig::uncheckAll()
......
......@@ -348,6 +348,23 @@ void QGCPX4SensorCalibration::setActiveUAS(UASInterface* uas)
activeUAS = uas;
updateSystemSpecs(uas->getUASID());
// If the parameters are ready, we aren't going to get paramterChanged signals. So fake them in order to make the UI work.
if (uas->getParamManager()->parametersReady()) {
QVariant value;
static const char* rgParams[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF" };
QGCUASParamManagerInterface* paramMgr = uas->getParamManager();
for (size_t i=0; i<sizeof(rgParams)/sizeof(rgParams[0]); i++) {
QVariant value;
QList<int> compIds = paramMgr->getComponentForParam(rgParams[i]);
Q_ASSERT(compIds.count() == 1);
paramMgr->getParameterValue(compIds[0], rgParams[i], value);
parameterChanged(uas->getUASID(), compIds[0], rgParams[i], value);
}
}
}
void QGCPX4SensorCalibration::updateSystemSpecs(int id)
......
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