SensorsComponentController.h 8.33 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*=====================================================================
 
 QGroundControl Open Source Ground Control Station
 
 (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 
 This file is part of the QGROUNDCONTROL project
 
 QGROUNDCONTROL 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.
 
 QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
 
 ======================================================================*/

/// @file
///     @author Don Gagne <don@thegagnes.com>

#ifndef SENSORSCOMPONENTCONTROLLER_H
#define SENSORSCOMPONENTCONTROLLER_H

#include <QObject>
#include <QQuickItem>

#include "UASInterface.h"
Don Gagne's avatar
Don Gagne committed
34
#include "FactPanelController.h"
35 36 37
#include "QGCLoggingCategory.h"

Q_DECLARE_LOGGING_CATEGORY(SensorsComponentControllerLog)
Don Gagne's avatar
Don Gagne committed
38 39

/// Sensors Component MVC Controller for SensorsComponent.qml.
Don Gagne's avatar
Don Gagne committed
40
class SensorsComponentController : public FactPanelController
Don Gagne's avatar
Don Gagne committed
41 42 43 44
{
    Q_OBJECT
    
public:
Don Gagne's avatar
Don Gagne committed
45
    SensorsComponentController(void);
Don Gagne's avatar
Don Gagne committed
46 47 48 49
    
    Q_PROPERTY(bool fixedWing READ fixedWing CONSTANT)
    
    Q_PROPERTY(QQuickItem* statusLog MEMBER _statusLog)
50 51
    Q_PROPERTY(QQuickItem* progressBar MEMBER _progressBar)
    
52 53 54 55
    Q_PROPERTY(QQuickItem* compassButton MEMBER _compassButton)
    Q_PROPERTY(QQuickItem* gyroButton MEMBER _gyroButton)
    Q_PROPERTY(QQuickItem* accelButton MEMBER _accelButton)
    Q_PROPERTY(QQuickItem* airspeedButton MEMBER _airspeedButton)
56
    Q_PROPERTY(QQuickItem* levelButton MEMBER _levelButton)
Don Gagne's avatar
Don Gagne committed
57 58
    Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton)
    Q_PROPERTY(QQuickItem* orientationCalAreaHelpText MEMBER _orientationCalAreaHelpText)
59
    
Don Gagne's avatar
Don Gagne committed
60
    Q_PROPERTY(bool showOrientationCalArea MEMBER _showOrientationCalArea NOTIFY showOrientationCalAreaChanged)
61
    
Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67 68
    Q_PROPERTY(bool orientationCalDownSideDone MEMBER _orientationCalDownSideDone NOTIFY orientationCalSidesDoneChanged)
    Q_PROPERTY(bool orientationCalUpsideDownSideDone MEMBER _orientationCalUpsideDownSideDone NOTIFY orientationCalSidesDoneChanged)
    Q_PROPERTY(bool orientationCalLeftSideDone MEMBER _orientationCalLeftSideDone NOTIFY orientationCalSidesDoneChanged)
    Q_PROPERTY(bool orientationCalRightSideDone MEMBER _orientationCalRightSideDone NOTIFY orientationCalSidesDoneChanged)
    Q_PROPERTY(bool orientationCalNoseDownSideDone MEMBER _orientationCalNoseDownSideDone NOTIFY orientationCalSidesDoneChanged)
    Q_PROPERTY(bool orientationCalTailDownSideDone MEMBER _orientationCalTailDownSideDone NOTIFY orientationCalSidesDoneChanged)
    
Don Gagne's avatar
Don Gagne committed
69 70 71 72 73 74 75
    Q_PROPERTY(bool orientationCalDownSideVisible MEMBER _orientationCalDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
    Q_PROPERTY(bool orientationCalUpsideDownSideVisible MEMBER _orientationCalUpsideDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
    Q_PROPERTY(bool orientationCalLeftSideVisible MEMBER _orientationCalLeftSideVisible NOTIFY orientationCalSidesVisibleChanged)
    Q_PROPERTY(bool orientationCalRightSideVisible MEMBER _orientationCalRightSideVisible NOTIFY orientationCalSidesVisibleChanged)
    Q_PROPERTY(bool orientationCalNoseDownSideVisible MEMBER _orientationCalNoseDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
    Q_PROPERTY(bool orientationCalTailDownSideVisible MEMBER _orientationCalTailDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
    
Don Gagne's avatar
Don Gagne committed
76 77 78 79 80 81
    Q_PROPERTY(bool orientationCalDownSideInProgress MEMBER _orientationCalDownSideInProgress NOTIFY orientationCalSidesInProgressChanged)
    Q_PROPERTY(bool orientationCalUpsideDownSideInProgress MEMBER _orientationCalUpsideDownSideInProgress NOTIFY orientationCalSidesInProgressChanged)
    Q_PROPERTY(bool orientationCalLeftSideInProgress MEMBER _orientationCalLeftSideInProgress NOTIFY orientationCalSidesInProgressChanged)
    Q_PROPERTY(bool orientationCalRightSideInProgress MEMBER _orientationCalRightSideInProgress NOTIFY orientationCalSidesInProgressChanged)
    Q_PROPERTY(bool orientationCalNoseDownSideInProgress MEMBER _orientationCalNoseDownSideInProgress NOTIFY orientationCalSidesInProgressChanged)
    Q_PROPERTY(bool orientationCalTailDownSideInProgress MEMBER _orientationCalTailDownSideInProgress NOTIFY orientationCalSidesInProgressChanged)
Don Gagne's avatar
Don Gagne committed
82
    
Don Gagne's avatar
Don Gagne committed
83
    Q_PROPERTY(bool orientationCalDownSideRotate MEMBER _orientationCalDownSideRotate NOTIFY orientationCalSidesRotateChanged)
84
    Q_PROPERTY(bool orientationCalUpsideDownSideRotate MEMBER _orientationCalUpsideDownSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
85
    Q_PROPERTY(bool orientationCalLeftSideRotate MEMBER _orientationCalLeftSideRotate NOTIFY orientationCalSidesRotateChanged)
86
    Q_PROPERTY(bool orientationCalRightSideRotate MEMBER _orientationCalRightSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
87
    Q_PROPERTY(bool orientationCalNoseDownSideRotate MEMBER _orientationCalNoseDownSideRotate NOTIFY orientationCalSidesRotateChanged)
88
    Q_PROPERTY(bool orientationCalTailDownSideRotate MEMBER _orientationCalTailDownSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
89 90 91
    
    Q_PROPERTY(bool waitingForCancel MEMBER _waitingForCancel NOTIFY waitingForCancelChanged)
    
Don Gagne's avatar
Don Gagne committed
92 93 94
    Q_INVOKABLE void calibrateCompass(void);
    Q_INVOKABLE void calibrateGyro(void);
    Q_INVOKABLE void calibrateAccel(void);
95
    Q_INVOKABLE void calibrateLevel(void);
Don Gagne's avatar
Don Gagne committed
96
    Q_INVOKABLE void calibrateAirspeed(void);
Don Gagne's avatar
Don Gagne committed
97
    Q_INVOKABLE void cancelCalibration(void);
Don Gagne's avatar
Don Gagne committed
98 99 100 101
    
    bool fixedWing(void);
    
signals:
102
    void showGyroCalAreaChanged(void);
Don Gagne's avatar
Don Gagne committed
103 104
    void showOrientationCalAreaChanged(void);
    void orientationCalSidesDoneChanged(void);
Don Gagne's avatar
Don Gagne committed
105
    void orientationCalSidesVisibleChanged(void);
Don Gagne's avatar
Don Gagne committed
106
    void orientationCalSidesInProgressChanged(void);
Don Gagne's avatar
Don Gagne committed
107 108 109 110
    void orientationCalSidesRotateChanged(void);
    void resetStatusTextArea(void);
    void waitingForCancelChanged(void);
    void setCompassRotations(void);
Don Gagne's avatar
Don Gagne committed
111 112 113 114 115
    
private slots:
    void _handleUASTextMessage(int uasId, int compId, int severity, QString text);
    
private:
Don Gagne's avatar
Don Gagne committed
116 117
    void _startLogCalibration(void);
    void _startVisualCalibration(void);
Don Gagne's avatar
Don Gagne committed
118 119
    void _appendStatusLog(const QString& text);
    void _refreshParams(void);
120
    void _hideAllCalAreas(void);
121
    void _resetInternalState(void);
122
    
Don Gagne's avatar
Don Gagne committed
123 124 125 126 127 128
    enum StopCalibrationCode {
        StopCalibrationSuccess,
        StopCalibrationFailed,
        StopCalibrationCancelled
    };
    void _stopCalibration(StopCalibrationCode code);
Don Gagne's avatar
Don Gagne committed
129 130
    
    void _updateAndEmitShowOrientationCalArea(bool show);
Don Gagne's avatar
Don Gagne committed
131

132 133 134 135 136 137
    QQuickItem* _statusLog;
    QQuickItem* _progressBar;
    QQuickItem* _compassButton;
    QQuickItem* _gyroButton;
    QQuickItem* _accelButton;
    QQuickItem* _airspeedButton;
138
    QQuickItem* _levelButton;
Don Gagne's avatar
Don Gagne committed
139 140
    QQuickItem* _cancelButton;
    QQuickItem* _orientationCalAreaHelpText;
141 142
    
    bool _showGyroCalArea;
Don Gagne's avatar
Don Gagne committed
143
    bool _showOrientationCalArea;
144 145
    
    bool _gyroCalInProgress;
Don Gagne's avatar
Don Gagne committed
146 147 148 149 150 151 152 153 154 155
    bool _magCalInProgress;
    bool _accelCalInProgress;
    
    bool _orientationCalDownSideDone;
    bool _orientationCalUpsideDownSideDone;
    bool _orientationCalLeftSideDone;
    bool _orientationCalRightSideDone;
    bool _orientationCalNoseDownSideDone;
    bool _orientationCalTailDownSideDone;
    
Don Gagne's avatar
Don Gagne committed
156 157 158 159 160 161 162
    bool _orientationCalDownSideVisible;
    bool _orientationCalUpsideDownSideVisible;
    bool _orientationCalLeftSideVisible;
    bool _orientationCalRightSideVisible;
    bool _orientationCalNoseDownSideVisible;
    bool _orientationCalTailDownSideVisible;
    
Don Gagne's avatar
Don Gagne committed
163 164 165 166 167 168
    bool _orientationCalDownSideInProgress;
    bool _orientationCalUpsideDownSideInProgress;
    bool _orientationCalLeftSideInProgress;
    bool _orientationCalRightSideInProgress;
    bool _orientationCalNoseDownSideInProgress;
    bool _orientationCalTailDownSideInProgress;
169
    
Don Gagne's avatar
Don Gagne committed
170
    bool _orientationCalDownSideRotate;
171
    bool _orientationCalUpsideDownSideRotate;
Don Gagne's avatar
Don Gagne committed
172
    bool _orientationCalLeftSideRotate;
173
    bool _orientationCalRightSideRotate;
Don Gagne's avatar
Don Gagne committed
174
    bool _orientationCalNoseDownSideRotate;
175
    bool _orientationCalTailDownSideRotate;
Don Gagne's avatar
Don Gagne committed
176 177 178
    
    bool _unknownFirmwareVersion;
    bool _waitingForCancel;
179 180
    
    static const int _supportedFirmwareCalVersion = 2;
Don Gagne's avatar
Don Gagne committed
181 182 183
};

#endif