mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-1150 UI for thermal calibration: Initial state machine implementation (Save setting and setup board working)
This commit is contained in:
parent
026247fd5c
commit
89dc9a03ec
@ -0,0 +1,96 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file thermalcalibrationmodel.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||
*
|
||||
* @brief ThermalCalibrationModel
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "thermalcalibrationmodel.h"
|
||||
#include "thermalcalibrationtransitions.h"
|
||||
#include "settinghandlingtransitions.h"
|
||||
#define NEXT_EVENT "next"
|
||||
#define PREVIOUS_EVENT "previous"
|
||||
#define ABORT_EVENT "abort"
|
||||
|
||||
ThermalCalibrationModel::ThermalCalibrationModel(QObject *parent) :
|
||||
WizardModel(parent)
|
||||
{
|
||||
m_helper = new ThermalCalibrationHelper();
|
||||
m_readyState = new WizardState(tr("Start"), this),
|
||||
m_workingState = new WizardState("workingState",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_calculateState = new WizardState(tr("Calculate calibration matrix"),m_workingState);
|
||||
m_finalizeState = new WizardState(tr("Completed"),m_workingState);
|
||||
|
||||
m_abortState = new WizardState("abort", this);
|
||||
|
||||
setTransitions();
|
||||
|
||||
this->setInitialState(m_readyState);
|
||||
m_steps << m_readyState
|
||||
<< m_setupState
|
||||
<< m_acquisitionState << m_calculateState << m_finalizeState;
|
||||
|
||||
}
|
||||
void ThermalCalibrationModel::init(){
|
||||
setStartEnabled(true);
|
||||
setEndEnabled(false);
|
||||
setCancelEnabled(false);
|
||||
start();
|
||||
setTemperature(QStringLiteral("0.01"));
|
||||
setTemperatureGradient(QStringLiteral("0.02"));
|
||||
emit instructionsChanged(instructions());
|
||||
}
|
||||
|
||||
void ThermalCalibrationModel::stepChanged(WizardState *state){
|
||||
|
||||
}
|
||||
|
||||
void ThermalCalibrationModel::setTransitions()
|
||||
{
|
||||
m_readyState->addTransition(this,SIGNAL(next()),m_workingState);
|
||||
// handles board status save
|
||||
// Ready->WorkingState->saveSettings->setup
|
||||
m_saveSettingState->addTransition(new BoardStatusSaveTransition(m_helper, m_saveSettingState, m_setupState));
|
||||
// board setup
|
||||
// setup
|
||||
m_setupState->addTransition(new BoardSetupTransition(m_helper, m_setupState, m_acquisitionState));
|
||||
|
||||
// acquisition -revertSettings-> calculation
|
||||
// m_acquisitionState->addTransition(this,SIGNAL(next()),m_calculateState);
|
||||
// revert settings after acquisition is completed
|
||||
//m_acquisitionState->addTransition(new BoardStatusRestoreTransition(m_helper, m_acquisitionState, m_calculateState));
|
||||
m_acquisitionState->addTransition(this,SIGNAL(next()), m_calculateState);
|
||||
|
||||
m_calculateState>addTransition(new BoardStatusRestoreTransition(m_helper,m_calculateState,m_finalizeState);
|
||||
|
||||
m_finalizeState->addTransition(this,SIGNAL(next()),m_readyState);
|
||||
// Ready
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file thermalcalibrationmodel.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||
*
|
||||
* @brief ThermalCalibrationModel
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef THERMALCALIBRATIONMODEL_H
|
||||
#define THERMALCALIBRATIONMODEL_H
|
||||
|
||||
#include "thermalcalibrationhelper.h"
|
||||
#include "thermalcalibrationtransitions.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QState>
|
||||
#include <QStateMachine>
|
||||
#include "../wizardstate.h"
|
||||
#include "../wizardmodel.h"
|
||||
|
||||
class ThermalCalibrationModel : public WizardModel
|
||||
{
|
||||
Q_PROPERTY(bool startEnable READ startEnabled NOTIFY startEnabledChanged)
|
||||
Q_PROPERTY(bool endEnable READ endEnabled NOTIFY endEnabledChanged)
|
||||
Q_PROPERTY(bool cancelEnable READ cancelEnabled NOTIFY cancelEnabledChanged)
|
||||
|
||||
Q_PROPERTY(QString temperature READ temperature NOTIFY temperatureChanged)
|
||||
Q_PROPERTY(QString temperatureGradient READ temperatureGradient NOTIFY temperatureGradientChanged)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThermalCalibrationModel(QObject *parent = 0);
|
||||
|
||||
bool startEnabled(){
|
||||
return m_startEnabled;
|
||||
}
|
||||
bool endEnabled(){
|
||||
return m_endEnabled;
|
||||
}
|
||||
bool cancelEnabled(){
|
||||
return m_cancelEnabled;
|
||||
}
|
||||
|
||||
void setStartEnabled(bool status){
|
||||
if(m_startEnabled != status){
|
||||
m_startEnabled = status;
|
||||
emit startEnabledChanged(status);
|
||||
}
|
||||
}
|
||||
|
||||
void setEndEnabled(bool status){
|
||||
if(m_endEnabled != status){
|
||||
m_endEnabled = status;
|
||||
emit endEnabledChanged(status);
|
||||
}
|
||||
}
|
||||
void setCancelEnabled(bool status) {
|
||||
if(m_cancelEnabled != status) {
|
||||
m_cancelEnabled = status;
|
||||
emit cancelEnabledChanged(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString temperature(){
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
QString temperatureGradient(){
|
||||
return m_temperatureGradient;
|
||||
}
|
||||
|
||||
void setTemperature(QString status) {
|
||||
if(m_temperature != status) {
|
||||
m_temperature = status;
|
||||
emit temperatureChanged(status);
|
||||
}
|
||||
}
|
||||
void setTemperatureGradient(QString status) {
|
||||
if(m_temperatureGradient != status) {
|
||||
m_temperatureGradient = status;
|
||||
emit temperatureGradientChanged(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool m_startEnabled;
|
||||
bool m_cancelEnabled;
|
||||
bool m_endEnabled;
|
||||
QString m_temperature;
|
||||
QString m_temperatureGradient;
|
||||
|
||||
ThermalCalibrationHelper *m_helper;
|
||||
|
||||
// Start from here
|
||||
WizardState *m_readyState;
|
||||
// this act as top level container for calibration state
|
||||
// to share common exit signals to abortState
|
||||
WizardState *m_workingState;
|
||||
//Save settings
|
||||
WizardState *m_saveSettingState;
|
||||
// Setup board for calibration
|
||||
WizardState *m_setupState;
|
||||
// Acquire samples
|
||||
WizardState *m_acquisitionState;
|
||||
// Calculate calibration parameters
|
||||
WizardState *m_calculateState;
|
||||
// Save calibration and restore board settings
|
||||
WizardState *m_finalizeState;
|
||||
// revert board settings if something goes wrong
|
||||
WizardState *m_abortState;
|
||||
|
||||
void setTransitions();
|
||||
|
||||
|
||||
signals:
|
||||
void startEnabledChanged(bool state);
|
||||
void endEnabledChanged(bool state);
|
||||
void cancelEnabledChanged(bool state);
|
||||
|
||||
void temperatureChanged(QString status);
|
||||
void temperatureGradientChanged(QString status);
|
||||
|
||||
void next();
|
||||
void previous();
|
||||
void abort();
|
||||
public slots:
|
||||
void stepChanged(WizardState *state);
|
||||
void init();
|
||||
void btnStart() {
|
||||
emit next();
|
||||
}
|
||||
|
||||
void btnEnd() {
|
||||
emit previous();
|
||||
}
|
||||
|
||||
void btnAbort(){
|
||||
emit abort();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // THERMALCALIBRATIONMODEL_H
|
@ -49,6 +49,7 @@ HEADERS += configplugin.h \
|
||||
calibration/thermal/thermalcalibrationtransitions.h \
|
||||
calibration/thermal/thermalcalibration.h \
|
||||
calibration/thermal/thermalcalibrationhelper.h \
|
||||
calibration/thermal/thermalcalibrationmodel.h \
|
||||
calibration/thermal/settinghandlingtransitions.h
|
||||
|
||||
SOURCES += configplugin.cpp \
|
||||
@ -84,6 +85,7 @@ SOURCES += configplugin.cpp \
|
||||
calibration/wizardmodel.cpp \
|
||||
calibration/thermal/thermalcalibration.cpp \
|
||||
calibration/thermal/thermalcalibrationhelper.cpp \
|
||||
calibration/thermal/thermalcalibrationmodel.cpp
|
||||
|
||||
FORMS += airframe.ui \
|
||||
airframe_ccpm.ui \
|
||||
|
Loading…
x
Reference in New Issue
Block a user