Commit 825ba9e4 authored by DonLakeFlyer's avatar DonLakeFlyer

Fix v1/v2 load semantics

parent cf237be6
...@@ -166,6 +166,14 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq ...@@ -166,6 +166,14 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq
int version = complexObject[JsonHelper::jsonVersionKey].toInt(); int version = complexObject[JsonHelper::jsonVersionKey].toInt();
if (version == 1) { if (version == 1) {
QList<JsonHelper::KeyValidateInfo> v1KeyInfoList = {
{ _jsonLoiterAltitudeRelativeKey, QJsonValue::Bool, true },
{ _jsonLandingAltitudeRelativeKey, QJsonValue::Bool, true },
};
if (!JsonHelper::validateKeys(complexObject, v1KeyInfoList, errorString)) {
return false;
}
bool loiterAltitudeRelative = complexObject[_jsonLoiterAltitudeRelativeKey].toBool(); bool loiterAltitudeRelative = complexObject[_jsonLoiterAltitudeRelativeKey].toBool();
bool landingAltitudeRelative = complexObject[_jsonLandingAltitudeRelativeKey].toBool(); bool landingAltitudeRelative = complexObject[_jsonLandingAltitudeRelativeKey].toBool();
if (loiterAltitudeRelative != landingAltitudeRelative) { if (loiterAltitudeRelative != landingAltitudeRelative) {
...@@ -176,13 +184,19 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq ...@@ -176,13 +184,19 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq
} else { } else {
_altitudesAreRelative = loiterAltitudeRelative; _altitudesAreRelative = loiterAltitudeRelative;
} }
_valueSetIsDistance = true;
} else if (version == 2) { } else if (version == 2) {
QList<JsonHelper::KeyValidateInfo> v2KeyInfoList = { QList<JsonHelper::KeyValidateInfo> v2KeyInfoList = {
{ _jsonAltitudesAreRelativeKey, QJsonValue::Bool, true }, { _jsonAltitudesAreRelativeKey, QJsonValue::Bool, true },
{ _jsonValueSetIsDistanceKey, QJsonValue::Bool, true },
}; };
if (!JsonHelper::validateKeys(complexObject, v2KeyInfoList, errorString)) { if (!JsonHelper::validateKeys(complexObject, v2KeyInfoList, errorString)) {
_ignoreRecalcSignals = false;
return false; return false;
} }
_altitudesAreRelative = complexObject[_jsonAltitudesAreRelativeKey].toBool();
_valueSetIsDistance = complexObject[_jsonValueSetIsDistanceKey].toBool();
} else { } else {
errorString = tr("%1 complex item version %2 not supported").arg(jsonComplexItemTypeValue).arg(version); errorString = tr("%1 complex item version %2 not supported").arg(jsonComplexItemTypeValue).arg(version);
_ignoreRecalcSignals = false; _ignoreRecalcSignals = false;
...@@ -204,7 +218,8 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq ...@@ -204,7 +218,8 @@ bool FixedWingLandingComplexItem::load(const QJsonObject& complexObject, int seq
_loiterRadiusFact.setRawValue(complexObject[_jsonLoiterRadiusKey].toDouble()); _loiterRadiusFact.setRawValue(complexObject[_jsonLoiterRadiusKey].toDouble());
_loiterClockwise = complexObject[_jsonLoiterClockwiseKey].toBool(); _loiterClockwise = complexObject[_jsonLoiterClockwiseKey].toBool();
_altitudesAreRelative = complexObject[_jsonAltitudesAreRelativeKey].toBool();
_calcGlideSlope();
_landingCoordSet = true; _landingCoordSet = true;
...@@ -328,6 +343,8 @@ bool FixedWingLandingComplexItem::scanForItem(QmlObjectListModel* visualItems, V ...@@ -328,6 +343,8 @@ bool FixedWingLandingComplexItem::scanForItem(QmlObjectListModel* visualItems, V
complexItem->_landingCoordinate.setLongitude(missionItemLand.param6()); complexItem->_landingCoordinate.setLongitude(missionItemLand.param6());
complexItem->_landingAltitudeFact.setRawValue(missionItemLand.param7()); complexItem->_landingAltitudeFact.setRawValue(missionItemLand.param7());
complexItem->_calcGlideSlope();
complexItem->_landingCoordSet = true; complexItem->_landingCoordSet = true;
complexItem->_ignoreRecalcSignals = false; complexItem->_ignoreRecalcSignals = false;
......
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