SensorsComponentController.h 7.82 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

Don Gagne's avatar
Don Gagne committed
10 11 12 13 14 15 16 17 18 19 20

/// @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
21
#include "FactPanelController.h"
22 23 24
#include "QGCLoggingCategory.h"

Q_DECLARE_LOGGING_CATEGORY(SensorsComponentControllerLog)
Don Gagne's avatar
Don Gagne committed
25 26

/// Sensors Component MVC Controller for SensorsComponent.qml.
Don Gagne's avatar
Don Gagne committed
27
class SensorsComponentController : public FactPanelController
Don Gagne's avatar
Don Gagne committed
28 29 30 31
{
    Q_OBJECT
    
public:
Don Gagne's avatar
Don Gagne committed
32
    SensorsComponentController(void);
Don Gagne's avatar
Don Gagne committed
33 34
    
    Q_PROPERTY(QQuickItem* statusLog MEMBER _statusLog)
35 36
    Q_PROPERTY(QQuickItem* progressBar MEMBER _progressBar)
    
37 38 39 40
    Q_PROPERTY(QQuickItem* compassButton MEMBER _compassButton)
    Q_PROPERTY(QQuickItem* gyroButton MEMBER _gyroButton)
    Q_PROPERTY(QQuickItem* accelButton MEMBER _accelButton)
    Q_PROPERTY(QQuickItem* airspeedButton MEMBER _airspeedButton)
41
    Q_PROPERTY(QQuickItem* levelButton MEMBER _levelButton)
Don Gagne's avatar
Don Gagne committed
42
    Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton)
Don Gagne's avatar
Don Gagne committed
43
    Q_PROPERTY(QQuickItem* setOrientationsButton MEMBER _setOrientationsButton)
Don Gagne's avatar
Don Gagne committed
44
    Q_PROPERTY(QQuickItem* orientationCalAreaHelpText MEMBER _orientationCalAreaHelpText)
45
    
Don Gagne's avatar
Don Gagne committed
46
    Q_PROPERTY(bool showOrientationCalArea MEMBER _showOrientationCalArea NOTIFY showOrientationCalAreaChanged)
47
    
Don Gagne's avatar
Don Gagne committed
48 49 50 51 52 53 54
    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
55 56 57 58 59 60 61
    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
62 63 64 65 66 67
    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
68
    
Don Gagne's avatar
Don Gagne committed
69
    Q_PROPERTY(bool orientationCalDownSideRotate MEMBER _orientationCalDownSideRotate NOTIFY orientationCalSidesRotateChanged)
