1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

Merge remote-tracking branch 'origin/thread/OP-1589_MixerSettings_Export' into rel-14.10

This commit is contained in:
Alessio Morale 2014-11-03 22:18:47 +01:00
commit 660470b9e9
3 changed files with 39 additions and 8 deletions

View File

@ -1,11 +1,11 @@
/**
******************************************************************************
*
* @file airframestabfixedwingpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @file airframeinitialtuningpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup
* @{
* @addtogroup AirframeStabFixedwingPage
* @addtogroup AirframeInitialTuningPage
* @{
* @brief
*****************************************************************************/
@ -151,6 +151,25 @@ void AirframeInitialTuningPage::templateSelectionChanged()
}
}
bool AirframeInitialTuningPage::airframeIsCompatible(int vehicleType, int vehicleSubType)
{
if (vehicleType != getWizard()->getVehicleType()) {
return false;
}
int wizSubType = getWizard()->getVehicleSubType();
switch (vehicleType) {
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_H:
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
{
return wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_H ||
wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_X;
}
default:
return vehicleSubType == wizSubType;
}
}
void AirframeInitialTuningPage::loadValidFiles()
{
ui->templateList->clear();
@ -174,8 +193,7 @@ void AirframeInitialTuningPage::loadValidFiles()
QJsonDocument templateDoc = QJsonDocument::fromJson(jsonData, &error);
if (error.error == QJsonParseError::NoError) {
QJsonObject json = templateDoc.object();
if (json["type"].toInt() == getWizard()->getVehicleType() &&
json["subtype"].toInt() == getWizard()->getVehicleSubType()) {
if (airframeIsCompatible(json["type"].toInt(), json["subtype"].toInt())) {
QString uuid = json["uuid"].toString();
if (!m_templates.contains(uuid)) {
m_templates[json["uuid"].toString()] = new QJsonObject(json);

View File

@ -1,11 +1,11 @@
/**
******************************************************************************
*
* @file airframestabfixedwingpage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @file airframeinitialtuningpage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup
* @{
* @addtogroup AirframeStabFixedwingPage
* @addtogroup AirframeInitialTuningPage
* @{
* @brief
*****************************************************************************/
@ -63,6 +63,7 @@ private:
QString getTemplateKey(QJsonObject *templ);
void updatePhoto(QJsonObject *templ);
void updateDescription(QJsonObject *templ);
bool airframeIsCompatible(int vehicleType, int vehicleSubType);
};
Q_DECLARE_METATYPE(QJsonObject *)

View File

@ -41,6 +41,7 @@
#include "stabilizationsettingsbank1.h"
#include "stabilizationsettingsbank2.h"
#include "stabilizationsettingsbank3.h"
#include "mixersettings.h"
#include "ekfconfiguration.h"
const char *VehicleTemplateExportDialog::EXPORT_BASE_NAME = "../share/openpilotgcs/cloudconfig";
@ -111,6 +112,11 @@ QString VehicleTemplateExportDialog::setupVehicleType()
m_subType = VehicleConfigurationSource::MULTI_ROTOR_QUAD_X;
return tr("Multirotor - Quadrocopter X");
case SystemSettings::AIRFRAMETYPE_QUADH:
m_type = VehicleConfigurationSource::VEHICLE_MULTI;
m_subType = VehicleConfigurationSource::MULTI_ROTOR_QUAD_H;
return tr("Multirotor - Quadrocopter H");
case SystemSettings::AIRFRAMETYPE_QUADP:
m_type = VehicleConfigurationSource::VEHICLE_MULTI;
m_subType = VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS;
@ -146,6 +152,11 @@ QString VehicleTemplateExportDialog::setupVehicleType()
m_subType = VehicleConfigurationSource::MULTI_ROTOR_HEXA_X;
return tr("Multirotor - Hexacopter X");
case SystemSettings::AIRFRAMETYPE_HEXAH:
m_type = VehicleConfigurationSource::VEHICLE_MULTI;
m_subType = VehicleConfigurationSource::MULTI_ROTOR_HEXA_H;
return tr("Multirotor - Hexacopter H");
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
m_type = VehicleConfigurationSource::VEHICLE_MULTI;
m_subType = VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y;
@ -181,6 +192,7 @@ void VehicleTemplateExportDialog::accept()
objectsToExport << StabilizationSettingsBank1::GetInstance(m_uavoManager);
objectsToExport << StabilizationSettingsBank2::GetInstance(m_uavoManager);
objectsToExport << StabilizationSettingsBank3::GetInstance(m_uavoManager);
objectsToExport << MixerSettings::GetInstance(m_uavoManager);
objectsToExport << EKFConfiguration::GetInstance(m_uavoManager);
m_uavoManager->toJson(exportObject, objectsToExport);