mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-1222 Fixed handling of conflicting configurations. Config is now invalidated if use goes back and make changes introducing conflicts.
Added more configuration saving logic.
This commit is contained in:
parent
1a2bf73969
commit
7cd46bdeee
@ -46,6 +46,11 @@ void AirSpeedPage::initializePage(VehicleConfigurationSource *settings)
|
||||
// Disable non estimated sensors if ports are taken by receivers
|
||||
setItemDisabled(VehicleConfigurationSource::AIRSPEED_EAGLETREE, true);
|
||||
setItemDisabled(VehicleConfigurationSource::AIRSPEED_MS4525, true);
|
||||
if (getSelectedItem()->id() == VehicleConfigurationSource::AIRSPEED_EAGLETREE ||
|
||||
getSelectedItem()->id() == VehicleConfigurationSource::AIRSPEED_MS4525) {
|
||||
// If previously selected invalid sensor, reset to estimated
|
||||
setSelectedItem(VehicleConfigurationSource::AIRSPEED_ESTIMATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,9 @@ void GpsPage::initializePage(VehicleConfigurationSource *settings)
|
||||
bool GpsPage::validatePage(SelectionItem *selectedItem)
|
||||
{
|
||||
getWizard()->setGpsType((SetupWizard::GPS_TYPE)selectedItem->id());
|
||||
if (getWizard()->getGpsType() == SetupWizard::GPS_DISABLED) {
|
||||
getWizard()->setAirspeedType(VehicleConfigurationSource::AIRSPEED_DISABLED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,20 @@ void SelectionPage::setItemDisabled(int id, bool disabled)
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionPage::setSelectedItem(int id)
|
||||
{
|
||||
for (int i = 0; i < m_selectionItems.count(); i++) {
|
||||
if (m_selectionItems.at(i)->id() == id) {
|
||||
ui->typeCombo->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectionItem *SelectionPage::getSelectedItem()
|
||||
{
|
||||
return m_selectionItems.at(ui->typeCombo->currentIndex());
|
||||
}
|
||||
|
||||
SelectionItem::SelectionItem(QString name, QString description, QString shapeId, int id, bool disabled) :
|
||||
m_name(name), m_description(description), m_shapeId(shapeId), m_id(id), m_disabled(disabled)
|
||||
{}
|
||||
|
@ -95,6 +95,8 @@ public:
|
||||
void setTitle(QString title);
|
||||
void setText(QString text);
|
||||
void setItemDisabled(int id, bool disabled);
|
||||
void setSelectedItem(int id);
|
||||
SelectionItem *getSelectedItem();
|
||||
|
||||
protected:
|
||||
virtual void setupSelection(Selection *selection) = 0;
|
||||
|
@ -116,12 +116,10 @@ void VehicleConfigurationHelper::clearModifiedObjects()
|
||||
void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
{
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(m_uavoManager);
|
||||
Q_ASSERT(hwSettings);
|
||||
HwSettings::DataFields data = hwSettings->getData();
|
||||
|
||||
GPSSettings *gpsSettings = NULL;
|
||||
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = 0;
|
||||
|
||||
AirspeedSettings *airspeedSettings = NULL;
|
||||
data.OptionalModules[HwSettings::OPTIONALMODULES_AIRSPEED] = 0;
|
||||
|
||||
switch (m_configSource->getControllerType()) {
|
||||
@ -196,7 +194,8 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
|
||||
if (m_configSource->getGpsType() != VehicleConfigurationSource::GPS_DISABLED) {
|
||||
|
||||
gpsSettings = GPSSettings::GetInstance(m_uavoManager);
|
||||
GPSSettings *gpsSettings = GPSSettings::GetInstance(m_uavoManager);
|
||||
Q_ASSERT(gpsSettings);
|
||||
GPSSettings::DataFields gpsData = gpsSettings->getData();
|
||||
|
||||
switch (m_configSource->getGpsType()) {
|
||||
@ -215,8 +214,15 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
case VehicleConfigurationSource::GPS_PLATINUM:
|
||||
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = 1;
|
||||
data.RM_MainPort = HwSettings::RM_MAINPORT_GPS;
|
||||
data.GPSSpeed = HwSettings::GPSSPEED_57600;
|
||||
//gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_PLATINUM;
|
||||
data.GPSSpeed = HwSettings::GPSSPEED_115200;
|
||||
/*
|
||||
gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_UBLOX;
|
||||
AuxMagSettings *magSettings = AuxMagSettings::GetInstance(m_uavoManager);
|
||||
AuxMagSettings::DataFields magsData = magSettings->getData();
|
||||
magsData.usage = AuxMagSettings::Both;
|
||||
magSettings->setData(magsData);
|
||||
addModifiedObject(magSettings, tr("Writing External Mag sensor settings"));
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = 0;
|
||||
@ -224,12 +230,14 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
}
|
||||
|
||||
gpsSettings->setData(gpsData);
|
||||
addModifiedObject(gpsSettings, tr("Writing GPS sensor settings"));
|
||||
}
|
||||
|
||||
if (m_configSource->getVehicleType() == VehicleConfigurationSource::VEHICLE_FIXEDWING &&
|
||||
m_configSource->getAirspeedType() != VehicleConfigurationSource::AIRSPEED_DISABLED) {
|
||||
|
||||
airspeedSettings = AirspeedSettings::GetInstance(m_uavoManager);
|
||||
AirspeedSettings *airspeedSettings = AirspeedSettings::GetInstance(m_uavoManager);
|
||||
Q_ASSERT(airspeedSettings);
|
||||
AirspeedSettings::DataFields airspeedData = airspeedSettings->getData();
|
||||
|
||||
switch (m_configSource->getAirspeedType()) {
|
||||
@ -253,17 +261,12 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
}
|
||||
|
||||
airspeedSettings->setData(airspeedData);
|
||||
addModifiedObject(airspeedSettings, tr("Writing Airspeed sensor settings"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (gpsSettings != NULL) {
|
||||
addModifiedObject(gpsSettings, tr("Writing GPS sensor settings"));
|
||||
}
|
||||
if (airspeedSettings != NULL) {
|
||||
addModifiedObject(airspeedSettings, tr("Writing Airspeed sensor settings"));
|
||||
}
|
||||
hwSettings->setData(data);
|
||||
addModifiedObject(hwSettings, tr("Writing hardware settings"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user