25 changed files with 1312 additions and 206 deletions
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
/*=====================================================================
|
||||
|
||||
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>
|
||||
|
||||
#include "APMAirframeComponentAirframes.h" |
||||
#include "APMAirframeComponentController.h" |
||||
|
||||
QMap<QString, APMAirframeComponentAirframes::AirframeType_t*> APMAirframeComponentAirframes::rgAirframeTypes; |
||||
|
||||
QMap<QString, APMAirframeComponentAirframes::AirframeType_t*>& APMAirframeComponentAirframes::get() { |
||||
return rgAirframeTypes; |
||||
} |
||||
|
||||
void APMAirframeComponentAirframes::insert(const QString& group, int groupId, const QString& image,const QString& name, const QString& file) |
||||
{ |
||||
AirframeType_t *g; |
||||
if (!rgAirframeTypes.contains(group)) { |
||||
g = new AirframeType_t; |
||||
g->name = group; |
||||
g->type = groupId; |
||||
g->imageResource = QString("qrc:/qmlimages/") + (!image.isEmpty() ? image : QString("AirframeStandardPlane.png")); |
||||
rgAirframeTypes.insert(group, g); |
||||
} else { |
||||
g = rgAirframeTypes.value(group); |
||||
} |
||||
|
||||
if (!name.isEmpty() && !file.isEmpty()) |
||||
g->rgAirframeInfo.append(new APMAirframe(name, file, g->type)); |
||||
} |
||||
|
||||
void APMAirframeComponentAirframes::clear() { |
||||
QList<AirframeType_t*> valueList = get().values(); |
||||
foreach(AirframeType_t *pType, valueList) { |
||||
qDeleteAll(pType->rgAirframeInfo); |
||||
delete pType; |
||||
} |
||||
rgAirframeTypes.clear(); |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 APMAirframeComponentAirframes_H |
||||
#define APMAirframeComponentAirframes_H |
||||
|
||||
#include <QObject> |
||||
#include <QQuickItem> |
||||
#include <QList> |
||||
#include <QMap> |
||||
|
||||
#include "UASInterface.h" |
||||
#include "AutoPilotPlugin.h" |
||||
|
||||
class APMAirframe; |
||||
|
||||
/// MVC Controller for AirframeComponent.qml.
|
||||
class APMAirframeComponentAirframes |
||||
{ |
||||
public: |
||||
typedef struct { |
||||
QString name; |
||||
QString imageResource; |
||||
int type; |
||||
QList<APMAirframe*> rgAirframeInfo; |
||||
} AirframeType_t; |
||||
typedef QMap<QString, AirframeType_t*> AirframeTypeMap; |
||||
|
||||
static AirframeTypeMap& get(); |
||||
static void clear(); |
||||
static void insert(const QString& group, int groupId, const QString& image,const QString& name = QString(), const QString& file = QString()); |
||||
|
||||
protected: |
||||
static AirframeTypeMap rgAirframeTypes; |
||||
|
||||
private: |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,208 @@
@@ -0,0 +1,208 @@
|
||||
/*=====================================================================
|
||||
|
||||
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>
|
||||
|
||||
#include "APMAirframeComponentController.h" |
||||
#include "APMAirframeComponentAirframes.h" |
||||
#include "APMRemoteParamsDownloader.h" |
||||
#include "QGCMAVLink.h" |
||||
#include "MultiVehicleManager.h" |
||||
#include "AutoPilotPluginManager.h" |
||||
#include "QGCApplication.h" |
||||
|
||||
#include <QVariant> |
||||
#include <QQmlProperty> |
||||
|
||||
bool APMAirframeComponentController::_typesRegistered = false; |
||||
|
||||
APMAirframeComponentController::APMAirframeComponentController(void) : |
||||
_airframeTypesModel(new QmlObjectListModel(this)) |
||||
{ |
||||
if (!_typesRegistered) { |
||||
_typesRegistered = true; |
||||
qmlRegisterUncreatableType<APMAirframeType>("QGroundControl.Controllers", 1, 0, "APMAiframeType", "Can only reference APMAirframeType"); |
||||
qmlRegisterUncreatableType<APMAirframe>("QGroundControl.Controllers", 1, 0, "APMAiframe", "Can only reference APMAirframe"); |
||||
} |
||||
_fillAirFrames(); |
||||
|
||||
Fact *frame = getParameterFact(FactSystem::defaultComponentId, "FRAME"); |
||||
connect(frame, &Fact::vehicleUpdated, this, &APMAirframeComponentController::_factFrameChanged); |
||||
_factFrameChanged(frame->rawValue()); |
||||
} |
||||
|
||||
APMAirframeComponentController::~APMAirframeComponentController() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void APMAirframeComponentController::_factFrameChanged(QVariant value) |
||||
{ |
||||
FrameId v = (FrameId) value.toInt(); |
||||
|
||||
for(int i = 0, size = _airframeTypesModel->count(); i < size; i++ ) { |
||||
APMAirframeType *airframeType = qobject_cast<APMAirframeType*>(_airframeTypesModel->get(i)); |
||||
Q_ASSERT(airframeType); |
||||
if (airframeType->type() == v) { |
||||
_currentAirframeType = airframeType; |
||||
break; |
||||
} |
||||
} |
||||
emit currentAirframeTypeChanged(_currentAirframeType); |
||||
} |
||||
|
||||
void APMAirframeComponentController::_fillAirFrames() |
||||
{ |
||||
for (int tindex = 0; tindex < APMAirframeComponentAirframes::get().count(); tindex++) { |
||||
const APMAirframeComponentAirframes::AirframeType_t* pType = APMAirframeComponentAirframes::get().values().at(tindex); |
||||
|
||||
APMAirframeType* airframeType = new APMAirframeType(pType->name, pType->imageResource, pType->type, this); |
||||
Q_CHECK_PTR(airframeType); |
||||
|
||||
for (int index = 0; index < pType->rgAirframeInfo.count(); index++) { |
||||
const APMAirframe* pInfo = pType->rgAirframeInfo.at(index); |
||||
Q_CHECK_PTR(pInfo); |
||||
|
||||
airframeType->addAirframe(pInfo->name(), pInfo->params(), pInfo->type()); |
||||
} |
||||
_airframeTypesModel->append(airframeType); |
||||
} |
||||
|
||||
emit loadAirframesCompleted(); |
||||
} |
||||
|
||||
void APMAirframeComponentController::_finishVehicleSetup() { |
||||
QDir dataLocation = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0) |
||||
+ QDir::separator() + qApp->applicationName(); |
||||
|
||||
QFile parametersFile(dataLocation.absoluteFilePath(_currentAirframe->params())); |
||||
parametersFile.open(QIODevice::ReadOnly); |
||||
|
||||
QTextStream reader(¶metersFile); |
||||
|
||||
while (!reader.atEnd()) { |
||||
QString line = reader.readLine().trimmed(); |
||||
if (line.isEmpty() || line.at(0) == QChar('#')) { |
||||
continue; |
||||
} |
||||
|
||||
QStringList aux = line.split(','); |
||||
if (parameterExists(-1, aux.at(0))) { |
||||
Fact *param = getParameterFact(-1, aux.at(0)); |
||||
param->setRawValue(QVariant::fromValue(aux.at(1))); |
||||
} |
||||
} |
||||
qgcApp()->setOverrideCursor(Qt::ArrowCursor); |
||||
sender()->deleteLater(); |
||||
emit currentAirframeChanged(_currentAirframe); |
||||
} |
||||
|
||||
APMAirframeType::APMAirframeType(const QString& name, const QString& imageResource, int type, QObject* parent) : |
||||
QObject(parent), |
||||
_name(name), |
||||
_imageResource(imageResource), |
||||
_type(type), |
||||
_dirty(false) |
||||
{ |
||||
} |
||||
|
||||
APMAirframeType::~APMAirframeType() |
||||
{ |
||||
} |
||||
|
||||
void APMAirframeType::addAirframe(const QString& name, const QString& file, int type) |
||||
{ |
||||
APMAirframe* airframe = new APMAirframe(name, file, type); |
||||
Q_CHECK_PTR(airframe); |
||||
|
||||
_airframes.append(QVariant::fromValue(airframe)); |
||||
} |
||||
|
||||
APMAirframe::APMAirframe(const QString& name, const QString& paramsFile, int type, QObject* parent) : |
||||
QObject(parent), |
||||
_name(name), |
||||
_paramsFile(paramsFile), |
||||
_type(type) |
||||
{ |
||||
} |
||||
|
||||
QString APMAirframe::name() const |
||||
{ |
||||
return _name; |
||||
} |
||||
|
||||
QString APMAirframe::params() const |
||||
{ |
||||
return _paramsFile; |
||||
} |
||||
|
||||
int APMAirframe::type() const |
||||
{ |
||||
return _type; |
||||
} |
||||
|
||||
APMAirframe::~APMAirframe() |
||||
{ |
||||
} |
||||
|
||||
QString APMAirframeType::imageResource() const |
||||
{ |
||||
return _imageResource; |
||||
} |
||||
|
||||
QString APMAirframeType::name() const |
||||
{ |
||||
return _name; |
||||
} |
||||
|
||||
int APMAirframeType::type() const |
||||
{ |
||||
return _type; |
||||
} |
||||
|
||||
APMAirframeType *APMAirframeComponentController::currentAirframeType() const |
||||
{ |
||||
return _currentAirframeType; |
||||
} |
||||
|
||||
APMAirframe *APMAirframeComponentController::currentAirframe() const |
||||
{ |
||||
return _currentAirframe; |
||||
} |
||||
|
||||
void APMAirframeComponentController::setCurrentAirframe(APMAirframe *t) |
||||
{ |
||||
_currentAirframe = t; |
||||
qgcApp()->setOverrideCursor(Qt::WaitCursor); |
||||
APMRemoteParamsDownloader *paramDownloader = new APMRemoteParamsDownloader(_currentAirframe->params()); |
||||
connect(paramDownloader, &APMRemoteParamsDownloader::finished, this, &APMAirframeComponentController::_finishVehicleSetup); |
||||
} |
||||
|
||||
void APMAirframeComponentController::setCurrentAirframeType(APMAirframeType *t) |
||||
{ |
||||
Fact *param = getParameterFact(-1, "FRAME"); |
||||
Q_ASSERT(param); |
||||
param->setRawValue(t->type()); |
||||
} |
||||
|
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 APMAirframeComponentController_H |
||||
#define APMAirframeComponentController_H |
||||
|
||||
#include <QObject> |
||||
#include <QQuickItem> |
||||
#include <QList> |
||||
#include <QAbstractListModel> |
||||
|
||||
#include "UASInterface.h" |
||||
#include "AutoPilotPlugin.h" |
||||
#include "FactPanelController.h" |
||||
#include "APMAirframeComponentAirframes.h" |
||||
|
||||
class APMAirframeModel; |
||||
class APMAirframeType; |
||||
|
||||
/// MVC Controller for APMAirframeComponent.qml.
|
||||
class APMAirframeComponentController : public FactPanelController |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
enum FrameId{FRAME_TYPE_PLUS = 0, |
||||
FRAME_TYPE_X = 1, |
||||
FRAME_TYPE_V = 2, |
||||
FRAME_TYPE_H = 3, |
||||
FRAME_TYPE_NEWY6 = 10}; |
||||
Q_ENUM(FrameId) |
||||
|
||||
APMAirframeComponentController(void); |
||||
~APMAirframeComponentController(); |
||||
|
||||
Q_PROPERTY(QmlObjectListModel* airframeTypesModel MEMBER _airframeTypesModel CONSTANT) |
||||
Q_PROPERTY(APMAirframeType* currentAirframeType READ currentAirframeType WRITE setCurrentAirframeType NOTIFY currentAirframeTypeChanged) |
||||
Q_PROPERTY(APMAirframe* currentAirframe READ currentAirframe WRITE setCurrentAirframe NOTIFY currentAirframeChanged) |
||||
|
||||
int currentAirframeIndex(void); |
||||
void setCurrentAirframeIndex(int newIndex); |
||||
|
||||
signals: |
||||
void loadAirframesCompleted(); |
||||
void currentAirframeTypeChanged(APMAirframeType* airframeType); |
||||
void currentAirframeChanged(APMAirframe* airframe); |
||||
|
||||
public slots: |
||||
APMAirframeType *currentAirframeType() const; |
||||
APMAirframe *currentAirframe() const; |
||||
void setCurrentAirframeType(APMAirframeType *t); |
||||
void setCurrentAirframe(APMAirframe *t); |
||||
|
||||
private slots: |
||||
void _fillAirFrames(void); |
||||
void _finishVehicleSetup(void); |
||||
void _factFrameChanged(QVariant v); |
||||
|
||||
private: |
||||
static bool _typesRegistered; |
||||
APMAirframeType *_currentAirframeType; |
||||
APMAirframe *_currentAirframe; |
||||
int _waitParamWriteSignalCount; |
||||
QmlObjectListModel *_airframeTypesModel; |
||||
}; |
||||
|
||||
class APMAirframe : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
APMAirframe(const QString& name, const QString& paramsFile, int type, QObject* parent = NULL); |
||||
~APMAirframe(); |
||||
|
||||
Q_PROPERTY(QString name MEMBER _name CONSTANT) |
||||
Q_PROPERTY(int type MEMBER _type CONSTANT) |
||||
Q_PROPERTY(QString params MEMBER _paramsFile CONSTANT) |
||||
|
||||
QString name() const; |
||||
QString params() const; |
||||
int type() const; |
||||
|
||||
private: |
||||
QString _name; |
||||
QString _paramsFile; |
||||
int _type; |
||||
}; |
||||
|
||||
class APMAirframeType : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
APMAirframeType(const QString& name, const QString& imageResource, int type, QObject* parent = NULL); |
||||
~APMAirframeType(); |
||||
|
||||
Q_PROPERTY(QString name MEMBER _name CONSTANT) |
||||
Q_PROPERTY(QString imageResource MEMBER _imageResource CONSTANT) |
||||
Q_PROPERTY(QVariantList airframes MEMBER _airframes CONSTANT) |
||||
Q_PROPERTY(int type MEMBER _type CONSTANT) |
||||
Q_PROPERTY(bool dirty MEMBER _dirty CONSTANT) |
||||
void addAirframe(const QString& name, const QString& paramsFile, int type); |
||||
|
||||
QString name() const; |
||||
QString imageResource() const; |
||||
int type() const; |
||||
private: |
||||
QString _name; |
||||
QString _imageResource; |
||||
QVariantList _airframes; |
||||
int _type; |
||||
bool _dirty; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 "APMAirframeLoader.h" |
||||
#include "QGCApplication.h" |
||||
#include "QGCLoggingCategory.h" |
||||
#include "APMAirframeComponentAirframes.h" |
||||
|
||||
#include <QFile> |
||||
#include <QFileInfo> |
||||
#include <QDir> |
||||
#include <QDebug> |
||||
|
||||
QGC_LOGGING_CATEGORY(APMAirframeLoaderLog, "APMAirframeLoaderLog") |
||||
|
||||
bool APMAirframeLoader::_airframeMetaDataLoaded = false; |
||||
|
||||
APMAirframeLoader::APMAirframeLoader(AutoPilotPlugin* autopilot, UASInterface* uas, QObject* parent) |
||||
{ |
||||
Q_UNUSED(autopilot); |
||||
Q_UNUSED(uas); |
||||
Q_UNUSED(parent); |
||||
Q_ASSERT(uas); |
||||
} |
||||
|
||||
/// Load Airframe Fact meta data
|
||||
void APMAirframeLoader::loadAirframeFactMetaData(void) |
||||
{ |
||||
if (_airframeMetaDataLoaded) { |
||||
return; |
||||
} |
||||
|
||||
qCDebug(APMAirframeLoaderLog) << "Loading APM airframe fact meta data"; |
||||
|
||||
Q_ASSERT(APMAirframeComponentAirframes::get().count() == 0); |
||||
|
||||
QString airframeFilename = ":/AutoPilotPlugins/APM/AirframeFactMetaData.xml"; |
||||
|
||||
qCDebug(APMAirframeLoaderLog) << "Loading meta data file:" << airframeFilename; |
||||
|
||||
QFile xmlFile(airframeFilename); |
||||
Q_ASSERT(xmlFile.exists()); |
||||
|
||||
bool success = xmlFile.open(QIODevice::ReadOnly); |
||||
Q_UNUSED(success); |
||||
Q_ASSERT(success); |
||||
|
||||
QXmlStreamReader xml(xmlFile.readAll()); |
||||
xmlFile.close(); |
||||
if (xml.hasError()) { |
||||
qCWarning(APMAirframeLoaderLog) << "Badly formed XML" << xml.errorString(); |
||||
return; |
||||
} |
||||
|
||||
QString airframeGroup; |
||||
QString image; |
||||
int groupId = 0; |
||||
while (!xml.atEnd()) { |
||||
if (xml.isStartElement()) { |
||||
QString elementName = xml.name().toString(); |
||||
QXmlStreamAttributes attr = xml.attributes(); |
||||
if (elementName == "airframe_group") { |
||||
airframeGroup = attr.value("name").toString(); |
||||
image = attr.value("image").toString(); |
||||
groupId = attr.value("id").toInt(); |
||||
APMAirframeComponentAirframes::insert(airframeGroup, groupId, image); |
||||
} else if (elementName == "airframe") { |
||||
QString name = attr.value("name").toString(); |
||||
QString file = attr.value("file").toString(); |
||||
APMAirframeComponentAirframes::insert(airframeGroup, groupId, image, name, file); |
||||
} |
||||
} |
||||
xml.readNext(); |
||||
} |
||||
|
||||
_airframeMetaDataLoaded = true; |
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
/*=====================================================================
|
||||
|
||||
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/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#ifndef APMAirframeLoader_H |
||||
#define APMAirframeLoader_H |
||||
|
||||
#include <QObject> |
||||
#include <QMap> |
||||
#include <QXmlStreamReader> |
||||
#include <QLoggingCategory> |
||||
|
||||
#include "ParameterLoader.h" |
||||
#include "FactSystem.h" |
||||
#include "UASInterface.h" |
||||
#include "AutoPilotPlugin.h" |
||||
|
||||
/// @file APMAirframeLoader.h
|
||||
/// @author Lorenz Meier <lm@qgroundcontrol.org>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(APMAirframeLoaderLog) |
||||
|
||||
/// Collection of Parameter Facts for PX4 AutoPilot
|
||||
|
||||
class APMAirframeLoader : QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
/// @param uas Uas which this set of facts is associated with
|
||||
APMAirframeLoader(AutoPilotPlugin* autpilot,UASInterface* uas, QObject* parent = NULL); |
||||
|
||||
static void loadAirframeFactMetaData(void); |
||||
|
||||
private: |
||||
static bool _airframeMetaDataLoaded; ///< true: parameter meta data already loaded
|
||||
static QMap<QString, FactMetaData*> _mapParameterName2FactMetaData; ///< Maps from a parameter name to FactMetaData
|
||||
}; |
||||
|
||||
#endif // APMAirframeLoader_H
|
@ -0,0 +1,181 @@
@@ -0,0 +1,181 @@
|
||||
/*=====================================================================
|
||||
|
||||
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/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#include "APMRemoteParamsDownloader.h" |
||||
|
||||
#include <QMessageBox> |
||||
#include <QDesktopServices> |
||||
#include <QFile> |
||||
#include <QFileDialog> |
||||
#include <QNetworkAccessManager> |
||||
#include <QNetworkReply> |
||||
#include <QTimer> |
||||
#include <QJsonDocument> |
||||
#include <QJsonObject> |
||||
#include <QJsonArray> |
||||
#include <QCryptographicHash> |
||||
#include <QApplication> |
||||
|
||||
#include "APMRemoteParamsDownloader.h" |
||||
|
||||
#define FRAME_PARAMS_LIST QUrl("https://api.github.com/repos/diydrones/ardupilot/contents/Tools/Frame_params")
|
||||
#define FRAME_PARAMS_URL "https://raw.github.com/diydrones/ardupilot/master/Tools/Frame_params/"
|
||||
|
||||
static QString dataLocation; |
||||
|
||||
APMRemoteParamsDownloader::APMRemoteParamsDownloader(const QString& file) : |
||||
m_fileToDownload(file), |
||||
m_networkReply(NULL), |
||||
m_downloadedParamFile(NULL) |
||||
{ |
||||
dataLocation = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0) |
||||
+ QDir::separator() + qApp->applicationName(); |
||||
refreshParamList(); |
||||
} |
||||
|
||||
QString APMRemoteParamsDownloader::statusText() const |
||||
{ |
||||
return m_statusText; |
||||
} |
||||
void APMRemoteParamsDownloader::setStatusText(const QString& text) |
||||
{ |
||||
m_statusText = text; |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::refreshParamList() |
||||
{ |
||||
setStatusText(tr("Refresh Param file list")); |
||||
|
||||
QUrl url = FRAME_PARAMS_LIST; |
||||
m_networkReply->deleteLater(); |
||||
m_networkReply = m_networkAccessManager.get(QNetworkRequest(url)); |
||||
connect(m_networkReply, SIGNAL(finished()), this, SLOT(httpParamListFinished())); |
||||
connect(m_networkReply, SIGNAL(downloadProgress(qint64,qint64)), |
||||
this, SLOT(updateDataReadProgress(qint64,qint64))); |
||||
} |
||||
|
||||
/* Returned Json Example
|
||||
"_links": { |
||||
"git":"https://api.github.com/repos/diydrones/ardupilot/git/blobs/a7074e606d695566f9a8c87724ad52e5e3baba7d", |
||||
"html":"https://github.com/diydrones/ardupilot/blob/master/Tools/Frame_params/Parrot_Bebop.param", |
||||
"self":"https://api.github.com/repos/diydrones/ardupilot/contents/Tools/Frame_params/Parrot_Bebop.param?ref=master" |
||||
}, |
||||
"download_url":"https://raw.githubusercontent.com/diydrones/ardupilot/master/Tools/Frame_params/Parrot_Bebop.param", |
||||
"git_url":"https://api.github.com/repos/diydrones/ardupilot/git/blobs/a7074e606d695566f9a8c87724ad52e5e3baba7d", |
||||
"html_url":"https://github.com/diydrones/ardupilot/blob/master/Tools/Frame_params/Parrot_Bebop.param", |
||||
"name":"Parrot_Bebop.param","path":"Tools/Frame_params/Parrot_Bebop.param","" |
||||
"sha":"a7074e606d695566f9a8c87724ad52e5e3baba7d", |
||||
"size":533, |
||||
"type":"file", |
||||
"url":"https://api.github.com/repos/diydrones/ardupilot/contents/Tools/Frame_params/Parrot_Bebop.param?ref=master" |
||||
*/ |
||||
void APMRemoteParamsDownloader::startFileDownloadRequest() |
||||
{ |
||||
QUrl url; |
||||
|
||||
QJsonObject obj; |
||||
|
||||
// Find the correct file from the json file list.
|
||||
while(curr != end) { |
||||
obj = (*curr).toObject(); |
||||
url = QUrl(obj["download_url"].toString()); |
||||
QString name = obj["name"].toString(); |
||||
if (name == m_fileToDownload) { |
||||
break; |
||||
} |
||||
curr++; |
||||
} |
||||
if (curr == end) |
||||
return; |
||||
|
||||
QDir parameterDir(dataLocation); |
||||
if (!parameterDir.exists()) |
||||
parameterDir.mkpath(dataLocation); |
||||
|
||||
QString filename = parameterDir.absoluteFilePath(obj["name"].toString()); |
||||
|
||||
if(m_downloadedParamFile) |
||||
m_downloadedParamFile->deleteLater(); |
||||
m_downloadedParamFile = new QFile(filename); |
||||
m_downloadedParamFile->open(QIODevice::WriteOnly); |
||||
|
||||
m_networkReply = m_networkAccessManager.get(QNetworkRequest(url)); |
||||
connect(m_networkReply, SIGNAL(finished()), this, SLOT(httpFinished())); |
||||
connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); |
||||
connect(m_networkReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDataReadProgress(qint64,qint64))); |
||||
curr++; |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::httpFinished() |
||||
{ |
||||
m_downloadedParamFile->flush(); |
||||
m_downloadedParamFile->close(); |
||||
|
||||
if (m_networkReply->error()) { |
||||
m_downloadedParamFile->remove(); |
||||
setStatusText(tr("Download failed: %1.").arg(m_networkReply->errorString())); |
||||
} |
||||
|
||||
m_networkReply->deleteLater(); |
||||
m_networkReply = NULL; |
||||
delete m_downloadedParamFile; |
||||
m_downloadedParamFile = NULL; |
||||
|
||||
emit finished(); |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::httpReadyRead() |
||||
{ |
||||
if (m_downloadedParamFile) |
||||
m_downloadedParamFile->write(m_networkReply->readAll()); |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes) |
||||
{ |
||||
Q_UNUSED(bytesRead); |
||||
Q_UNUSED(totalBytes); |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::httpParamListFinished() |
||||
{ |
||||
if (m_networkReply->error()) { |
||||
qDebug() << "Download failed:" << m_networkReply->errorString(); |
||||
return; |
||||
} |
||||
processDownloadedVersionObject(m_networkReply->readAll()); |
||||
startFileDownloadRequest(); |
||||
} |
||||
|
||||
void APMRemoteParamsDownloader::processDownloadedVersionObject(const QByteArray &listObject) |
||||
{ |
||||
QJsonParseError jsonErrorChecker; |
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(listObject, &jsonErrorChecker); |
||||
if (jsonErrorChecker.error != QJsonParseError::NoError) { |
||||
qDebug() << "Json error while parsing document:" << jsonErrorChecker.errorString(); |
||||
return; |
||||
} |
||||
|
||||
m_documentArray = jsonDocument.array(); |
||||
curr = m_documentArray.constBegin(); |
||||
end = m_documentArray.constEnd(); |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
#ifndef APMREMOTEPARAMSCONTROLLER_H |
||||
#define APMREMOTEPARAMSCONTROLLER_H |
||||
|
||||
#include <QObject> |
||||
#include <QNetworkAccessManager> |
||||
#include <QUrl> |
||||
#include <QJsonArray> |
||||
|
||||
class QNetworkReply; |
||||
class QFile; |
||||
class QUrl; |
||||
|
||||
class APMRemoteParamsDownloader : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(QString statusText READ statusText) |
||||
public: |
||||
explicit APMRemoteParamsDownloader(const QString& file); |
||||
QString statusText() const; |
||||
public slots: |
||||
void refreshParamList(); |
||||
void httpParamListFinished(); |
||||
void httpFinished(); |
||||
void httpReadyRead(); |
||||
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes); |
||||
private: |
||||
void setStatusText(const QString& text); |
||||
void startFileDownloadRequest(); |
||||
void manualListSetup(); |
||||
void processDownloadedVersionObject(const QByteArray& listObject); |
||||
void startDownloadingRemoteParams(); |
||||
signals: |
||||
void finished(); |
||||
private: |
||||
QString m_fileToDownload; |
||||
QString m_statusText; |
||||
QNetworkAccessManager m_networkAccessManager; |
||||
QNetworkReply* m_networkReply; |
||||
QFile* m_downloadedParamFile; |
||||
|
||||
// the list of needed documents.
|
||||
QJsonArray m_documentArray; |
||||
QJsonArray::const_iterator curr; |
||||
QJsonArray::const_iterator end; |
||||
}; |
||||
|
||||
#endif // APMREMOTEPARAMSCONTROLLER_H
|
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?> |
||||
<airframes> |
||||
<version>1</version> |
||||
<airframe_group image="AirframeQuadRotorPlus.png" name="Plus Style" id="0"> |
||||
<airframe name="3DR Aero M" file="3DR_AERO_M.param"/> |
||||
<airframe name="3DR Aero RTF" file="3DR_Aero_RTF.param"/> |
||||
<airframe name="3DR Rover" file="3DR_Rover.param"/> |
||||
<airframe name="3DR Tarot" file="3DR_Tarot.bgsc"/> |
||||
<airframe name="Parrot Bebop" file="Parrot_Bebop.param"/> |
||||
<airframe name="Storm32" file="SToRM32-MAVLink.param"/> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeQuadRotorX.png" name="X Style" id="1"> |
||||
<airframe name="3DR X8-M RTF" file="3DR_X8-M_RTF.param"/> |
||||
<airframe name="3DR Y6A" file="3DR_Y6A_RTF.param"/> |
||||
<airframe name="3DR X8+ RTF" file="3DR_X8+_RTF.param"/> |
||||
<airframe name="3DR QUAD X4 RTF" file="3DR_QUAD_X4_RTF.param"/> |
||||
<airframe name="3DR X8" file="3DR_X8_RTF.param"/> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeSimulation.png" name="V Style" id="2"> |
||||
<airframe name="Iris with GoPro" file="Iris with Front Mount Go Pro.param"/> |
||||
<airframe name="Iris with Tarot" file="Iris with Tarot Gimbal.param"/> |
||||
<airframe name="3DR Iris+" file="3DR_Iris+.param"/> |
||||
<airframe name="Iris" file="Iris.param"/> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeQuadRotorH.png" name="H Style" id="3"> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeHexaRotorX.png" name="Y6B" id="10"> |
||||
<airframe name="3DR Y6B" file="3DR_Y6B_RTF.param"/> |
||||
</airframe_group> |
||||
<airframes> |
@ -1,148 +1,148 @@
@@ -1,148 +1,148 @@
|
||||
/*=====================================================================
|
||||
|
||||
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>
|
||||
|
||||
#ifndef AUTOPILOTPLUGIN_H |
||||
#define AUTOPILOTPLUGIN_H |
||||
|
||||
#include <QObject> |
||||
#include <QList> |
||||
#include <QString> |
||||
#include <QQmlContext> |
||||
|
||||
#include "VehicleComponent.h" |
||||
#include "FactSystem.h" |
||||
#include "Vehicle.h" |
||||
|
||||
class ParameterLoader; |
||||
class Vehicle; |
||||
class FirmwarePlugin; |
||||
|
||||
/// This is the base class for AutoPilot plugins
|
||||
///
|
||||
/// The AutoPilotPlugin class is an abstract base class which represent the methods and objects
|
||||
/// which are specific to a certain AutoPilot. This is the only place where AutoPilot specific
|
||||
/// code should reside in QGroundControl. The remainder of the QGroundControl source is
|
||||
/// generic to a common mavlink implementation.
|
||||
|
||||
class AutoPilotPlugin : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
AutoPilotPlugin(Vehicle* vehicle, QObject* parent); |
||||
~AutoPilotPlugin(); |
||||
|
||||
/// true: parameters are ready for use
|
||||
Q_PROPERTY(bool parametersReady READ parametersReady NOTIFY parametersReadyChanged) |
||||
|
||||
/// true: parameters are missing from firmware response, false: all parameters received from firmware
|
||||
Q_PROPERTY(bool missingParameters READ missingParameters NOTIFY missingParametersChanged) |
||||
|
||||
/// List of VehicleComponent objects
|
||||
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT) |
||||
|
||||
/// false: One or more vehicle components require setup
|
||||
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged) |
||||
|
||||
/// Reset all parameters to their default values
|
||||
Q_INVOKABLE void resetAllParametersToDefaults(void); |
||||
|
||||
/// Re-request the full set of parameters from the autopilot
|
||||
Q_INVOKABLE void refreshAllParameters(void); |
||||
|
||||
/// Request a refresh on the specific parameter
|
||||
Q_INVOKABLE void refreshParameter(int componentId, const QString& name); |
||||
|
||||
/// Request a refresh on all parameters that begin with the specified prefix
|
||||
Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix); |
||||
|
||||
/// Returns true if the specifed parameter exists from the default component
|
||||
Q_INVOKABLE bool parameterExists(int componentId, const QString& name); |
||||
|
||||
/// Returns all parameter names
|
||||
QStringList parameterNames(int componentId); |
||||
|
||||
/// Returns the specified parameter Fact from the default component
|
||||
/// WARNING: Returns a default Fact if parameter does not exists. If that possibility exists, check for existince first with
|
||||
/// parameterExists.
|
||||
Fact* getParameterFact(int componentId, const QString& name); |
||||
|
||||
/// Writes the parameter facts to the specified stream
|
||||
void writeParametersToStream(QTextStream &stream); |
||||
|
||||
/// Reads the parameters from the stream and updates values
|
||||
/// @return Errors during load. Empty string for no errors
|
||||
QString readParametersFromStream(QTextStream &stream); |
||||
|
||||
/// Returns true if the specifed fact exists
|
||||
Q_INVOKABLE bool factExists(FactSystem::Provider_t provider, ///< fact provider
|
||||
int componentId, ///< fact component, -1=default component
|
||||
const QString& name); ///< fact name
|
||||
|
||||
/// Returns the specified Fact.
|
||||
/// WARNING: Will assert if fact does not exists. If that possibility exists, check for existince first with
|
||||
/// factExists.
|
||||
Fact* getFact(FactSystem::Provider_t provider, ///< fact provider
|
||||
int componentId, ///< fact component, -1=default component
|
||||
const QString& name); ///< fact name
|
||||
|
||||
const QMap<int, QMap<QString, QStringList> >& getGroupMap(void); |
||||
|
||||
// Must be implemented by derived class
|
||||
virtual const QVariantList& vehicleComponents(void) = 0; |
||||
|
||||
// Property accessors
|
||||
bool parametersReady(void) { return _parametersReady; } |
||||
bool missingParameters(void) { return _missingParameters; } |
||||
bool setupComplete(void); |
||||
|
||||
Vehicle* vehicle(void) { return _vehicle; } |
||||
|
||||
signals: |
||||
void parametersReadyChanged(bool parametersReady); |
||||
void missingParametersChanged(bool missingParameters); |
||||
void setupCompleteChanged(bool setupComplete); |
||||
void parameterListProgress(float value); |
||||
|
||||
protected: |
||||
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
|
||||
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { } |
||||
|
||||
Vehicle* _vehicle; |
||||
FirmwarePlugin* _firmwarePlugin; |
||||
bool _parametersReady; |
||||
bool _missingParameters; |
||||
bool _setupComplete; |
||||
|
||||
private slots: |
||||
void _uasDisconnected(void); |
||||
void _parametersReadyChanged(bool parametersReady); |
||||
|
||||
private: |
||||
void _recalcSetupComplete(void);
|
||||
}; |
||||
|
||||
#endif |
||||
/*=====================================================================
|
||||
|
||||
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>
|
||||
|
||||
#ifndef AUTOPILOTPLUGIN_H |
||||
#define AUTOPILOTPLUGIN_H |
||||
|
||||
#include <QObject> |
||||
#include <QList> |
||||
#include <QString> |
||||
#include <QQmlContext> |
||||
|
||||
#include "VehicleComponent.h" |
||||
#include "FactSystem.h" |
||||
#include "Vehicle.h" |
||||
|
||||
class ParameterLoader; |
||||
class Vehicle; |
||||
class FirmwarePlugin; |
||||
|
||||
/// This is the base class for AutoPilot plugins
|
||||
///
|
||||
/// The AutoPilotPlugin class is an abstract base class which represent the methods and objects
|
||||
/// which are specific to a certain AutoPilot. This is the only place where AutoPilot specific
|
||||
/// code should reside in QGroundControl. The remainder of the QGroundControl source is
|
||||
/// generic to a common mavlink implementation.
|
||||
|
||||
class AutoPilotPlugin : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
AutoPilotPlugin(Vehicle* vehicle, QObject* parent); |
||||
~AutoPilotPlugin(); |
||||
|
||||
/// true: parameters are ready for use
|
||||
Q_PROPERTY(bool parametersReady READ parametersReady NOTIFY parametersReadyChanged) |
||||
|
||||
/// true: parameters are missing from firmware response, false: all parameters received from firmware
|
||||
Q_PROPERTY(bool missingParameters READ missingParameters NOTIFY missingParametersChanged) |
||||
|
||||
/// List of VehicleComponent objects
|
||||
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT) |
||||
|
||||
/// false: One or more vehicle components require setup
|
||||
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged) |
||||
|
||||
/// Reset all parameters to their default values
|
||||
Q_INVOKABLE void resetAllParametersToDefaults(void); |
||||
|
||||
/// Re-request the full set of parameters from the autopilot
|
||||
Q_INVOKABLE void refreshAllParameters(void); |
||||
|
||||
/// Request a refresh on the specific parameter
|
||||
Q_INVOKABLE void refreshParameter(int componentId, const QString& name); |
||||
|
||||
/// Request a refresh on all parameters that begin with the specified prefix
|
||||
Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix); |
||||
|
||||
/// Returns true if the specifed parameter exists from the default component
|
||||
Q_INVOKABLE bool parameterExists(int componentId, const QString& name); |
||||
|
||||
/// Returns all parameter names
|
||||
QStringList parameterNames(int componentId); |
||||
|
||||
/// Returns the specified parameter Fact from the default component
|
||||
/// WARNING: Returns a default Fact if parameter does not exists. If that possibility exists, check for existince first with
|
||||
/// parameterExists.
|
||||
Fact* getParameterFact(int componentId, const QString& name); |
||||
|
||||
/// Writes the parameter facts to the specified stream
|
||||
void writeParametersToStream(QTextStream &stream); |
||||
|
||||
/// Reads the parameters from the stream and updates values
|
||||
/// @return Errors during load. Empty string for no errors
|
||||
QString readParametersFromStream(QTextStream &stream); |
||||
|
||||
/// Returns true if the specifed fact exists
|
||||
Q_INVOKABLE bool factExists(FactSystem::Provider_t provider, ///< fact provider
|
||||
int componentId, ///< fact component, -1=default component
|
||||
const QString& name); ///< fact name
|
||||
|
||||
/// Returns the specified Fact.
|
||||
/// WARNING: Will assert if fact does not exists. If that possibility exists, check for existince first with
|
||||
/// factExists.
|
||||
Fact* getFact(FactSystem::Provider_t provider, ///< fact provider
|
||||
int componentId, ///< fact component, -1=default component
|
||||
const QString& name); ///< fact name
|
||||
|
||||
const QMap<int, QMap<QString, QStringList> >& getGroupMap(void); |
||||
|
||||
// Must be implemented by derived class
|
||||
virtual const QVariantList& vehicleComponents(void) = 0; |
||||
|
||||
// Property accessors
|
||||
bool parametersReady(void) { return _parametersReady; } |
||||
bool missingParameters(void) { return _missingParameters; } |
||||
bool setupComplete(void); |
||||
|
||||
Vehicle* vehicle(void) { return _vehicle; } |
||||
|
||||
signals: |
||||
void parametersReadyChanged(bool parametersReady); |
||||
void missingParametersChanged(bool missingParameters); |
||||
void setupCompleteChanged(bool setupComplete); |
||||
void parameterListProgress(float value); |
||||
|
||||
protected: |
||||
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
|
||||
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { } |
||||
|
||||
Vehicle* _vehicle; |
||||
FirmwarePlugin* _firmwarePlugin; |
||||
bool _parametersReady; |
||||
bool _missingParameters; |
||||
bool _setupComplete; |
||||
|
||||
private slots: |
||||
void _uasDisconnected(void); |
||||
void _parametersReadyChanged(bool parametersReady); |
||||
|
||||
private: |
||||
void _recalcSetupComplete(void); |
||||
}; |
||||
|
||||
#endif |
||||
|
Loading…
Reference in new issue