Commit 4b4ece63 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4036 from DonLakeFlyer/OfflineVehicle

Offline vehicle support
parents cbd6c750 a42225cc
......@@ -273,6 +273,8 @@
<file alias="APMParameterFactMetaData.Sub.3.4.xml">src/FirmwarePlugin/APM/APMParameterFactMetaData.Sub.3.4.xml</file>
<file alias="CopterGeoFenceEditor.qml">src/FirmwarePlugin/APM/CopterGeoFenceEditor.qml</file>
<file alias="PlaneGeoFenceEditor.qml">src/FirmwarePlugin/APM/PlaneGeoFenceEditor.qml</file>
<file alias="Copter.OfflineEditing.params">src/FirmwarePlugin/APM/Copter3.4.OfflineEditing.params</file>
<file alias="Plane.OfflineEditing.params">src/FirmwarePlugin/APM/Plane3.7.OfflineEditing.params</file>
</qresource>
<qresource prefix="/FirmwarePlugin">
<file alias="GeoFenceEditor.qml">src/FirmwarePlugin/GeoFenceEditor.qml</file>
......
......@@ -52,7 +52,7 @@ bool APMAirframeComponent::requiresSetup(void) const
bool APMAirframeComponent::setupComplete(void) const
{
if (_requiresFrameSetup) {
return _autopilot->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FRAME"))->rawValue().toInt() >= 0;
return _vehicle->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FRAME"))->rawValue().toInt() >= 0;
} else {
return true;
}
......
......@@ -609,16 +609,15 @@ void APMCompassCal::startCalibration(void)
connect(_calWorkerThread, &CalWorkerThread::vehicleTextMessage, this, &APMCompassCal::vehicleTextMessage);
// Clear the offset parameters so we get raw data
AutoPilotPlugin* plugin = _vehicle->autopilotPlugin();
for (int i=0; i<3; i++) {
_calWorkerThread->rgCompassAvailable[i] = true;
const char* deviceIdParam = CalWorkerThread::rgCompassParams[i][3];
if (plugin->parameterExists(-1, deviceIdParam)) {
_calWorkerThread->rgCompassAvailable[i] = plugin->getParameterFact(-1, deviceIdParam)->rawValue().toInt() > 0;
if (_vehicle->parameterExists(-1, deviceIdParam)) {
_calWorkerThread->rgCompassAvailable[i] = _vehicle->getParameterFact(-1, deviceIdParam)->rawValue().toInt() > 0;
for (int j=0; j<3; j++) {
const char* offsetParam = CalWorkerThread::rgCompassParams[i][j];
Fact* paramFact = plugin->getParameterFact(-1, offsetParam);
Fact* paramFact = _vehicle->getParameterFact(-1, offsetParam);
_rgSavedCompassOffsets[i][j] = paramFact->rawValue().toFloat();
paramFact->setRawValue(0.0);
......@@ -637,12 +636,11 @@ void APMCompassCal::cancelCalibration(void)
_stopCalibration();
// Put the original offsets back
AutoPilotPlugin* plugin = _vehicle->autopilotPlugin();
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
const char* offsetParam = CalWorkerThread::rgCompassParams[i][j];
if (plugin->parameterExists(-1, offsetParam)) {
plugin->getParameterFact(-1, offsetParam)-> setRawValue(_rgSavedCompassOffsets[i][j]);
if (_vehicle->parameterExists(-1, offsetParam)) {
_vehicle->getParameterFact(-1, offsetParam)-> setRawValue(_rgSavedCompassOffsets[i][j]);
}
}
}
......
......@@ -40,7 +40,7 @@ bool APMPowerComponent::requiresSetup(void) const
bool APMPowerComponent::setupComplete(void) const
{
return _autopilot->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("BATT_CAPACITY"))->rawValue().toInt() != 0;
return _vehicle->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("BATT_CAPACITY"))->rawValue().toInt() != 0;
}
QStringList APMPowerComponent::setupCompleteChangedTriggerList(void) const
......
......@@ -19,7 +19,7 @@ APMRadioComponent::APMRadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilo
_mapParams << QStringLiteral("RCMAP_ROLL") << QStringLiteral("RCMAP_PITCH") << QStringLiteral("RCMAP_YAW") << QStringLiteral("RCMAP_THROTTLE");
foreach (const QString& mapParam, _mapParams) {
Fact* fact = _autopilot->getParameterFact(-1, mapParam);
Fact* fact = _vehicle->getParameterFact(-1, mapParam);
connect(fact, &Fact::valueChanged, this, &APMRadioComponent::_triggerChanged);
}
......@@ -56,7 +56,7 @@ bool APMRadioComponent::setupComplete(void) const
// First check for all attitude controls mapped
for (int i=0; i<_mapParams.count(); i++) {
mapValues << _autopilot->getParameterFact(FactSystem::defaultComponentId, _mapParams[i])->rawValue().toInt();
mapValues << _vehicle->getParameterFact(FactSystem::defaultComponentId, _mapParams[i])->rawValue().toInt();
if (mapValues[i] <= 0) {
return false;
}
......@@ -64,14 +64,14 @@ bool APMRadioComponent::setupComplete(void) const
// Next check RC#_MIN/MAX/TRIM all at defaults
foreach (const QString& mapParam, _mapParams) {
int channel = _autopilot->getParameterFact(-1, mapParam)->rawValue().toInt();
if (_autopilot->getParameterFact(-1, QString("RC%1_MIN").arg(channel))->rawValue().toInt() != 1100) {
int channel = _vehicle->getParameterFact(-1, mapParam)->rawValue().toInt();
if (_vehicle->getParameterFact(-1, QString("RC%1_MIN").arg(channel))->rawValue().toInt() != 1100) {
return true;
}
if (_autopilot->getParameterFact(-1, QString("RC%1_MAX").arg(channel))->rawValue().toInt() != 1900) {
if (_vehicle->getParameterFact(-1, QString("RC%1_MAX").arg(channel))->rawValue().toInt() != 1900) {
return true;
}
if (_autopilot->getParameterFact(-1, QString("RC%1_TRIM").arg(channel))->rawValue().toInt() != 1500) {
if (_vehicle->getParameterFact(-1, QString("RC%1_TRIM").arg(channel))->rawValue().toInt() != 1500) {
return true;
}
}
......@@ -116,17 +116,17 @@ void APMRadioComponent::_connectSetupTriggers(void)
// Get the channels for attitude controls and connect to those values for triggers
foreach (const QString& mapParam, _mapParams) {
int channel = _autopilot->getParameterFact(FactSystem::defaultComponentId, mapParam)->rawValue().toInt();
int channel = _vehicle->getParameterFact(FactSystem::defaultComponentId, mapParam)->rawValue().toInt();
Fact* fact = _autopilot->getParameterFact(-1, QString("RC%1_MIN").arg(channel));
Fact* fact = _vehicle->getParameterFact(-1, QString("RC%1_MIN").arg(channel));
_triggerFacts << fact;
connect(fact, &Fact::valueChanged, this, &APMRadioComponent::_triggerChanged);
fact = _autopilot->getParameterFact(-1, QString("RC%1_MAX").arg(channel));
fact = _vehicle->getParameterFact(-1, QString("RC%1_MAX").arg(channel));
_triggerFacts << fact;
connect(fact, &Fact::valueChanged, this, &APMRadioComponent::_triggerChanged);
fact = _autopilot->getParameterFact(-1, QString("RC%1_TRIM").arg(channel));
fact = _vehicle->getParameterFact(-1, QString("RC%1_TRIM").arg(channel));
_triggerFacts << fact;
connect(fact, &Fact::valueChanged, this, &APMRadioComponent::_triggerChanged);
}
......
......@@ -62,7 +62,7 @@ QStringList APMSensorsComponent::setupCompleteChangedTriggerList(void) const
// Accelerometer triggers
triggers << "INS_ACCOFFS_X" << "INS_ACCOFFS_Y" << "INS_ACCOFFS_Z";
if (_autopilot->parameterExists(FactSystem::defaultComponentId, QStringLiteral("INS_USE"))) {
if (_vehicle->parameterExists(FactSystem::defaultComponentId, QStringLiteral("INS_USE"))) {
triggers << QStringLiteral("INS_USE") << QStringLiteral("INS_USE2") << QStringLiteral("INS_USE3");
triggers << QStringLiteral("INS_ACC2OFFS_X") << QStringLiteral("INS_ACC2OFFS_Y") << QStringLiteral("INS_ACC2OFFS_Z");
triggers << QStringLiteral("INS_ACC3OFFS_X") << QStringLiteral("INS_ACC3OFFS_Y") << QStringLiteral("INS_ACC3OFFS_Z");
......@@ -108,10 +108,10 @@ bool APMSensorsComponent::compassSetupNeeded(void) const
rgOffsets[2] << QStringLiteral("COMPASS_OFS3_X") << QStringLiteral("COMPASS_OFS3_Y") << QStringLiteral("COMPASS_OFS3_Z");
for (size_t i=0; i<cCompass; i++) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, rgDevicesIds[i])->rawValue().toInt() != 0 &&
_autopilot->getParameterFact(FactSystem::defaultComponentId, rgCompassUse[i])->rawValue().toInt() != 0) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, rgDevicesIds[i])->rawValue().toInt() != 0 &&
_vehicle->getParameterFact(FactSystem::defaultComponentId, rgCompassUse[i])->rawValue().toInt() != 0) {
for (size_t j=0; j<cOffset; j++) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, rgOffsets[i][j])->rawValue().toFloat() == 0.0f) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, rgOffsets[i][j])->rawValue().toFloat() == 0.0f) {
return true;
}
}
......@@ -133,7 +133,7 @@ bool APMSensorsComponent::accelSetupNeeded(void) const
rgOffsets.clear();
// This parameter is not available in all firmware version. Specifically missing from older Solo firmware.
if (_autopilot->parameterExists(FactSystem::defaultComponentId, QStringLiteral("INS_USE"))) {
if (_vehicle->parameterExists(FactSystem::defaultComponentId, QStringLiteral("INS_USE"))) {
rgUse << QStringLiteral("INS_USE") << QStringLiteral("INS_USE2") << QStringLiteral("INS_USE3");
// We have usage information for the remaining accels, so we can test them sa well
......@@ -147,9 +147,9 @@ bool APMSensorsComponent::accelSetupNeeded(void) const
}
for (int i=0; i<rgAccels.count(); i++) {
if (rgUse.count() == 0 || _autopilot->getParameterFact(FactSystem::defaultComponentId, rgUse[i])->rawValue().toInt() != 0) {
if (rgUse.count() == 0 || _vehicle->getParameterFact(FactSystem::defaultComponentId, rgUse[i])->rawValue().toInt() != 0) {
for (int j=0; j<rgAccels[0].count(); j++) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, rgAccels[i][j])->rawValue().toFloat() == 0.0f) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, rgAccels[i][j])->rawValue().toFloat() == 0.0f) {
return true;
}
}
......
......@@ -60,7 +60,7 @@ QUrl APMTuningComponent::setupSource(void) const
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
// Older firmwares do not have CH9_OPT, we don't support Tuning on older firmwares
if (_autopilot->parameterExists(-1, QStringLiteral("CH9_OPT"))) {
if (_vehicle->parameterExists(-1, QStringLiteral("CH9_OPT"))) {
qmlFile = QStringLiteral("qrc:/qml/APMTuningComponentCopter.qml");
}
break;
......
......@@ -117,16 +117,6 @@ void AutoPilotPlugin::refreshParametersPrefix(int componentId, const QString& na
_vehicle->getParameterLoader()->refreshParametersPrefix(componentId, namePrefix);
}
bool AutoPilotPlugin::parameterExists(int componentId, const QString& name) const
{
return _vehicle->getParameterLoader()->parameterExists(componentId, name);
}
Fact* AutoPilotPlugin::getParameterFact(int componentId, const QString& name)
{
return _vehicle->getParameterLoader()->getFact(componentId, name);
}
bool AutoPilotPlugin::factExists(FactSystem::Provider_t provider, int componentId, const QString& name)
{
switch (provider) {
......
......@@ -7,131 +7,119 @@
*
****************************************************************************/
#ifndef AUTOPILOTPLUGIN_H
#define AUTOPILOTPLUGIN_H
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include <QObject>
#include <QList>
#include <QString>
#include <QQmlContext>
#ifndef AUTOPILOTPLUGIN_H
#define AUTOPILOTPLUGIN_H
#include "VehicleComponent.h"
#include "FactSystem.h"
#include "Vehicle.h"
#include <QObject>
#include <QList>
#include <QString>
#include <QQmlContext>
class ParameterLoader;
class Vehicle;
class FirmwarePlugin;
#include "VehicleComponent.h"
#include "FactSystem.h"
#include "Vehicle.h"
/// 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 ParameterLoader;
class Vehicle;
class FirmwarePlugin;
class AutoPilotPlugin : public QObject
{
Q_OBJECT
/// 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.
public:
AutoPilotPlugin(Vehicle* vehicle, QObject* parent);
~AutoPilotPlugin();
class AutoPilotPlugin : public QObject
{
Q_OBJECT
/// true: parameters are ready for use
Q_PROPERTY(bool parametersReady READ parametersReady NOTIFY parametersReadyChanged)
public:
AutoPilotPlugin(Vehicle* vehicle, QObject* parent);
~AutoPilotPlugin();
/// true: parameters are missing from firmware response, false: all parameters received from firmware
Q_PROPERTY(bool missingParameters READ missingParameters NOTIFY missingParametersChanged)
/// true: parameters are ready for use
Q_PROPERTY(bool parametersReady READ parametersReady NOTIFY parametersReadyChanged)
/// List of VehicleComponent objects
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT)
/// true: parameters are missing from firmware response, false: all parameters received from firmware
Q_PROPERTY(bool missingParameters READ missingParameters NOTIFY missingParametersChanged)
/// false: One or more vehicle components require setup
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged)
/// List of VehicleComponent objects
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT)
/// Reset all parameters to their default values
Q_INVOKABLE void resetAllParametersToDefaults(void);
/// false: One or more vehicle components require setup
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged)
/// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(unsigned char componentID = MAV_COMP_ID_ALL);
/// Reset all parameters to their default values
Q_INVOKABLE void resetAllParametersToDefaults(void);
/// Request a refresh on the specific parameter
Q_INVOKABLE void refreshParameter(int componentId, const QString& name);
/// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(unsigned char componentID = MAV_COMP_ID_ALL);
/// Request a refresh on all parameters that begin with the specified prefix
Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix);
/// Request a refresh on the specific parameter
Q_INVOKABLE void refreshParameter(int componentId, const QString& name);
/// Returns all parameter names
QStringList parameterNames(int componentId);
/// Request a refresh on all parameters that begin with the specified prefix
Q_INVOKABLE void refreshParametersPrefix(int componentId, const QString& namePrefix);
/// Writes the parameter facts to the specified stream
void writeParametersToStream(QTextStream &stream);
/// Returns true if the specifed parameter exists from the default component
Q_INVOKABLE bool parameterExists(int componentId, const QString& name) const;
/// Reads the parameters from the stream and updates values
/// @return Errors during load. Empty string for no errors
QString readParametersFromStream(QTextStream &stream);
/// Returns all parameter names
QStringList parameterNames(int componentId);
/// 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 parameter Fact from the default component
/// WARNING: Returns a default Fact if parameter does not exists. If that possibility exists, check for existence first with
/// parameterExists.
Fact* getParameterFact(int componentId, const QString& name);
/// Returns the specified Fact.
/// WARNING: Will assert if fact does not exists. If that possibility exists, check for existence first with
/// factExists.
Fact* getFact(FactSystem::Provider_t provider, ///< fact provider
int componentId, ///< fact component, -1=default component
const QString& name); ///< fact name
/// Writes the parameter facts to the specified stream
void writeParametersToStream(QTextStream &stream);
const QMap<int, QMap<QString, QStringList> >& getGroupMap(void);
/// Reads the parameters from the stream and updates values
/// @return Errors during load. Empty string for no errors
QString readParametersFromStream(QTextStream &stream);
// Must be implemented by derived class
virtual const QVariantList& vehicleComponents(void) = 0;
/// 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
// Property accessors
bool parametersReady(void) { return _parametersReady; }
bool missingParameters(void) { return _missingParameters; }
bool setupComplete(void);
/// Returns the specified Fact.
/// WARNING: Will assert if fact does not exists. If that possibility exists, check for existence first with
/// factExists.
Fact* getFact(FactSystem::Provider_t provider, ///< fact provider
int componentId, ///< fact component, -1=default component
const QString& name); ///< fact name
Vehicle* vehicle(void) { return _vehicle; }
virtual void _parametersReadyPreChecks(bool parametersReady) = 0;
const QMap<int, QMap<QString, QStringList> >& getGroupMap(void);
signals:
void parametersReadyChanged(bool parametersReady);
void missingParametersChanged(bool missingParameters);
void setupCompleteChanged(bool setupComplete);
void parameterListProgress(float value);
// Must be implemented by derived class
virtual const QVariantList& vehicleComponents(void) = 0;
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }
// Property accessors
bool parametersReady(void) { return _parametersReady; }
bool missingParameters(void) { return _missingParameters; }
bool setupComplete(void);
Vehicle* _vehicle;
FirmwarePlugin* _firmwarePlugin;
bool _parametersReady;
bool _missingParameters;
bool _setupComplete;
Vehicle* vehicle(void) { return _vehicle; }
virtual void _parametersReadyPreChecks(bool parametersReady) = 0;
signals:
void parametersReadyChanged(bool parametersReady);
void missingParametersChanged(bool missingParameters);
void setupCompleteChanged(bool setupComplete);
void parameterListProgress(float value);
private slots:
void _uasDisconnected(void);
void _parametersReadyChanged(bool parametersReady);
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }
private:
void _recalcSetupComplete(void);
};
Vehicle* _vehicle;
FirmwarePlugin* _firmwarePlugin;
bool _parametersReady;
bool _missingParameters;
bool _setupComplete;
private slots:
void _uasDisconnected(void);
void _parametersReadyChanged(bool parametersReady);
private:
void _recalcSetupComplete(void);
};
#endif
#endif
......@@ -129,7 +129,7 @@ bool AirframeComponent::requiresSetup(void) const
bool AirframeComponent::setupComplete(void) const
{
return _autopilot->getParameterFact(FactSystem::defaultComponentId, "SYS_AUTOSTART")->rawValue().toInt() != 0;
return _vehicle->getParameterFact(FactSystem::defaultComponentId, "SYS_AUTOSTART")->rawValue().toInt() != 0;
}
QStringList AirframeComponent::setupCompleteChangedTriggerList(void) const
......
......@@ -43,17 +43,17 @@ QString FlightModesComponent::iconResource(void) const
bool FlightModesComponent::requiresSetup(void) const
{
return _autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
return _vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
}
bool FlightModesComponent::setupComplete(void) const
{
if (_autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
if (_vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
return true;
}
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_MODE_SW")->rawValue().toInt() != 0 ||
(_autopilot->parameterExists(FactSystem::defaultComponentId, "RC_MAP_FLTMODE") && _autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_FLTMODE")->rawValue().toInt() != 0)) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_MODE_SW")->rawValue().toInt() != 0 ||
(_vehicle->parameterExists(FactSystem::defaultComponentId, "RC_MAP_FLTMODE") && _vehicle->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_FLTMODE")->rawValue().toInt() != 0)) {
return true;
}
......@@ -81,7 +81,7 @@ QUrl FlightModesComponent::summaryQmlSource(void) const
QString FlightModesComponent::prerequisiteSetup(void) const
{
if (_autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
if (_vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
// No RC input
return QString();
} else {
......
......@@ -117,8 +117,8 @@ void PX4AutoPilotPlugin::_parametersReadyPreChecks(bool missingParameters)
// Check for older parameter version set
// FIXME: Firmware is moving to version stamp parameter set. Once that is complete the version stamp
// should be used instead.
if (parameterExists(FactSystem::defaultComponentId, "SENS_GYRO_XOFF") ||
parameterExists(FactSystem::defaultComponentId, "COM_DL_LOSS_EN")) {
if (_vehicle->parameterExists(FactSystem::defaultComponentId, "SENS_GYRO_XOFF") ||
_vehicle->parameterExists(FactSystem::defaultComponentId, "COM_DL_LOSS_EN")) {
_incorrectParameterVersion = true;
qgcApp()->showMessage("This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup.");
......
......@@ -35,18 +35,18 @@ QString PX4RadioComponent::iconResource(void) const
bool PX4RadioComponent::requiresSetup(void) const
{
return _autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
return _vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
}
bool PX4RadioComponent::setupComplete(void) const
{
if (_autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
if (_vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
// The best we can do to detect the need for a radio calibration is look for attitude
// controls to be mapped.
QStringList attitudeMappings;
attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
foreach(const QString &mapParam, attitudeMappings) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
return false;
}
}
......@@ -76,7 +76,7 @@ QUrl PX4RadioComponent::summaryQmlSource(void) const
QString PX4RadioComponent::prerequisiteSetup(void) const
{
if (_autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
if (_vehicle->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
PX4AutoPilotPlugin* plugin = dynamic_cast<PX4AutoPilotPlugin*>(_autopilot);
if (!plugin->airframeComponent()->setupComplete()) {
......
......@@ -44,9 +44,9 @@ bool PowerComponent::requiresSetup(void) const
bool PowerComponent::setupComplete(void) const
{
QVariant cvalue, evalue, nvalue;
return _autopilot->getParameterFact(FactSystem::defaultComponentId, "BAT_V_CHARGED")->rawValue().toFloat() != 0.0f &&
_autopilot->getParameterFact(FactSystem::defaultComponentId, "BAT_V_EMPTY")->rawValue().toFloat() != 0.0f &&
_autopilot->getParameterFact(FactSystem::defaultComponentId, "BAT_N_CELLS")->rawValue().toInt() != 0;
return _vehicle->getParameterFact(FactSystem::defaultComponentId, "BAT_V_CHARGED")->rawValue().toFloat() != 0.0f &&
_vehicle->getParameterFact(FactSystem::defaultComponentId, "BAT_V_EMPTY")->rawValue().toFloat() != 0.0f &&
_vehicle->getParameterFact(FactSystem::defaultComponentId, "BAT_N_CELLS")->rawValue().toInt() != 0;
}
QStringList PowerComponent::setupCompleteChangedTriggerList(void) const
......
......@@ -49,14 +49,14 @@ bool SensorsComponent::requiresSetup(void) const
bool SensorsComponent::setupComplete(void) const
{
foreach (const QString &triggerParam, _deviceIds) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, triggerParam)->rawValue().toFloat() == 0.0f) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, triggerParam)->rawValue().toFloat() == 0.0f) {
return false;
}
}
if (_vehicle->fixedWing() || _vehicle->vtol()) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, _airspeedBreaker)->rawValue().toInt() != 162128) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, _airspeedCal)->rawValue().toFloat() == 0.0f) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, _airspeedBreaker)->rawValue().toInt() != 162128) {
if (_vehicle->getParameterFact(FactSystem::defaultComponentId, _airspeedCal)->rawValue().toFloat() == 0.0f) {
return false;
}
}
......
......@@ -306,9 +306,9 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in
// Work out what the autopilot is configured to
int sides = 0;
if (_autopilot->parameterExists(FactSystem::defaultComponentId, "CAL_MAG_SIDES")) {
if (_vehicle->parameterExists(FactSystem::defaultComponentId, "CAL_MAG_SIDES")) {
// Read the requested calibration directions off the system
sides = _autopilot->getParameterFact(FactSystem::defaultComponentId, "CAL_MAG_SIDES")->rawValue().toFloat();
sides = _vehicle->getParameterFact(FactSystem::defaultComponentId, "CAL_MAG_SIDES")->rawValue().toFloat();
} else {
// There is no valid setting, default to all six sides
sides = (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 0);
......
......@@ -31,6 +31,8 @@ FactPanelController::FactPanelController(bool standaloneUnitTesting)
if (_vehicle) {
_uas = _vehicle->uas();
_autopilot = _vehicle->autopilotPlugin();
} else {
_vehicle = qgcApp()->toolbox()->multiVehicleManager()->offlineEditingVehicle();
}
if (!standaloneUnitTesting) {
......@@ -102,7 +104,7 @@ bool FactPanelController::_allParametersExists(int componentId, QStringList name
bool noMissingFacts = true;
foreach (const QString &name, names) {
if (_autopilot && !_autopilot->parameterExists(componentId, name)) {
if (_vehicle && !_vehicle->parameterExists(componentId, name)) {
_reportMissingParameter(componentId, name);
noMissingFacts = false;
}
......@@ -120,8 +122,8 @@ void FactPanelController::_checkForMissingFactPanel(void)
Fact* FactPanelController::getParameterFact(int componentId, const QString& name, bool reportMissing)
{
if (_autopilot && _autopilot->parameterExists(componentId, name)) {
Fact* fact = _autopilot->getParameterFact(componentId, name);
if (_vehicle && _vehicle->parameterExists(componentId, name)) {
Fact* fact = _vehicle->getParameterFact(componentId, name);
QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership);
return fact;
} else {
......@@ -133,7 +135,7 @@ Fact* FactPanelController::getParameterFact(int componentId, const QString& name
bool FactPanelController::parameterExists(int componentId, const QString& name)
{
return _autopilot ? _autopilot->parameterExists(componentId, name) : false;
return _vehicle ? _vehicle->parameterExists(componentId, name) : false;
}
void FactPanelController::_showInternalError(const QString& errorMsg)
......
......@@ -96,7 +96,7 @@ void FactSystemTestBase::_qmlUpdate_test(void)
// Change the value
QVariant paramValue = 12;
_plugin->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_THROTTLE")->setRawValue(paramValue);
qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_THROTTLE")->setRawValue(paramValue);
QTest::qWait(500); // Let the signals flow through
......
......@@ -39,7 +39,7 @@ const char* ParameterLoader::_cachedMetaDataFilePrefix = "ParameterFactMetaData"
ParameterLoader::ParameterLoader(Vehicle* vehicle)
: QObject(vehicle)
, _vehicle(vehicle)
, _mavlink(qgcApp()->toolbox()->mavlinkProtocol())
, _mavlink(NULL)
, _parametersReady(false)
, _initialLoadComplete(false)
, _waitingForDefaultComponent(false)
......@@ -53,8 +53,12 @@ ParameterLoader::ParameterLoader(Vehicle* vehicle)
, _initialRequestRetryCount(0)
, _totalParamCount(0)
{
Q_ASSERT(_vehicle);
Q_ASSERT(_mavlink);
if (_vehicle->isOfflineEditingVehicle()) {
_loadOfflineEditingParams();
return;
}
_mavlink = qgcApp()->toolbox()->mavlinkProtocol();
// We signal this to ouselves in order to start timer on our thread
connect(this, &ParameterLoader::restartWaitingParamTimer, this, &ParameterLoader::_restartWaitingParamTimer);
......@@ -1212,3 +1216,71 @@ QString ParameterLoader::_remapParamNameToVersion(const QString& paramName)
return mappedParamName;
}
/// The offline editing vehicle can have custom loaded params bolted into it.
void ParameterLoader::_loadOfflineEditingParams(void)
{
QString paramFilename = _vehicle->firmwarePlugin()->offlineEditingParamFile(_vehicle);
if (paramFilename.isEmpty()) {
return;
}
QFile paramFile(paramFilename);
if (!paramFile.open(QFile::ReadOnly)) {
qCWarning(ParameterLoaderLog) << "Unable to open offline editing params file" << paramFilename;
}
QTextStream paramStream(&paramFile);
while (!paramStream.atEnd()) {
QString line = paramStream.readLine();
if (line.startsWith("#")) {
continue;
}
QStringList paramData = line.split("\t");
Q_ASSERT(paramData.count() == 5);
_defaultComponentId = paramData.at(1).toInt();
QString paramName = paramData.at(2);
QString valStr = paramData.at(3);
MAV_PARAM_TYPE paramType = static_cast<MAV_PARAM_TYPE>(paramData.at(4).toUInt());
QVariant paramValue;
switch (paramType) {
case MAV_PARAM_TYPE_REAL32:
paramValue = QVariant(valStr.toFloat());
break;
case MAV_PARAM_TYPE_UINT32:
paramValue = QVariant(valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT32:
paramValue = QVariant(valStr.toInt());
break;
case MAV_PARAM_TYPE_UINT16:
paramValue = QVariant((quint16)valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT16:
paramValue = QVariant((qint16)valStr.toInt());
break;
case MAV_PARAM_TYPE_UINT8:
paramValue = QVariant((quint8)valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT8:
paramValue = QVariant((qint8)valStr.toUInt());
break;
default:
qCritical() << "Unknown type" << paramType;
paramValue = QVariant(valStr.toInt());
break;
}
Fact* fact = new Fact(_defaultComponentId, paramName, _mavTypeToFactType(paramType), this);
_mapParameterName2Variant[_defaultComponentId][paramName] = QVariant::fromValue(fact);
}
_addMetaDataToDefaultComponent();
_parametersReady = true;
_initialLoadComplete = true;
}
......@@ -125,6 +125,7 @@ private:
void _tryCacheHashLoad(int uasId, int componentId, QVariant hash_value);
void _addMetaDataToDefaultComponent(void);
QString _remapParamNameToVersion(const QString& paramName);
void _loadOfflineEditingParams(void);
MAV_PARAM_TYPE _factTypeToMavType(FactMetaData::ValueType_t factType);
FactMetaData::ValueType_t _mavTypeToFactType(MAV_PARAM_TYPE mavType);
......
......@@ -31,6 +31,10 @@ APMGeoFenceManager::APMGeoFenceManager(Vehicle* vehicle)
{
connect(_vehicle, &Vehicle::mavlinkMessageReceived, this, &APMGeoFenceManager::_mavlinkMessageReceived);
connect(_vehicle->getParameterLoader(), &ParameterLoader::parametersReady, this, &APMGeoFenceManager::_parametersReady);
if (_vehicle->getParameterLoader()->parametersAreReady()) {
_parametersReady();
}
}
APMGeoFenceManager::~APMGeoFenceManager()
......@@ -40,6 +44,10 @@ APMGeoFenceManager::~APMGeoFenceManager()
void APMGeoFenceManager::sendToVehicle(void)
{
if (_vehicle->isOfflineEditingVehicle()) {
return;
}
if (_readTransactionInProgress) {
_sendError(InternalError, QStringLiteral("Geo-Fence write attempted while read in progress."));
return;
......@@ -82,6 +90,10 @@ void APMGeoFenceManager::sendToVehicle(void)
void APMGeoFenceManager::loadFromVehicle(void)
{
if (_vehicle->isOfflineEditingVehicle()) {
return;
}
_polygon.clear();
if (!_geoFenceSupported()) {
......
......@@ -210,7 +210,7 @@ bool ArduCopterFirmwarePlugin::multiRotorCoaxialMotors(Vehicle* vehicle)
bool ArduCopterFirmwarePlugin::multiRotorXConfig(Vehicle* vehicle)
{
return vehicle->autopilotPlugin()->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() != 0;
return vehicle->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() != 0;
}
QString ArduCopterFirmwarePlugin::geoFenceRadiusParam(Vehicle* vehicle)
......
......@@ -67,6 +67,7 @@ public:
bool multiRotorCoaxialMotors(Vehicle* vehicle) final;
bool multiRotorXConfig(Vehicle* vehicle) final;
QString geoFenceRadiusParam(Vehicle* vehicle) final;
QString offlineEditingParamFile(Vehicle* vehicle) final { Q_UNUSED(vehicle); return QStringLiteral(":/FirmwarePlugin/APM/Copter.OfflineEditing.params"); }
private:
static bool _remapParamNameIntialized;
......
......@@ -54,6 +54,9 @@ class ArduPlaneFirmwarePlugin : public APMFirmwarePlugin
public:
ArduPlaneFirmwarePlugin(void);
// Overrides from FirmwarePlugin
QString offlineEditingParamFile(Vehicle* vehicle) final { Q_UNUSED(vehicle); return QStringLiteral(":/FirmwarePlugin/APM/Plane.OfflineEditing.params"); }
};
#endif
This diff is collapsed.
......@@ -36,11 +36,6 @@ Column {
color: qgcPal.text
}
QGCLabel {
text: qsTr("Must be connected to Vehicle to change fence settings.")
visible: !QGroundControl.multiVehicleManager.activeVehicle
}
Repeater {
model: geoFenceController.params
......@@ -80,7 +75,7 @@ Column {
anchors.left: parent.left
anchors.right: parent.right
flightMap: editorMap
polygon: root.polygon
polygon: geoFenceController.polygon
sectionLabel: qsTr("Fence Polygon:")
visible: geoFenceController.polygonSupported
}
......
This diff is collapsed.
......@@ -218,7 +218,7 @@ Column {
anchors.left: parent.left
anchors.right: parent.right
flightMap: editorMap
polygon: root.polygon
polygon: geoFenceController.polygon
sectionLabel: qsTr("Fence Polygon:")
}
}
......@@ -216,6 +216,9 @@ public:
/// Returns the parameter which holds the fence circle radius if supported.
virtual QString geoFenceRadiusParam(Vehicle* vehicle) { Q_UNUSED(vehicle); return QString(); }
/// Return the resource file which contains the set of params loaded for offline editing.
virtual QString offlineEditingParamFile(Vehicle* vehicle) { Q_UNUSED(vehicle); return QString(); }
};
#endif
......@@ -12,7 +12,7 @@ import QGroundControl.FactSystem 1.0
QGCLabel {
width: availableWidth
wrapMode: Text.WordWrap
text: qsTr("This vehicle does tno support GeoFence.")
text: qsTr("This vehicle does not support GeoFence.")
//property var contoller - controller - Must be passed in from Loader
//property real availableWidth - Available width for control - Must be passed in from Loader
......
......@@ -30,7 +30,7 @@ QGCFlickable {
property color textColor
property var maxHeight
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.disconnectedVehicle
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
property real _margins: ScreenTools.defaultFontPixelWidth / 2
QGCPalette { id:qgcPal; colorGroupEnabled: true }
......
......@@ -29,7 +29,7 @@ QGCFlickable {
property color backgroundColor
property var maxHeight
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.disconnectedVehicle
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property real _barWidth: Math.round(ScreenTools.defaultFontPixelWidth * 3)
......
......@@ -62,11 +62,11 @@ void GeoFenceController::_signalAll(void)
emit editorQmlChanged(editorQml());
}
void GeoFenceController::_activeVehicleBeingRemoved(Vehicle* vehicle)
void GeoFenceController::_activeVehicleBeingRemoved(void)
{
_clearGeoFence();
_signalAll();
vehicle->geoFenceManager()->disconnect(this);
_activeVehicle->geoFenceManager()->disconnect(this);
}
void GeoFenceController::_activeVehicleSet(void)
......@@ -122,23 +122,23 @@ void GeoFenceController::removeAll(void)
void GeoFenceController::loadFromVehicle(void)
{
if (_activeVehicle && _activeVehicle->getParameterLoader()->parametersAreReady() && !syncInProgress()) {
if (_activeVehicle->getParameterLoader()->parametersAreReady() && !syncInProgress()) {
_activeVehicle->geoFenceManager()->loadFromVehicle();
} else {
qCWarning(GeoFenceControllerLog) << "GeoFenceController::loadFromVehicle call at wrong time" << _activeVehicle << _activeVehicle->getParameterLoader()->parametersAreReady() << syncInProgress();
qCWarning(GeoFenceControllerLog) << "GeoFenceController::loadFromVehicle call at wrong time" << _activeVehicle->getParameterLoader()->parametersAreReady() << syncInProgress();
}
}
void GeoFenceController::sendToVehicle(void)
{
if (_activeVehicle && _activeVehicle->getParameterLoader()->parametersAreReady() && !syncInProgress()) {
if (_activeVehicle->getParameterLoader()->parametersAreReady() && !syncInProgress()) {
_activeVehicle->geoFenceManager()->setPolygon(polygon());
_activeVehicle->geoFenceManager()->setBreachReturnPoint(breachReturnPoint());
setDirty(false);
_polygon.setDirty(false);
_activeVehicle->geoFenceManager()->sendToVehicle();
} else {
qCWarning(GeoFenceControllerLog) << "GeoFenceController::loadFromVehicle call at wrong time" << _activeVehicle << _activeVehicle->getParameterLoader()->parametersAreReady() << syncInProgress();
qCWarning(GeoFenceControllerLog) << "GeoFenceController::loadFromVehicle call at wrong time" << _activeVehicle->getParameterLoader()->parametersAreReady() << syncInProgress();
}
}
......@@ -150,11 +150,7 @@ void GeoFenceController::_clearGeoFence(void)
bool GeoFenceController::syncInProgress(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->inProgress();
} else {
return false;
}
return _activeVehicle->geoFenceManager()->inProgress();
}
bool GeoFenceController::dirty(void) const
......@@ -183,38 +179,22 @@ void GeoFenceController::_polygonDirtyChanged(bool dirty)
bool GeoFenceController::fenceSupported(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->fenceSupported();
} else {
return true;
}
return _activeVehicle->geoFenceManager()->fenceSupported();
}
bool GeoFenceController::circleSupported(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->circleSupported();
} else {
return true;
}
return _activeVehicle->geoFenceManager()->circleSupported();
}
bool GeoFenceController::polygonSupported(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->polygonSupported();
} else {
return true;
}
return _activeVehicle->geoFenceManager()->polygonSupported();
}
bool GeoFenceController::breachReturnSupported(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->breachReturnSupported();
} else {
return true;
}
return _activeVehicle->geoFenceManager()->breachReturnSupported();
}
void GeoFenceController::_setDirty(void)
......@@ -231,37 +211,20 @@ void GeoFenceController::_setPolygon(const QList<QGeoCoordinate>& polygon)
float GeoFenceController::circleRadius(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->circleRadius();
} else {
return 0.0;
}
return _activeVehicle->geoFenceManager()->circleRadius();
}
QVariantList GeoFenceController::params(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->params();
} else {
return QVariantList();
}
return _activeVehicle->geoFenceManager()->params();
}
QStringList GeoFenceController::paramLabels(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->paramLabels();
} else {
return QStringList();
}
return _activeVehicle->geoFenceManager()->paramLabels();
}
QString GeoFenceController::editorQml(void) const
{
if (_activeVehicle) {
return _activeVehicle->geoFenceManager()->editorQml();
} else {
// FIXME: Offline editing support
return QString();
}
return _activeVehicle->geoFenceManager()->editorQml();
}
......@@ -85,7 +85,7 @@ private:
void _clearGeoFence(void);
void _signalAll(void);
void _activeVehicleBeingRemoved(Vehicle* vehicle) final;
void _activeVehicleBeingRemoved(void) final;
void _activeVehicleSet(void) final;
bool _dirty;
......
......@@ -174,12 +174,12 @@ void MissionCommandTreeTest::testJsonLoad(void)
void MissionCommandTreeTest::testOverride(void)
{
// Generic/Generic should not have any overrides
Vehicle* vehicle = new Vehicle(MAV_AUTOPILOT_GENERIC, MAV_TYPE_GENERIC);
Vehicle* vehicle = new Vehicle(MAV_AUTOPILOT_GENERIC, MAV_TYPE_GENERIC, qgcApp()->toolbox()->firmwarePluginManager());
_checkBaseValues(_commandTree->getUIInfo(vehicle, (MAV_CMD)4), 4);
delete vehicle;
// Generic/FixedWing should have overrides
vehicle = new Vehicle(MAV_AUTOPILOT_GENERIC, MAV_TYPE_FIXED_WING);
vehicle = new Vehicle(MAV_AUTOPILOT_GENERIC, MAV_TYPE_FIXED_WING, qgcApp()->toolbox()->firmwarePluginManager());
_checkOverrideValues(_commandTree->getUIInfo(vehicle, (MAV_CMD)4), 4);
delete vehicle;
}
......@@ -195,7 +195,7 @@ void MissionCommandTreeTest::testAllTrees(void)
// This will cause all of the variants of collapsed trees to be built
foreach(MAV_AUTOPILOT firmwareType, firmwareList) {
foreach (MAV_TYPE vehicleType, vehicleList) {
Vehicle* vehicle = new Vehicle(firmwareType, vehicleType);
Vehicle* vehicle = new Vehicle(firmwareType, vehicleType, qgcApp()->toolbox()->firmwarePluginManager());
qDebug() << firmwareType << vehicleType;
QVERIFY(qgcApp()->toolbox()->missionCommandTree()->getUIInfo(vehicle, MAV_CMD_NAV_WAYPOINT) != NULL);
delete vehicle;
......
......@@ -1023,17 +1023,17 @@ void MissionController::_itemCommandChanged(void)
_recalcWaypointLines();
}
void MissionController::_activeVehicleBeingRemoved(Vehicle* vehicle)
void MissionController::_activeVehicleBeingRemoved(void)
{
qCDebug(MissionControllerLog) << "_activeVehicleSet _activeVehicleBeingRemoved";
qCDebug(MissionControllerLog) << "MissionController::_activeVehicleBeingRemoved";
MissionManager* missionManager = vehicle->missionManager();
MissionManager* missionManager = _activeVehicle->missionManager();
disconnect(missionManager, &MissionManager::newMissionItemsAvailable, this, &MissionController::_newMissionItemsAvailableFromVehicle);
disconnect(missionManager, &MissionManager::inProgressChanged, this, &MissionController::_inProgressChanged);
disconnect(missionManager, &MissionManager::currentItemChanged, this, &MissionController::_currentMissionItemChanged);
disconnect(vehicle, &Vehicle::homePositionAvailableChanged, this, &MissionController::_activeVehicleHomePositionAvailableChanged);
disconnect(vehicle, &Vehicle::homePositionChanged, this, &MissionController::_activeVehicleHomePositionChanged);
disconnect(_activeVehicle, &Vehicle::homePositionAvailableChanged, this, &MissionController::_activeVehicleHomePositionAvailableChanged);
disconnect(_activeVehicle, &Vehicle::homePositionChanged, this, &MissionController::_activeVehicleHomePositionChanged);
// We always remove all items on vehicle change. This leaves a user model hole:
// If the user has unsaved changes in the Plan view they will lose them
......
......@@ -131,7 +131,7 @@ private:
int _nextSequenceNumber(void);
// Overrides from PlanElementController
void _activeVehicleBeingRemoved(Vehicle* vehicle) final;
void _activeVehicleBeingRemoved(void) final;
void _activeVehicleSet(void) final;
private:
......
......@@ -44,6 +44,10 @@ MissionManager::~MissionManager()
void MissionManager::writeMissionItems(const QList<MissionItem*>& missionItems)
{
if (_vehicle->isOfflineEditingVehicle()) {
return;
}
if (inProgress()) {
qCDebug(MissionManagerLog) << "writeMissionItems called while transaction in progress";
return;
......@@ -131,6 +135,10 @@ void MissionManager::writeArduPilotGuidedMissionItem(const QGeoCoordinate& gotoC
void MissionManager::requestMissionItems(void)
{
if (_vehicle->isOfflineEditingVehicle()) {
return;
}
qCDebug(MissionManagerLog) << "requestMissionItems read sequence";
if (inProgress()) {
......
......@@ -9,11 +9,12 @@
#include "PlanElementController.h"
#include "QGCApplication.h"
#include "MultiVehicleManager.h"
PlanElementController::PlanElementController(QObject* parent)
: QObject(parent)
, _activeVehicle(NULL)
, _multiVehicleMgr(qgcApp()->toolbox()->multiVehicleManager())
, _activeVehicle(_multiVehicleMgr->offlineEditingVehicle())
, _editMode(false)
{
......@@ -34,16 +35,16 @@ void PlanElementController::start(bool editMode)
void PlanElementController::_activeVehicleChanged(Vehicle* activeVehicle)
{
if (_activeVehicle) {
Vehicle* vehicleSave = _activeVehicle;
_activeVehicleBeingRemoved();
_activeVehicle = NULL;
_activeVehicleBeingRemoved(vehicleSave);
}
_activeVehicle = activeVehicle;
if (_activeVehicle) {
_activeVehicleSet();
if (activeVehicle) {
_activeVehicle = activeVehicle;
} else {
_activeVehicle = _multiVehicleMgr->offlineEditingVehicle();
}
_activeVehicleSet();
// Whenever vehicle changes we need to update syncInProgress
emit syncInProgressChanged(syncInProgress());
......
......@@ -52,13 +52,13 @@ signals:
void dirtyChanged (bool dirty);
protected:
Vehicle* _activeVehicle;
MultiVehicleManager* _multiVehicleMgr;
Vehicle* _activeVehicle; ///< Currently active vehicle, can be disconnected offline editing vehicle
bool _editMode;
/// Called when the current active vehicle has been removed. Derived classes should override
/// to implement custom behavior. When this is called _activeVehicle has already been cleared.
virtual void _activeVehicleBeingRemoved(Vehicle* removedVehicle) = 0;
/// Called when the current active vehicle is about to be removed. Derived classes should override
/// to implement custom behavior.
virtual void _activeVehicleBeingRemoved(void) = 0;
/// Called when a new active vehicle has been set. Derived classes should override
/// to implement custom behavior.
......
......@@ -10,6 +10,7 @@
#include "SimpleMissionItemTest.h"
#include "SimpleMissionItem.h"
#include "QGCApplication.h"
const SimpleMissionItemTest::ItemInfo_t SimpleMissionItemTest::_rgItemInfo[] = {
{ MAV_CMD_NAV_WAYPOINT, MAV_FRAME_GLOBAL_RELATIVE_ALT },
......@@ -80,7 +81,7 @@ SimpleMissionItemTest::SimpleMissionItemTest(void)
void SimpleMissionItemTest::_testEditorFacts(void)
{
Vehicle* vehicle = new Vehicle(MAV_AUTOPILOT_PX4, MAV_TYPE_FIXED_WING);
Vehicle* vehicle = new Vehicle(MAV_AUTOPILOT_PX4, MAV_TYPE_FIXED_WING, qgcApp()->toolbox()->firmwarePluginManager());
for (size_t i=0; i<sizeof(_rgItemInfo)/sizeof(_rgItemInfo[0]); i++) {
const ItemInfo_t* info = &_rgItemInfo[i];
......
......@@ -343,6 +343,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
initializeVideoStreaming(argc, argv);
_toolbox = new QGCToolbox(this);
_toolbox->setChildToolboxes();
}
QGCApplication::~QGCApplication()
......
......@@ -71,7 +71,10 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_qgcPositionManager = new QGCPositionManager(app);
_followMe = new FollowMe(app);
_videoManager = new VideoManager(app);
}
void QGCToolbox::setChildToolboxes(void)
{
_audioOutput->setToolbox(this);
_autopilotPluginManager->setToolbox(this);
_factSystem->setToolbox(this);
......
......@@ -61,6 +61,8 @@ public:
#endif
private:
void setChildToolboxes(void);
GAudioOutput* _audioOutput;
AutoPilotPluginManager* _autopilotPluginManager;
FactSystem* _factSystem;
......@@ -81,6 +83,8 @@ private:
FollowMe* _followMe;
QGCPositionManager* _qgcPositionManager;
VideoManager* _videoManager;
friend class QGCApplication;
};
/// This is the base class for all tools
......
......@@ -68,7 +68,7 @@ QStringList ParameterEditorController::searchParametersForComponent(int componen
if (searchText.isEmpty()) {
list += paramName;
} else {
Fact* fact = _autopilot->getParameterFact(componentId, paramName);
Fact* fact = _vehicle->getParameterFact(componentId, paramName);
if (searchInName && fact->name().contains(searchText, Qt::CaseInsensitive)) {
list += paramName;
......@@ -189,11 +189,11 @@ void ParameterEditorController::_updateParameters(void)
if (_searchText.isEmpty()) {
const QMap<int, QMap<QString, QStringList> >& groupMap = _autopilot->getGroupMap();
foreach (const QString& parameter, groupMap[_currentComponentId][_currentGroup]) {
newParameterList.append(_autopilot->getParameterFact(_currentComponentId, parameter));
newParameterList.append(_vehicle->getParameterFact(_currentComponentId, parameter));
}
} else {
foreach(const QString &parameter, _autopilot->parameterNames(_vehicle->defaultComponentId())) {
Fact* fact = _autopilot->getParameterFact(_vehicle->defaultComponentId(), parameter);
Fact* fact = _vehicle->getParameterFact(_vehicle->defaultComponentId(), parameter);
if (fact->name().contains(_searchText, Qt::CaseInsensitive) ||
fact->shortDescription().contains(_searchText, Qt::CaseInsensitive) ||
fact->longDescription().contains(_searchText, Qt::CaseInsensitive)) {
......
......@@ -7,16 +7,13 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "MultiVehicleManager.h"
#include "AutoPilotPlugin.h"
#include "MAVLinkProtocol.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "FollowMe.h"
#include "QGroundControlQmlGlobal.h"
#ifdef __mobile__
#include "MobileScreenMgr.h"
......@@ -33,7 +30,7 @@ MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
, _activeVehicleAvailable(false)
, _parameterReadyVehicleAvailable(false)
, _activeVehicle(NULL)
, _disconnectedVehicle(NULL)
, _offlineEditingVehicle(NULL)
, _firmwarePluginManager(NULL)
, _autopilotPluginManager(NULL)
, _joystickManager(NULL)
......@@ -50,8 +47,6 @@ MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
if (_gcsHeartbeatEnabled) {
_gcsHeartbeatTimer.start();
}
_disconnectedVehicle = new Vehicle(MAV_AUTOPILOT_PX4, MAV_TYPE_QUADROTOR, this);
}
void MultiVehicleManager::setToolbox(QGCToolbox *toolbox)
......@@ -67,6 +62,11 @@ void MultiVehicleManager::setToolbox(QGCToolbox *toolbox)
qmlRegisterUncreatableType<MultiVehicleManager>("QGroundControl.MultiVehicleManager", 1, 0, "MultiVehicleManager", "Reference only");
connect(_mavlinkProtocol, &MAVLinkProtocol::vehicleHeartbeatInfo, this, &MultiVehicleManager::_vehicleHeartbeatInfo);
_offlineEditingVehicle = new Vehicle(static_cast<MAV_AUTOPILOT>(QGroundControlQmlGlobal::offlineEditingFirmwareType()->rawValue().toInt()),
static_cast<MAV_TYPE>(QGroundControlQmlGlobal::offlineEditingVehicleType()->rawValue().toInt()),
_firmwarePluginManager,
this);
}
void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicleId, int vehicleMavlinkVersion, int vehicleFirmwareType, int vehicleType)
......
......@@ -45,8 +45,8 @@ public:
Q_PROPERTY(QmlObjectListModel* vehicles READ vehicles CONSTANT)
Q_PROPERTY(bool gcsHeartBeatEnabled READ gcsHeartbeatEnabled WRITE setGcsHeartbeatEnabled NOTIFY gcsHeartBeatEnabledChanged)
/// A disconnected vehicle is used to simulate vehicle information while no vehicle is connected.
Q_PROPERTY(Vehicle* disconnectedVehicle MEMBER _disconnectedVehicle CONSTANT)
/// A disconnected vehicle used for offline editing. It will match the vehicle type specified in Settings.
Q_PROPERTY(Vehicle* offlineEditingVehicle READ offlineEditingVehicle CONSTANT)
// Methods
......@@ -68,6 +68,8 @@ public:
bool gcsHeartbeatEnabled(void) const { return _gcsHeartbeatEnabled; }
void setGcsHeartbeatEnabled(bool gcsHeartBeatEnabled);
Vehicle* offlineEditingVehicle(void) { return _offlineEditingVehicle; }
/// Determines if the link is in use by a Vehicle
/// @param link Link to test against
/// @param skipVehicle Don't consider this Vehicle as part of the test
......@@ -101,7 +103,7 @@ private:
bool _activeVehicleAvailable; ///< true: An active vehicle is available
bool _parameterReadyVehicleAvailable; ///< true: An active vehicle with ready parameters is available
Vehicle* _activeVehicle; ///< Currently active vehicle from a ui perspective
Vehicle* _disconnectedVehicle; ///< Disconnected vechicle for FactGroup access
Vehicle* _offlineEditingVehicle; ///< Disconnected vechicle used for offline editing
QList<Vehicle*> _vehiclesBeingDeleted; ///< List of Vehicles being deleted in queued phases
Vehicle* _vehicleBeingSetActive; ///< Vehicle being set active in queued phases
......
......@@ -65,7 +65,7 @@ Vehicle::Vehicle(LinkInterface* link,
: FactGroup(_vehicleUIUpdateRateMSecs, ":/json/Vehicle/VehicleFact.json")
, _id(vehicleId)
, _active(false)
, _disconnectedVehicle(false)
, _offlineEditingVehicle(false)
, _firmwareType(firmwareType)
, _vehicleType(vehicleType)
, _firmwarePlugin(NULL)
......@@ -203,7 +203,7 @@ Vehicle::Vehicle(LinkInterface* link,
connect(_parameterLoader, &ParameterLoader::parametersReady, _autopilotPlugin, &AutoPilotPlugin::_parametersReadyPreChecks);
connect(_parameterLoader, &ParameterLoader::parameterListProgress, _autopilotPlugin, &AutoPilotPlugin::parameterListProgress);
// GeoFenceManager needs to access ParameterLoader so make sure to create afters
// GeoFenceManager needs to access ParameterLoader so make sure to create after
_geoFenceManager = _firmwarePlugin->newGeoFenceManager(this);
connect(_geoFenceManager, &GeoFenceManager::error, this, &Vehicle::_geoFenceManagerError);
......@@ -254,12 +254,15 @@ Vehicle::Vehicle(LinkInterface* link,
_vibrationFactGroup.setVehicle(this);
}
// Disconnected Vehicle
Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, QObject* parent)
// Disconnected Vehicle for offline editing
Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
MAV_TYPE vehicleType,
FirmwarePluginManager* firmwarePluginManager,
QObject* parent)
: FactGroup(_vehicleUIUpdateRateMSecs, ":/json/Vehicle/VehicleFact.json", parent)
, _id(0)
, _active(false)
, _disconnectedVehicle(true)
, _offlineEditingVehicle(true)
, _firmwareType(firmwareType)
, _vehicleType(vehicleType)
, _firmwarePlugin(NULL)
......@@ -290,12 +293,14 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, QObject* pare
, _connectionLostEnabled(true)
, _missionManager(NULL)
, _missionManagerInitialRequestComplete(false)
, _geoFenceManager(NULL)
, _geoFenceManagerInitialRequestComplete(false)
, _parameterLoader(NULL)
, _armed(false)
, _base_mode(0)
, _custom_mode(0)
, _nextSendMessageMultipleIndex(0)
, _firmwarePluginManager(NULL)
, _firmwarePluginManager(firmwarePluginManager)
, _autopilotPluginManager(NULL)
, _joystickManager(NULL)
, _flowImageIndex(0)
......@@ -322,10 +327,16 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, QObject* pare
, _windFactGroup(this)
, _vibrationFactGroup(this)
{
// This is a hack for disconnected vehicle used while unit testing
if (qgcApp()->toolbox() && qgcApp()->toolbox()->firmwarePluginManager()) {
_firmwarePlugin = qgcApp()->toolbox()->firmwarePluginManager()->firmwarePluginForAutopilot(_firmwareType, _vehicleType);
}
_firmwarePlugin = _firmwarePluginManager->firmwarePluginForAutopilot(_firmwareType, _vehicleType);
_missionManager = new MissionManager(this);
connect(_missionManager, &MissionManager::error, this, &Vehicle::_missionManagerError);
_parameterLoader = new ParameterLoader(this);
// GeoFenceManager needs to access ParameterLoader so make sure to create after
_geoFenceManager = _firmwarePlugin->newGeoFenceManager(this);
connect(_geoFenceManager, &GeoFenceManager::error, this, &Vehicle::_geoFenceManagerError);
// Build FactGroup object model
......@@ -1406,11 +1417,6 @@ void Vehicle::disconnectInactiveVehicle(void)
}
}
ParameterLoader* Vehicle::getParameterLoader(void)
{
return _parameterLoader;
}
void Vehicle::_imageReady(UASInterface*)
{
if(_uas)
......@@ -1829,7 +1835,7 @@ void Vehicle::motorTest(int motor, int percent, int timeoutSecs)
/// Returns true if the specifed parameter exists from the default component
bool Vehicle::parameterExists(int componentId, const QString& name) const
{
return _autopilotPlugin->parameterExists(componentId, name);
return getParameterLoader()->parameterExists(componentId, name);
}
/// Returns the specified parameter Fact from the default component
......@@ -1837,7 +1843,7 @@ bool Vehicle::parameterExists(int componentId, const QString& name) const
/// parameterExists.
Fact* Vehicle::getParameterFact(int componentId, const QString& name)
{
return _autopilotPlugin->getParameterFact(componentId, name);
return getParameterLoader()->getFact(componentId, name);
}
void Vehicle::_newMissionItemsAvailable(void)
......
......@@ -216,9 +216,11 @@ public:
AutoPilotPluginManager* autopilotPluginManager,
JoystickManager* joystickManager);
// The following is used to create a disconnected Vehicle. Disconnected vehicles are used used to access FactGroup information
// without needing a real connection as well as offline mission planning.
Vehicle(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, QObject* parent = NULL);
// The following is used to create a disconnected Vehicle for use while offline editing.
Vehicle(MAV_AUTOPILOT firmwareType,
MAV_TYPE vehicleType,
FirmwarePluginManager* firmwarePluginManager,
QObject* parent = NULL);
~Vehicle();
......@@ -276,6 +278,7 @@ public:
Q_PROPERTY(int motorCount READ motorCount CONSTANT)
Q_PROPERTY(bool coaxialMotors READ coaxialMotors CONSTANT)
Q_PROPERTY(bool xConfigMotors READ xConfigMotors CONSTANT)
Q_PROPERTY(bool isOfflineEditingVehicle READ isOfflineEditingVehicle CONSTANT)
/// true: Vehicle is flying, false: Vehicle is on ground
Q_PROPERTY(bool flying READ flying WRITE setFlying NOTIFY flyingChanged)
......@@ -497,32 +500,33 @@ public:
MessageError
} MessageType_t;
bool messageTypeNone () { return _currentMessageType == MessageNone; }
bool messageTypeNormal () { return _currentMessageType == MessageNormal; }
bool messageTypeWarning () { return _currentMessageType == MessageWarning; }
bool messageTypeError () { return _currentMessageType == MessageError; }
int newMessageCount () { return _currentMessageCount; }
int messageCount () { return _messageCount; }
QString formatedMessages ();
QString formatedMessage () { return _formatedMessage; }
QString latestError () { return _latestError; }
float latitude () { return _coordinate.latitude(); }
float longitude () { return _coordinate.longitude(); }
bool mavPresent () { return _mav != NULL; }
QString currentState () { return _currentState; }
int rcRSSI () { return _rcRSSI; }
bool px4Firmware () const { return _firmwareType == MAV_AUTOPILOT_PX4; }
bool apmFirmware () const { return _firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA; }
bool genericFirmware () const { return !px4Firmware() && !apmFirmware(); }
bool connectionLost () const { return _connectionLost; }
bool connectionLostEnabled() const { return _connectionLostEnabled; }
uint messagesReceived () { return _messagesReceived; }
uint messagesSent () { return _messagesSent; }
uint messagesLost () { return _messagesLost; }
bool flying () const { return _flying; }
bool guidedMode () const;
uint8_t baseMode () const { return _base_mode; }
uint32_t customMode () const { return _custom_mode; }
bool messageTypeNone () { return _currentMessageType == MessageNone; }
bool messageTypeNormal () { return _currentMessageType == MessageNormal; }
bool messageTypeWarning () { return _currentMessageType == MessageWarning; }
bool messageTypeError () { return _currentMessageType == MessageError; }
int newMessageCount () { return _currentMessageCount; }
int messageCount () { return _messageCount; }
QString formatedMessages ();
QString formatedMessage () { return _formatedMessage; }
QString latestError () { return _latestError; }
float latitude () { return _coordinate.latitude(); }
float longitude () { return _coordinate.longitude(); }
bool mavPresent () { return _mav != NULL; }
QString currentState () { return _currentState; }
int rcRSSI () { return _rcRSSI; }
bool px4Firmware () const { return _firmwareType == MAV_AUTOPILOT_PX4; }
bool apmFirmware () const { return _firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA; }
bool genericFirmware () const { return !px4Firmware() && !apmFirmware(); }
bool connectionLost () const { return _connectionLost; }
bool connectionLostEnabled () const { return _connectionLostEnabled; }
uint messagesReceived () { return _messagesReceived; }
uint messagesSent () { return _messagesSent; }
uint messagesLost () { return _messagesLost; }
bool flying () const { return _flying; }
bool guidedMode () const;
uint8_t baseMode () const { return _base_mode; }
uint32_t customMode () const { return _custom_mode; }
bool isOfflineEditingVehicle () const { return _offlineEditingVehicle; }
Fact* roll (void) { return &_rollFact; }
Fact* heading (void) { return &_headingFact; }
......@@ -540,7 +544,8 @@ public:
void setConnectionLostEnabled(bool connectionLostEnabled);
ParameterLoader* getParameterLoader(void);
ParameterLoader* getParameterLoader(void) { return _parameterLoader; }
ParameterLoader* getParameterLoader(void) const { return _parameterLoader; }
static const int cMaxRcChannels = 18;
......@@ -697,9 +702,9 @@ private:
QString _vehicleIdSpeech(void);
private:
int _id; ///< Mavlink system id
int _id; ///< Mavlink system id
bool _active;
bool _disconnectedVehicle; ///< This Vehicle is a "disconnected" vehicle for ui use when no active vehicle is available
bool _offlineEditingVehicle; ///< This Vehicle is a "disconnected" vehicle for ui use while offline editing
MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType;
......
......@@ -49,8 +49,8 @@ void VehicleComponent::setupTriggerSignals(void)
{
// Watch for changed on trigger list params
foreach (const QString &paramName, setupCompleteChangedTriggerList()) {
if (_autopilot->parameterExists(FactSystem::defaultComponentId, paramName)) {
Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName);
if (_vehicle->parameterExists(FactSystem::defaultComponentId, paramName)) {
Fact* fact = _vehicle->getParameterFact(FactSystem::defaultComponentId, paramName);
connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated);
}
}
......
......@@ -378,7 +378,7 @@ void RadioConfigTest::_fullCalibrationWorker(MAV_AUTOPILOT firmwareType)
switchList << "RC_MAP_MODE_SW" << "RC_MAP_LOITER_SW" << "RC_MAP_RETURN_SW" << "RC_MAP_POSCTL_SW" << "RC_MAP_ACRO_SW";
foreach (const QString &switchParam, switchList) {
Q_ASSERT(_autopilot->getParameterFact(FactSystem::defaultComponentId, switchParam)->rawValue().toInt() != channel + 1);
Q_ASSERT(_vehicle->getParameterFact(FactSystem::defaultComponentId, switchParam)->rawValue().toInt() != channel + 1);
}
}
......@@ -393,7 +393,7 @@ void RadioConfigTest::_fullCalibrationWorker(MAV_AUTOPILOT firmwareType)
if (!found) {
const char* paramName = _functionInfo()[function].parameterName;
if (paramName) {
_rgFunctionChannelMap[function] = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt();
_rgFunctionChannelMap[function] = _vehicle->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt();
qCDebug(RadioConfigTestLog) << "Assigning switch" << function << _rgFunctionChannelMap[function];
if (_rgFunctionChannelMap[function] == 0) {
_rgFunctionChannelMap[function] = -1; // -1 signals no mapping
......@@ -469,8 +469,8 @@ void RadioConfigTest::_validateParameters(void)
const char* paramName = _functionInfo()[chanFunction].parameterName;
if (paramName) {
qCDebug(RadioConfigTestLog) << "Validate" << chanFunction << _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt();
QCOMPARE(_autopilot->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt(), expectedParameterValue);
qCDebug(RadioConfigTestLog) << "Validate" << chanFunction << _vehicle->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt();
QCOMPARE(_vehicle->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt(), expectedParameterValue);
}
}
......@@ -485,13 +485,13 @@ void RadioConfigTest::_validateParameters(void)
int rcTrimExpected = _channelSettingsValidate()[chan].rcTrim;
bool rcReversedExpected = _channelSettingsValidate()[chan].reversed;
int rcMinActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
int rcMinActual = _vehicle->getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
QCOMPARE(convertOk, true);
int rcMaxActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
int rcMaxActual = _vehicle->getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
QCOMPARE(convertOk, true);
int rcTrimActual = _autopilot->getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
int rcTrimActual = _vehicle->getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel))->rawValue().toInt(&convertOk);
QCOMPARE(convertOk, true);
float rcReversedFloat = _autopilot->getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->rawValue().toFloat(&convertOk);
float rcReversedFloat = _vehicle->getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->rawValue().toFloat(&convertOk);
QCOMPARE(convertOk, true);
bool rcReversedActual = (rcReversedFloat == -1.0f);
......@@ -515,7 +515,7 @@ void RadioConfigTest::_validateParameters(void)
const char* paramName = _functionInfo()[chanFunction].parameterName;
if (paramName) {
// qCDebug(RadioConfigTestLog) << chanFunction << expectedValue << mapParamsSet[paramName].toInt();
QCOMPARE(_autopilot->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt(), expectedValue);
QCOMPARE(_vehicle->getParameterFact(FactSystem::defaultComponentId, paramName)->rawValue().toInt(), expectedValue);
}
}
}
......
......@@ -30,9 +30,8 @@ QGCMapRCToParamDialog::QGCMapRCToParamDialog(QString param_id, UASInterface *mav
ui->setupUi(this);
// refresh the parameter from onboard to make sure the current value is used
AutoPilotPlugin* autopilot = _multiVehicleManager->getVehicleById(mav->getUASID())->autopilotPlugin();
Q_ASSERT(autopilot);
Fact* paramFact = autopilot->getParameterFact(FactSystem::defaultComponentId, param_id);
Vehicle* vehicle = _multiVehicleManager->getVehicleById(mav->getUASID());
Fact* paramFact = vehicle->getParameterFact(FactSystem::defaultComponentId, param_id);
ui->minValueDoubleSpinBox->setValue(paramFact->rawMin().toDouble());
ui->maxValueDoubleSpinBox->setValue(paramFact->rawMax().toDouble());
......@@ -44,7 +43,7 @@ QGCMapRCToParamDialog::QGCMapRCToParamDialog(QString param_id, UASInterface *mav
ui->paramIdLabel->setText(param_id);
connect(paramFact, &Fact::valueChanged, this, &QGCMapRCToParamDialog::_parameterUpdated);
autopilot->refreshParameter(FactSystem::defaultComponentId, param_id);
vehicle->autopilotPlugin()->refreshParameter(FactSystem::defaultComponentId, param_id);
}
QGCMapRCToParamDialog::~QGCMapRCToParamDialog()
......
......@@ -125,7 +125,7 @@ QGCView {
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
id: offlineLabel
text: qsTr("Offline Mission Editing")
text: qsTr("Offline Mission Editing (Requires Restart)")
font.family: ScreenTools.demiboldFontFamily
}
}
......
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