Commit 6256bc21 authored by DonLakeFlyer's avatar DonLakeFlyer

parent 9f396d68
......@@ -321,9 +321,9 @@ bool FactMetaData::isInRawMinLimit(const QVariant& variantValue) const
case valueTypeInt64:
return _rawMin.value<int64_t>() <= variantValue.value<int64_t>();
case valueTypeFloat:
return _rawMin.value<float>() <= variantValue.value<float>();
return qIsNaN(variantValue.toFloat()) || _rawMin.value<float>() <= variantValue.value<float>();
case valueTypeDouble:
return _rawMin.value<double>() <= variantValue.value<double>();
return qIsNaN(variantValue.toDouble()) || _rawMin.value<double>() <= variantValue.value<double>();
default:
return true;
}
......@@ -351,9 +351,9 @@ bool FactMetaData::isInRawMaxLimit(const QVariant& variantValue) const
case valueTypeInt64:
return _rawMax.value<int64_t>() >= variantValue.value<int64_t>();
case valueTypeFloat:
return _rawMax.value<float>() >= variantValue.value<float>();
return qIsNaN(variantValue.toFloat()) || _rawMax.value<float>() >= variantValue.value<float>();
case valueTypeDouble:
return _rawMax.value<double>() >= variantValue.value<double>();
return qIsNaN(variantValue.toDouble()) || _rawMax.value<double>() >= variantValue.value<double>();
default:
return true;
}
......@@ -1294,26 +1294,31 @@ FactMetaData* FactMetaData::createFromJsonObject(const QJsonObject& json, QMap<Q
metaData->setRawUnits(json[_unitsJsonKey].toString());
}
QString defaultValueJsonKey;
QString defaultValueJsonKey = _defaultValueJsonKey;
#ifdef __mobile__
if (json.contains(_mobileDefaultValueJsonKey)) {
defaultValueJsonKey = _mobileDefaultValueJsonKey;
}
#endif
if (defaultValueJsonKey.isEmpty() && json.contains(_defaultValueJsonKey)) {
defaultValueJsonKey = _defaultValueJsonKey;
}
if (!defaultValueJsonKey.isEmpty()) {
QVariant typedValue;
QString errorString;
QVariant initialValue = json[defaultValueJsonKey].toVariant();
if (metaData->convertAndValidateRaw(initialValue, true /* convertOnly */, typedValue, errorString)) {
metaData->setRawDefaultValue(typedValue);
if (json.contains(defaultValueJsonKey)) {
const QJsonValue jsonValue = json[defaultValueJsonKey];
if (jsonValue.type() == QJsonValue::Null && (type == valueTypeFloat || type == valueTypeDouble)) {
metaData->setRawDefaultValue(type == valueTypeFloat ? std::numeric_limits<float>::quiet_NaN() : std::numeric_limits<double>::quiet_NaN());
} else {
qWarning() << "Invalid default value, name:" << metaData->name()
<< " type:" << metaData->type()
<< " value:" << initialValue
<< " error:" << errorString;
QVariant typedValue;
QString errorString;
QVariant initialValue = jsonValue.toVariant();
if (metaData->convertAndValidateRaw(initialValue, true /* convertOnly */, typedValue, errorString)) {
metaData->setRawDefaultValue(typedValue);
} else {
qWarning() << "Invalid default value, name:" << metaData->name()
<< " type:" << metaData->type()
<< " value:" << initialValue
<< " error:" << errorString;
}
}
}
......
{
"version": 1,
"fileType": "FactMetaData",
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "goodAttitudeEsimate",
"shortDesc": "Good Attitude Esimate",
"type": "bool",
"default": false
"name": "goodAttitudeEsimate",
"shortDesc": "Good Attitude Esimate",
"type": "bool",
"default": false
},
{
"name": "goodHorizVelEstimate",
"shortDesc": "Good Horiz Vel Estimate",
"type": "bool",
"default": false
"name": "goodHorizVelEstimate",
"shortDesc": "Good Horiz Vel Estimate",
"type": "bool",
"default": false
},
{
"name": "goodVertVelEstimate",
"shortDesc": "Good Vert Vel Estimate",
"type": "bool",
"default": false
"name": "goodVertVelEstimate",
"shortDesc": "Good Vert Vel Estimate",
"type": "bool",
"default": false
},
{
"name": "goodHorizPosRelEstimate",
"shortDesc": "Good Horiz Pos Rel Estimate",
"type": "bool",
"default": false
"name": "goodHorizPosRelEstimate",
"shortDesc": "Good Horiz Pos Rel Estimate",
"type": "bool",
"default": false
},
{
"name": "goodHorizPosAbsEstimate",
"shortDesc": "Good Horiz Pos Abs Estimate",
"type": "bool",
"default": false
"name": "goodHorizPosAbsEstimate",
"shortDesc": "Good Horiz Pos Abs Estimate",
"type": "bool",
"default": false
},
{
"name": "goodVertPosAbsEstimate",
"shortDesc": "Good Vert Pos Abs Estimate",
"type": "bool",
"default": false
"name": "goodVertPosAbsEstimate",
"shortDesc": "Good Vert Pos Abs Estimate",
"type": "bool",
"default": false
},
{
"name": "goodVertPosAGLEstimate",
"shortDesc": "Good Vert Pos AGL Estimate",
"type": "bool",
"default": false
"name": "goodVertPosAGLEstimate",
"shortDesc": "Good Vert Pos AGL Estimate",
"type": "bool",
"default": false
},
{
"name": "goodConstPosModeEstimate",
"shortDesc": "Good Const Pos Mode Estimate",
"type": "bool",
"default": false
"name": "goodConstPosModeEstimate",
"shortDesc": "Good Const Pos Mode Estimate",
"type": "bool",
"default": false
},
{
"name": "goodPredHorizPosRelEstimate",
"shortDesc": "Good Pred Horiz Pos Rel Estimate",
"type": "bool",
"default": false
"name": "goodPredHorizPosRelEstimate",
"shortDesc": "Good Pred Horiz Pos Rel Estimate",
"type": "bool",
"default": false
},
{
"name": "goodPredHorizPosAbsEstimate",
"shortDesc": "Good Pred Horiz Pos Abs Estimate",
"type": "bool",
"default": false
"name": "goodPredHorizPosAbsEstimate",
"shortDesc": "Good Pred Horiz Pos Abs Estimate",
"type": "bool",
"default": false
},
{
"name": "gpsGlitch",
"shortDesc": "Gps Glitch",
"type": "bool",
"default": false
"name": "gpsGlitch",
"shortDesc": "Gps Glitch",
"type": "bool",
"default": false
},
{
"name": "accelError",
"shortDesc": "Accel Error",
"type": "bool",
"default": false
"name": "accelError",
"shortDesc": "Accel Error",
"type": "bool",
"default": false
},
{
"name": "velRatio",
"shortDesc": "Vel Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "velRatio",
"shortDesc": "Vel Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "horizPosRatio",
"shortDesc": "Horiz Pos Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "horizPosRatio",
"shortDesc": "Horiz Pos Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "vertPosRatio",
"shortDesc": "Vert Pos Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "vertPosRatio",
"shortDesc": "Vert Pos Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "magRatio",
"shortDesc": "Mag Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "magRatio",
"shortDesc": "Mag Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "haglRatio",
"shortDesc": "HAGL Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "haglRatio",
"shortDesc": "HAGL Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "tasRatio",
"shortDesc": "TAS Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "tasRatio",
"shortDesc": "TAS Ratio",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "horizPosAccuracy",
"shortDesc": "Horiz Pos Accuracy",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "horizPosAccuracy",
"shortDesc": "Horiz Pos Accuracy",
"type": "float",
"decimalPlaces": 2,
"default": null
},
{
"name": "vertPosAccuracy",
"shortDesc": "Vert Pos Accuracy",
"type": "float",
"decimalPlaces": 2,
"default": null
"name": "vertPosAccuracy",
"shortDesc": "Vert Pos Accuracy",
"type": "float",
"decimalPlaces": 2,
"default": null
}
]
}
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