From cb1471a2f784a7d8733d683431504c8c4ace761c Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Thu, 25 Oct 2018 10:43:13 -0300 Subject: [PATCH] APMMotorComponent: Create it --- CMakeLists.txt | 1 + qgroundcontrol.pro | 2 ++ .../APM/APMAutoPilotPlugin.cc | 4 +-- src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h | 4 +-- src/AutoPilotPlugins/APM/APMMotorComponent.cc | 27 +++++++++++++++++ src/AutoPilotPlugins/APM/APMMotorComponent.h | 29 +++++++++++++++++++ 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/AutoPilotPlugins/APM/APMMotorComponent.cc create mode 100644 src/AutoPilotPlugins/APM/APMMotorComponent.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ff71765..87327f241 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,7 @@ list(APPEND QGC_SRC src/AutoPilotPlugins/APM/APMFlightModesComponent.cc src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc src/AutoPilotPlugins/APM/APMLightsComponent.cc + src/AutoPilotPlugins/APM/APMMotorComponent.cc src/AutoPilotPlugins/APM/APMPowerComponent.cc src/AutoPilotPlugins/APM/APMRadioComponent.cc src/AutoPilotPlugins/APM/APMSafetyComponent.cc diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 8fb300a93..72d68bfef 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -970,6 +970,7 @@ APMFirmwarePlugin { src/AutoPilotPlugins/APM/APMHeliComponent.h \ src/AutoPilotPlugins/APM/APMLightsComponent.h \ src/AutoPilotPlugins/APM/APMSubFrameComponent.h \ + src/AutoPilotPlugins/APM/APMMotorComponent.h \ src/AutoPilotPlugins/APM/APMPowerComponent.h \ src/AutoPilotPlugins/APM/APMRadioComponent.h \ src/AutoPilotPlugins/APM/APMSafetyComponent.h \ @@ -996,6 +997,7 @@ APMFirmwarePlugin { src/AutoPilotPlugins/APM/APMHeliComponent.cc \ src/AutoPilotPlugins/APM/APMLightsComponent.cc \ src/AutoPilotPlugins/APM/APMSubFrameComponent.cc \ + src/AutoPilotPlugins/APM/APMMotorComponent.cc \ src/AutoPilotPlugins/APM/APMPowerComponent.cc \ src/AutoPilotPlugins/APM/APMRadioComponent.cc \ src/AutoPilotPlugins/APM/APMSafetyComponent.cc \ diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 8d26f94ad..c0f218d9a 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -23,7 +23,7 @@ #include "APMTuningComponent.h" #include "APMSensorsComponent.h" #include "APMPowerComponent.h" -#include "MotorComponent.h" +#include "APMMotorComponent.h" #include "APMCameraComponent.h" #include "APMLightsComponent.h" #include "APMSubFrameComponent.h" @@ -88,7 +88,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) int versionInt = _vehicle->firmwareMajorVersion() * 100 + _vehicle->firmwareMinorVersion() * 10 + _vehicle->firmwarePatchVersion(); if (_vehicle->sub() && versionInt >= 353) { - _motorComponent = new MotorComponent(_vehicle, this); + _motorComponent = new APMMotorComponent(_vehicle, this); _motorComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_motorComponent)); } diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h index 5d9c03c43..09bb7c24f 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h @@ -22,7 +22,7 @@ class APMTuningComponent; class APMSafetyComponent; class APMSensorsComponent; class APMPowerComponent; -class MotorComponent; +class APMMotorComponent; class APMCameraComponent; class APMLightsComponent; class APMSubFrameComponent; @@ -50,7 +50,7 @@ protected: APMSubFrameComponent* _subFrameComponent; APMFlightModesComponent* _flightModesComponent; APMPowerComponent* _powerComponent; - MotorComponent* _motorComponent; + APMMotorComponent* _motorComponent; APMRadioComponent* _radioComponent; APMSafetyComponent* _safetyComponent; APMSensorsComponent* _sensorsComponent; diff --git a/src/AutoPilotPlugins/APM/APMMotorComponent.cc b/src/AutoPilotPlugins/APM/APMMotorComponent.cc new file mode 100644 index 000000000..ce54a1646 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMMotorComponent.cc @@ -0,0 +1,27 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "APMMotorComponent.h" + +APMMotorComponent::APMMotorComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : + MotorComponent(vehicle, autopilot, parent), + _name(tr("Motors")) +{ + +} + +QUrl APMMotorComponent::setupSource(void) const +{ + switch (_vehicle->vehicleType()) { + case MAV_TYPE_SUBMARINE: + return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMSubMotorComponent.qml")); + default: + return QUrl::fromUserInput(QStringLiteral("qrc:/qml/MotorComponent.qml")); + } +} diff --git a/src/AutoPilotPlugins/APM/APMMotorComponent.h b/src/AutoPilotPlugins/APM/APMMotorComponent.h new file mode 100644 index 000000000..20e4c4919 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMMotorComponent.h @@ -0,0 +1,29 @@ +/**************************************************************************** + * + * (c) 2009-2018 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +#ifndef APMMotorComponent_H +#define APMMotorComponent_H + +#include "MotorComponent.h" + +class APMMotorComponent : public MotorComponent +{ + Q_OBJECT + +public: + APMMotorComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + QUrl setupSource(void) const final; + +private: + const QString _name; +}; + +#endif -- 2.22.0