SafetyComponent.cc 1.8 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
9

Don Gagne's avatar
Don Gagne committed
10 11 12 13 14

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

#include "SafetyComponent.h"
Don Gagne's avatar
Don Gagne committed
15
#include "PX4AutoPilotPlugin.h"
Don Gagne's avatar
Don Gagne committed
16

17
SafetyComponent::SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
18
    VehicleComponent(vehicle, autopilot, parent),
Don Gagne's avatar
Don Gagne committed
19 20 21 22 23 24 25 26 27 28 29
    _name(tr("Safety"))
{
}

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

QString SafetyComponent::description(void) const
{
30
    return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself.");
Don Gagne's avatar
Don Gagne committed
31 32
}

33
QString SafetyComponent::iconResource(void) const
Don Gagne's avatar
Don Gagne committed
34
{
35
    return "/qmlimages/SafetyComponentIcon.png";
Don Gagne's avatar
Don Gagne committed
36 37 38 39 40 41 42 43 44 45 46 47 48
}

bool SafetyComponent::requiresSetup(void) const
{
    return false;
}

bool SafetyComponent::setupComplete(void) const
{
    // FIXME: What aboout invalid settings?
    return true;
}

Don Gagne's avatar
Don Gagne committed
49
QStringList SafetyComponent::setupCompleteChangedTriggerList(void) const
Don Gagne's avatar
Don Gagne committed
50
{
Don Gagne's avatar
Don Gagne committed
51
    return QStringList();
Don Gagne's avatar
Don Gagne committed
52 53
}

54
QUrl SafetyComponent::setupSource(void) const
Don Gagne's avatar
Don Gagne committed
55
{
56
    return QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml");
Don Gagne's avatar
Don Gagne committed
57 58
}

59
QUrl SafetyComponent::summaryQmlSource(void) const
Don Gagne's avatar
Don Gagne committed
60
{
61
    return QUrl::fromUserInput("qrc:/qml/SafetyComponentSummary.qml");
Don Gagne's avatar
Don Gagne committed
62
}
Don Gagne's avatar
Don Gagne committed
63 64 65 66 67

QString SafetyComponent::prerequisiteSetup(void) const
{
    PX4AutoPilotPlugin* plugin = dynamic_cast<PX4AutoPilotPlugin*>(_autopilot);
    Q_ASSERT(plugin);
68

Don Gagne's avatar
Don Gagne committed
69 70 71
    if (!plugin->airframeComponent()->setupComplete()) {
        return plugin->airframeComponent()->name();
    }
72

Don Gagne's avatar
Don Gagne committed
73 74
    return QString();
}