Commit 2e0b4c46 authored by Gus Grubba's avatar Gus Grubba

Merge pull request #2730 from dogmaphobic/generalizingWiFiBridge

Making the ESP8266 component "common" instead of APM/PX4 only.
parents bb93217c 02c07853
......@@ -562,7 +562,6 @@ HEADERS+= \
src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.h \
src/AutoPilotPlugins/APM/APMCameraComponent.h \
src/AutoPilotPlugins/APM/APMCompassCal.h \
src/AutoPilotPlugins/APM/APMComponent.h \
src/AutoPilotPlugins/APM/APMFlightModesComponent.h \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \
src/AutoPilotPlugins/APM/APMPowerComponent.h \
......@@ -573,6 +572,7 @@ HEADERS+= \
src/AutoPilotPlugins/APM/APMTuningComponent.h \
src/AutoPilotPlugins/Common/RadioComponentController.h \
src/AutoPilotPlugins/Common/ESP8266ComponentController.h \
src/AutoPilotPlugins/Common/ESP8266Component.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \
......@@ -582,9 +582,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/PowerComponent.h \
src/AutoPilotPlugins/PX4/PowerComponentController.h \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/PX4Component.h \
src/AutoPilotPlugins/PX4/PX4RadioComponent.h \
src/AutoPilotPlugins/PX4/PX4ESP8266Component.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
......@@ -620,7 +618,6 @@ SOURCES += \
src/AutoPilotPlugins/APM/APMAirframeComponentController.cc \
src/AutoPilotPlugins/APM/APMCameraComponent.cc \
src/AutoPilotPlugins/APM/APMCompassCal.cc \
src/AutoPilotPlugins/APM/APMComponent.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \
src/AutoPilotPlugins/APM/APMPowerComponent.cc \
......@@ -631,6 +628,7 @@ SOURCES += \
src/AutoPilotPlugins/APM/APMTuningComponent.cc \
src/AutoPilotPlugins/Common/RadioComponentController.cc \
src/AutoPilotPlugins/Common/ESP8266ComponentController.cc \
src/AutoPilotPlugins/Common/ESP8266Component.cc \
src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
......@@ -641,9 +639,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/PowerComponent.cc \
src/AutoPilotPlugins/PX4/PowerComponentController.cc \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/PX4Component.cc \
src/AutoPilotPlugins/PX4/PX4RadioComponent.cc \
src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
......
......@@ -28,7 +28,7 @@
#include "ArduCopterFirmwarePlugin.h"
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: APMComponent(vehicle, autopilot, parent)
: VehicleComponent(vehicle, autopilot, parent)
, _requiresFrameSetup(false)
, _name("Airframe")
{
......
......@@ -24,16 +24,16 @@
#ifndef APMAirframeComponent_H
#define APMAirframeComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMAirframeComponent : public APMComponent
class APMAirframeComponent : public VehicleComponent
{
Q_OBJECT
public:
APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from APMComponent
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -27,7 +27,7 @@
#include "FirmwarePlugin/APM/APMParameterMetaData.h" // FIXME: Hack
#include "FirmwarePlugin/APM/APMFirmwarePlugin.h" // FIXME: Hack
#include "FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h"
#include "APMComponent.h"
#include "VehicleComponent.h"
#include "APMAirframeComponent.h"
#include "APMAirframeComponentAirframes.h"
#include "APMAirframeComponentController.h"
......@@ -40,6 +40,7 @@
#include "APMSensorsComponent.h"
#include "APMPowerComponent.h"
#include "APMCameraComponent.h"
#include "ESP8266Component.h"
/// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type.
APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
......@@ -54,6 +55,7 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
, _sensorsComponent(NULL)
, _tuningComponent(NULL)
, _airframeFacts(new APMAirframeLoader(this, vehicle->uas(), this))
, _esp8266Component(NULL)
{
APMAirframeLoader::loadAirframeFactMetaData();
}
......@@ -89,6 +91,13 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
//-- Is there an ESP8266 Connected?
if(factExists(FactSystem::ParameterProvider, MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) {
_esp8266Component = new ESP8266Component(_vehicle, this);
_esp8266Component->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_esp8266Component));
}
_sensorsComponent = new APMSensorsComponent(_vehicle, this);
_sensorsComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
......@@ -100,6 +109,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_tuningComponent = new APMTuningComponent(_vehicle, this);
_tuningComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent));
} else {
qWarning() << "Call to vehicleCompenents prior to parametersReady";
}
......
......@@ -36,6 +36,7 @@ class APMSafetyComponent;
class APMSensorsComponent;
class APMPowerComponent;
class APMCameraComponent;
class ESP8266Component;
/// This is the APM specific implementation of the AutoPilot class.
class APMAutoPilotPlugin : public AutoPilotPlugin
......@@ -57,6 +58,7 @@ public:
APMSafetyComponent* safetyComponent (void) const { return _safetyComponent; }
APMSensorsComponent* sensorsComponent (void) const { return _sensorsComponent; }
APMTuningComponent* tuningComponent (void) const { return _tuningComponent; }
ESP8266Component* esp8266Component (void) const { return _esp8266Component; }
public slots:
// FIXME: This is public until we restructure AutoPilotPlugin/FirmwarePlugin/Vehicle
......@@ -75,6 +77,7 @@ private:
APMSensorsComponent* _sensorsComponent;
APMTuningComponent* _tuningComponent;
APMAirframeLoader* _airframeFacts;
ESP8266Component* _esp8266Component;
};
#endif
......@@ -30,7 +30,7 @@
#include "APMAirframeComponent.h"
APMCameraComponent::APMCameraComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: APMComponent(vehicle, autopilot, parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name(tr("Camera"))
{
}
......
......@@ -24,16 +24,16 @@
#ifndef APMCameraComponent_H
#define APMCameraComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMCameraComponent : public APMComponent
class APMCameraComponent : public VehicleComponent
{
Q_OBJECT
public:
APMCameraComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "APMComponent.h"
#include "Fact.h"
#include "AutoPilotPlugin.h"
APMComponent::APMComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent)
{
Q_ASSERT(vehicle);
Q_ASSERT(autopilot);
}
void APMComponent::setupTriggerSignals(void)
{
foreach (const QString& paramName, setupCompleteChangedTriggerList()) {
Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName);
connect(fact, &Fact::valueChanged, this, &APMComponent::_triggerUpdated);
}
}
void APMComponent::_triggerUpdated(QVariant value)
{
Q_UNUSED(value);
emit setupCompleteChanged(setupComplete());
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef APMComponent_H
#define APMComponent_H
#include "VehicleComponent.h"
#include <QStringList>
/// @file
/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
class APMComponent : public VehicleComponent
{
Q_OBJECT
public:
APMComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
/// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL.
virtual QStringList setupCompleteChangedTriggerList(void) const = 0;
/// Should be called after the component is created (but not in constructor) to setup the
/// signals which are used to track parameter changes which affect setupComplete state.
void setupTriggerSignals(void);
private slots:
void _triggerUpdated(QVariant value);
};
#endif
......@@ -27,7 +27,7 @@
#include "APMRadioComponent.h"
APMFlightModesComponent::APMFlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Flight Modes"))
{
}
......
......@@ -24,16 +24,16 @@
#ifndef APMFlightModesComponent_H
#define APMFlightModesComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMFlightModesComponent : public APMComponent
class APMFlightModesComponent : public VehicleComponent
{
Q_OBJECT
public:
APMFlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -26,7 +26,7 @@
#include "APMAirframeComponent.h"
APMPowerComponent::APMPowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: APMComponent(vehicle, autopilot, parent),
: VehicleComponent(vehicle, autopilot, parent),
_name("Power")
{
}
......
......@@ -24,16 +24,16 @@
#ifndef APMPowerComponent_H
#define APMPowerComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMPowerComponent : public APMComponent
class APMPowerComponent : public VehicleComponent
{
Q_OBJECT
public:
APMPowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -26,7 +26,7 @@
#include "APMAirframeComponent.h"
APMRadioComponent::APMRadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Radio"))
{
_mapParams << QStringLiteral("RCMAP_ROLL") << QStringLiteral("RCMAP_PITCH") << QStringLiteral("RCMAP_YAW") << QStringLiteral("RCMAP_THROTTLE");
......
......@@ -24,17 +24,17 @@
#ifndef APMRadioComponent_H
#define APMRadioComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
#include "Fact.h"
class APMRadioComponent : public APMComponent
class APMRadioComponent : public VehicleComponent
{
Q_OBJECT
public:
APMRadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -30,7 +30,7 @@
#include "APMAirframeComponent.h"
APMSafetyComponent::APMSafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: APMComponent(vehicle, autopilot, parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name(tr("Safety"))
{
}
......
......@@ -24,16 +24,16 @@
#ifndef APMSafetyComponent_H
#define APMSafetyComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMSafetyComponent : public APMComponent
class APMSafetyComponent : public VehicleComponent
{
Q_OBJECT
public:
APMSafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -29,7 +29,7 @@
// These two list must be kept in sync
APMSensorsComponent::APMSensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Sensors"))
{
......
......@@ -24,9 +24,9 @@
#ifndef APMSensorsComponent_H
#define APMSensorsComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMSensorsComponent : public APMComponent
class APMSensorsComponent : public VehicleComponent
{
Q_OBJECT
......@@ -36,7 +36,7 @@ public:
bool compassSetupNeeded(void) const;
bool accelSetupNeeded(void) const;
// Virtuals from APMComponent
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -26,7 +26,7 @@
#include "APMAirframeComponent.h"
APMTuningComponent::APMTuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: APMComponent(vehicle, autopilot, parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name("Tuning")
{
}
......
......@@ -24,16 +24,16 @@
#ifndef APMTuningComponent_H
#define APMTuningComponent_H
#include "APMComponent.h"
#include "VehicleComponent.h"
class APMTuningComponent : public APMComponent
class APMTuningComponent : public VehicleComponent
{
Q_OBJECT
public:
APMTuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const final;
// Virtuals from VehicleComponent
......
......@@ -21,57 +21,57 @@
======================================================================*/
#include "PX4ESP8266Component.h"
#include "PX4AutoPilotPlugin.h"
#include "ESP8266Component.h"
#include "AutoPilotPlugin.h"
PX4ESP8266Component::PX4ESP8266Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: PX4Component(vehicle, autopilot, parent)
ESP8266Component::ESP8266Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name(tr("WiFi Bridge"))
{
}
QString PX4ESP8266Component::name(void) const
QString ESP8266Component::name(void) const
{
return _name;
}
QString PX4ESP8266Component::description(void) const
QString ESP8266Component::description(void) const
{
return tr("The ESP8266 WiFi Bridge Component is used to setup the WiFi link.");
}
QString PX4ESP8266Component::iconResource(void) const
QString ESP8266Component::iconResource(void) const
{
return "/qmlimages/wifi.svg";
}
bool PX4ESP8266Component::requiresSetup(void) const
bool ESP8266Component::requiresSetup(void) const
{
return false;
}
bool PX4ESP8266Component::setupComplete(void) const
bool ESP8266Component::setupComplete(void) const
{
return true;
}
QStringList PX4ESP8266Component::setupCompleteChangedTriggerList(void) const
QStringList ESP8266Component::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}
QUrl PX4ESP8266Component::setupSource(void) const
QUrl ESP8266Component::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/ESP8266Component.qml");
}
QUrl PX4ESP8266Component::summaryQmlSource(void) const
QUrl ESP8266Component::summaryQmlSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/ESP8266ComponentSummary.qml");
}
QString PX4ESP8266Component::prerequisiteSetup(void) const
QString ESP8266Component::prerequisiteSetup(void) const
{
return QString();
}
......@@ -21,18 +21,18 @@
======================================================================*/
#ifndef PX4ESP8266Component_H
#define PX4ESP8266Component_H
#ifndef ESP8266Component_H
#define ESP8266Component_H
#include "PX4Component.h"
#include "VehicleComponent.h"
class PX4ESP8266Component : public PX4Component
class ESP8266Component : public VehicleComponent
{
Q_OBJECT
public:
PX4ESP8266Component (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
ESP8266Component (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList() const;
// Virtuals from VehicleComponent
......
......@@ -69,7 +69,7 @@ static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
#endif
AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Airframe"))
{
#if 0
......
......@@ -24,20 +24,20 @@
#ifndef AIRFRAMECOMPONENT_H
#define AIRFRAMECOMPONENT_H
#include "PX4Component.h"
#include "VehicleComponent.h"
/// @file
/// @brief The Airframe VehicleComponent is used to set the SYS_AUTOSTART airframe id.
/// @author Don Gagne <don@thegagnes.com>
class AirframeComponent : public PX4Component
class AirframeComponent : public VehicleComponent
{
Q_OBJECT
public:
AirframeComponent(Vehicle* vehicles, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -34,7 +34,7 @@ struct SwitchListItem {
};
FlightModesComponent::FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Flight Modes"))
{
}
......
......@@ -24,20 +24,20 @@
#ifndef FLIGHTMODESCOMPONENT_H
#define FLIGHTMODESCOMPONENT_H
#include "PX4Component.h"
#include "VehicleComponent.h"
/// @file
/// @brief The FlightModes VehicleComponent is used to set the associated Flight Mode switches.
/// @author Don Gagne <don@thegagnes.com>
class FlightModesComponent : public PX4Component
class FlightModesComponent : public VehicleComponent
{
Q_OBJECT
public:
FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -105,7 +105,7 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
//-- Is there an ESP8266 Connected?
if(factExists(FactSystem::ParameterProvider, MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) {
_esp8266Component = new PX4ESP8266Component(_vehicle, this);
_esp8266Component = new ESP8266Component(_vehicle, this);
_esp8266Component->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_esp8266Component));
}
......
......@@ -28,7 +28,7 @@
#include "PX4AirframeLoader.h"
#include "AirframeComponent.h"
#include "PX4RadioComponent.h"
#include "PX4ESP8266Component.h"
#include "ESP8266Component.h"
#include "FlightModesComponent.h"
#include "SensorsComponent.h"
#include "SafetyComponent.h"
......@@ -56,7 +56,7 @@ public:
// These methods should only be used by objects within the plugin
AirframeComponent* airframeComponent(void) { return _airframeComponent; }
PX4RadioComponent* radioComponent(void) { return _radioComponent; }
PX4ESP8266Component* esp8266Component(void) { return _esp8266Component; }
ESP8266Component* esp8266Component(void) { return _esp8266Component; }
FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; }
......@@ -72,7 +72,7 @@ private:
QVariantList _components;
AirframeComponent* _airframeComponent;
PX4RadioComponent* _radioComponent;
PX4ESP8266Component* _esp8266Component;
ESP8266Component* _esp8266Component;
FlightModesComponent* _flightModesComponent;
SensorsComponent* _sensorsComponent;
SafetyComponent* _safetyComponent;
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "PX4Component.h"
#include "Fact.h"
#include "AutoPilotPlugin.h"
PX4Component::PX4Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent)
{
Q_ASSERT(vehicle);
Q_ASSERT(autopilot);
}
void PX4Component::setupTriggerSignals(void)
{
// Watch for changed on trigger list params
foreach (const QString &paramName, setupCompleteChangedTriggerList()) {
Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName);
connect(fact, &Fact::valueChanged, this, &PX4Component::_triggerUpdated);
}
}
void PX4Component::_triggerUpdated(QVariant value)
{
Q_UNUSED(value);
emit setupCompleteChanged(setupComplete());
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef PX4COMPONENT_H
#define PX4COMPONENT_H
#include "VehicleComponent.h"
#include <QStringList>
/// @file
/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
class PX4Component : public VehicleComponent
{
Q_OBJECT
public:
PX4Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
/// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL.
virtual QStringList setupCompleteChangedTriggerList(void) const = 0;
/// Should be called after the component is created (but not in constructor) to setup the
/// signals which are used to track parameter changes which affect setupComplete state.
void setupTriggerSignals(void);
private slots:
void _triggerUpdated(QVariant value);
};
#endif
......@@ -25,7 +25,7 @@
#include "PX4AutoPilotPlugin.h"
PX4RadioComponent::PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Radio"))
{
}
......
......@@ -24,16 +24,16 @@
#ifndef PX4RadioComponent_H
#define PX4RadioComponent_H
#include "PX4Component.h"
#include "VehicleComponent.h"
class PX4RadioComponent : public PX4Component
class PX4RadioComponent : public VehicleComponent
{
Q_OBJECT
public:
PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -26,7 +26,7 @@
#include "AirframeComponent.h"
PX4TuningComponent::PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: PX4Component(vehicle, autopilot, parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name("Tuning")
{
}
......
......@@ -24,16 +24,16 @@
#ifndef PX4TuningComponent_H
#define PX4TuningComponent_H
#include "PX4Component.h"
#include "VehicleComponent.h"
class PX4TuningComponent : public PX4Component
class PX4TuningComponent : public VehicleComponent
{
Q_OBJECT
public:
PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -29,7 +29,7 @@
#include "PX4AutoPilotPlugin.h"
PowerComponent::PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Power"))
{
}
......
......@@ -24,20 +24,20 @@
#ifndef PowerComponent_H
#define PowerComponent_H
#include "PX4Component.h"
#include "VehicleComponent.h"
/// @file
/// @brief Battery, propeller and magnetometer settings
/// @author Gus Grubba <mavlink@grubba.com>
class PowerComponent : public PX4Component
class PowerComponent : public VehicleComponent
{
Q_OBJECT
public:
PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -28,7 +28,7 @@
#include "PX4AutoPilotPlugin.h"
SafetyComponent::SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Safety"))
{
}
......
......@@ -24,21 +24,21 @@
#ifndef SafetyComponent_H
#define SafetyComponent_H
#include "PX4Component.h"
#include "VehicleComponent.h"
/// @file
/// @brief The Radio VehicleComponent is used to calibrate the trasmitter and assign function mapping
/// to channels.
/// @author Don Gagne <don@thegagnes.com>
class SafetyComponent : public PX4Component
class SafetyComponent : public VehicleComponent
{
Q_OBJECT
public:
SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -32,7 +32,7 @@
// These two list must be kept in sync
SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Sensors"))
{
......
......@@ -24,20 +24,20 @@
#ifndef SENSORSCOMPONENT_H
#define SENSORSCOMPONENT_H
#include "PX4Component.h"
#include "VehicleComponent.h"
/// @file
/// @brief The Sensors VehicleComponent is used to calibrate the the various sensors associated with the board.
/// @author Don Gagne <don@thegagnes.com>
class SensorsComponent : public PX4Component
class SensorsComponent : public VehicleComponent
{
Q_OBJECT
public:
SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
// Virtuals from VehicleComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
......
......@@ -217,6 +217,11 @@ int APMFirmwarePlugin::manualControlReservedButtonCount(void)
void APMFirmwarePlugin::adjustMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
{
//-- Don't process messages to/from UDP Bridge. It doesn't suffer from these issues
if (message->compid == MAV_COMP_ID_UDP_BRIDGE) {
return;
}
if (message->msgid == MAVLINK_MSG_ID_PARAM_VALUE) {
mavlink_param_value_t paramValue;
mavlink_param_union_t paramUnion;
......
......@@ -57,3 +57,17 @@ void VehicleComponent::addSummaryQmlComponent(QQmlContext* context, QQuickItem*
item->setParentItem(parent);
item->setProperty("vehicleComponent", QVariant::fromValue(this));
}
void VehicleComponent::setupTriggerSignals(void)
{
// Watch for changed on trigger list params
foreach (const QString &paramName, setupCompleteChangedTriggerList()) {
Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName);
connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated);
}
}
void VehicleComponent::_triggerUpdated(QVariant /*value*/)
{
emit setupCompleteChanged(setupComplete());
}
......@@ -66,9 +66,20 @@ public:
virtual void addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent);
/// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL.
virtual QStringList setupCompleteChangedTriggerList(void) const = 0;
/// Should be called after the component is created (but not in constructor) to setup the
/// signals which are used to track parameter changes which affect setupComplete state.
virtual void setupTriggerSignals(void);
signals:
void setupCompleteChanged(bool setupComplete);
protected slots:
void _triggerUpdated(QVariant value);
protected:
Vehicle* _vehicle;
AutoPilotPlugin* _autopilot;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment