1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1351 improved instructions handling for thermal calibration (removed duplicates, specified instruction types)

This commit is contained in:
Philippe Renon 2014-05-28 23:07:31 +02:00
parent c9b64d6399
commit 60700cab7f
13 changed files with 109 additions and 86 deletions

View File

@ -29,13 +29,15 @@
#ifndef BOARDSETUPTRANSITION_H #ifndef BOARDSETUPTRANSITION_H
#define BOARDSETUPTRANSITION_H #define BOARDSETUPTRANSITION_H
#include "thermalcalibrationhelper.h"
#include <QSignalTransition> #include <QSignalTransition>
#include <QEventTransition> #include <QEventTransition>
#include "thermalcalibrationhelper.h"
namespace OpenPilot { namespace OpenPilot {
class BoardSetupTransition : public QSignalTransition { class BoardSetupTransition : public QSignalTransition {
Q_OBJECT Q_OBJECT
public: public:
BoardSetupTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState) BoardSetupTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState)
: QSignalTransition(helper, SIGNAL(setupBoardCompleted(bool))), : QSignalTransition(helper, SIGNAL(setupBoardCompleted(bool))),
@ -66,11 +68,14 @@ public:
{ {
Q_UNUSED(e); Q_UNUSED(e);
} }
public slots: public slots:
void enterState() void enterState()
{ {
m_helper->addInstructions(tr("Configuring board for calibration."));
m_helper->setupBoard(); m_helper->setupBoard();
} }
private: private:
ThermalCalibrationHelper *m_helper; ThermalCalibrationHelper *m_helper;
}; };

View File

@ -34,9 +34,11 @@
#include "../wizardstate.h" #include "../wizardstate.h"
#include "thermalcalibrationhelper.h" #include "thermalcalibrationhelper.h"
namespace OpenPilot { namespace OpenPilot {
class CompensationCalculationTransition : public QSignalTransition { class CompensationCalculationTransition : public QSignalTransition {
Q_OBJECT Q_OBJECT
public: public:
CompensationCalculationTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState) CompensationCalculationTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState)
: QSignalTransition(helper, SIGNAL(calculationCompleted())), : QSignalTransition(helper, SIGNAL(calculationCompleted())),
@ -52,19 +54,19 @@ public:
Q_UNUSED(e); Q_UNUSED(e);
QString nextStateName; QString nextStateName;
if (m_helper->calibrationSuccessful()) { if (m_helper->calibrationSuccessful()) {
nextStateName = tr("Calibration completed succesfully"); m_helper->addInstructions(tr("Calibration completed successfully."), WizardModel::Success);
} else { } else {
nextStateName = tr("Calibration failed! Please read the instructions and retry"); m_helper->addInstructions(tr("Calibration failed! Please read the instructions and retry."), WizardModel::Failure);
} }
static_cast<WizardState *>(targetState())->setStepName(nextStateName);
} }
public slots: public slots:
void enterState() void enterState()
{ {
m_helper->addInstructions("Calculating calibration data.");
m_helper->calculate(); m_helper->calculate();
} }
private: private:
ThermalCalibrationHelper *m_helper; ThermalCalibrationHelper *m_helper;
}; };

View File

@ -29,13 +29,15 @@
#ifndef DATAACQUISITIONTRANSITION_H #ifndef DATAACQUISITIONTRANSITION_H
#define DATAACQUISITIONTRANSITION_H #define DATAACQUISITIONTRANSITION_H
#include "thermalcalibrationhelper.h"
#include <QSignalTransition> #include <QSignalTransition>
#include <QEventTransition> #include <QEventTransition>
#include "thermalcalibrationhelper.h"
namespace OpenPilot { namespace OpenPilot {
class DataAcquisitionTransition : public QSignalTransition { class DataAcquisitionTransition : public QSignalTransition {
Q_OBJECT Q_OBJECT
public: public:
DataAcquisitionTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState) DataAcquisitionTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState)
: QSignalTransition(helper, SIGNAL(collectionCompleted())), : QSignalTransition(helper, SIGNAL(collectionCompleted())),
@ -55,8 +57,10 @@ public:
public slots: public slots:
void enterState() void enterState()
{ {
m_helper->addInstructions(tr("Please wait during samples acquisition. This can take several minutes..."), WizardModel::Prompt);
m_helper->initAcquisition(); m_helper->initAcquisition();
} }
private: private:
ThermalCalibrationHelper *m_helper; ThermalCalibrationHelper *m_helper;
}; };

View File

@ -28,13 +28,16 @@
#ifndef SETTINGSHANDLINGTRANSITIONS_H #ifndef SETTINGSHANDLINGTRANSITIONS_H
#define SETTINGSHANDLINGTRANSITIONS_H #define SETTINGSHANDLINGTRANSITIONS_H
#include "thermalcalibrationhelper.h"
#include <QSignalTransition> #include <QSignalTransition>
#include <QEventTransition> #include <QEventTransition>
#include "thermalcalibrationhelper.h"
namespace OpenPilot { namespace OpenPilot {
class BoardStatusSaveTransition : public QSignalTransition { class BoardStatusSaveTransition : public QSignalTransition {
Q_OBJECT Q_OBJECT
public: public:
BoardStatusSaveTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState) BoardStatusSaveTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState)
: QSignalTransition(helper, SIGNAL(statusSaveCompleted(bool))), : QSignalTransition(helper, SIGNAL(statusSaveCompleted(bool))),
@ -65,18 +68,21 @@ public:
{ {
Q_UNUSED(e); Q_UNUSED(e);
} }
public slots: public slots:
void enterState() void enterState()
{ {
m_helper->addInstructions(tr("Saving initial settings."));
m_helper->statusSave(); m_helper->statusSave();
} }
private: private:
ThermalCalibrationHelper *m_helper; ThermalCalibrationHelper *m_helper;
}; };
class BoardStatusRestoreTransition : public QSignalTransition { class BoardStatusRestoreTransition : public QSignalTransition {
Q_OBJECT Q_OBJECT
public: public:
BoardStatusRestoreTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState) BoardStatusRestoreTransition(ThermalCalibrationHelper *helper, QState *currentState, QState *targetState)
: QSignalTransition(helper, SIGNAL(statusRestoreCompleted(bool))), : QSignalTransition(helper, SIGNAL(statusRestoreCompleted(bool))),
@ -102,12 +108,15 @@ public:
} }
return false; return false;
} }
public slots: public slots:
void enterState() void enterState()
{ {
m_helper->addInstructions(tr("Restoring board configuration."));
m_helper->endAcquisition(); m_helper->endAcquisition();
m_helper->statusRestore(); m_helper->statusRestore();
} }
private: private:
ThermalCalibrationHelper *m_helper; ThermalCalibrationHelper *m_helper;
}; };

View File

