SensorsComponentController.cc 17.3 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

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

#include "SensorsComponentController.h"
#include "QGCMAVLink.h"
16
#include "UAS.h"
17
#include "QGCApplication.h"
18
#include "ParameterManager.h"
Don Gagne's avatar
Don Gagne committed
19 20 21 22

#include <QVariant>
#include <QQmlProperty>

23 24
QGC_LOGGING_CATEGORY(SensorsComponentControllerLog, "SensorsComponentControllerLog")

Don Gagne's avatar
Don Gagne committed
25
SensorsComponentController::SensorsComponentController(void) :
26 27
    _statusLog(NULL),
    _progressBar(NULL),
Don Gagne's avatar
Don Gagne committed
28 29 30 31
    _compassButton(NULL),
    _gyroButton(NULL),
    _accelButton(NULL),
    _airspeedButton(NULL),
32
    _levelButton(NULL),
Don Gagne's avatar
Don Gagne committed
33
    _cancelButton(NULL),
Don Gagne's avatar
Don Gagne committed
34
    _setOrientationsButton(NULL),
Don Gagne's avatar
Don Gagne committed
35
    _showOrientationCalArea(false),
36
    _gyroCalInProgress(false),
Don Gagne's avatar
Don Gagne committed
37 38 39 40 41 42 43 44
    _magCalInProgress(false),
    _accelCalInProgress(false),
    _orientationCalDownSideDone(false),
    _orientationCalUpsideDownSideDone(false),
    _orientationCalLeftSideDone(false),
    _orientationCalRightSideDone(false),
    _orientationCalNoseDownSideDone(false),
    _orientationCalTailDownSideDone(false),
Don Gagne's avatar
Don Gagne committed
45 46 47 48 49 50
    _orientationCalDownSideVisible(false),
    _orientationCalUpsideDownSideVisible(false),
    _orientationCalLeftSideVisible(false),
    _orientationCalRightSideVisible(false),
    _orientationCalNoseDownSideVisible(false),
    _orientationCalTailDownSideVisible(false),
Don Gagne's avatar
Don Gagne committed
51 52 53 54 55 56
    _orientationCalDownSideInProgress(false),
    _orientationCalUpsideDownSideInProgress(false),
    _orientationCalLeftSideInProgress(false),
    _orientationCalRightSideInProgress(false),
    _orientationCalNoseDownSideInProgress(false),
    _orientationCalTailDownSideInProgress(false),
Don Gagne's avatar
Don Gagne committed
57
    _orientationCalDownSideRotate(false),
58
    _orientationCalUpsideDownSideRotate(false),
Don Gagne's avatar
Don Gagne committed
59
    _orientationCalLeftSideRotate(false),
60
    _orientationCalRightSideRotate(false),
Don Gagne's avatar
Don Gagne committed
61
    _orientationCalNoseDownSideRotate(false),
62
    _orientationCalTailDownSideRotate(false),
Don Gagne's avatar
Don Gagne committed
63
    _unknownFirmwareVersion(false),
Don Gagne's avatar
Don Gagne committed
64
    _waitingForCancel(false)
Don Gagne's avatar
Don Gagne committed
65
{
66
}
Don Gagne's avatar
Don Gagne committed
67

68 69 70
bool SensorsComponentController::usingUDPLink(void)
{
    return _vehicle->priorityLink()->getLinkConfiguration()->type() == LinkConfiguration::TypeUdp;
Don Gagne's avatar
Don Gagne committed
71 72 73 74 75
}

/// Appends the specified text to the status log area in the ui
void SensorsComponentController::_appendStatusLog(const QString& text)
{
DonLakeFlyer's avatar
DonLakeFlyer committed
76 77 78 79
    if (!_statusLog) {
        qWarning() << "Internal error";
        return;
    }
Don Gagne's avatar
Don Gagne committed
80 81 82 83 84 85 86 87 88
    
    QVariant returnedValue;
    QVariant varText = text;
    QMetaObject::invokeMethod(_statusLog,
                              "append",
                              Q_RETURN_ARG(QVariant, returnedValue),
                              Q_ARG(QVariant, varText));
}

Don Gagne's avatar
Don Gagne committed
89
void SensorsComponentController::_startLogCalibration(void)
Don Gagne's avatar
Don Gagne committed
90
{
Don Gagne's avatar
Don Gagne committed
91
    _unknownFirmwareVersion = false;
92 93
    _hideAllCalAreas();
    
Don Gagne's avatar
Don Gagne committed
94 95 96 97 98 99 100
    connect(_uas, &UASInterface::textMessageReceived, this, &SensorsComponentController::_handleUASTextMessage);
    
    _cancelButton->setEnabled(false);
}

void SensorsComponentController::_startVisualCalibration(void)
{
101 102 103 104
    _compassButton->setEnabled(false);
    _gyroButton->setEnabled(false);
    _accelButton->setEnabled(false);
    _airspeedButton->setEnabled(false);