QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AirframeComponent.cc
Go to the documentation of this file.
1#include "AirframeComponent.h"
2
4#include "Fact.h"
5#include "ParameterManager.h"
6#include "Vehicle.h"
7
8AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
9 : VehicleComponent(vehicle, autopilot, AutoPilotPlugin::UnknownVehicleComponent, parent)
10 , _name(tr("Airframe"))
11{
12
13}
14
15QString AirframeComponent::name(void) const
16{
17 return _name;
18}
19
21{
22 return tr("Configure the airframe type and apply default tuning parameters.");
23}
24
26{
27 return "/qmlimages/AirframeComponentIcon.png";
28}
29
31{
32 return true;
33}
34
36{
37 return _vehicle->parameterManager()->getParameter(ParameterManager::defaultComponentId, QStringLiteral("SYS_AUTOSTART"))->rawValue().toInt() != 0;
38}
39
41{
42 return QStringList(QStringLiteral("SYS_AUTOSTART"));
43}
44
46{
47 return QUrl::fromUserInput("qrc:/qml/QGroundControl/AutoPilotPlugins/PX4/AirframeComponent.qml");
48}
49
51{
52 return {QStringLiteral("MAV_SYS_ID")};
53}
54
62
63QList<VehicleSummaryItem> AirframeComponent::summaryItems(void) const
64{
65 QList<VehicleSummaryItem> items;
66
67 const Fact* const systemId = _parameterFact(QStringLiteral("MAV_SYS_ID"));
68 if (systemId) {
69 items.append({tr("System ID"), systemId->cookedValueString(), VehicleSummaryItem::Normal});
70 }
71
72 const Fact* const autostart = _parameterFact(QStringLiteral("SYS_AUTOSTART"));
73 const int autostartId = autostart ? autostart->rawValue().toInt() : 0;
74 QString typeName;
75 QString vehicleName;
76 if (autostartId == 0) {
77 items.append({tr("Airframe type"), tr("Setup required"), VehicleSummaryItem::Attention});
78 items.append({tr("Vehicle"), tr("Setup required"), VehicleSummaryItem::Attention});
79 } else if (AirframeComponentAirframes::find(autostartId, typeName, vehicleName)) {
80 items.append({tr("Airframe type"), typeName, VehicleSummaryItem::Normal});
81 items.append({tr("Vehicle"), vehicleName, VehicleSummaryItem::Normal});
82 } else {
83 items.append({tr("Vehicle"), QString::number(autostartId), VehicleSummaryItem::Normal});
84 }
85
86 if (_vehicle->firmwareMajorVersion() == Vehicle::versionNotSetValue) {
87 items.append({tr("Firmware Version"), tr("Unknown"), VehicleSummaryItem::Muted});
88 } else {
89 items.append({tr("Firmware Version"),
90 QStringLiteral("%1.%2.%3%4")
91 .arg(_vehicle->firmwareMajorVersion())
92 .arg(_vehicle->firmwareMinorVersion())
93 .arg(_vehicle->firmwarePatchVersion())
94 .arg(_vehicle->firmwareVersionTypeString()),
95 VehicleSummaryItem::Normal});
96 }
97
98 if (_vehicle->firmwareCustomMajorVersion() != Vehicle::versionNotSetValue) {
99 items.append({tr("Custom Fw. Ver."),
100 QStringLiteral("%1.%2.%3")
101 .arg(_vehicle->firmwareCustomMajorVersion())
102 .arg(_vehicle->firmwareCustomMinorVersion())
103 .arg(_vehicle->firmwareCustomPatchVersion()),
104 VehicleSummaryItem::Normal});
105 }
106
107 return items;
108}
static bool find(int autostartId, QString &typeName, QString &vehicleName)
Type and vehicle name of the airframe with the autostart id. Returns false when there is no such airf...
virtual QStringList summaryChangedTriggerList() const
Parameters whose change emits summaryItemsChanged, besides those that change setupComplete.
virtual bool requiresSetup(void) const
virtual QString name(void) const
AirframeComponent(Vehicle *vehicles, AutoPilotPlugin *autopilot, QObject *parent=nullptr)
virtual QList< VehicleSummaryItem > summaryItems() const
Values for this component's card on the Summary page. A component with none falls back to summaryQmlS...
virtual QString iconResource(void) const
virtual void setupTriggerSignals()
virtual QString description(void) const
virtual bool setupComplete(void) const
virtual QUrl setupSource(void) const
virtual QStringList setupCompleteChangedTriggerList(void) const
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 cookedValueString() const
Definition Fact.cc:489
QVariant rawValue() const
Definition Fact.h:87
static constexpr int defaultComponentId
VehicleComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent, QObject *parent=nullptr)
void summaryItemsChanged()
Fact * _parameterFact(const QString &name) const
Fact of a parameter of the default component, nullptr when the vehicle does not have it.
virtual void setupTriggerSignals()
void firmwareCustomVersionChanged()
void firmwareVersionChanged()
static const int versionNotSetValue