@ -199,7 +199,7 @@ bool ThermalCalibrationHelper::restoreInitialSettings()
void ThermalCalibrationHelper::setupBoard() void ThermalCalibrationHelper::setupBoard()
{ {
setProcessPercentage(ProcessPercentageSetupBoard); setProgress(ProcessPercentageSetupBoard);
if (setupBoardForCalibration()) { if (setupBoardForCalibration()) {
emit setupBoardCompleted(true); emit setupBoardCompleted(true);
} else { } else {
@ -219,7 +219,7 @@ void ThermalCalibrationHelper::statusRestore()
void ThermalCalibrationHelper::statusSave() void ThermalCalibrationHelper::statusSave()
{ {
setProcessPercentage(ProcessPercentageSaveSettings); setProgress(ProcessPercentageSaveSettings);
// prevent saving multiple times // prevent saving multiple times
if (!isBoardInitialSettingsSaved() && saveBoardInitialSettings()) { if (!isBoardInitialSettingsSaved() && saveBoardInitialSettings()) {
emit statusSaveCompleted(true); emit statusSaveCompleted(true);
@ -230,7 +230,7 @@ void ThermalCalibrationHelper::statusSave()
void ThermalCalibrationHelper::initAcquisition() void ThermalCalibrationHelper::initAcquisition()
{ {
setProcessPercentage(ProcessPercentageBaseAcquisition); setProgress(ProcessPercentageBaseAcquisition);
QMutexLocker lock(&sensorsUpdateLock); QMutexLocker lock(&sensorsUpdateLock);
m_targetduration = 0; m_targetduration = 0;
m_gradient = 0.0f; m_gradient = 0.0f;
@ -325,7 +325,7 @@ void ThermalCalibrationHelper::cleanup()
void ThermalCalibrationHelper::calculate() void ThermalCalibrationHelper::calculate()
{ {
setProcessPercentage(ProcessPercentageBaseCalculation); setProgress(ProcessPercentageBaseCalculation);
int count = m_baroSamples.count(); int count = m_baroSamples.count();
Eigen::VectorXf datax(count); Eigen::VectorXf datax(count);
Eigen::VectorXf datay(1); Eigen::VectorXf datay(1);
@ -341,7 +341,7 @@ void ThermalCalibrationHelper::calculate()
m_results.baroTempMin = datat.array().minCoeff(); m_results.baroTempMin = datat.array().minCoeff();
m_results.baroTempMax = datat.array().maxCoeff(); m_results.baroTempMax = datat.array().maxCoeff();
setProcessPercentage(processPercentage() + 2); setProgress(processPercentage() + 2);
count = m_gyroSamples.count(); count = m_gyroSamples.count();
datax.resize(count); datax.resize(count);
datay.resize(count); datay.resize(count);
@ -360,7 +360,7 @@ void ThermalCalibrationHelper::calculate()
m_results.accelGyroTempMax = datat.array().maxCoeff(); m_results.accelGyroTempMax = datat.array().maxCoeff();
// TODO: sanity checks needs to be enforced before accel calibration can be enabled and usable. // TODO: sanity checks needs to be enforced before accel calibration can be enabled and usable.
/* /*
setProcessPercentage(processPercentage() + 2); setProgress(processPercentage() + 2);
count = m_accelSamples.count(); count = m_accelSamples.count();
datax.resize(count); datax.resize(count);
datay.resize(count); datay.resize(count);
@ -413,7 +413,7 @@ void ThermalCalibrationHelper::updateTemp(float temp)
// gradient is expressed in °C/min // gradient is expressed in °C/min
float gradient = 60.0 * (m_temperature - m_lastCheckpointTemp) / (float)secondsSinceLastCheck; float gradient = 60.0 * (m_temperature - m_lastCheckpointTemp) / (float)secondsSinceLastCheck;
m_gradient = gradient; m_gradient = gradient;
emit gradientChanged(gradient); emit temperatureGradientChanged(gradient);
qDebug() << "Temp Gradient " << gradient << " Elapsed" << elapsed; qDebug() << "Temp Gradient " << gradient << " Elapsed" << elapsed;
m_debugStream << "INFO::Trace Temp Gradient " << gradient << " Elapsed" << elapsed << endl; m_debugStream << "INFO::Trace Temp Gradient " << gradient << " Elapsed" << elapsed << endl;
@ -431,10 +431,9 @@ void ThermalCalibrationHelper::updateTemp(float temp)
} }
if (m_targetduration != 0) { if (m_targetduration != 0) {
int tmp = ((ProcessPercentageBaseCalculation - ProcessPercentageBaseAcquisition) int tmp = ((ProcessPercentageBaseCalculation - ProcessPercentageBaseAcquisition) * elapsed) / m_targetduration;
* elapsed) / m_targetduration;
tmp = tmp > ProcessPercentageBaseCalculation - 5 ? ProcessPercentageBaseCalculation - 5 : tmp; tmp = tmp > ProcessPercentageBaseCalculation - 5 ? ProcessPercentageBaseCalculation - 5 : tmp;
setProcessPercentage(tmp); setProgress(tmp);
} else if (m_gradient > .1 && m_initialGradient / 2.0f > m_gradient) { } else if (m_gradient > .1 && m_initialGradient / 2.0f > m_gradient) {
qDebug() << "M_gradient " << m_gradient << " Elapsed" << elapsed << " m_initialGradient" << m_initialGradient; qDebug() << "M_gradient " << m_gradient << " Elapsed" << elapsed << " m_initialGradient" << m_initialGradient;
// make a rough estimation of the time needed // make a rough estimation of the time needed

View File

@ -47,11 +47,13 @@
#include <magsensor.h> #include <magsensor.h>
#include "accelgyrosettings.h" #include "accelgyrosettings.h"
// Calibration data // Calibration data
#include <accelgyrosettings.h> #include <accelgyrosettings.h>
#include <revocalibration.h> #include <revocalibration.h>
#include <revosettings.h> #include <revosettings.h>
#include "../wizardmodel.h"
namespace OpenPilot { namespace OpenPilot {
typedef struct { typedef struct {
// this is not needed for revo, but should for CC/CC3D // this is not needed for revo, but should for CC/CC3D
@ -85,10 +87,13 @@ typedef struct {
float accelGyroTempMin; float accelGyroTempMin;
float accelGyroTempMax; float accelGyroTempMax;
} thermalCalibrationResults; } thermalCalibrationResults;
class ThermalCalibrationHelper : public QObject { class ThermalCalibrationHelper : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit ThermalCalibrationHelper(QObject *parent = 0); explicit ThermalCalibrationHelper(QObject *parent = 0);
float temperature() float temperature()
{ {
return m_temperature; return m_temperature;
@ -103,6 +108,7 @@ public:
{ {
return m_processPercentage; return m_processPercentage;
} }
void endAcquisition(); void endAcquisition();
bool calibrationSuccessful() bool calibrationSuccessful()
@ -112,12 +118,13 @@ public:
} }
signals: signals:
void instructionsAdded(QString text, WizardModel::MessageType type = WizardModel::Info);
void statusRestoreCompleted(bool succesful); void statusRestoreCompleted(bool succesful);
void statusSaveCompleted(bool succesful); void statusSaveCompleted(bool succesful);
void setupBoardCompleted(bool succesful); void setupBoardCompleted(bool succesful);
void temperatureChanged(float value); void temperatureChanged(float value);
void gradientChanged(float value); void temperatureGradientChanged(float value);
void processPercentageChanged(int percentage); void progressChanged(int value);
void collectionCompleted(); void collectionCompleted();
void calculationCompleted(); void calculationCompleted();
void abort(); void abort();
@ -152,14 +159,19 @@ public slots:
void calculate(); void calculate();
void collectSample(UAVObject *sample); void collectSample(UAVObject *sample);
void setProcessPercentage(int value) void setProgress(int value)
{ {
if (m_processPercentage != value) { if (m_processPercentage != value) {
m_processPercentage = value; m_processPercentage = value;
emit processPercentageChanged(value); emit progressChanged(value);
} }
} }
void addInstructions(QString text, WizardModel::MessageType type = WizardModel::Info)
{
emit instructionsAdded(text, type);
}
void cleanup(); void cleanup();
private: private:

View File

@ -33,7 +33,6 @@
#include "compensationcalculationtransition.h" #include "compensationcalculationtransition.h"
namespace OpenPilot { namespace OpenPilot {
ThermalCalibrationModel::ThermalCalibrationModel(QObject *parent) : ThermalCalibrationModel::ThermalCalibrationModel(QObject *parent) :
WizardModel(parent), WizardModel(parent),
m_startEnabled(false), m_startEnabled(false),
@ -42,27 +41,29 @@ ThermalCalibrationModel::ThermalCalibrationModel(QObject *parent) :
m_initDone(false) m_initDone(false)
{ {
m_helper.reset(new ThermalCalibrationHelper()); m_helper.reset(new ThermalCalibrationHelper());
m_readyState = new WizardState("", this),
m_workingState = new WizardState(NULL, this);
m_saveSettingState = new WizardState(tr("Saving initial settings"), m_workingState); m_readyState = new WizardState("Ready", this),
m_workingState = new WizardState("Working", this);
m_saveSettingState = new WizardState("Storing Settings", m_workingState);
m_workingState->setInitialState(m_saveSettingState); m_workingState->setInitialState(m_saveSettingState);
m_setupState = new WizardState(tr("Setup board for calibration"), m_workingState); m_setupState = new WizardState("SetupBoard", m_workingState);
m_acquisitionState = new WizardState(tr("*** Please Wait *** Samples acquisition, this can take several minutes"), m_workingState); m_acquisitionState = new WizardState("Acquiring", m_workingState);
m_restoreState = new WizardState(tr("Restore board settings"), m_workingState); m_restoreState = new WizardState("Restoring Settings", m_workingState);
m_calculateState = new WizardState(tr("Calculate calibration data"), m_workingState); m_calculateState = new WizardState("Calculating", m_workingState);
m_abortState = new WizardState(tr("Canceled"), this); m_abortState = new WizardState("Canceled", this);
m_completedState = new WizardState("Completed", this);
// note: step name for this state is changed by CompensationCalculationTransition based on result
m_completedState = new WizardState(NULL, this);
setTransitions(); setTransitions();
connect(m_helper.data(), SIGNAL(gradientChanged(float)), this, SLOT(setTemperatureGradient(float)));
connect(m_helper.data(), SIGNAL(temperatureChanged(float)), this, SLOT(setTemperature(float))); connect(m_helper.data(), SIGNAL(temperatureChanged(float)), this, SLOT(setTemperature(float)));
connect(m_helper.data(), SIGNAL(processPercentageChanged(int)), this, SLOT(setProgress(int))); connect(m_helper.data(), SIGNAL(temperatureGradientChanged(float)), this, SLOT(setTemperatureGradient(float)));
connect(m_helper.data(), SIGNAL(progressChanged(int)), this, SLOT(setProgress(int)));
connect(m_helper.data(), SIGNAL(instructionsAdded(QString, WizardModel::MessageType)), this, SLOT(addInstructions(QString, WizardModel::MessageType)));
connect(m_readyState, SIGNAL(entered()), this, SLOT(wizardReady())); connect(m_readyState, SIGNAL(entered()), this, SLOT(wizardReady()));
connect(m_readyState, SIGNAL(exited()), this, SLOT(wizardStarted())); connect(m_readyState, SIGNAL(exited()), this, SLOT(wizardStarted()));
connect(m_completedState, SIGNAL(entered()), this, SLOT(wizardReady())); connect(m_completedState, SIGNAL(entered()), this, SLOT(wizardReady()));
@ -117,5 +118,4 @@ void ThermalCalibrationModel::setTransitions()
m_workingState->addTransition(this, SIGNAL(abort()), m_abortState); m_workingState->addTransition(this, SIGNAL(abort()), m_abortState);
// Ready // Ready
} }
} }

View File

@ -30,25 +30,21 @@
#define THERMALCALIBRATIONMODEL_H #define THERMALCALIBRATIONMODEL_H
#include "thermalcalibrationhelper.h" #include "thermalcalibrationhelper.h"
#include "../wizardstate.h"
#include "../wizardmodel.h"
#include <QObject> #include <QObject>
#include <QState> #include <QState>
#include <QStateMachine> #include <QStateMachine>
#include "../wizardstate.h"
#include "../wizardmodel.h"
namespace OpenPilot { namespace OpenPilot {
class ThermalCalibrationModel : public WizardModel { class ThermalCalibrationModel : public WizardModel {
Q_PROPERTY(bool startEnable READ startEnabled NOTIFY startEnabledChanged) Q_OBJECT Q_PROPERTY(bool startEnable READ startEnabled NOTIFY startEnabledChanged)
Q_PROPERTY(bool endEnable READ endEnabled NOTIFY endEnabledChanged) Q_PROPERTY(bool endEnable READ endEnabled NOTIFY endEnabledChanged)
Q_PROPERTY(bool cancelEnable READ cancelEnabled NOTIFY cancelEnabledChanged) Q_PROPERTY(bool cancelEnable READ cancelEnabled NOTIFY cancelEnabledChanged)
Q_PROPERTY(float temperature READ temperature NOTIFY temperatureChanged) Q_PROPERTY(float temperature READ temperature NOTIFY temperatureChanged)
Q_PROPERTY(float temperatureGradient READ temperatureGradient NOTIFY temperatureGradientChanged) Q_PROPERTY(float temperatureGradient READ temperatureGradient NOTIFY temperatureGradientChanged)
Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged) Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged)
Q_OBJECT
public: public:
explicit ThermalCalibrationModel(QObject *parent = 0); explicit ThermalCalibrationModel(QObject *parent = 0);
@ -92,7 +88,6 @@ public:
} }
} }
public slots: public slots:
int progress() int progress()
{ {
@ -125,13 +120,10 @@ public slots:
} }
} }
void setProgress(int status) void setProgress(int progress)
{ {
m_progress = status; m_progress = progress;
emit progressChanged(status); emit progressChanged(progress);
if (this->currentState()) {
setInstructions(this->currentState()->stepName());
}
} }
private: private:
@ -164,7 +156,7 @@ private:
WizardState *m_finalizeState; WizardState *m_finalizeState;
// revert board settings if something goes wrong // revert board settings if something goes wrong
WizardState *m_abortState; WizardState *m_abortState;
// just the same as readystate, but it is reached after havign completed the calibration // just the same as ready state, but it is reached after having completed the calibration
WizardState *m_completedState; WizardState *m_completedState;
void setTransitions(); void setTransitions();
@ -191,7 +183,6 @@ signals:
{ {
// HACKS // HACKS
// clear instructions // clear instructions
setInstructions(QString());
emit temperatureGradientChanged(0); emit temperatureGradientChanged(0);
// END OF HACKS // END OF HACKS
emit next(); emit next();
@ -213,10 +204,10 @@ signals:
} }
void wizardStarted() void wizardStarted()
{ {
started();
setStartEnabled(false); setStartEnabled(false);
setEndEnabled(true); setEndEnabled(true);
setCancelEnabled(true); setCancelEnabled(true);
started();
} }
}; };
} }

View File

@ -28,17 +28,19 @@
#ifndef WIZARDMODEL_H #ifndef WIZARDMODEL_H
#define WIZARDMODEL_H #define WIZARDMODEL_H
#include <QStateMachine>
#include <QQmlListProperty>
#include "wizardstate.h" #include "wizardstate.h"
#include <accelsensor.h> #include <accelsensor.h>
#include <QStateMachine>
#include <QQmlListProperty>
class WizardModel : public QStateMachine { class WizardModel : public QStateMachine {
Q_OBJECT Q_PROPERTY(QQmlListProperty<QObject> steps READ steps CONSTANT) Q_OBJECT Q_PROPERTY(QQmlListProperty<QObject> steps READ steps CONSTANT)
// Q_PROPERTY(QString instructions READ instructions NOTIFY instructionsChanged) // Q_PROPERTY(QString instructions READ instructions NOTIFY instructionsChanged)
Q_PROPERTY(WizardState * currentState READ currentState NOTIFY currentStateChanged) Q_PROPERTY(WizardState * currentState READ currentState NOTIFY currentStateChanged)
public: public:
enum MessageType { Info, Notice, Warning, Error }; enum MessageType { Info, Prompt, Warn, Success, Failure };
explicit WizardModel(QObject *parent = 0); explicit WizardModel(QObject *parent = 0);
@ -52,12 +54,14 @@ public:
return m_instructions; return m_instructions;
} }
void setInstructions(QString text, MessageType type = WizardModel::Info) WizardState *currentState();
public slots:
void addInstructions(QString text, WizardModel::MessageType type = WizardModel::Info)
{ {
m_instructions = text; m_instructions = text;
emit displayInstructions(text, type); emit instructionsAdded(text, type);
} }
WizardState *currentState();
protected: protected:
QList<QObject *> m_steps; QList<QObject *> m_steps;
@ -66,9 +70,8 @@ private:
QString m_instructions; QString m_instructions;
signals: signals:
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info); void instructionsAdded(QString text, WizardModel::MessageType type = WizardModel::Info);
void currentStateChanged(WizardState *status); void currentStateChanged(WizardState *status);
}; };
#endif // WIZARDMODEL_H #endif // WIZARDMODEL_H

View File

@ -27,6 +27,7 @@
*/ */
#include "wizardstate.h" #include "wizardstate.h"
#include "QDebug" #include "QDebug"
WizardState::WizardState(QString name, QState *parent) : WizardState::WizardState(QString name, QState *parent) :
QState(parent) QState(parent)
{ {
@ -41,12 +42,6 @@ void WizardState::setCompletion(qint8 completion)
emit completionChanged(); emit completionChanged();
} }
void WizardState::setStepName(QString name)
{
m_stepName = name;
emit stepNameChanged();
}
void WizardState::onEntry(QEvent *event) void WizardState::onEntry(QEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);

View File

@ -34,9 +34,11 @@ class WizardState : public QState {
Q_OBJECT Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged) Q_OBJECT Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged)
Q_PROPERTY(bool isDone READ isDone NOTIFY isDoneChanged) Q_PROPERTY(bool isDone READ isDone NOTIFY isDoneChanged)
Q_PROPERTY(qint8 completion READ completion NOTIFY completionChanged) Q_PROPERTY(qint8 completion READ completion NOTIFY completionChanged)
Q_PROPERTY(QString stepName READ stepName WRITE setStepName NOTIFY stepNameChanged) Q_PROPERTY(QString stepName READ stepName)
public: public:
explicit WizardState(QString name, QState *parent = 0); explicit WizardState(QString name, QState *parent = 0);
bool isActive() bool isActive()
{ {
return m_active; return m_active;
@ -57,17 +59,18 @@ public:
return m_stepName; return m_stepName;
} }
void setStepName(QString name);
void setCompletion(qint8 completion); void setCompletion(qint8 completion);
virtual void onEntry(QEvent *event) Q_DECL_OVERRIDE; virtual void onEntry(QEvent *event) Q_DECL_OVERRIDE;
virtual void onExit(QEvent *event) Q_DECL_OVERRIDE; virtual void onExit(QEvent *event) Q_DECL_OVERRIDE;
signals: signals:
void isActiveChanged(); void isActiveChanged();
void isDoneChanged(); void isDoneChanged();
void stepNameChanged();
void completionChanged(); void completionChanged();
public slots: public slots:
void clean(); void clean();
private: private:
void setIsDone(bool done); void setIsDone(bool done);
bool m_done; bool m_done;

View File

@ -109,8 +109,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_thermalCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations())); connect(m_thermalCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations()));
connect(m_thermalCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations())); connect(m_thermalCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations()));
connect(m_thermalCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)), connect(m_thermalCalibrationModel, SIGNAL(instructionsAdded(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType))); this, SLOT(addInstructions(QString, WizardModel::MessageType)));
connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(float)), this, SLOT(displayTemperature(float))); connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(float)), this, SLOT(displayTemperature(float)));
connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(float)), this, SLOT(displayTemperatureGradient(float))); connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(float)), this, SLOT(displayTemperatureGradient(float)));
connect(m_thermalCalibrationModel, SIGNAL(progressChanged(int)), m_ui->thermalBiasProgress, SLOT(setValue(int))); connect(m_thermalCalibrationModel, SIGNAL(progressChanged(int)), m_ui->thermalBiasProgress, SLOT(setValue(int)));
@ -127,11 +127,11 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_sixPointCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation())); connect(m_sixPointCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation()));
connect(m_sixPointCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation())); connect(m_sixPointCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation()));
connect(m_sixPointCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)), connect(m_sixPointCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType))); this, SLOT(addInstructions(QString, WizardModel::MessageType)));
connect(m_sixPointCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_sixPointCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_sixPointCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->sixPointsSave, SLOT(setEnabled(bool))); connect(m_sixPointCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->sixPointsSave, SLOT(setEnabled(bool)));
// level calibration // board level calibration
m_levelCalibrationModel = new OpenPilot::LevelCalibrationModel(this); m_levelCalibrationModel = new OpenPilot::LevelCalibrationModel(this);
connect(m_ui->boardLevelStart, SIGNAL(clicked()), m_levelCalibrationModel, SLOT(start())); connect(m_ui->boardLevelStart, SIGNAL(clicked()), m_levelCalibrationModel, SLOT(start()));
connect(m_ui->boardLevelSavePos, SIGNAL(clicked()), m_levelCalibrationModel, SLOT(savePosition())); connect(m_ui->boardLevelSavePos, SIGNAL(clicked()), m_levelCalibrationModel, SLOT(savePosition()));
@ -139,7 +139,7 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_levelCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations())); connect(m_levelCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations()));
connect(m_levelCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations())); connect(m_levelCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations()));
connect(m_levelCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)), connect(m_levelCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType))); this, SLOT(addInstructions(QString, WizardModel::MessageType)));
connect(m_levelCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_levelCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_levelCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->boardLevelSavePos, SLOT(setEnabled(bool))); connect(m_levelCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->boardLevelSavePos, SLOT(setEnabled(bool)));
connect(m_levelCalibrationModel, SIGNAL(progressChanged(int)), this->m_ui->boardLevelProgress, SLOT(setValue(int))); connect(m_levelCalibrationModel, SIGNAL(progressChanged(int)), this->m_ui->boardLevelProgress, SLOT(setValue(int)));
@ -155,7 +155,7 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_gyroBiasCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation())); connect(m_gyroBiasCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation()));
connect(m_gyroBiasCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation())); connect(m_gyroBiasCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation()));
connect(m_gyroBiasCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)), connect(m_gyroBiasCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType))); this, SLOT(addInstructions(QString, WizardModel::MessageType)));
connect(m_gyroBiasCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_gyroBiasCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_ui->hlClearButton, SIGNAL(clicked()), this, SLOT(clearHomeLocation())); connect(m_ui->hlClearButton, SIGNAL(clicked()), this, SLOT(clearHomeLocation()));
@ -248,17 +248,16 @@ void ConfigRevoWidget::clearInstructions()
m_ui->calibrationInstructions->clear(); m_ui->calibrationInstructions->clear();
} }
void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageType type) void ConfigRevoWidget::addInstructions(QString text, WizardModel::MessageType type)
{ {
if (!text.isNull()) { if (!text.isNull()) {
switch (type) { switch (type) {
case WizardModel::Error: case WizardModel::Failure:
text = QString("<font color='red'>%1</font>").arg(text); text = QString("<font color='red'>%1</font>").arg(text);
break; break;
case WizardModel::Notice: case WizardModel::Prompt:
text = QString("<font color='blue'>%1</font>").arg(text); text = QString("<font color='blue'>%1</font>").arg(text);
break; break;
case WizardModel::Info:
default: default:
break; break;
} }
@ -266,7 +265,8 @@ void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageTyp
} }
} }
void ConfigRevoWidget::displayTemperature(float temp) { void ConfigRevoWidget::displayTemperature(float temp)
{
m_ui->temperatureLabel->setText(tr("Temperature %1 °C").arg(temp, 5, 'f', 2)); m_ui->temperatureLabel->setText(tr("Temperature %1 °C").arg(temp, 5, 'f', 2));
} }

View File

@ -69,7 +69,7 @@ private slots:
void recallBoardRotation(); void recallBoardRotation();
void displayVisualHelp(QString elementID); void displayVisualHelp(QString elementID);
void clearInstructions(); void clearInstructions();
void displayInstructions(QString instructions, WizardModel::MessageType type = WizardModel::Info); void addInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
void displayTemperature(float temp); void displayTemperature(float temp);
void displayTemperatureGradient(float tempGradient); void displayTemperatureGradient(float tempGradient);