SensorsComponentController.h 5.19 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    Q_PROPERTY(bool showGyroCalArea MEMBER _showGyroCalArea NOTIFY showGyroCalAreaChanged)
    Q_PROPERTY(bool showAccelCalArea MEMBER _showAccelCalArea NOTIFY showAccelCalAreaChanged)
    
    Q_PROPERTY(bool gyroCalInProgress MEMBER _gyroCalInProgress NOTIFY gyroCalInProgressChanged)
    
    Q_PROPERTY(bool accelCalDownSideDone MEMBER _accelCalDownSideDone NOTIFY accelCalSidesDoneChanged)
    Q_PROPERTY(bool accelCalUpsideDownSideDone MEMBER _accelCalUpsideDownSideDone NOTIFY accelCalSidesDoneChanged)
    Q_PROPERTY(bool accelCalLeftSideDone MEMBER _accelCalLeftSideDone NOTIFY accelCalSidesDoneChanged)
    Q_PROPERTY(bool accelCalRightSideDone MEMBER _accelCalRightSideDone NOTIFY accelCalSidesDoneChanged)
    Q_PROPERTY(bool accelCalNoseDownSideDone MEMBER _accelCalNoseDownSideDone NOTIFY accelCalSidesDoneChanged)
    Q_PROPERTY(bool accelCalTailDownSideDone MEMBER _accelCalTailDownSideDone NOTIFY accelCalSidesDoneChanged)
    
    Q_PROPERTY(bool accelCalDownSideInProgress MEMBER _accelCalDownSideInProgress NOTIFY accelCalSidesInProgressChanged)
    Q_PROPERTY(bool accelCalUpsideDownSideInProgress MEMBER _accelCalUpsideDownSideInProgress NOTIFY accelCalSidesInProgressChanged)
    Q_PROPERTY(bool accelCalLeftSideInProgress MEMBER _accelCalLeftSideInProgress NOTIFY accelCalSidesInProgressChanged)
    Q_PROPERTY(bool accelCalRightSideInProgress MEMBER _accelCalRightSideInProgress NOTIFY accelCalSidesInProgressChanged)
    Q_PROPERTY(bool accelCalNoseDownSideInProgress MEMBER _accelCalNoseDownSideInProgress NOTIFY accelCalSidesInProgressChanged)
    Q_PROPERTY(bool accelCalTailDownSideInProgress MEMBER _accelCalTailDownSideInProgress NOTIFY accelCalSidesInProgressChanged)
Don Gagne's avatar
Don Gagne committed
72 73 74 75 76 77 78 79 80
    
    Q_INVOKABLE void calibrateCompass(void);
    Q_INVOKABLE void calibrateGyro(void);
    Q_INVOKABLE void calibrateAccel(void);
    Q_INVOKABLE void calibrateAirspeed(void);
    
    bool fixedWing(void);
    
signals:
81 82 83 84 85
    void showGyroCalAreaChanged(void);
    void showAccelCalAreaChanged(void);
    void gyroCalInProgressChanged(void);
    void accelCalSidesDoneChanged(void);
    void accelCalSidesInProgressChanged(void);
Don Gagne's avatar
Don Gagne committed
86 87 88 89 90
    
private slots:
    void _handleUASTextMessage(int uasId, int compId, int severity, QString text);
    
private:
91 92
    void _startCalibration(void);
    void _stopCalibration(bool failed);
Don Gagne's avatar
Don Gagne committed
93 94 95
    void _beginTextLogging(void);
    void _appendStatusLog(const QString& text);
    void _refreshParams(void);
96 97 98 99 100 101
    void _hideAllCalAreas(void);
    
    void _updateAndEmitGyroCalInProgress(bool inProgress);
    
    void _updateAndEmitShowGyroCalArea(bool show);
    void _updateAndEmitShowAccelCalArea(bool show);
Don Gagne's avatar
Don Gagne committed
102

103 104 105 106 107 108
    QQuickItem* _statusLog;
    QQuickItem* _progressBar;
    QQuickItem* _compassButton;
    QQuickItem* _gyroButton;
    QQuickItem* _accelButton;
    QQuickItem* _airspeedButton;
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    
    bool _showGyroCalArea;
    bool _showAccelCalArea;
    
    bool _gyroCalInProgress;
    
    bool _accelCalDownSideDone;
    bool _accelCalUpsideDownSideDone;
    bool _accelCalLeftSideDone;
    bool _accelCalRightSideDone;
    bool _accelCalNoseDownSideDone;
    bool _accelCalTailDownSideDone;
    
    bool _accelCalDownSideInProgress;
    bool _accelCalUpsideDownSideInProgress;
    bool _accelCalLeftSideInProgress;
    bool _accelCalRightSideInProgress;
    bool _accelCalNoseDownSideInProgress;
    bool _accelCalTailDownSideInProgress;
    
129 130
    bool _textLoggingStarted;
    
Don Gagne's avatar
Don Gagne committed
131 132 133 134
    AutoPilotPlugin*    _autopilot;
};

#endif