Commit 97a07325 authored by dogmaphobic's avatar dogmaphobic

Merge remote-tracking branch 'mavlink/master' into toolbarWork

* mavlink/master: (30 commits)
  android lower minSdkVersion to 16
  Update README.md
  Fix G constant, emit updates more regularly
  QGC: Fix excessive noise terms
  check for new and old flightgear path
  set correct path to flightgear executable on osx
  fix android auto versionName update
  travis-ci try installing PyOpenSSL with pip
  travis-ci add python-openssl for google play publish
  travis-ci run doxygen config last
  travis-ci pip install --user
  travis-ci install google-api-python-client
  fix travis decrypt google play credentials
  android auto version and deploy to google play
  update android version
  Remove Flightgear and JSBSim and only leave the option which actually works.
  Wait after window close to prevent qml warnings
  Restructure to prevent shutdown warnings
  QT_FATAL_WARNINGS back on
  Remove remaining singletons
  ...

Conflicts:
	src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
parents da8d8bb5 a120ffe7
......@@ -17,12 +17,9 @@ matrix:
- os: linux
env: SPEC=linux-g++-64 CONFIG=installer
sudo: false
- os: linux
env: CONFIG=doxygen
sudo: false
- os: osx
osx_image: xcode7
env: SPEC=macx-clang CONFIG=debug
env: SPEC=macx-clang CONFIG=debug QT_FATAL_WARNINGS=1
- os: osx
osx_image: xcode7
env: SPEC=macx-clang CONFIG=installer
......@@ -34,6 +31,9 @@ matrix:
language: android
env: SPEC=android-g++ CONFIG=installer
sudo: false
- os: linux
env: CONFIG=doxygen
sudo: false
android:
components:
......@@ -111,6 +111,7 @@ before_script:
- if [ "${CONFIG}" != "doxygen" ]; then qmake -r qgroundcontrol.pro CONFIG+=${CONFIG} CONFIG+=WarningsAsErrorsOn -spec ${SPEC}; fi
script:
- ./tools/update_android_version.sh
- echo 'Building QGroundControl' && echo -en 'travis_fold:start:script.1\\r'
- if [ "${CONFIG}" != "doxygen" ]; then make -j4; fi
- if [ "${CONFIG}" = "doxygen" ]; then cd src && doxygen documentation.dox; fi
......@@ -118,6 +119,14 @@ script:
- if [[ "${TRAVIS_OS_NAME}" = "linux" && "${CONFIG}" = "debug" ]]; then ./debug/qgroundcontrol --unittest; fi
- if [[ "${TRAVIS_OS_NAME}" = "osx" && "${CONFIG}" = "debug" ]]; then ./debug/qgroundcontrol.app/Contents/MacOS/qgroundcontrol --unittest; fi
after_success:
- if [[ "${TRAVIS_OS_NAME}" = "android" && "${TRAVIS_PULL_REQUEST}" = "false" && "${TRAVIS_BRANCH}" = "master" ]]; then
pip install --user google-api-python-client PyOpenSSL
&& openssl aes-256-cbc -K $encrypted_25db6eb7c3fd_key -iv $encrypted_25db6eb7c3fd_iv -in Google_Play_Android_Developer-bb93ae7d61ca.p12.enc -out android/Google_Play_Android_Developer-bb93ae7d61ca.p12 -d
&& ./tools/google_play_upload.py org.mavlink.qgroundcontrol release/package/qgroundcontrol.apk
;
fi
deploy:
- provider: s3
access_key_id: AKIAIVORNALE7NHD3T6Q
......
......@@ -200,7 +200,6 @@ FORMS += \
src/ui/uas/UASQuickView.ui \
src/ui/uas/UASQuickViewItemSelect.ui \
src/ui/UASInfo.ui \
src/ui/UASRawStatusView.ui \
}
HEADERS += \
......@@ -240,7 +239,6 @@ HEADERS += \
src/QGCPalette.h \
src/QGCQmlWidgetHolder.h \
src/QGCQuickWidget.h \
src/QGCSingleton.h \
src/QGCTemporaryFile.h \
src/QGCToolbox.h \
src/QmlControls/CoordinateVector.h \
......@@ -317,7 +315,6 @@ HEADERS += \
src/ui/uas/UASQuickViewItem.h \
src/ui/uas/UASQuickViewItemSelect.h \
src/ui/uas/UASQuickViewTextItem.h \
src/ui/UASRawStatusView.h \
src/VehicleSetup/JoystickConfigController.h \
src/ViewWidgets/CustomCommandWidget.h \
src/ViewWidgets/CustomCommandWidgetController.h \
......@@ -355,7 +352,6 @@ SOURCES += \
src/QGCPalette.cc \
src/QGCQmlWidgetHolder.cpp \
src/QGCQuickWidget.cc \
src/QGCSingleton.cc \
src/QGCTemporaryFile.cc \
src/QGCToolbox.cc \
src/QGCGeo.cc \
......@@ -423,7 +419,6 @@ SOURCES += \
src/ui/uas/UASQuickViewItem.cc \
src/ui/uas/UASQuickViewItemSelect.cc \
src/ui/uas/UASQuickViewTextItem.cc \
src/ui/UASRawStatusView.cpp \
src/VehicleSetup/JoystickConfigController.cc \
src/ViewWidgets/CustomCommandWidget.cc \
src/ViewWidgets/CustomCommandWidgetController.cc \
......
......@@ -20,12 +20,9 @@
## Obtaining source code
Source code for QGroundControl is kept on GitHub: https://github.com/mavlink/qgroundcontrol.
```
git clone https://github.com/mavlink/qgroundcontrol.git
cd qgroundcontrol
git submodule init
git submodule update
git clone --recursive https://github.com/mavlink/qgroundcontrol.git
```
Each time you pull new source to your repository you should re-run "git submodule update" to get the latest submodules as well.
Each time you pull new source to your repository you should run `git submodule update` to get the latest submodules as well.
### Supported Builds
QGroundControl builds are supported for OSX, Linux, Windows and Android. QGroundControl uses [Qt](http://www.qt.io) as it's cross-platform support library and uses [QtCreator](http://doc.qt.io/qtcreator/index.html) as it's default build environment.
......
<?xml version="1.0"?>
<manifest package="org.mavlink.qgroundcontrol" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.7.1-668-g4ad2975" android:versionCode="8" android:installLocation="auto">
<manifest package="org.mavlink.qgroundcontrol" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.7.1-801-g075d5af" android:versionCode="2109" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qgroundcontrol.qgchelper.UsbDeviceJNI" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="sensorLandscape" android:launchMode="singleTask">
<intent-filter>
......@@ -48,7 +48,7 @@
<!-- Background running -->
</activity>
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="22"/>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- Needed to keep working while 'asleep' -->
......
......@@ -27,8 +27,8 @@
#include "APMAirframeComponent.h"
#include "QGCQmlWidgetHolder.h"
APMAirframeComponent::APMAirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(uas, autopilot, parent),
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(vehicle, autopilot, parent),
_name(tr("Airframe"))
{
......
......@@ -31,7 +31,7 @@ class APMAirframeComponent : public APMComponent
Q_OBJECT
public:
APMAirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from APMComponent
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -48,7 +48,7 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
Q_ASSERT(_vehicle);
if (parametersReady()) {
_airframeComponent = new APMAirframeComponent(_vehicle->uas(), this);
_airframeComponent = new APMAirframeComponent(_vehicle, this);
Q_CHECK_PTR(_airframeComponent);
_airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
......
......@@ -28,10 +28,10 @@
#include "Fact.h"
#include "AutoPilotPlugin.h"
APMComponent::APMComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(uas, autopilot, parent)
APMComponent::APMComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent)
{
Q_ASSERT(uas);
Q_ASSERT(vehicle);
Q_ASSERT(autopilot);
}
......
......@@ -37,7 +37,7 @@ class APMComponent : public VehicleComponent
Q_OBJECT
public:
APMComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
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.
......
......@@ -170,7 +170,7 @@ const QMap<int, QMap<QString, QStringList> >& AutoPilotPlugin::getGroupMap(void)
void AutoPilotPlugin::writeParametersToStream(QTextStream &stream)
{
_vehicle->getParameterLoader()->writeParametersToStream(stream, _vehicle->uas()->getUASName());
_vehicle->getParameterLoader()->writeParametersToStream(stream);
}
QString AutoPilotPlugin::readParametersFromStream(QTextStream &stream)
......
......@@ -68,8 +68,8 @@ static const struct mavType mavTypeInfo[] = {
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
#endif
AirframeComponent::AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Airframe"))
{
#if 0
......
......@@ -35,7 +35,7 @@ class AirframeComponent : public PX4Component
Q_OBJECT
public:
AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
AirframeComponent(Vehicle* vehicles, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -43,8 +43,8 @@ static const SwitchListItem switchList[] = {
};
static const size_t cSwitchList = sizeof(switchList) / sizeof(switchList[0]);
FlightModesComponent::FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
FlightModesComponent::FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Flight Modes"))
{
}
......
......@@ -35,7 +35,7 @@ class FlightModesComponent : public PX4Component
Q_OBJECT
public:
FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -66,7 +66,7 @@ FlightModesComponentController::~FlightModesComponentController()
void FlightModesComponentController::_init(void)
{
// FIXME: What about VTOL? That confuses the whole Flight Mode naming scheme
_fixedWing = _uas->getSystemType() == MAV_TYPE_FIXED_WING;
_fixedWing = _vehicle->vehicleType() == MAV_TYPE_FIXED_WING;
// We need to know min and max for channel in order to calculate percentage range
for (int channel=0; channel<_chanMax; channel++) {
......
......@@ -94,32 +94,32 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
Q_ASSERT(_vehicle);
if (parametersReady()) {
_airframeComponent = new AirframeComponent(_vehicle->uas(), this);
_airframeComponent = new AirframeComponent(_vehicle, this);
Q_CHECK_PTR(_airframeComponent);
_airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
_radioComponent = new RadioComponent(_vehicle->uas(), this);
_radioComponent = new RadioComponent(_vehicle, this);
Q_CHECK_PTR(_radioComponent);
_radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
_flightModesComponent = new FlightModesComponent(_vehicle->uas(), this);
_flightModesComponent = new FlightModesComponent(_vehicle, this);
Q_CHECK_PTR(_flightModesComponent);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));
_sensorsComponent = new SensorsComponent(_vehicle->uas(), this);
_sensorsComponent = new SensorsComponent(_vehicle, this);
Q_CHECK_PTR(_sensorsComponent);
_sensorsComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
_powerComponent = new PowerComponent(_vehicle->uas(), this);
_powerComponent = new PowerComponent(_vehicle, this);
Q_CHECK_PTR(_powerComponent);
_powerComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
_safetyComponent = new SafetyComponent(_vehicle->uas(), this);
_safetyComponent = new SafetyComponent(_vehicle, this);
Q_CHECK_PTR(_safetyComponent);
_safetyComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));
......
......@@ -28,10 +28,10 @@
#include "Fact.h"
#include "AutoPilotPlugin.h"
PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(uas, autopilot, parent)
PX4Component::PX4Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent)
{
Q_ASSERT(uas);
Q_ASSERT(vehicle);
Q_ASSERT(autopilot);
}
......
......@@ -37,7 +37,7 @@ class PX4Component : public VehicleComponent
Q_OBJECT
public:
PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
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.
......
......@@ -28,8 +28,8 @@
#include "QGCQmlWidgetHolder.h"
#include "PX4AutoPilotPlugin.h"
PowerComponent::PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
PowerComponent::PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Power"))
{
}
......
......@@ -35,7 +35,7 @@ class PowerComponent : public PX4Component
Q_OBJECT
public:
PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
PowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -28,8 +28,8 @@
#include "QGCQmlWidgetHolder.h"
#include "PX4AutoPilotPlugin.h"
RadioComponent::RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
RadioComponent::RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Radio"))
{
}
......
......@@ -36,7 +36,7 @@ class RadioComponent : public PX4Component
Q_OBJECT
public:
RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -28,8 +28,8 @@
#include "QGCQmlWidgetHolder.h"
#include "PX4AutoPilotPlugin.h"
SafetyComponent::SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
SafetyComponent::SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Safety"))
{
}
......
......@@ -36,7 +36,7 @@ class SafetyComponent : public PX4Component
Q_OBJECT
public:
SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -31,8 +31,8 @@
// These two list must be kept in sync
SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(vehicle, autopilot, parent),
_name(tr("Sensors"))
{
......@@ -87,11 +87,15 @@ QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const
QStringList triggers;
triggers << "CAL_MAG0_ID" << "CAL_GYRO0_ID" << "CAL_ACC0_ID";
if (_uas->getSystemType() == MAV_TYPE_FIXED_WING ||
_uas->getSystemType() == MAV_TYPE_VTOL_DUOROTOR ||
_uas->getSystemType() == MAV_TYPE_VTOL_QUADROTOR ||
_uas->getSystemType() == MAV_TYPE_VTOL_TILTROTOR) {
triggers << "SENS_DPRES_OFF";
switch (_vehicle->vehicleType()) {
case MAV_TYPE_FIXED_WING:
case MAV_TYPE_VTOL_DUOROTOR:
case MAV_TYPE_VTOL_QUADROTOR:
case MAV_TYPE_VTOL_TILTROTOR:
triggers << "SENS_DPRES_OFF";
break;
default:
break;
}
return triggers;
......@@ -115,13 +119,16 @@ QUrl SensorsComponent::summaryQmlSource(void) const
{
QString summaryQml;
if (_uas->getSystemType() == MAV_TYPE_FIXED_WING ||
_uas->getSystemType() == MAV_TYPE_VTOL_DUOROTOR ||
_uas->getSystemType() == MAV_TYPE_VTOL_QUADROTOR ||
_uas->getSystemType() == MAV_TYPE_VTOL_TILTROTOR) {
summaryQml = "qrc:/qml/SensorsComponentSummaryFixedWing.qml";
} else {
summaryQml = "qrc:/qml/SensorsComponentSummary.qml";
switch (_vehicle->vehicleType()) {
case MAV_TYPE_FIXED_WING:
case MAV_TYPE_VTOL_DUOROTOR:
case MAV_TYPE_VTOL_QUADROTOR:
case MAV_TYPE_VTOL_TILTROTOR:
summaryQml = "qrc:/qml/SensorsComponentSummaryFixedWing.qml";
break;
default:
summaryQml = "qrc:/qml/SensorsComponentSummary.qml";
break;
}
return QUrl::fromUserInput(summaryQml);
......
......@@ -35,7 +35,7 @@ class SensorsComponent : public PX4Component
Q_OBJECT
public:
SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
......
......@@ -445,12 +445,15 @@ void SensorsComponentController::_refreshParams(void)
bool SensorsComponentController::fixedWing(void)
{
UASInterface* uas = _autopilot->vehicle()->uas();
Q_ASSERT(uas);
return uas->getSystemType() == MAV_TYPE_FIXED_WING ||
uas->getSystemType() == MAV_TYPE_VTOL_DUOROTOR ||
uas->getSystemType() == MAV_TYPE_VTOL_QUADROTOR ||
uas->getSystemType() == MAV_TYPE_VTOL_TILTROTOR;
switch (_vehicle->vehicleType()) {
case MAV_TYPE_FIXED_WING:
case MAV_TYPE_VTOL_DUOROTOR:
case MAV_TYPE_VTOL_QUADROTOR:
case MAV_TYPE_VTOL_TILTROTOR:
return true;
default:
return false;
}
}
void SensorsComponentController::_updateAndEmitShowOrientationCalArea(bool show)
......
......@@ -708,9 +708,9 @@ QString ParameterLoader::readParametersFromStream(QTextStream& stream)
return errors;
}
void ParameterLoader::writeParametersToStream(QTextStream &stream, const QString& name)
void ParameterLoader::writeParametersToStream(QTextStream &stream)
{
stream << "# Onboard parameters for system " << name << "\n";
stream << "# Onboard parameters for vehicle " << _vehicle->id() << "\n";
stream << "#\n";
stream << "# MAV ID COMPONENT ID PARAM NAME VALUE (FLOAT)\n";
......
......@@ -85,7 +85,7 @@ public:
/// Returns error messages from loading
QString readParametersFromStream(QTextStream& stream);
void writeParametersToStream(QTextStream &stream, const QString& name);
void writeParametersToStream(QTextStream &stream);
signals:
/// Signalled when the full set of facts are ready
......
......@@ -97,6 +97,8 @@ void APMParameterMetaData::_loadParameterFactMetaData(void)
/// Override from FactLoad which connects the meta data to the fact
void APMParameterMetaData::addMetaDataToFact(Fact* fact)
{
_loadParameterFactMetaData();
// FIXME: Will need to switch here based on _vehicle->firmwareType() to pull right set of meta data
FactMetaData* metaData = new FactMetaData(fact->type(), fact);
......
......@@ -27,9 +27,8 @@
#include "ArduCopterFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin)
APMCopterMode::APMCopterMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
APMCopterMode::APMCopterMode(uint32_t mode, bool settable) :
APMCustomMode(mode, settable)
{
QMap<uint32_t,QString> enumToString;
enumToString.insert(STABILIZE, "Stabilize");
......
......@@ -61,16 +61,9 @@ public:
class ArduCopterFirmwarePlugin : public APMFirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(ArduCopterFirmwarePlugin, ArduCopterFirmwarePlugin)
public:
protected:
/// All access to singleton is through instance()
ArduCopterFirmwarePlugin(void);
private:
};
#endif
......@@ -27,9 +27,8 @@
#include "ArduPlaneFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(ArduPlaneFirmwarePlugin, ArduPlaneFirmwarePlugin)
APMPlaneMode::APMPlaneMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
APMPlaneMode::APMPlaneMode(uint32_t mode, bool settable)
: APMCustomMode(mode, settable)
{
QMap<uint32_t,QString> enumToString;
enumToString.insert(MANUAL, "Manual");
......
......@@ -59,16 +59,9 @@ public:
class ArduPlaneFirmwarePlugin : public APMFirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(ArduPlaneFirmwarePlugin, ArduPlaneFirmwarePlugin)
public:
protected:
/// All access to singleton is through instance()
ArduPlaneFirmwarePlugin(void);
private:
};
#endif
......@@ -27,9 +27,8 @@
#include "ArduRoverFirmwarePlugin.h"
#include "Generic/GenericFirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(ArduRoverFirmwarePlugin, ArduRoverFirmwarePlugin)
APMRoverMode::APMRoverMode(uint32_t mode, bool settable) : APMCustomMode(mode, settable)
APMRoverMode::APMRoverMode(uint32_t mode, bool settable)
: APMCustomMode(mode, settable)
{
QMap<uint32_t,QString> enumToString;
enumToString.insert(MANUAL, "Manual");
......
......@@ -59,16 +59,9 @@ public:
class ArduRoverFirmwarePlugin : public APMFirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(ArduRoverFirmwarePlugin, ArduRoverFirmwarePlugin)
public:
protected:
/// All access to singleton is through instance()
ArduRoverFirmwarePlugin(void);
private:
};
#endif
......@@ -27,7 +27,6 @@
#ifndef FirmwarePlugin_H
#define FirmwarePlugin_H
#include "QGCSingleton.h"
#include "QGCMAVLink.h"
#include "VehicleComponent.h"
#include "AutoPilotPlugin.h"
......@@ -46,7 +45,7 @@ class Vehicle;
/// in the base class supports mavlink generic firmware. Override the base clase virtuals
/// to create you firmware specific plugin.
class FirmwarePlugin : public QGCSingleton
class FirmwarePlugin : public QObject
{
Q_OBJECT
......@@ -110,9 +109,6 @@ public:
/// Adds the parameter meta data to the Fact
virtual void addMetaDataToFact(Fact* fact) = 0;
protected:
FirmwarePlugin(void) { };
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
......@@ -31,51 +31,67 @@
#include "APM/ArduRoverFirmwarePlugin.h"
#include "PX4/PX4FirmwarePlugin.h"
FirmwarePluginManager::FirmwarePluginManager(QGCApplication* app)
: QGCTool(app)
, _arduCopterFirmwarePlugin(NULL)
, _arduPlaneFirmwarePlugin(NULL)
, _arduRoverFirmwarePlugin(NULL)
, _genericFirmwarePlugin(NULL)
, _px4FirmwarePlugin(NULL)
{
}
FirmwarePluginManager::~FirmwarePluginManager()
{
delete _arduCopterFirmwarePlugin;
delete _arduPlaneFirmwarePlugin;
delete _arduRoverFirmwarePlugin;
delete _genericFirmwarePlugin;
delete _px4FirmwarePlugin;
}
FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType)
{
switch (autopilotType) {
case MAV_AUTOPILOT_ARDUPILOTMEGA:
switch (vehicleType) {
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
return ArduCopterFirmwarePlugin::instance();
break;
case MAV_TYPE_FIXED_WING:
return ArduPlaneFirmwarePlugin::instance();
break;
case MAV_TYPE_GROUND_ROVER:
case MAV_TYPE_SURFACE_BOAT:
case MAV_TYPE_SUBMARINE:
return ArduRoverFirmwarePlugin::instance();
break;
case MAV_TYPE_GENERIC:
case MAV_TYPE_ANTENNA_TRACKER:
case MAV_TYPE_GCS:
case MAV_TYPE_AIRSHIP:
case MAV_TYPE_FREE_BALLOON:
case MAV_TYPE_ROCKET:
case MAV_TYPE_FLAPPING_WING:
case MAV_TYPE_KITE:
case MAV_TYPE_ONBOARD_CONTROLLER:
case MAV_TYPE_VTOL_DUOROTOR:
case MAV_TYPE_VTOL_QUADROTOR:
case MAV_TYPE_VTOL_TILTROTOR:
case MAV_TYPE_VTOL_RESERVED2:
case MAV_TYPE_VTOL_RESERVED3:
case MAV_TYPE_VTOL_RESERVED4:
case MAV_TYPE_VTOL_RESERVED5:
case MAV_TYPE_GIMBAL:
default:
return GenericFirmwarePlugin::instance();
break;
case MAV_AUTOPILOT_ARDUPILOTMEGA:
switch (vehicleType) {
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
if (!_arduCopterFirmwarePlugin) {
_arduCopterFirmwarePlugin = new ArduCopterFirmwarePlugin;
}
return _arduCopterFirmwarePlugin;
case MAV_TYPE_FIXED_WING:
if (!_arduPlaneFirmwarePlugin) {
_arduPlaneFirmwarePlugin = new ArduPlaneFirmwarePlugin;
}
case MAV_AUTOPILOT_PX4:
return PX4FirmwarePlugin::instance();
return _arduPlaneFirmwarePlugin;
case MAV_TYPE_GROUND_ROVER:
case MAV_TYPE_SURFACE_BOAT:
case MAV_TYPE_SUBMARINE:
if (!_arduRoverFirmwarePlugin) {
_arduRoverFirmwarePlugin = new ArduRoverFirmwarePlugin;
}
return _arduRoverFirmwarePlugin;
default:
return GenericFirmwarePlugin::instance();
break;
}
case MAV_AUTOPILOT_PX4:
if (!_px4FirmwarePlugin) {
_px4FirmwarePlugin = new PX4FirmwarePlugin;
}
return _px4FirmwarePlugin;
default:
break;
}
if (!_genericFirmwarePlugin) {
_genericFirmwarePlugin = new GenericFirmwarePlugin;
}
return _genericFirmwarePlugin;
}
......@@ -34,6 +34,11 @@
#include "QGCToolbox.h"
class QGCApplication;
class ArduCopterFirmwarePlugin;
class ArduPlaneFirmwarePlugin;
class ArduRoverFirmwarePlugin;
class PX4FirmwarePlugin;
class GenericFirmwarePlugin;
/// FirmwarePluginManager is a singleton which is used to return the correct FirmwarePlugin for a MAV_AUTOPILOT type.
......@@ -42,13 +47,21 @@ class FirmwarePluginManager : public QGCTool
Q_OBJECT
public:
FirmwarePluginManager(QGCApplication* app) : QGCTool(app) { }
FirmwarePluginManager(QGCApplication* app);
~FirmwarePluginManager();
/// Returns appropriate plugin for autopilot type.
/// @param autopilotType Type of autopilot to return plugin for.
/// @param vehicleType Vehicle type of autopilot to return plugin for.
/// @return Singleton FirmwarePlugin instance for the specified MAV_AUTOPILOT.
FirmwarePlugin* firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType);
private:
ArduCopterFirmwarePlugin* _arduCopterFirmwarePlugin;
ArduPlaneFirmwarePlugin* _arduPlaneFirmwarePlugin;
ArduRoverFirmwarePlugin* _arduRoverFirmwarePlugin;
GenericFirmwarePlugin* _genericFirmwarePlugin;
PX4FirmwarePlugin* _px4FirmwarePlugin;
};
#endif
......@@ -29,13 +29,6 @@
#include <QDebug>
IMPLEMENT_QGC_SINGLETON(GenericFirmwarePlugin, FirmwarePlugin)
GenericFirmwarePlugin::GenericFirmwarePlugin(void)
{
}
QList<VehicleComponent*> GenericFirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle)
{
Q_UNUSED(vehicle);
......
......@@ -32,8 +32,6 @@
class GenericFirmwarePlugin : public FirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(GenericFirmwarePlugin, FirmwarePlugin)
public:
// Overrides from FirmwarePlugin
......@@ -49,9 +47,6 @@ public:
virtual bool sendHomePositionToVehicle(void);
virtual void addMetaDataToFact(Fact* fact);
virtual QString getDefaultComponentIdParam(void) const { return QString(); }
private:
GenericFirmwarePlugin(void);
};
#endif
......@@ -29,8 +29,6 @@
#include <QDebug>
IMPLEMENT_QGC_SINGLETON(PX4FirmwarePlugin, FirmwarePlugin)
enum PX4_CUSTOM_MAIN_MODE {
PX4_CUSTOM_MAIN_MODE_MANUAL = 1,
PX4_CUSTOM_MAIN_MODE_ALTCTL,
......@@ -88,11 +86,6 @@ static const struct Modes2Name rgModes2Name[] = {
};
PX4FirmwarePlugin::PX4FirmwarePlugin(void)
{
}
QList<VehicleComponent*> PX4FirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle)
{
Q_UNUSED(vehicle);
......
......@@ -34,11 +34,8 @@ class PX4FirmwarePlugin : public FirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(PX4FirmwarePlugin, FirmwarePlugin)
public:
// Overrides from FirmwarePlugin
virtual bool isCapable(FirmwareCapabilities capabilities);
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle);
virtual QStringList flightModes(void);
......@@ -52,9 +49,6 @@ public:
virtual QString getDefaultComponentIdParam(void) const { return QString("SYS_AUTOSTART"); }
private:
/// All access to singleton is through AutoPilotPluginManager::instance
PX4FirmwarePlugin(void);
PX4ParameterMetaData _parameterMetaData;
};
......
......@@ -347,6 +347,7 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
/// Override from FactLoad which connects the meta data to the fact
void PX4ParameterMetaData::addMetaDataToFact(Fact* fact)
{
_loadParameterFactMetaData();
if (_mapParameterName2FactMetaData.contains(fact->name())) {
fact->setMetaData(_mapParameterName2FactMetaData[fact->name()]);
} else {
......
......@@ -85,11 +85,6 @@ Item {
FlightDisplayViewController { id: _controller }
MissionController {
id: _missionController
Component.onCompleted: start(false /* editMode */)
}
function reloadContents() {
if(_flightVideo) {
_flightVideo.visible = false
......
......@@ -54,6 +54,11 @@ FlightMap {
}
}
MissionController {
id: _missionController
Component.onCompleted: start(false /* editMode */)
}
// Home position
MissionItemIndicator {
label: "H"
......
......@@ -117,62 +117,7 @@ void HomePositionManager::_loadSettings(void)
if (_homePositions.count() == 0) {
_homePositions.append(new HomePosition("ETH Campus", QGeoCoordinate(47.3769, 8.549444, 470.0), this));
}
// Deprecated settings for old editor
settings.beginGroup("QGC_UASMANAGER");
bool changed = setHomePosition(settings.value("HOMELAT", homeLat).toDouble(),
settings.value("HOMELON", homeLon).toDouble(),
settings.value("HOMEALT", homeAlt).toDouble());
// Make sure to fire the change - this will
// make sure widgets get the signal once
if (!changed)
{
emit homePositionChanged(homeLat, homeLon, homeAlt);
}
settings.endGroup();
}
bool HomePositionManager::setHomePosition(double lat, double lon, double alt)
{
// Checking for NaN and infitiny
// and checking for borders
bool changed = false;
if (!isnan(lat) && !isnan(lon) && !isnan(alt)
&& !isinf(lat) && !isinf(lon) && !isinf(alt)
&& lat <= 90.0 && lat >= -90.0 && lon <= 180.0 && lon >= -180.0)
{
if (fabs(homeLat - lat) > 1e-7) changed = true;
if (fabs(homeLon - lon) > 1e-7) changed = true;
if (fabs(homeAlt - alt) > 0.5f) changed = true;
if (changed)
{
homeLat = lat;
homeLon = lon;
homeAlt = alt;
emit homePositionChanged(homeLat, homeLon, homeAlt);
}
}
return changed;
}
bool HomePositionManager::setHomePositionAndNotify(double lat, double lon, double alt)
{
// Checking for NaN and infitiny
// and checking for borders
bool changed = setHomePosition(lat, lon, alt);
if (changed) {
qgcApp()->toolbox()->multiVehicleManager()->setHomePositionForAllVehicles(homeLat, homeLon, homeAlt);
}
return changed;
}
}
void HomePositionManager::updateHomePosition(const QString& name, const QGeoCoordinate& coordinate)
......
......@@ -112,21 +112,6 @@ public:
return homeAlt;
}
public slots:
// Deprecated methods
/** @brief Set the current home position, but do not change it on the UAVs */
bool setHomePosition(double lat, double lon, double alt);
/** @brief Set the current home position on all UAVs*/
bool setHomePositionAndNotify(double lat, double lon, double alt);
signals:
/** @brief Current home position changed */
void homePositionChanged(double lat, double lon, double alt);
protected:
double homeLat;
double homeLon;
......
......@@ -49,7 +49,6 @@
#include "QGCMessageBox.h"
#include "MainWindow.h"
#include "UDPLink.h"
#include "QGCSingleton.h"
#include "LinkManager.h"
#include "HomePositionManager.h"
#include "UASMessageHandler.h"
......@@ -322,7 +321,11 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
QGCApplication::~QGCApplication()
{
_destroySingletons();
MainWindow* mainWindow = MainWindow::instance();
if (mainWindow) {
delete mainWindow;
}
shutdownVideoStreaming();
delete _toolbox;
}
......@@ -433,8 +436,6 @@ bool QGCApplication::_initForNormalAppBoot(void)
{
QSettings settings;
_createSingletons();
#ifdef __mobile__
_styleIsDark = false;
#else
......@@ -573,37 +574,6 @@ QGCApplication* qgcApp(void)
return QGCApplication::_app;
}
/// @brief We create all the non-ui based singletons here instead of allowing them to be created randomly
/// by calls to instance. The reason being that depending on boot sequence the singleton may end
/// up being creating on something other than the main thread.
void QGCApplication::_createSingletons(void)
{
// No dependencies
FirmwarePlugin* firmwarePlugin = GenericFirmwarePlugin::_createSingleton();
Q_UNUSED(firmwarePlugin);
Q_ASSERT(firmwarePlugin);
// No dependencies
firmwarePlugin = PX4FirmwarePlugin::_createSingleton();
firmwarePlugin = ArduCopterFirmwarePlugin::_createSingleton();
firmwarePlugin = ArduPlaneFirmwarePlugin::_createSingleton();
firmwarePlugin = ArduRoverFirmwarePlugin::_createSingleton();
}
void QGCApplication::_destroySingletons(void)
{
MainWindow* mainWindow = MainWindow::instance();
if (mainWindow) {
delete mainWindow;
}
GenericFirmwarePlugin::_deleteSingleton();
PX4FirmwarePlugin::_deleteSingleton();
ArduCopterFirmwarePlugin::_deleteSingleton();
ArduPlaneFirmwarePlugin::_deleteSingleton();
ArduRoverFirmwarePlugin::_deleteSingleton();
}
void QGCApplication::informationMessageBoxOnMainThread(const QString& title, const QString& msg)
{
QGCMessageBox::information(title, msg);
......
......@@ -168,8 +168,6 @@ private slots:
void _missingParamsDisplay(void);
private:
void _createSingletons(void);
void _destroySingletons(void);
void _loadCurrentStyle(void);
static const char* _settingsVersionKey; ///< Settings key which hold settings version
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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
/// @brief Base class for global singletons
///
/// @author Don Gagne <don@thegagnes.com>
#include "QGCSingleton.h"
#include "QGCApplication.h"
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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>
#ifndef QGCSINGLETON_H
#define QGCSINGLETON_H
#include <QObject>
#include <QMutex>
/// @def DECLARE_QGC_SINGLETON
/// Include this macro in your Derived Class definition
/// @param className Derived Class name
/// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name.
#define DECLARE_QGC_SINGLETON(className, interfaceName) \
public: \
static interfaceName* instance(bool nullOk = false); \
static void setMockInstance(interfaceName* mock); \
static interfaceName* _createSingleton(void); \
static void _deleteSingleton(void); \
private: \
static interfaceName* _instance; \
static interfaceName* _mockInstance; \
static interfaceName* _realInstance; \
/// @def IMPLEMENT_QGC_SINGLETON
/// Include this macro in your Derived Class implementation
/// @param className Derived Class name
/// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name.
#define IMPLEMENT_QGC_SINGLETON(className, interfaceName) \
interfaceName* className::_instance = NULL; \
interfaceName* className::_mockInstance = NULL; \
interfaceName* className::_realInstance = NULL; \
\
interfaceName* className::_createSingleton(void) \
{ \
Q_ASSERT(_instance == NULL); \
_instance = new className; \
return _instance; \
} \
\
void className::_deleteSingleton(void) \
{ \
if (className::_instance) { \
className* instance = qobject_cast<className*>(className::_instance); \
Q_ASSERT_X(instance != NULL, "QGCSingleton", "If you hit this assert you may have forgotten to clear a Mock instance"); \
className::_instance = NULL; \
delete instance; \
} \
} \
\
interfaceName* className::instance(bool nullOk) \
{ \
if (!nullOk) { \
Q_ASSERT_X(_instance, "QGCSingleton", "Request for singleton that is NULL. If you hit this, then you have likely run into a startup or shutdown sequence bug (possibly intermittent)."); \
} \
return _instance; \
} \
\
void className::setMockInstance(interfaceName* mock) \
{ \
if (mock) { \
Q_ASSERT(_instance); \
Q_ASSERT(!_realInstance); \
\
_realInstance = _instance; \
_instance = dynamic_cast<interfaceName*>(mock); \
Q_ASSERT(_instance); \
_mockInstance = mock; \
} else { \
Q_ASSERT(_instance); \
Q_ASSERT(_realInstance); \
\
_instance = _realInstance; \
_realInstance = NULL; \
_mockInstance = NULL; \
} \
}
class QGCApplication;
class UnitTest;
/// This is the base class for all app global singletons
///
/// All global singletons are created/destroyed at boot time by QGCApplication::_createSingletons and destroyed by QGC::Application::_destroySingletons.
/// This is done in order to make sure they are all created on the main thread. As such no other code other than Unit Test
/// code has access to the constructor/destructor. QGCSingleton supports replacing singletons with a mock implementation.
/// In this case your object must derive from an interface which in turn derives from QGCSingleton. Youu can then use
/// the setMock method to add and remove you mock implementation. See HomePositionManager example usage. In order to provide the
/// appropriate methods to make all this work you need to use the DECLARE_QGC_SINGLETON and IMPLEMENT_QGC_SINGLETON
/// macros as follows:
/// @code{.unparsed}
/// // Header file
///
/// class MySingleton : public QGCSingleton {
/// Q_OBJECT
///
/// DECLARE_QGC_SINGLETON(MySingleton, MySingleton)
///
/// ...
///
/// private:
/// // Constructor/Desctructor private since all access is through the singleton methods
/// MySingleton(QObject* parent == NULL);
/// ~MySingleton();
///
/// ...
/// }
///
/// // Code file
///
/// IMPLEMENT_QGC_SINGLETON(MySingleton, MySingleton)
///
/// MySingleton::MySingleton(QObject* parent) :
/// QGCSigleton(parent)
/// {
/// }
///
/// // Other class methods...
///
/// @endcode
/// The example above does not use an inteface so the second parameter to the macro is the class name as well.
class QGCSingleton : public QObject
{
Q_OBJECT
};
#endif
......@@ -30,6 +30,8 @@
#include "UAS.h"
#include "QGCApplication.h"
QGC_LOGGING_CATEGORY(MultiVehicleManagerLog, "MultiVehicleManagerLog")
MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
: QGCTool(app)
, _activeVehicleAvailable(false)
......@@ -97,6 +99,8 @@ bool MultiVehicleManager::notifyHeartbeatInfo(LinkInterface* link, int vehicleId
/// and all other right things happen when the Vehicle goes away.
void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle)
{
qCDebug(MultiVehicleManagerLog) << "_deleteVehiclePhase1";
_vehicleBeingDeleted = vehicle;
// Remove from map
......@@ -133,6 +137,8 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle)
void MultiVehicleManager::_deleteVehiclePhase2 (void)
{
qCDebug(MultiVehicleManagerLog) << "_deleteVehiclePhase2";
/// Qml has been notified of vehicle about to go away and should be disconnected from it by now.
/// This means we can now clear the active vehicle property and delete the Vehicle for real.
......@@ -157,6 +163,8 @@ void MultiVehicleManager::_deleteVehiclePhase2 (void)
void MultiVehicleManager::setActiveVehicle(Vehicle* vehicle)
{
qCDebug(MultiVehicleManagerLog) << "setActiveVehicle" << vehicle;
if (vehicle != _activeVehicle) {
if (_activeVehicle) {
_activeVehicle->setActive(false);
......@@ -180,6 +188,8 @@ void MultiVehicleManager::setActiveVehicle(Vehicle* vehicle)
void MultiVehicleManager::_setActiveVehiclePhase2(void)
{
qCDebug(MultiVehicleManagerLog) << "_setActiveVehiclePhase2";
// Now we signal the new active vehicle
_activeVehicle = _vehicleBeingSetActive;
emit activeVehicleChanged(_activeVehicle);
......@@ -212,13 +222,6 @@ void MultiVehicleManager::_autopilotParametersReadyChanged(bool parametersReady)
}
}
void MultiVehicleManager::setHomePositionForAllVehicles(double lat, double lon, double alt)
{
for (int i=0; i< _vehicles.count(); i++) {
qobject_cast<Vehicle*>(_vehicles[i])->uas()->setHomePosition(lat, lon, alt);
}
}
void MultiVehicleManager::saveSetting(const QString &name, const QString& value)
{
QSettings settings;
......
......@@ -31,6 +31,7 @@
#include "QGCMAVLink.h"
#include "QmlObjectListModel.h"
#include "QGCToolbox.h"
#include "QGCLoggingCategory.h"
class FirmwarePluginManager;
class AutoPilotPluginManager;
......@@ -38,6 +39,8 @@ class JoystickManager;
class QGCApplication;
class MAVLinkProtocol;
Q_DECLARE_LOGGING_CATEGORY(MultiVehicleManagerLog)
class MultiVehicleManager : public QGCTool
{
Q_OBJECT
......@@ -65,8 +68,6 @@ public:
Q_INVOKABLE Vehicle* getVehicleById(int vehicleId);
void setHomePositionForAllVehicles(double lat, double lon, double alt);
UAS* activeUas(void) { return _activeVehicle ? _activeVehicle->uas() : NULL; }
QList<Vehicle*> vehicles(void);
......
......@@ -90,8 +90,6 @@ Vehicle::Vehicle(LinkInterface* link,
, _batteryPercent(0.0)
, _batteryConsumed(-1.0)
, _currentHeartbeatTimeout(0)
, _waypointDistance(0.0)
, _currentWaypoint(0)
, _satelliteCount(-1)
, _satelliteLock(0)
, _updateCount(0)
......@@ -154,15 +152,12 @@ Vehicle::Vehicle(LinkInterface* link,
connect(_mav, &UASInterface::heartbeatTimeout, this, &Vehicle::_heartbeatTimeout);
connect(_mav, &UASInterface::batteryChanged, this, &Vehicle::_updateBatteryRemaining);
connect(_mav, &UASInterface::batteryConsumedChanged, this, &Vehicle::_updateBatteryConsumedChanged);
connect(_mav, &UASInterface::nameChanged, this, &Vehicle::_updateName);
connect(_mav, &UASInterface::systemTypeSet, this, &Vehicle::_setSystemType);
connect(_mav, &UASInterface::localizationChanged, this, &Vehicle::_setSatLoc);
UAS* pUas = dynamic_cast<UAS*>(_mav);
if(pUas) {
_setSatelliteCount(pUas->getSatelliteCount(), QString(""));
connect(pUas, &UAS::satelliteCountChanged, this, &Vehicle::_setSatelliteCount);
}
_setSystemType(_mav, _mav->getSystemType());
_loadSettings();
......@@ -188,8 +183,6 @@ Vehicle::Vehicle(LinkInterface* link,
Vehicle::~Vehicle()
{
qDebug() << "~Vehicle";
delete _missionManager;
_missionManager = NULL;
......@@ -519,12 +512,6 @@ void Vehicle::_updateNavigationControllerData(UASInterface *uas, float, float, f
* Internal
*/
bool Vehicle::_isAirplane() {
if (_mav)
return _mav->isAirplane();
return false;
}
void Vehicle::_addChange(int id)
{
if(!_changes.contains(id)) {
......@@ -639,86 +626,6 @@ void Vehicle::_updateState(UASInterface*, QString name, QString)
}
}
void Vehicle::_updateName(const QString& name)
{
if (_systemName != name) {
_systemName = name;
emit systemNameChanged();
}
}
/**
* The current system type is represented through the system icon.
*
* @param uas Source system, has to be the same as this->uas
* @param systemType type ID, following the MAVLink system type conventions
* @see http://pixhawk.ethz.ch/software/mavlink
*/
void Vehicle::_setSystemType(UASInterface*, unsigned int systemType)
{
_systemPixmap = "qrc:/res/mavs/";
switch (systemType) {
case MAV_TYPE_GENERIC:
_systemPixmap += "Generic";
break;
case MAV_TYPE_FIXED_WING:
_systemPixmap += "FixedWing";
break;
case MAV_TYPE_QUADROTOR:
_systemPixmap += "QuadRotor";
break;
case MAV_TYPE_COAXIAL:
_systemPixmap += "Coaxial";
break;
case MAV_TYPE_HELICOPTER:
_systemPixmap += "Helicopter";
break;
case MAV_TYPE_ANTENNA_TRACKER:
_systemPixmap += "AntennaTracker";
break;
case MAV_TYPE_GCS:
_systemPixmap += "Groundstation";
break;
case MAV_TYPE_AIRSHIP:
_systemPixmap += "Airship";
break;
case MAV_TYPE_FREE_BALLOON:
_systemPixmap += "FreeBalloon";
break;
case MAV_TYPE_ROCKET:
_systemPixmap += "Rocket";
break;
case MAV_TYPE_GROUND_ROVER:
_systemPixmap += "GroundRover";
break;
case MAV_TYPE_SURFACE_BOAT:
_systemPixmap += "SurfaceBoat";
break;
case MAV_TYPE_SUBMARINE:
_systemPixmap += "Submarine";
break;
case MAV_TYPE_HEXAROTOR:
_systemPixmap += "HexaRotor";
break;
case MAV_TYPE_OCTOROTOR:
_systemPixmap += "OctoRotor";
break;
case MAV_TYPE_TRICOPTER:
_systemPixmap += "TriCopter";
break;
case MAV_TYPE_FLAPPING_WING:
_systemPixmap += "FlappingWing";
break;
case MAV_TYPE_KITE:
_systemPixmap += "Kite";
break;
default:
_systemPixmap += "Unknown";
break;
}
emit systemPixmapChanged();
}
void Vehicle::_heartbeatTimeout(bool timeout, unsigned int ms)
{
unsigned int elapsed = ms;
......@@ -756,39 +663,6 @@ void Vehicle::_setSatLoc(UASInterface*, int fix)
}
}
void Vehicle::_updateWaypointDistance(double distance)
{
if (_waypointDistance != distance) {
_waypointDistance = distance;
emit waypointDistanceChanged();
}
}
void Vehicle::_updateCurrentWaypoint(quint16 id)
{
if (_currentWaypoint != id) {
_currentWaypoint = id;
emit currentWaypointChanged();
}
}
void Vehicle::_updateWaypointViewOnly(int, MissionItem* /*wp*/)
{
/*
bool changed = false;
for(int i = 0; i < _waypoints.count(); i++) {
if(_waypoints[i].sequenceNumber() == wp->sequenceNumber()) {
_waypoints[i] = *wp;
changed = true;
break;
}
}
if(changed) {
emit waypointListChanged();
}
*/
}
void Vehicle::_handleTextMessage(int newCount)
{
// Reset?
......@@ -939,16 +813,25 @@ bool Vehicle::joystickEnabled(void)
void Vehicle::setJoystickEnabled(bool enabled)
{
// The magic parameter will go away,
// until then don't mess with the logic here!
Fact* fact = _autopilotPlugin->getParameterFact(FactSystem::defaultComponentId, "COM_RC_IN_MODE");
if (!fact) {
qCWarning(JoystickLog) << "Missing COM_RC_IN_MODE parameter";
}
if (fact->value().toInt() != 2) {
// Any value greater than one
// indicates special handling on
// the autopilot side. Force the
// joystick to on.
if (fact->value().toInt() > 1) {
// Mandatory in this setting
_joystickEnabled = true;
} else {
fact->setValue(enabled ? 1 : 0);
_joystickEnabled = enabled;
}
_joystickEnabled = enabled;
_startJoystick(_joystickEnabled);
_saveSettings();
}
......@@ -1158,6 +1041,10 @@ void Vehicle::_parametersReady(bool parametersReady)
_missionManagerInitialRequestComplete = true;
_missionManager->requestMissionItems();
}
if (parametersReady) {
setJoystickEnabled(_joystickEnabled);
}
}
void Vehicle::_communicationInactivityTimedOut(void)
......
This diff is collapsed.
......@@ -63,10 +63,6 @@ void SetupViewTest::_clickThrough_test(void)
QTest::qWait(1000);
}
// On MainWindow close we should get a message box telling the user to disconnect first.
setExpectedMessageBox(QGCMessageBox::Yes);
_disconnectMockLink();
_closeMainWindow();
checkExpectedMessageBox();
}
......@@ -27,12 +27,12 @@
#include "VehicleComponent.h"
#include "AutoPilotPlugin.h"
VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent::VehicleComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
QObject(parent),
_uas(uas),
_vehicle(vehicle),
_autopilot(autopilot)
{
Q_ASSERT(uas);
Q_ASSERT(vehicle);
Q_ASSERT(autopilot);
}
......
......@@ -31,7 +31,7 @@
#include <QQmlContext>
#include <QQuickItem>
#include "UASInterface.h"
#include "Vehicle.h"
class AutoPilotPlugin;
......@@ -53,7 +53,7 @@ class VehicleComponent : public QObject
Q_PROPERTY(QString prerequisiteSetup READ prerequisiteSetup)
public:
VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
VehicleComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
~VehicleComponent();
virtual QString name(void) const = 0;
......@@ -73,8 +73,8 @@ signals:
void setupCompleteChanged(bool setupComplete);
protected:
UASInterface* _uas;
AutoPilotPlugin* _autopilot;
Vehicle* _vehicle;
AutoPilotPlugin* _autopilot;
};
#endif
......@@ -198,13 +198,6 @@ void MAVLinkProtocol::_linkStatusChanged(LinkInterface* link, bool connected)
// Use the same shared pointer as LinkManager
_connectedLinks.append(_linkMgr->sharedPointerForLink(link));
#ifndef __mobile__
if (_connectedLinks.count() == 1) {
// This is the first link, we need to start logging
_startLogging();
}
#endif
// Send command to start MAVLink
// XXX hacky but safe
// Start NSH
......@@ -364,6 +357,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
#endif
if (message.msgid == MAVLINK_MSG_ID_HEARTBEAT) {
#ifndef __mobile__
// Start loggin on first heartbeat
_startLogging();
#endif
// Notify the vehicle manager of the heartbeat. This will create/update vehicles as needed.
mavlink_heartbeat_t heartbeat;
mavlink_msg_heartbeat_decode(&message, &heartbeat);
......@@ -657,20 +655,20 @@ bool MAVLinkProtocol::_closeLogFile(void)
void MAVLinkProtocol::_startLogging(void)
{
Q_ASSERT(!_tempLogFile.isOpen());
if (!_tempLogFile.isOpen()) {
if (!_logSuspendReplay) {
if (!_tempLogFile.open()) {
emit protocolStatusMessage(tr("MAVLink Protocol"), tr("Opening Flight Data file for writing failed. "
"Unable to write to %1. Please choose a different file location.").arg(_tempLogFile.fileName()));
_closeLogFile();
_logSuspendError = true;
return;
}
qDebug() << "Temp log" << _tempLogFile.fileName();
if (!_logSuspendReplay) {
if (!_tempLogFile.open()) {
emit protocolStatusMessage(tr("MAVLink Protocol"), tr("Opening Flight Data file for writing failed. "
"Unable to write to %1. Please choose a different file location.").arg(_tempLogFile.fileName()));
_closeLogFile();
_logSuspendError = true;
return;
_logSuspendError = false;
}
qDebug() << "Temp log" << _tempLogFile.fileName();
_logSuspendError = false;
}
}
......
This diff is collapsed.
......@@ -38,18 +38,20 @@ This file is part of the QGROUNDCONTROL project
#include <QUdpSocket>
#include <QTimer>
#include <QProcess>
#include <LinkInterface.h>
#include "LinkInterface.h"
#include "QGCConfig.h"
#include "UASInterface.h"
#include "QGCHilLink.h"
#include <QGCHilFlightGearConfiguration.h>
#include "QGCHilFlightGearConfiguration.h"
#include "Vehicle.h"
class QGCFlightGearLink : public QGCHilLink
{
Q_OBJECT
public:
QGCFlightGearLink(UASInterface* mav, QString startupArguments, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
QGCFlightGearLink(Vehicle* vehicle, QString startupArguments, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
~QGCFlightGearLink();
bool isConnected();
......@@ -135,20 +137,6 @@ public slots:
void processError(QProcess::ProcessError err);
protected:
QString name;
QHostAddress host;
QHostAddress currentHost;
quint16 currentPort;
quint16 port;
int id;
bool connectState;
UASInterface* mav;
unsigned int flightGearVersion;
QString startupArguments;
bool _sensorHilEnabled;
float barometerOffsetkPa;
void setName(QString name);
private slots:
......@@ -158,6 +146,7 @@ private slots:
private:
static bool _findUIArgument(const QStringList& uiArgList, const QString& argLabel, QString& argValue);
Vehicle* _vehicle;
QString _fgProcessName; ///< FlightGear process to start
QString _fgProcessWorkingDirPath; ///< Working directory to start FG process in, empty for none
QStringList _fgArgList; ///< Arguments passed to FlightGear process
......@@ -166,6 +155,19 @@ private:
QProcess* _fgProcess; ///< FlightGear process
QString _fgProtocolFileFullyQualified; ///< Fully qualified file name for protocol file
QString name;
QHostAddress host;
QHostAddress currentHost;
quint16 currentPort;
quint16 port;
int id;
bool connectState;
unsigned int flightGearVersion;
QString startupArguments;
bool _sensorHilEnabled;
float barometerOffsetkPa;
};
#endif // QGCFLIGHTGEARLINK_H
......@@ -41,20 +41,20 @@ This file is part of the QGROUNDCONTROL project
#include "QGC.h"
#include "QGCMessageBox.h"
QGCJSBSimLink::QGCJSBSimLink(UASInterface* mav, QString startupArguments, QString remoteHost, QHostAddress host, quint16 port) :
socket(NULL),
process(NULL),
startupArguments(startupArguments)
QGCJSBSimLink::QGCJSBSimLink(Vehicle* vehicle, QString startupArguments, QString remoteHost, QHostAddress host, quint16 port)
: _vehicle(vehicle)
, socket(NULL)
, process(NULL)
, startupArguments(startupArguments)
{
// We're doing it wrong - because the Qt folks got the API wrong:
// http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
moveToThread(this);
this->host = host;
this->port = port+mav->getUASID();
this->port = port + _vehicle->id();
this->connectState = false;
this->currentPort = 49000+mav->getUASID();
this->mav = mav;
this->currentPort = 49000 + _vehicle->id();
this->name = tr("JSBSim Link (port:%1)").arg(port);
setRemoteHost(remoteHost);
}
......@@ -75,7 +75,7 @@ void QGCJSBSimLink::run()
{
qDebug() << "STARTING FLIGHTGEAR LINK";
if (!mav) return;
if (!_vehicle) return;
socket = new QUdpSocket(this);
socket->moveToThread(this);
connectState = socket->bind(host, port, QAbstractSocket::ReuseAddressHint);
......@@ -84,15 +84,11 @@ void QGCJSBSimLink::run()
process = new QProcess(this);
connect(mav, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8)));
connect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)));
connect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8)));
connect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), _vehicle->uas(), SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)));
UAS* uas = dynamic_cast<UAS*>(mav);
if (uas)
{
uas->startHil();
}
_vehicle->uas()->startHil();
//connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(sendUAVUpdate()));
// Catch process error
......@@ -139,7 +135,7 @@ void QGCJSBSimLink::run()
/*Prepare JSBSim Arguments */
if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
if (_vehicle->vehicleType() == MAV_TYPE_QUADROTOR)
{
arguments << QString("--realtime --suspend --nice --simulation-rate=1000 --logdirectivefile=%s/flightgear.xml --script=%s/%s").arg(rootJSB).arg(rootJSB).arg(script);
}
......@@ -364,8 +360,8 @@ bool QGCJSBSimLink::disconnectSimulation()
{
disconnect(process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(processError(QProcess::ProcessError)));
disconnect(mav, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8)));
disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)));
disconnect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8)));
disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), _vehicle->uas(), SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)));
if (process)
{
......
......@@ -40,8 +40,8 @@ This file is part of the QGROUNDCONTROL project
#include <QProcess>
#include <LinkInterface.h>
#include "QGCConfig.h"
#include "UASInterface.h"
#include "QGCHilLink.h"
#include "Vehicle.h"
class QGCJSBSimLink : public QGCHilLink
{
......@@ -49,7 +49,7 @@ class QGCJSBSimLink : public QGCHilLink
//Q_INTERFACES(QGCJSBSimLinkInterface:LinkInterface)
public:
QGCJSBSimLink(UASInterface* mav, QString startupArguments, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
QGCJSBSimLink(Vehicle* vehicle, QString startupArguments, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress host = QHostAddress::Any, quint16 port = 49005);
~QGCJSBSimLink();
bool isConnected();
......@@ -127,7 +127,8 @@ public slots:
void setStartupArguments(QString startupArguments);
protected:
private:
Vehicle* _vehicle;
QString name;
QHostAddress host;
QHostAddress currentHost;
......@@ -147,7 +148,6 @@ protected:
QMutex statisticsMutex;
QMutex dataMutex;
QTimer refreshTimer;
UASInterface* mav;
QProcess* process;
unsigned int flightGearVersion;
QString startupArguments;
......@@ -155,10 +155,6 @@ protected:
bool _sensorHilEnabled;
void setName(QString name);
signals:
};
#endif // QGCJSBSimLink_H
This diff is collapsed.
......@@ -40,8 +40,8 @@ This file is part of the QGROUNDCONTROL project
#include <QProcess>
#include <LinkInterface.h>
#include "QGCConfig.h"
#include "UASInterface.h"
#include "QGCHilLink.h"
#include "Vehicle.h"
class QGCXPlaneLink : public QGCHilLink
{
......@@ -49,7 +49,7 @@ class QGCXPlaneLink : public QGCHilLink
//Q_INTERFACES(QGCXPlaneLinkInterface:LinkInterface)
public:
QGCXPlaneLink(UASInterface* mav, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress localHost = QHostAddress::Any, quint16 localPort = 49005);
QGCXPlaneLink(Vehicle* vehicle, QString remoteHost=QString("127.0.0.1:49000"), QHostAddress localHost = QHostAddress::Any, quint16 localPort = 49005);
~QGCXPlaneLink();
/**
......@@ -164,7 +164,7 @@ public slots:
void setRandomAttitude();
protected:
UASInterface* mav;
Vehicle* _vehicle;
QString name;
QHostAddress localHost;
quint16 localPort;
......
......@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkProxy>
#include <QNetworkInterface>
#include <iostream>
#include "UDPLink.h"
......@@ -461,8 +462,38 @@ void UDPConfiguration::addHost(const QString& host, int port)
if(ipAdd.isEmpty()) {
qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port;
} else {
_hosts[ipAdd] = port;
//qDebug() << "UDP:" << "Adding Host:" << ipAdd << ":" << port;
// In simulation and testing setups the vehicle and the GCS can be
// running on the same host. This leads to packets arriving through
// the local network or the loopback adapter, which makes it look
// like the vehicle is connected through two different links,
// complicating routing.
//
// We detect this case and force all traffic to a simulated instance
// onto the local loopback interface.
bool not_local = true;
// Run through all IPv4 interfaces and check if their canonical
// IP address in string representation matches the source IP address
foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
if (ipAdd.endsWith(address.toString())) {
// This is a local address of the same host
not_local = false;
}
}
}
if (not_local) {
// This is a normal remote host, add it using its IPv4 address
_hosts[ipAdd] = port;
//qDebug() << "UDP:" << "Adding Host:" << ipAdd << ":" << port;
} else {
// It is localhost, so talk to it through the IPv4 loopback interface
_hosts["127.0.0.1"] = port;
}
}
}
}
......
......@@ -124,10 +124,6 @@ void UnitTest::init(void)
_expectMissedFileDialog = false;
_expectMissedMessageBox = false;
// Each test gets a clean global state
qgcApp()->_destroySingletons();
qgcApp()->_createSingletons();
MAVLinkProtocol::deleteTempLogFiles();
}
......@@ -152,8 +148,6 @@ void UnitTest::cleanup(void)
QEXPECT_FAIL("", "Expecting failure due internal testing", Continue);
}
QCOMPARE(_missedFileDialogCount, 0);
qgcApp()->_destroySingletons();
}
void UnitTest::setExpectedMessageBox(QMessageBox::StandardButton response)
......@@ -423,5 +417,9 @@ void UnitTest::_closeMainWindow(bool cancelExpected)
mainWindowSpy.wait(2000);
QCOMPARE(mainWindowSpy.count(), cancelExpected ? 0 : 1);
// This leaves enough time for any dangling Qml components to get cleaned up.
// This prevents qWarning from bad references in Qml
QTest::qWait(1000);
}
}
This diff is collapsed.
......@@ -71,15 +71,8 @@ public:
/* MANAGEMENT */
/** @brief The name of the robot */
QString getUASName(void) const;
/** @brief Get the unique system id */
int getUASID() const;
/** @brief Get the airframe */
int getAirframe() const
{
return airframe;
}
/** @brief Get the components */
QMap<int, QString> getComponents();
......@@ -88,13 +81,9 @@ public:
/** @brief Add one measurement and get low-passed voltage */
float filterVoltage(float value);
Q_PROPERTY(double localX READ getLocalX WRITE setLocalX NOTIFY localXChanged)
Q_PROPERTY(double localY READ getLocalY WRITE setLocalY NOTIFY localYChanged)
Q_PROPERTY(double localZ READ getLocalZ WRITE setLocalZ NOTIFY localZChanged)
Q_PROPERTY(double latitude READ getLatitude WRITE setLatitude NOTIFY latitudeChanged)
Q_PROPERTY(double longitude READ getLongitude WRITE setLongitude NOTIFY longitudeChanged)
Q_PROPERTY(double satelliteCount READ getSatelliteCount WRITE setSatelliteCount NOTIFY satelliteCountChanged)
Q_PROPERTY(bool isLocalPositionKnown READ localPositionKnown)
Q_PROPERTY(bool isGlobalPositionKnown READ globalPositionKnown)
Q_PROPERTY(double roll READ getRoll WRITE setRoll NOTIFY rollChanged)
Q_PROPERTY(double pitch READ getPitch WRITE setPitch NOTIFY pitchChanged)
......@@ -248,11 +237,6 @@ public:
return satelliteCount;
}
virtual bool localPositionKnown() const
{
return isLocalPositionKnown;
}
virtual bool globalPositionKnown() const
{
return isGlobalPositionKnown;
......@@ -369,9 +353,6 @@ public:
temperature_var = var;
}
bool isRotaryWing();
bool isFixedWing();
friend class FileManager;
protected: //COMMENTS FOR TEST UNIT
......@@ -387,10 +368,6 @@ protected: //COMMENTS FOR TEST UNIT
QTimer statusTimeout; ///< Timer for various status timeouts
/// BASIC UAS TYPE, NAME AND STATE
QString name; ///< Human-friendly name of the vehicle, e.g. bravo
unsigned char type; ///< UAS type (from type enum)
int airframe; ///< The airframe type
int autopilot; ///< Type of the Autopilot: -1: None, 0: Generic, 1: PIXHAWK, 2: SLUGS, 3: Ardupilot (up to 15 types), defined in MAV_AUTOPILOT_TYPE ENUM
uint8_t base_mode; ///< The current mode of the MAV
uint32_t custom_mode; ///< The current mode of the MAV
int status; ///< The current status of the MAV
......@@ -427,7 +404,6 @@ protected: //COMMENTS FOR TEST UNIT
/// POSITION
bool positionLock; ///< Status if position information is available or not
bool isLocalPositionKnown; ///< If the local position has been received for this MAV
bool isGlobalPositionKnown; ///< If the global position has been received for this MAV
double localX;
......@@ -502,8 +478,6 @@ protected: //COMMENTS FOR TEST UNIT
#endif
public:
/** @brief Set the current battery type */
void setBattery(BatteryType type, int cells);
/** @brief Get the current charge level */
float getChargeLevel();
/** @brief Get the human-readable status message for this code */
......@@ -520,34 +494,10 @@ public:
}
#endif
int getSystemType();
bool isAirplane();
QImage getImage();
void requestImage();
int getAutopilotType(){
return autopilot;
}
public slots:
/** @brief Set the autopilot type */
void setAutopilotType(int apType)
{
autopilot = apType;
emit systemSpecsChanged(uasId);
}
/** @brief Set the type of airframe */
void setSystemType(int systemType);
/** @brief Set the specific airframe type */
void setAirframe(int airframe)
{
if((airframe >= QGC_AIRFRAME_GENERIC) && (airframe < QGC_AIRFRAME_END_OF_ENUM))
{
this->airframe = airframe;
emit systemSpecsChanged(uasId);
}
}
/** @brief Executes a command with 7 params */
void executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, float param5, float param6, float param7, int component);
......@@ -620,9 +570,6 @@ public slots:
/** @brief Update the system state */
void updateState();
/** @brief Set world frame origin / home position at this GPS position */
void setHomePosition(double lat, double lon, double alt);
void startCalibration(StartCalibrationType calType);
void stopCalibration(void);
......@@ -686,12 +633,6 @@ protected:
quint64 lastSendTimeSensors; ///< Last HIL Sensors message sent
quint64 lastSendTimeOpticalFlow; ///< Last HIL Optical Flow message sent
protected slots:
/** @brief Write settings to disk */
void writeSettings();
/** @brief Read settings from disk */
void readSettings();
private:
void _say(const QString& text, int severity = 6);
......
......@@ -43,16 +43,6 @@ This file is part of the QGROUNDCONTROL project
class FileManager;
enum BatteryType
{
NICD = 0,
NIMH = 1,
LIION = 2,
LIPOLY = 3,
LIFE = 4,
AGZN = 5
}; ///< The type of battery used
/**
* @brief Interface for all robots.
*
......@@ -67,17 +57,10 @@ public:
/* MANAGEMENT */
/** @brief The name of the robot **/
virtual QString getUASName() const = 0;
virtual int getUASID() const = 0; ///< Get the ID of the connected UAS
/** @brief The time interval the robot is switched on **/
virtual quint64 getUptime() const = 0;
virtual double getLocalX() const = 0;
virtual double getLocalY() const = 0;
virtual double getLocalZ() const = 0;
virtual bool localPositionKnown() const = 0;
virtual double getLatitude() const = 0;
virtual double getLongitude() const = 0;
virtual double getAltitudeAMSL() const = 0;
......@@ -88,30 +71,8 @@ public:
virtual double getPitch() const = 0;
virtual double getYaw() const = 0;
/** @brief Set the airframe of this MAV */
virtual int getAirframe() const = 0;
virtual FileManager* getFileManager() = 0;
enum Airframe {
QGC_AIRFRAME_GENERIC = 0,
QGC_AIRFRAME_EASYSTAR,
QGC_AIRFRAME_TWINSTAR,
QGC_AIRFRAME_MERLIN,
QGC_AIRFRAME_CHEETAH,
QGC_AIRFRAME_MIKROKOPTER,
QGC_AIRFRAME_REAPER,
QGC_AIRFRAME_PREDATOR,
QGC_AIRFRAME_COAXIAL,
QGC_AIRFRAME_PTERYX,
QGC_AIRFRAME_TRICOPTER,
QGC_AIRFRAME_HEXCOPTER,
QGC_AIRFRAME_X8,
QGC_AIRFRAME_VIPER_2_0,
QGC_AIRFRAME_CAMFLYER_Q,
QGC_AIRFRAME_END_OF_ENUM
};
/**
* @brief Get the color for this UAS
*
......@@ -151,15 +112,6 @@ public:
return colors[nextColor];//return the next color
}
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
virtual int getSystemType() = 0;
/** @brief Is it an airplane (or like one)?,..)*/
virtual bool isAirplane() = 0;
/** @brief Get the type of the autopilot (PIXHAWK, APM, UDB, PPZ,..) */
virtual int getAutopilotType() = 0;
virtual void setAutopilotType(int apType) = 0;
virtual QMap<int, QString> getComponents() = 0;
QColor getColor()
......@@ -167,9 +119,6 @@ public:
return color;
}
static const unsigned int WAYPOINT_RADIUS_DEFAULT_FIXED_WING = 25;
static const unsigned int WAYPOINT_RADIUS_DEFAULT_ROTARY_WING = 5;
enum StartCalibrationType {
StartCalibrationRadio,
StartCalibrationGyro,
......@@ -204,18 +153,8 @@ public slots:
/** @brief Executes a command **/
virtual void executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, float param5, float param6, float param7, int component) = 0;
/** @brief Selects the airframe */
virtual void setAirframe(int airframe) = 0;
/** @brief Order the robot to pair its receiver **/
virtual void pairRX(int rxType, int rxSubType) = 0;
virtual void setHomePosition(double lat, double lon, double alt) = 0;
/** @brief Return if this a rotary wing */
virtual bool isRotaryWing() = 0;
/** @brief Return if this is a fixed wing */
virtual bool isFixedWing() = 0;
/** @brief Send the full HIL state to the MAV */
#ifndef __mobile__
......@@ -322,8 +261,6 @@ signals:
void positionSetPointsChanged(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired, quint64 usec);
/** @brief A user (or an autonomous mission or obstacle avoidance planner) requested to set a new setpoint */
void userPositionSetPointsChanged(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired);
void localPositionChanged(UASInterface*, double x, double y, double z, quint64 usec);
void localPositionChanged(UASInterface*, int component, double x, double y, double z, quint64 usec);
void globalPositionChanged(UASInterface*, double lat, double lon, double altAMSL, double altWGS84, quint64 usec);
void altitudeChanged(UASInterface*, double altitudeAMSL, double altitudeWGS84, double altitudeRelative, double climbRate, quint64 usec);
/** @brief Update the status of one satellite used for localization */
......@@ -339,8 +276,6 @@ signals:
void imageStarted(int imgid, int width, int height, int depth, int channels);
void imageDataReceived(int imgid, const unsigned char* imageData, int length, int startIndex);
/** @brief Emit the new system type */
void systemTypeSet(UASInterface* uas, unsigned int type);
/** @brief Attitude control enabled/disabled */
void attitudeControlEnabled(bool enabled);
......
......@@ -60,7 +60,6 @@ This file is part of the QGROUNDCONTROL project
#include "QGCUASFileViewMulti.h"
#include "UASQuickView.h"
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
#include "CustomCommandWidget.h"
#include "QGCDockWidget.h"
#include "UASInfoWidget.h"
......
......@@ -29,6 +29,7 @@
#include "QGCHilFlightGearConfiguration.h"
#include "QGCHilJSBSimConfiguration.h"
#include "QGCHilXPlaneConfiguration.h"
#include "UAS.h"
QGCHilConfiguration::QGCHilConfiguration(Vehicle* vehicle, QWidget *parent)
: QWidget(parent)
......@@ -87,7 +88,7 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
{
// Ensure the sim exists and is disabled
_vehicle->uas()->enableHilFlightGear(false, "", true, this);
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(_vehicle->uas(), this);
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(_vehicle, this);
hfgconf->show();
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(_vehicle->uas()->getHILSimulation());
......@@ -113,17 +114,19 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
connect(xplane, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
}
}
else if (4)
{
// Ensure the sim exists and is disabled
_vehicle->uas()->enableHilJSBSim(false, "");
QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(_vehicle->uas(), this);
hfgconf->show();
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(_vehicle->uas()->getHILSimulation());
if (jsb)
{
connect(jsb, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
}
}
// Disabling JSB Sim since its not well maintained,
// but as refactoring is pending we're not ditching the code yet
// else if (4)
// {
// // Ensure the sim exists and is disabled
// _vehicle->uas()->enableHilJSBSim(false, "");
// QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(_vehicle, this);
// hfgconf->show();
// ui->simulatorConfigurationLayout->addWidget(hfgconf);
// QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(_vehicle->uas()->getHILSimulation());
// if (jsb)
// {
// connect(jsb, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
// }
// }
}
......@@ -52,11 +52,6 @@
<string>X-Plane 9</string>
</property>
</item>
<item>
<property name="text">
<string>JSBSim</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
......@@ -69,7 +64,7 @@
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="statusLabel">
<property name="text">
<string></string>
<string/>
</property>
</widget>
</item>
......
#include "QGCHilFlightGearConfiguration.h"
#include "MainWindow.h"
#include "UAS.h"
#include <QMenu>
......@@ -16,32 +17,30 @@ const char* QGCHilFlightGearConfiguration::_sensorHilKey = "SEN
// the QGCFlightGearLink code instead.
const char* QGCHilFlightGearConfiguration::_defaultOptions = "--roll=0 --pitch=0 --vc=0 --heading=300 --timeofday=noon --disable-hud-3d --disable-fullscreen --geometry=400x300 --disable-anti-alias-hud --wind=0@0 --turbulence=0.0 --disable-sound --disable-random-objects --disable-ai-traffic --shading-flat --fog-disable --disable-specular-highlight --disable-panel --disable-clouds --fdm=jsb --units-meters --enable-terrasync";
QGCHilFlightGearConfiguration::QGCHilFlightGearConfiguration(UAS* mav, QWidget *parent) :
QWidget(parent),
_mav(mav),
_mavSettingsSubGroup(NULL),
_resetOptionsAction(tr("Reset to default options"), this)
QGCHilFlightGearConfiguration::QGCHilFlightGearConfiguration(Vehicle* vehicle, QWidget *parent)
: QWidget(parent)
, _vehicle(vehicle)
, _mavSettingsSubGroup(NULL)
, _resetOptionsAction(tr("Reset to default options"), this)
{
Q_ASSERT(_mav);
_ui.setupUi(this);
QStringList items;
if (_mav->getSystemType() == MAV_TYPE_FIXED_WING)
if (_vehicle->vehicleType() == MAV_TYPE_FIXED_WING)
{
items << "EasyStar";
/*items << "EasyStar";*/
items << "Rascal110-JSBSim";
items << "c172p";
/*items << "c172p";
items << "YardStik";
items << "Malolo1";
items << "Malolo1";*/
_mavSettingsSubGroup = _mavSettingsSubGroupFixedWing;
}
else if (_mav->getSystemType() == MAV_TYPE_QUADROTOR)
/*else if (_vehicle->vehicleType() == MAV_TYPE_QUADROTOR)
{
items << "arducopter";
_mavSettingsSubGroup = _mavSettingsSubGroupQuadRotor;
}
}*/
else
{
// FIXME: Should disable all input, won't work. Show error message in the status label thing.
......@@ -118,12 +117,12 @@ void QGCHilFlightGearConfiguration::on_startButton_clicked()
//XXX check validity of inputs
QString options = _ui.optionsPlainTextEdit->toPlainText();
options.append(" --aircraft=" + _ui.aircraftComboBox->currentText());
_mav->enableHilFlightGear(true, options, _ui.sensorHilCheckBox->isChecked(), this);
_vehicle->uas()->enableHilFlightGear(true, options, _ui.sensorHilCheckBox->isChecked(), this);
}
void QGCHilFlightGearConfiguration::on_stopButton_clicked()
{
_mav->stopHil();
_vehicle->uas()->stopHil();
}
void QGCHilFlightGearConfiguration::on_barometerOffsetLineEdit_textChanged(const QString& baroOffset)
......
......@@ -5,7 +5,7 @@
#include "QGCHilLink.h"
#include "QGCFlightGearLink.h"
#include "UAS.h"
#include "Vehicle.h"
#include "ui_QGCHilFlightGearConfiguration.h"
......@@ -18,7 +18,7 @@ class QGCHilFlightGearConfiguration : public QWidget
Q_OBJECT
public:
explicit QGCHilFlightGearConfiguration(UAS* mav, QWidget *parent = 0);
explicit QGCHilFlightGearConfiguration(Vehicle* vehicle, QWidget *parent = 0);
~QGCHilFlightGearConfiguration();
protected:
......@@ -31,8 +31,8 @@ private slots:
void _showContextMenu(const QPoint& pt);
private:
Vehicle* _vehicle;
Ui::QGCHilFlightGearConfiguration _ui;
UAS* _mav; /// mav associated with this ui
static const char* _settingsGroup; /// Top level settings group
const char* _mavSettingsSubGroup; /// We maintain a settings sub group per mav type
......
......@@ -2,16 +2,17 @@
#include "ui_QGCHilJSBSimConfiguration.h"
#include "MainWindow.h"
#include "UAS.h"
QGCHilJSBSimConfiguration::QGCHilJSBSimConfiguration(UAS* mav,QWidget *parent) :
QWidget(parent),
mav(mav),
ui(new Ui::QGCHilJSBSimConfiguration)
QGCHilJSBSimConfiguration::QGCHilJSBSimConfiguration(Vehicle* vehicle, QWidget *parent)
: QWidget(parent)
, _vehicle(vehicle)
, ui(new Ui::QGCHilJSBSimConfiguration)
{
ui->setupUi(this);
QStringList items = QStringList();
if (mav->getSystemType() == MAV_TYPE_FIXED_WING)
if (_vehicle->vehicleType() == MAV_TYPE_FIXED_WING)
{
items << "EasyStar";
items << "Rascal110-JSBSim";
......@@ -19,7 +20,7 @@ QGCHilJSBSimConfiguration::QGCHilJSBSimConfiguration(UAS* mav,QWidget *parent) :
items << "YardStik";
items << "Malolo1";
}
else if (mav->getSystemType() == MAV_TYPE_QUADROTOR)
else if (_vehicle->vehicleType() == MAV_TYPE_QUADROTOR)
{
items << "arducopter";
}
......@@ -40,10 +41,10 @@ void QGCHilJSBSimConfiguration::on_startButton_clicked()
//XXX check validity of inputs
QString options = ui->optionsPlainTextEdit->toPlainText();
options.append(" --script=" + ui->aircraftComboBox->currentText());
mav->enableHilJSBSim(true, options);
_vehicle->uas()->enableHilJSBSim(true, options);
}
void QGCHilJSBSimConfiguration::on_stopButton_clicked()
{
mav->stopHil();
_vehicle->uas()->stopHil();
}
......@@ -5,7 +5,7 @@
#include "QGCHilLink.h"
#include "QGCFlightGearLink.h"
#include "UAS.h"
#include "Vehicle.h"
namespace Ui {
class QGCHilJSBSimConfiguration;
......@@ -16,17 +16,16 @@ class QGCHilJSBSimConfiguration : public QWidget
Q_OBJECT
public:
explicit QGCHilJSBSimConfiguration(UAS* mav, QWidget *parent = 0);
explicit QGCHilJSBSimConfiguration(Vehicle* vehicle, QWidget *parent = 0);
~QGCHilJSBSimConfiguration();
protected:
UAS* mav;
private slots:
void on_startButton_clicked();
void on_stopButton_clicked();
private:
Vehicle* _vehicle;
Ui::QGCHilJSBSimConfiguration *ui;
};
......
......@@ -65,7 +65,7 @@ QGCMAVLinkInspector::QGCMAVLinkInspector(const QString& title, QAction* action,
void QGCMAVLinkInspector::_vehicleAdded(Vehicle* vehicle)
{
ui->systemComboBox->addItem(vehicle->uas()->getUASName(), vehicle->id());
ui->systemComboBox->addItem(QString("Vehicle %1").arg(vehicle->id()), vehicle->id());
// Add a tree for a new UAS
addUAStoTree(vehicle->id());
......@@ -340,14 +340,7 @@ void QGCMAVLinkInspector::addUAStoTree(int sysId)
{
UASInterface* uas = vehicle->uas();
QStringList idstring;
if (uas->getUASName() == "")
{
idstring << tr("UAS ") + QString::number(uas->getUASID());
}
else
{
idstring << uas->getUASName();
}
idstring << QString("Vehicle %1").arg(uas->getUASID());
QTreeWidgetItem* uasWidget = new QTreeWidgetItem(idstring);
uasWidget->setFirstColumnSpanned(true);
uasTreeWidgetItems.insert(sysId,uasWidget);
......
......@@ -6,12 +6,8 @@ QGCTabbedInfoView::QGCTabbedInfoView(const QString& title, QAction* action, QWid
{
ui.setupUi(this);
messageView = new UASMessageViewWidget(qgcApp()->toolbox()->uasMessageHandler(), this);
//actionsWidget = new UASActionsWidget(this);
quickView = new UASQuickView(this);
//rawView = new UASRawStatusView(this);
ui.tabWidget->addTab(quickView,"Quick");
//ui.tabWidget->addTab(actionsWidget,"Actions");
//ui.tabWidget->addTab(rawView,"Status");
ui.tabWidget->addTab(messageView,"Messages");
loadSettings();
......@@ -19,7 +15,6 @@ QGCTabbedInfoView::QGCTabbedInfoView(const QString& title, QAction* action, QWid
void QGCTabbedInfoView::addSource(MAVLinkDecoder *decoder)
{
m_decoder = decoder;
//rawView->addSource(decoder);
quickView->addSource(decoder);
}
......
......@@ -5,7 +5,6 @@
#include "MAVLinkDecoder.h"
#include "UASMessageView.h"
#include "UASQuickView.h"
#include "UASRawStatusView.h"
#include "ui_QGCTabbedInfoView.h"
......@@ -22,7 +21,6 @@ private:
Ui::QGCTabbedInfoView ui;
UASMessageViewWidget *messageView;
UASQuickView *quickView;
UASRawStatusView *rawView;
};
#endif // QGCTABBEDINFOVIEW_H
#include "UASRawStatusView.h"
#include "MAVLinkDecoder.h"
#include "UASInterface.h"
#include "UAS.h"
#include <QTimer>
#include <QScrollBar>
UASRawStatusView::UASRawStatusView(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
ui.tableWidget->setColumnCount(2);
ui.tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui.tableWidget->setShowGrid(false);
ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
QTimer *timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(updateTableTimerTick()));
// FIXME reinstate once fixed.
//timer->start(2000);
}
void UASRawStatusView::addSource(MAVLinkDecoder *decoder)
{
connect(decoder,SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)),this,SLOT(valueChanged(int,QString,QString,QVariant,quint64)));
}
void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant &variant, const quint64 msec)
{
Q_UNUSED(uasId);
Q_UNUSED(unit);
Q_UNUSED(msec);
bool ok;
double value = variant.toDouble(&ok);
QMetaType::Type type = static_cast<QMetaType::Type>(variant.type());
if(!ok || type == QMetaType::QString || type == QMetaType::QByteArray)
return;
valueMap[name] = value;
if (nameToUpdateWidgetMap.contains(name))
{
nameToUpdateWidgetMap[name]->setText(QString::number(value));
}
else
{
m_tableDirty = true;
}
return;
}
void UASRawStatusView::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
m_tableDirty = true;
}
void UASRawStatusView::updateTableTimerTick()
{
if (m_tableDirty)
{
m_tableDirty = false;
int columncount = 2;
bool good = false;
while (!good)
{
ui.tableWidget->clear();
ui.tableWidget->setRowCount(0);
ui.tableWidget->setColumnCount(columncount);
ui.tableWidget->horizontalHeader()->hide();
ui.tableWidget->verticalHeader()->hide();
int currcolumn = 0;
int currrow = 0;
int totalheight = 2 + ui.tableWidget->horizontalScrollBar()->height();
bool broke = false;
for (QMap<QString,double>::const_iterator i=valueMap.constBegin();i!=valueMap.constEnd();i++)
{
if (ui.tableWidget->rowCount() < currrow+1)
{
ui.tableWidget->setRowCount(currrow+1);
}
ui.tableWidget->setItem(currrow,currcolumn,new QTableWidgetItem(i.key().split(".")[1]));
QTableWidgetItem *item = new QTableWidgetItem(QString::number(i.value()));
nameToUpdateWidgetMap[i.key()] = item;
ui.tableWidget->setItem(currrow,currcolumn+1,item);
ui.tableWidget->resizeRowToContents(currrow);
totalheight += ui.tableWidget->rowHeight(currrow);
currrow++;
if ((totalheight + ui.tableWidget->rowHeight(currrow-1)) > ui.tableWidget->height())
{
currcolumn+=2;
totalheight = 2 + ui.tableWidget->horizontalScrollBar()->height();
currrow = 0;
if (currcolumn >= columncount)
{
//We're over what we can do. Add a column and continue.
columncount+=2;
broke = true;
i = valueMap.constEnd(); // Ensure loop breakout.
break;
}
}
}
if (!broke)
{
good = true;
}
}
ui.tableWidget->resizeColumnsToContents();
//ui.tableWidget->columnCount()-2
}
}
UASRawStatusView::~UASRawStatusView()
{
}
#ifndef UASRAWSTATUSVIEW_H
#define UASRAWSTATUSVIEW_H
#include <QWidget>
#include "MAVLinkDecoder.h"
#include "ui_UASRawStatusView.h"
class UASRawStatusView : public QWidget
{
Q_OBJECT
public:
explicit UASRawStatusView(QWidget *parent = 0);
~UASRawStatusView();
void addSource(MAVLinkDecoder *decoder);
private slots:
void updateTableTimerTick();
void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
protected:
void resizeEvent(QResizeEvent *event);
private:
QMap<QString,double> valueMap;
QMap<QString,QTableWidgetItem*> nameToUpdateWidgetMap;
Ui::UASRawStatusView ui;
bool m_tableDirty;
};
#endif // UASRAWSTATUSVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UASRawStatusView</class>
<widget class="QWidget" name="UASRawStatusView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#!/usr/bin/python
#
# Copyright 2014 Marta Rodriguez.
#
# Licensed under the Apache License, Version 2.0 (the 'License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Uploads an apk to the beta track."""
import argparse
from apiclient.discovery import build
import httplib2
from oauth2client import client
TRACK = 'beta' # Can be 'alpha', beta', 'production' or 'rollout'
SERVICE_ACCOUNT_EMAIL = (
'868554619222-u4gvu4asjemc8n22o595j0fr2dg4012j@developer.gserviceaccount.com')
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('package_name',
help='The package name. Example: com.android.sample')
argparser.add_argument('apk_file',
nargs='?',
default='qgroundcontrol.apk',
help='The path to the APK file to upload.')
def main():
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
f = file('android/Google_Play_Android_Developer-bb93ae7d61ca.p12', 'rb')
key = f.read()
f.close()
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
# is the Email address created for the Service account. It must be the email
# address associated with the key that was created.
credentials = client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/androidpublisher')
http = httplib2.Http()
http = credentials.authorize(http)
service = build('androidpublisher', 'v2', http=http)
# Process flags and read their values.
flags = argparser.parse_args()
package_name = flags.package_name
apk_file = flags.apk_file
try:
edit_request = service.edits().insert(body={}, packageName=package_name)
result = edit_request.execute()
edit_id = result['id']
apk_response = service.edits().apks().upload(
editId=edit_id,
packageName=package_name,
media_body=apk_file).execute()
print 'Version code %d has been uploaded' % apk_response['versionCode']
track_response = service.edits().tracks().update(
editId=edit_id,
track=TRACK,
packageName=package_name,
body={u'versionCodes': [apk_response['versionCode']]}).execute()
print 'Track %s is set for version code(s) %s' % (
track_response['track'], str(track_response['versionCodes']))
commit_request = service.edits().commit(
editId=edit_id, packageName=package_name).execute()
print 'Edit "%s" has been committed' % (commit_request['id'])
except client.AccessTokenRefreshError:
print ('The credentials have been revoked or expired, please re-run the '
'application to re-authorize')
if __name__ == '__main__':
main()
#! /bin/bash
MANIFEST_FILE=android/AndroidManifest.xml
VERSIONCODE=`git rev-list master --first-parent --count`
VERSIONNAME=`git describe --always --tags | sed -e 's/^v//'`
echo "VersionCode: ${VERSIONCODE}"
echo "VersionName: ${VERSIONNAME}"
sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"${VERSIONCODE}\"/" $MANIFEST_FILE
sed -i -e 's/versionName *= *"[^"]*"/versionName="'$VERSIONNAME'"/' $MANIFEST_FILE
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