mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
OP-1150 UI for thermal calibration: fix deadlock at end of acquisition, moved uavo disconnect at state exit to handle abort
This commit is contained in:
parent
847c3327eb
commit
3f5af83d42
@ -48,9 +48,15 @@ public:
|
||||
|
||||
virtual void onTransition(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
qDebug() << "DataAcquisitionTransition::collectionCompleted";
|
||||
}
|
||||
|
||||
virtual void exit(int __status){
|
||||
Q_UNUSED(__status);
|
||||
m_helper->endAcquisition();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void enterState()
|
||||
{
|
||||
|
@ -284,7 +284,7 @@ void ThermalCalibrationHelper::updateTemp(float temp)
|
||||
m_initialGradient = m_gradient;
|
||||
}
|
||||
if (m_gradient < TargetGradient) {
|
||||
endAcquisition();
|
||||
emit collectionCompleted();
|
||||
}
|
||||
|
||||
if (m_targetduration != 0) {
|
||||
@ -302,16 +302,14 @@ void ThermalCalibrationHelper::updateTemp(float temp)
|
||||
|
||||
void ThermalCalibrationHelper::endAcquisition()
|
||||
{
|
||||
// this is called from the collectSample that already has the lock
|
||||
// QMutexLocker lock(&sensorsUpdateLock);
|
||||
QMutexLocker lock(&sensorsUpdateLock);
|
||||
disconnectUAVOs();
|
||||
emit collectionCompleted();
|
||||
setProcessPercentage(ProcessPercentageBaseCalculation);
|
||||
}
|
||||
|
||||
void ThermalCalibrationHelper::connectUAVOs()
|
||||
{
|
||||
AccelSensor *accel = AccelSensor::GetInstance(getObjectManager());
|
||||
|
||||
connect(accel, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(collectSample(UAVObject *)));
|
||||
|
||||
GyroSensor *gyro = GyroSensor::GetInstance(getObjectManager());
|
||||
@ -327,7 +325,6 @@ void ThermalCalibrationHelper::connectUAVOs()
|
||||
void ThermalCalibrationHelper::disconnectUAVOs()
|
||||
{
|
||||
AccelSensor *accel = AccelSensor::GetInstance(getObjectManager());
|
||||
|
||||
disconnect(accel, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(collectSample(UAVObject *)));
|
||||
|
||||
GyroSensor *gyro = GyroSensor::GetInstance(getObjectManager());
|
||||
|
@ -88,7 +88,7 @@ signals:
|
||||
void processPercentageChanged(int percentage);
|
||||
void collectionCompleted();
|
||||
void calculationCompleted();
|
||||
|
||||
void abort();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "settingshandlingtransitions.h"
|
||||
#include "boardsetuptransition.h"
|
||||
#include "dataacquisitiontransition.h"
|
||||
#include "compensationcalculationtransition.h"
|
||||
|
||||
#define NEXT_EVENT "next"
|
||||
#define PREVIOUS_EVENT "previous"
|
||||
@ -40,18 +41,18 @@ ThermalCalibrationModel::ThermalCalibrationModel(QObject *parent) :
|
||||
{
|
||||
m_helper = new ThermalCalibrationHelper();
|
||||
m_readyState = new WizardState(tr("Start"), this),
|
||||
m_workingState = new WizardState("workingState", this);
|
||||
m_workingState = new WizardState(NULL, this);
|
||||
|
||||
m_saveSettingState = new WizardState(tr("Saving initial settings"), m_workingState);
|
||||
m_workingState->setInitialState(m_saveSettingState);
|
||||
|
||||
m_setupState = new WizardState(tr("Setup board for calibration"), m_workingState);
|
||||
|
||||
m_acquisitionState = new WizardState(tr("Samples acquisition"), m_workingState);
|
||||
m_acquisitionState = new WizardState(tr("*** Please Wait *** Samples acquisition, this can take several minutes"), m_workingState);
|
||||
m_calculateState = new WizardState(tr("Calculate calibration matrix"), m_workingState);
|
||||
m_finalizeState = new WizardState(tr("Completed"), m_workingState);
|
||||
|
||||
m_abortState = new WizardState("abort", this);
|
||||
m_abortState = new WizardState("Canceled", this);
|
||||
|
||||
setTransitions();
|
||||
|
||||
@ -75,7 +76,9 @@ void ThermalCalibrationModel::init()
|
||||
emit instructionsChanged(instructions());
|
||||
}
|
||||
|
||||
void ThermalCalibrationModel::stepChanged(WizardState *state) {}
|
||||
void ThermalCalibrationModel::stepChanged(WizardState *state) {
|
||||
Q_UNUSED(state);
|
||||
}
|
||||
|
||||
void ThermalCalibrationModel::setTransitions()
|
||||
{
|
||||
@ -92,9 +95,10 @@ void ThermalCalibrationModel::setTransitions()
|
||||
// revert settings after acquisition is completed
|
||||
// m_acquisitionState->addTransition(new BoardStatusRestoreTransition(m_helper, m_acquisitionState, m_calculateState));
|
||||
m_acquisitionState->addTransition(new DataAcquisitionTransition(m_helper, m_acquisitionState, m_calculateState));
|
||||
|
||||
m_workingState->addTransition(m_helper, SIGNAL(abort()), m_abortState) ;
|
||||
m_calculateState->addTransition(new BoardStatusRestoreTransition(m_helper, m_calculateState, m_finalizeState));
|
||||
|
||||
m_abortState->addTransition(new BoardStatusRestoreTransition(m_helper, m_abortState, m_readyState));
|
||||
m_finalizeState->addTransition(this, SIGNAL(next()), m_readyState);
|
||||
// Ready
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "wizardmodel.h"
|
||||
|
||||
#include "QDebug"
|
||||
WizardModel::WizardModel(QObject *parent) :
|
||||
QStateMachine(parent)
|
||||
{}
|
||||
@ -34,8 +34,9 @@ WizardModel::WizardModel(QObject *parent) :
|
||||
WizardState *WizardModel::currentState()
|
||||
{
|
||||
foreach(QAbstractState * value, this->configuration()) {
|
||||
if (value->parent() != 0) { \
|
||||
return static_cast<WizardState *>(value);
|
||||
WizardState *state = static_cast<WizardState *>(value);
|
||||
if (state->children().count() <= 1) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user