SensorsComponentController.h 6.11 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 34 35 36 37 38 39 40 41 42 43 44 45 46
/*=====================================================================
 
 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"
#include "AutoPilotPlugin.h"

/// Sensors Component MVC Controller for SensorsComponent.qml.
class SensorsComponentController : public QObject
{
    Q_OBJECT
    
public:
    SensorsComponentController(AutoPilotPlugin* autopilot, QObject* parent = NULL);
    
    Q_PROPERTY(bool fixedWing READ fixedWing CONSTANT)
    
    Q_PROPERTY(QQuickItem* statusLog MEMBER _statusLog)
47 48
    Q_PROPERTY(QQuickItem* progressBar MEMBER _progressBar)
    
49 50 51 52 53
    Q_PROPERTY(QQuickItem* compassButton MEMBER _compassButton)
    Q_PROPERTY(QQuickItem* gyroButton MEMBER _gyroButton)
    Q_PROPERTY(QQuickItem* accelButton MEMBER _accelButton)
    Q_PROPERTY(QQuickItem* airspeedButton MEMBER _airspeedButton)
    
54 55 56 57
    Q_PROPERTY(bool showCompass0 MEMBER _showCompass0 CONSTANT)
    Q_PROPERTY(bool showCompass1 MEMBER _showCompass1 CONSTANT)
    Q_PROPERTY(bool showCompass2 MEMBER _showCompass2 CONSTANT)
    
58
    Q_PROPERTY(bool showGyroCalArea MEMBER _showGyroCalArea NOTIFY showGyroCalAreaChanged)
Don Gagne's avatar
Don Gagne committed
59
    Q_PROPERTY(bool showOrientationCalArea MEMBER _showOrientationCalArea NOTIFY showOrientationCalAreaChanged)
60 61 62
    
    Q_PROPERTY(bool gyroCalInProgress MEMBER _gyroCalInProgress NOTIFY gyroCalInProgressChanged)
    
Don Gagne's avatar
Don Gagne committed
63
    Q_PROPERTY(QString calInProgressText MEMBER _calInProgressText NOTIFY calInProgressTextChanged)
64
    
Don Gagne's avatar
Don Gagne committed
65 66 67 68 69 70 71 72 73 74 75 76 77
    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)
    
    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
78 79 80 81 82 83 84 85 86
    
    Q_INVOKABLE void calibrateCompass(void);
    Q_INVOKABLE void calibrateGyro(void);
    Q_INVOKABLE void calibrateAccel(void);
    Q_INVOKABLE void calibrateAirspeed(void);
    
    bool fixedWing(void);
    
signals:
87
    void showGyroCalAreaChanged(void);
Don Gagne's avatar
Don Gagne committed
88
    void showOrientationCalAreaChanged(void);
89
    void gyroCalInProgressChanged(void);
Don Gagne's avatar
Don Gagne committed
90 91 92
    void orientationCalSidesDoneChanged(void);
    void orientationCalSidesInProgressChanged(void);
    void calInProgressTextChanged(const QString& newText);
Don Gagne's avatar
Don Gagne committed
93 94 95 96 97
    
private slots:
    void _handleUASTextMessage(int uasId, int compId, int severity, QString text);
    
private:
98 99
    void _startCalibration(void);
    void _stopCalibration(bool failed);
Don Gagne's avatar
Don Gagne committed
100 101 102
    void _beginTextLogging(void);
    void _appendStatusLog(const QString& text);
    void _refreshParams(void);
103 104 105 106
    void _hideAllCalAreas(void);
    
    void _updateAndEmitGyroCalInProgress(bool inProgress);
    
Don Gagne's avatar
Don Gagne committed
107 108
    void _updateAndEmitCalInProgressText(const QString& text);
    
109
    void _updateAndEmitShowGyroCalArea(bool show);
Don Gagne's avatar
Don Gagne committed
110
    void _updateAndEmitShowOrientationCalArea(bool show);
Don Gagne's avatar
Don Gagne committed
111

112 113 114 115 116 117
    QQuickItem* _statusLog;
    QQuickItem* _progressBar;
    QQuickItem* _compassButton;
    QQuickItem* _gyroButton;
    QQuickItem* _accelButton;
    QQuickItem* _airspeedButton;
118 119
    
    bool _showGyroCalArea;
Don Gagne's avatar
Don Gagne committed
120
    bool _showOrientationCalArea;
121
    
122 123 124 125
    bool _showCompass0;
    bool _showCompass1;
    bool _showCompass2;
    
126
    bool _gyroCalInProgress;
Don Gagne's avatar
Don Gagne committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    bool _magCalInProgress;
    bool _accelCalInProgress;
    
    QString _calInProgressText;
    
    bool _orientationCalDownSideDone;
    bool _orientationCalUpsideDownSideDone;
    bool _orientationCalLeftSideDone;
    bool _orientationCalRightSideDone;
    bool _orientationCalNoseDownSideDone;
    bool _orientationCalTailDownSideDone;
    
    bool _orientationCalDownSideInProgress;
    bool _orientationCalUpsideDownSideInProgress;
    bool _orientationCalLeftSideInProgress;
    bool _orientationCalRightSideInProgress;
    bool _orientationCalNoseDownSideInProgress;
    bool _orientationCalTailDownSideInProgress;
145
    
146 147
    bool _textLoggingStarted;
    
Don Gagne's avatar
Don Gagne committed
148 149 150 151
    AutoPilotPlugin*    _autopilot;
};

#endif