QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PX4FailsafesComponent.cc
Go to the documentation of this file.
2
3#include <optional>
4
5#include "Fact.h"
6#include "Vehicle.h"
7
9 : VehicleComponent(vehicle, autopilot, AutoPilotPlugin::UnknownVehicleComponent, parent)
10 , _name(tr("Failsafes"))
11{}
12
14{
15 return tr("Configure what the vehicle does when it loses a link, runs low on power or detects a fault.");
16}
17
19{
20 return QStringLiteral("/InstrumentValueIcons/exclamation-outline.svg");
21}
22
24{
25 return {
26 tr("RC loss"), tr("Joystick loss"), tr("Radio"), tr("Signal loss"),
27 tr("Data link loss"), tr("Telemetry"), tr("Ground station"), tr("GCS"),
28 tr("Geofence"), tr("Fence"), tr("Breach"), tr("Low battery"),
29 tr("Critical battery"), tr("GPS loss"), tr("Wind"), tr("Flight time"),
30 tr("Traffic avoidance"),
31 };
32}
33
35{
36 return QUrl::fromUserInput(
37 QStringLiteral("qrc:/qml/QGroundControl/AutoPilotPlugins/PX4/PX4FailsafesComponent.qml"));
38}
39
41{
42 return {"COM_LOW_BAT_ACT", "NAV_RCL_ACT", "COM_RC_IN_MODE", "NAV_DLL_ACT", "GF_ACTION", "COM_QC_ACT"};
43}
44
45QList<VehicleSummaryItem> PX4FailsafesComponent::summaryItems() const
46{
47 QList<VehicleSummaryItem> items;
48
49 // offValue is the raw action value which turns the failsafe off, if it has one
50 const auto addAction = [this, &items](const char* param, const QString& caption, std::optional<int> offValue) {
51 Fact* const fact = _parameterFact(QLatin1String(param));
52 if (!fact) {
53 return;
54 }
55 items.append({caption, fact->enumStringValue(),
56 fact->rawValue().toInt() == offValue ? VehicleSummaryItem::Muted : VehicleSummaryItem::Normal});
57 };
58
59 addAction("COM_LOW_BAT_ACT", tr("Low Battery"), std::nullopt);
60
61 // Keep in sync with PX4FailsafeRows.js: manual control loss only applies when a manual control source is in use
62 const Fact* const manualControlSource = _parameterFact(QStringLiteral("COM_RC_IN_MODE"));
63 if (!manualControlSource || manualControlSource->rawValue().toInt() != 4) {
64 addAction("NAV_RCL_ACT", tr("Manual Control Loss"), 0);
65 }
66 addAction("NAV_DLL_ACT", tr("Data Link Loss"), 0);
67 addAction("GF_ACTION", tr("Geofence"), 0);
68 if (_vehicle && _vehicle->vtol()) {
69 addAction("COM_QC_ACT", tr("Quadchute"), std::nullopt);
70 }
71
72 return items;
73}
The AutoPilotPlugin class is an abstract base class which represents the methods and objects which ar...
A Fact is used to hold a single value within the system.
Definition Fact.h:15
QString enumStringValue()
Definition Fact.cc:248
QVariant rawValue() const
Definition Fact.h:87
PX4FailsafesComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, QObject *parent=nullptr)
QString iconResource() const final
QStringList searchKeywords() const final
Translated search terms for the whole component, for pages without vehicleConfigJson() sections.
QString description() const final
QList< VehicleSummaryItem > summaryItems() const final
Values for this component's card on the Summary page. A component with none falls back to summaryQmlS...
QStringList summaryChangedTriggerList() const final
Parameters whose change emits summaryItemsChanged, besides those that change setupComplete.
QUrl setupSource() const final
VehicleComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent, QObject *parent=nullptr)
Fact * _parameterFact(const QString &name) const
Fact of a parameter of the default component, nullptr when the vehicle does not have it.