Browse Source

Merge pull request #9034 from DonLakeFlyer/ParamJsonIndex

COMPONENT_INFORMATION: Parameter json metadata - support 'FOO<#>_BAR' param name metadata
QGC4.4
Don Gagne 5 years ago committed by GitHub
parent
commit
7f7bfe6351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/Vehicle/CompInfoParam.cc
  2. 2
      src/Vehicle/CompInfoParam.h
  3. 23896
      src/comm/MockLink.Parameter.MetaData.json

15
src/Vehicle/CompInfoParam.cc

@ -22,7 +22,8 @@ QGC_LOGGING_CATEGORY(CompInfoParamLog, "CompInfoParamLog") @@ -22,7 +22,8 @@ QGC_LOGGING_CATEGORY(CompInfoParamLog, "CompInfoParamLog")
const char* CompInfoParam::_jsonScopeKey = "scope";
const char* CompInfoParam::_jsonParametersKey = "parameters";
const char* CompInfoParam::_cachedMetaDataFilePrefix = "ParameterFactMetaData";
const char* CompInfoParam::_cachedMetaDataFilePrefix = "ParameterFactMetaData";
const char* CompInfoParam::_parameterIndexTag = "<#>";
CompInfoParam::CompInfoParam(uint8_t compId, Vehicle* vehicle, QObject* parent)
: CompInfo(COMP_METADATA_TYPE_PARAMETER, compId, vehicle, parent)
@ -84,10 +85,20 @@ FactMetaData* CompInfoParam::factMetaDataForName(const QString& name, FactMetaDa @@ -84,10 +85,20 @@ FactMetaData* CompInfoParam::factMetaDataForName(const QString& name, FactMetaDa
if (_opaqueParameterMetaData) {
return vehicle->firmwarePlugin()->_getMetaDataForFact(_opaqueParameterMetaData, name, type, vehicle->vehicleType());
} else {
QString indexTagName = name;
if (!_nameToMetaDataMap.contains(name)) {
// Checked for indexed parameter names: "FOO<#>_BAR" will match "FOO1_BAR"
QRegularExpression regex("\\d+");
indexTagName = indexTagName.replace(regex, _parameterIndexTag);
if (!_nameToMetaDataMap.contains(indexTagName)) {
indexTagName.clear();
}
}
if (indexTagName.isEmpty()) {
indexTagName = name;
_nameToMetaDataMap[name] = new FactMetaData(type, this);
}
return _nameToMetaDataMap[name];
return _nameToMetaDataMap[indexTagName];
}
}

2
src/Vehicle/CompInfoParam.h

@ -49,7 +49,7 @@ private: @@ -49,7 +49,7 @@ private:
QObject* _opaqueParameterMetaData = nullptr;
static const char* _cachedMetaDataFilePrefix;
static const char* _jsonScopeKey;
static const char* _jsonParametersKey;
static const char* _parameterIndexTag;
};

23896
src/comm/MockLink.Parameter.MetaData.json

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save