APMAirframeComponent.cc 3.08 KB
Newer Older
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
/*=====================================================================
 
 QGroundControl Open Source Ground Control Station
 
 (c) 2009 - 2014 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>

#include "APMAirframeComponent.h"
28
#include "ArduCopterFirmwarePlugin.h"
29

30 31
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
    : APMComponent(vehicle, autopilot, parent)
32
    , _requiresFrameSetup(false)
33
    , _name("Airframe")
34
{
35 36 37 38 39 40 41
    if (qobject_cast<ArduCopterFirmwarePlugin*>(_vehicle->firmwarePlugin()) != NULL) {
        _requiresFrameSetup = true;
        MAV_TYPE vehicleType = vehicle->vehicleType();
        if (vehicleType == MAV_TYPE_TRICOPTER || vehicleType == MAV_TYPE_HELICOPTER) {
            _requiresFrameSetup = false;
        }
    }
42 43 44 45 46 47 48 49 50 51
}

QString APMAirframeComponent::name(void) const
{
    return _name;
}

QString APMAirframeComponent::description(void) const
{
    return tr("The Airframe Component is used to select the airframe which matches your vehicle. "
nopeppermint's avatar
nopeppermint committed
52
              "This will in turn set up the various tuning values for flight parameters.");
53 54 55 56
}

QString APMAirframeComponent::iconResource(void) const
{
57
    return QStringLiteral("/qmlimages/AirframeComponentIcon.png");
58 59 60 61
}

bool APMAirframeComponent::requiresSetup(void) const
{
62
    return _requiresFrameSetup;
63 64 65 66
}

bool APMAirframeComponent::setupComplete(void) const
{
67
    if (_requiresFrameSetup) {
68
        return _autopilot->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FRAME"))->rawValue().toInt() >= 0;
69 70 71
    } else {
        return true;
    }
72 73 74 75
}

QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const
{
76 77
    QStringList list;

78
    if (_requiresFrameSetup) {
79
        list << QStringLiteral("FRAME");
80 81 82
    }

    return list;
83 84 85 86
}

QUrl APMAirframeComponent::setupSource(void) const
{
87
    if (_requiresFrameSetup) {
88
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponent.qml"));
89 90 91
    } else {
        return QUrl();
    }
92 93 94 95
}

QUrl APMAirframeComponent::summaryQmlSource(void) const
{
96
    if (_requiresFrameSetup) {
97
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponentSummary.qml"));
98 99 100
    } else {
        return QUrl();
    }
101 102 103 104 105 106
}

QString APMAirframeComponent::prerequisiteSetup(void) const
{
    return QString();
}