Skip to content

Commit

Permalink
Add lights settings component for Sub.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjehangir committed Oct 14, 2016
1 parent 99d161e commit adc0c94
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 0 deletions.
1 change: 1 addition & 0 deletions qgcresources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<file alias="GeoTagIcon">src/AnalyzeView/GeoTagIcon.png</file>
<file alias="LandMode.svg">src/AutoPilotPlugins/PX4/Images/LandMode.svg</file>
<file alias="LandModeCopter.svg">src/AutoPilotPlugins/PX4/Images/LandModeCopter.svg</file>
<file alias="LightsComponentIcon.png">src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png</file>
<file alias="LogDownloadIcon">src/AnalyzeView/LogDownloadIcon.png</file>
<file alias="LowBattery.svg">src/AutoPilotPlugins/PX4/Images/LowBattery.svg</file>
<file alias="LowBatteryLight.svg">src/AutoPilotPlugins/PX4/Images/LowBatteryLight.svg</file>
Expand Down
2 changes: 2 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ HEADERS+= \
src/AutoPilotPlugins/APM/APMAirframeComponentController.h \
src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.h \
src/AutoPilotPlugins/APM/APMCameraComponent.h \
src/AutoPilotPlugins/APM/APMLightsComponent.h \
src/AutoPilotPlugins/APM/APMCompassCal.h \
src/AutoPilotPlugins/APM/APMFlightModesComponent.h \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \
Expand Down Expand Up @@ -730,6 +731,7 @@ SOURCES += \
src/AutoPilotPlugins/APM/APMAirframeComponent.cc \
src/AutoPilotPlugins/APM/APMAirframeComponentController.cc \
src/AutoPilotPlugins/APM/APMCameraComponent.cc \
src/AutoPilotPlugins/APM/APMLightsComponent.cc \
src/AutoPilotPlugins/APM/APMCompassCal.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \
Expand Down
2 changes: 2 additions & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
<file alias="APMNotSupported.qml">src/AutoPilotPlugins/APM/APMNotSupported.qml</file>
<file alias="APMCameraComponent.qml">src/AutoPilotPlugins/APM/APMCameraComponent.qml</file>
<file alias="APMCameraComponentSummary.qml">src/AutoPilotPlugins/APM/APMCameraComponentSummary.qml</file>
<file alias="APMLightsComponent.qml">src/AutoPilotPlugins/APM/APMLightsComponent.qml</file>
<file alias="APMLightsComponentSummary.qml">src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml</file>
<file alias="APMPowerComponent.qml">src/AutoPilotPlugins/APM/APMPowerComponent.qml</file>
<file alias="APMPowerComponentSummary.qml">src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml</file>
<file alias="APMRadioComponentSummary.qml">src/AutoPilotPlugins/APM/APMRadioComponentSummary.qml</file>
Expand Down
8 changes: 8 additions & 0 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "APMPowerComponent.h"
#include "MotorComponent.h"
#include "APMCameraComponent.h"
#include "APMLightsComponent.h"
#include "ESP8266Component.h"

/// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type.
Expand All @@ -35,6 +36,7 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
, _incorrectParameterVersion(false)
, _airframeComponent(NULL)
, _cameraComponent(NULL)
, _lightsComponent(NULL)
, _flightModesComponent(NULL)
, _powerComponent(NULL)
#if 0
Expand Down Expand Up @@ -104,6 +106,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_cameraComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_cameraComponent));

if (_vehicle->sub()) {
_lightsComponent = new APMLightsComponent(_vehicle, this);
_lightsComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_lightsComponent));
}

//-- Is there an ESP8266 Connected?
if(_vehicle->parameterManager()->parameterExists(MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) {
_esp8266Component = new ESP8266Component(_vehicle, this);
Expand Down
3 changes: 3 additions & 0 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class APMSensorsComponent;
class APMPowerComponent;
class MotorComponent;
class APMCameraComponent;
class APMLightsComponent;
class ESP8266Component;

/// This is the APM specific implementation of the AutoPilot class.
Expand All @@ -40,6 +41,7 @@ class APMAutoPilotPlugin : public AutoPilotPlugin

APMAirframeComponent* airframeComponent (void) const { return _airframeComponent; }
APMCameraComponent* cameraComponent (void) const { return _cameraComponent; }
APMLightsComponent* lightsComponent (void) const { return _lightsComponent; }
APMFlightModesComponent* flightModesComponent(void) const { return _flightModesComponent; }
APMPowerComponent* powerComponent (void) const { return _powerComponent; }
#if 0
Expand All @@ -58,6 +60,7 @@ class APMAutoPilotPlugin : public AutoPilotPlugin

APMAirframeComponent* _airframeComponent;
APMCameraComponent* _cameraComponent;
APMLightsComponent* _lightsComponent;
APMFlightModesComponent* _flightModesComponent;
APMPowerComponent* _powerComponent;
#if 0
Expand Down
76 changes: 76 additions & 0 deletions src/AutoPilotPlugins/APM/APMLightsComponent.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/****************************************************************************
*
* (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.
*
****************************************************************************/


/// @file
/// @author Don Gagne <[email protected]>
/// @author Rustom Jehangir <[email protected]>

#include "APMLightsComponent.h"
#include "QGCQmlWidgetHolder.h"
#include "APMAutoPilotPlugin.h"
#include "APMAirframeComponent.h"

APMLightsComponent::APMLightsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name(tr("Lights"))
{
}

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

QString APMLightsComponent::description(void) const
{
return tr("The Lights Component is used to setup lights settings.");
}

QString APMLightsComponent::iconResource(void) const
{
return QStringLiteral("/qmlimages/LightsComponentIcon.png");
}

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

bool APMLightsComponent::setupComplete(void) const
{
return true;
}

QStringList APMLightsComponent::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}

QUrl APMLightsComponent::setupSource(void) const
{
return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMLightsComponent.qml"));
}

QUrl APMLightsComponent::summaryQmlSource(void) const
{
return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMLightsComponentSummary.qml"));
}

QString APMLightsComponent::prerequisiteSetup(void) const
{
APMAutoPilotPlugin* plugin = dynamic_cast<APMAutoPilotPlugin*>(_autopilot);
Q_ASSERT(plugin);

if (!plugin->airframeComponent()->setupComplete()) {
return plugin->airframeComponent()->name();
}

return QString();
}
40 changes: 40 additions & 0 deletions src/AutoPilotPlugins/APM/APMLightsComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/****************************************************************************
*
* (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.
*
****************************************************************************/


#ifndef APMLightsComponent_H
#define APMLightsComponent_H

#include "VehicleComponent.h"

class APMLightsComponent : public VehicleComponent
{
Q_OBJECT

public:
APMLightsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);

// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;

// Virtuals from VehicleComponent
QString name(void) const final;
QString description(void) const final;
QString iconResource(void) const final;
bool requiresSetup(void) const final;
bool setupComplete(void) const final;
QUrl setupSource(void) const final;
QUrl summaryQmlSource(void) const final;
QString prerequisiteSetup(void) const final;

private:
const QString _name;
};

#endif
Loading

0 comments on commit adc0c94

Please sign in to comment.