70
    Q_PROPERTY(bool orientationCalUpsideDownSideRotate MEMBER _orientationCalUpsideDownSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
71
    Q_PROPERTY(bool orientationCalLeftSideRotate MEMBER _orientationCalLeftSideRotate NOTIFY orientationCalSidesRotateChanged)
72
    Q_PROPERTY(bool orientationCalRightSideRotate MEMBER _orientationCalRightSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
73
    Q_PROPERTY(bool orientationCalNoseDownSideRotate MEMBER _orientationCalNoseDownSideRotate NOTIFY orientationCalSidesRotateChanged)
74
    Q_PROPERTY(bool orientationCalTailDownSideRotate MEMBER _orientationCalTailDownSideRotate NOTIFY orientationCalSidesRotateChanged)
Don Gagne's avatar
Don Gagne committed
75 76 77
    
    Q_PROPERTY(bool waitingForCancel MEMBER _waitingForCancel NOTIFY waitingForCancelChanged)
    
Don Gagne's avatar
Don Gagne committed
78 79 80
    Q_INVOKABLE void calibrateCompass(void);
    Q_INVOKABLE void calibrateGyro(void);
    Q_INVOKABLE void calibrateAccel(void);
81
    Q_INVOKABLE void calibrateLevel(void);
Don Gagne's avatar
Don Gagne committed
82
    Q_INVOKABLE void calibrateAirspeed(void);
Don Gagne's avatar
Don Gagne committed
83
    Q_INVOKABLE void cancelCalibration(void);
84
    Q_INVOKABLE bool usingUDPLink(void);
Don Gagne's avatar
Don Gagne committed
85 86
    
signals:
87
    void showGyroCalAreaChanged(void);
Don Gagne's avatar
Don Gagne committed
88 89
    void showOrientationCalAreaChanged(void);
    void orientationCalSidesDoneChanged(void);
Don Gagne's avatar
Don Gagne committed
90
    void orientationCalSidesVisibleChanged(void);
Don Gagne's avatar
Don Gagne committed
91
    void orientationCalSidesInProgressChanged(void);
Don Gagne's avatar
Don Gagne committed
92 93 94 95
    void orientationCalSidesRotateChanged(void);
    void resetStatusTextArea(void);
    void waitingForCancelChanged(void);
    void setCompassRotations(void);
Don Gagne's avatar
Don Gagne committed
96 97 98 99 100
    
private slots:
    void _handleUASTextMessage(int uasId, int compId, int severity, QString text);
    
private:
Don Gagne's avatar
Don Gagne committed
101 102
    void _startLogCalibration(void);
    void _startVisualCalibration(void);
Don Gagne's avatar
Don Gagne committed
103 104
    void _appendStatusLog(const QString& text);
    void _refreshParams(void);
105
    void _hideAllCalAreas(void);
106
    void _resetInternalState(void);
107
    
Don Gagne's avatar
Don Gagne committed
108 109 110 111 112 113
    enum StopCalibrationCode {
        StopCalibrationSuccess,
        StopCalibrationFailed,
        StopCalibrationCancelled
    };
    void _stopCalibration(StopCalibrationCode code);
Don Gagne's avatar
Don Gagne committed
114 115
    
    void _updateAndEmitShowOrientationCalArea(bool show);
Don Gagne's avatar
Don Gagne committed
116

117 118 119 120 121 122
    QQuickItem* _statusLog;
    QQuickItem* _progressBar;
    QQuickItem* _compassButton;
    QQuickItem* _gyroButton;
    QQuickItem* _accelButton;
    QQuickItem* _airspeedButton;
123
    QQuickItem* _levelButton;
Don Gagne's avatar
Don Gagne committed
124
    QQuickItem* _cancelButton;
Don Gagne's avatar
Don Gagne committed
125
    QQuickItem* _setOrientationsButton;
Don Gagne's avatar
Don Gagne committed
126
    QQuickItem* _orientationCalAreaHelpText;
127 128
    
    bool _showGyroCalArea;
Don Gagne's avatar
Don Gagne committed
129
    bool _showOrientationCalArea;
130 131
    
    bool _gyroCalInProgress;
Don Gagne's avatar
Don Gagne committed
132 133 134 135 136 137 138 139 140 141
    bool _magCalInProgress;
    bool _accelCalInProgress;
    
    bool _orientationCalDownSideDone;
    bool _orientationCalUpsideDownSideDone;
    bool _orientationCalLeftSideDone;
    bool _orientationCalRightSideDone;
    bool _orientationCalNoseDownSideDone;
    bool _orientationCalTailDownSideDone;
    
Don Gagne's avatar
Don Gagne committed
142 143 144 145 146 147 148
    bool _orientationCalDownSideVisible;
    bool _orientationCalUpsideDownSideVisible;
    bool _orientationCalLeftSideVisible;
    bool _orientationCalRightSideVisible;
    bool _orientationCalNoseDownSideVisible;
    bool _orientationCalTailDownSideVisible;
    
Don Gagne's avatar
Don Gagne committed
149 150 151 152 153 154
    bool _orientationCalDownSideInProgress;
    bool _orientationCalUpsideDownSideInProgress;
    bool _orientationCalLeftSideInProgress;
    bool _orientationCalRightSideInProgress;
    bool _orientationCalNoseDownSideInProgress;
    bool _orientationCalTailDownSideInProgress;
155
    
Don Gagne's avatar
Don Gagne committed
156
    bool _orientationCalDownSideRotate;
157
    bool _orientationCalUpsideDownSideRotate;
Don Gagne's avatar
Don Gagne committed
158
    bool _orientationCalLeftSideRotate;
159
    bool _orientationCalRightSideRotate;
Don Gagne's avatar
Don Gagne committed
160
    bool _orientationCalNoseDownSideRotate;
161
    bool _orientationCalTailDownSideRotate;
Don Gagne's avatar
Don Gagne committed
162 163 164
    
    bool _unknownFirmwareVersion;
    bool _waitingForCancel;
165 166
    
    static const int _supportedFirmwareCalVersion = 2;
Don Gagne's avatar
Don Gagne committed
167 168 169
};

#endif