APMAirframeComponent.cc 2.49 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.
 *
 ****************************************************************************/

10
#include "APMAirframeComponent.h"
11
#include "ArduCopterFirmwarePlugin.h"
12
#include "ParameterManager.h"
13

14
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
15
    : VehicleComponent(vehicle, autopilot, parent)
16
    , _requiresFrameSetup(false)
17
    , _name("Airframe")
18
{
19 20 21 22 23 24 25
    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;
        }
    }
26 27 28 29 30 31 32 33 34
}

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

QString APMAirframeComponent::description(void) const
{
35 36
    return tr("Airframe Setup is used to select the airframe which matches your vehicle. "
              "You can also the load default parameter values associated with known vehicle types.");
37 38 39 40
}

QString APMAirframeComponent::iconResource(void) const
{
41
    return QStringLiteral("/qmlimages/AirframeComponentIcon.png");
42 43 44 45
}

bool APMAirframeComponent::requiresSetup(void) const
{
46
    return _requiresFrameSetup;
47 48 49 50
}

bool APMAirframeComponent::setupComplete(void) const
{
51
    if (_requiresFrameSetup) {
52
        return _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, QStringLiteral("FRAME"))->rawValue().toInt() >= 0;
53 54 55
    } else {
        return true;
    }
56 57 58 59
}

QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const
{
60 61
    QStringList list;

62
    if (_requiresFrameSetup) {
63
        list << QStringLiteral("FRAME");
64 65 66
    }

    return list;
67 68 69 70
}

QUrl APMAirframeComponent::setupSource(void) const
{
71
    if (_requiresFrameSetup) {
72
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponent.qml"));
73 74 75
    } else {
        return QUrl();
    }
76 77 78 79
}

QUrl APMAirframeComponent::summaryQmlSource(void) const
{
80
    if (_requiresFrameSetup) {
81
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponentSummary.qml"));
82 83 84
    } else {
        return QUrl();
    }
85 86 87 88 89 90
}

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