27 changed files with 264 additions and 222 deletions
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 5637057af5ab8ec5667e3f8e5f8c73d3bc60eed8 |
||||
Subproject commit 9e07c7d0b6eb91f0fd84f911dc91e68e865ba7ed |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#include "CompInfoGeneral.h" |
||||
|
||||
#include "JsonHelper.h" |
||||
#include "FactMetaData.h" |
||||
#include "FirmwarePlugin.h" |
||||
#include "FirmwarePluginManager.h" |
||||
#include "QGCApplication.h" |
||||
|
||||
#include <QStandardPaths> |
||||
#include <QJsonDocument> |
||||
#include <QJsonArray> |
||||
|
||||
QGC_LOGGING_CATEGORY(CompInfoGeneralLog, "CompInfoGeneralLog") |
||||
|
||||
const char* CompInfoGeneral::_jsonMetadataTypesKey = "metadataTypes"; |
||||
|
||||
CompInfoGeneral::CompInfoGeneral(uint8_t compId, Vehicle* vehicle, QObject* parent) |
||||
: CompInfo(COMP_METADATA_TYPE_GENERAL, compId, vehicle, parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void CompInfoGeneral::setUris(CompInfo &compInfo) const |
||||
{ |
||||
const auto& metadataTypeIter = _supportedTypes.constFind(compInfo.type); |
||||
if (metadataTypeIter == _supportedTypes.constEnd()) { |
||||
compInfo._uris = {}; // reset
|
||||
} else { |
||||
compInfo._uris = *metadataTypeIter; |
||||
} |
||||
} |
||||
|
||||
void CompInfoGeneral::setJson(const QString& metadataJsonFileName, const QString& /*translationJsonFileName*/) |
||||
{ |
||||
if (metadataJsonFileName.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
QString errorString; |
||||
QJsonDocument jsonDoc; |
||||
|
||||
if (!JsonHelper::isJsonFile(metadataJsonFileName, jsonDoc, errorString)) { |
||||
qCWarning(CompInfoGeneralLog) << "Metadata json file open failed: compid:" << compId << errorString; |
||||
return; |
||||
} |
||||
QJsonObject jsonObj = jsonDoc.object(); |
||||
|
||||
QList<JsonHelper::KeyValidateInfo> keyInfoList = { |
||||
{ JsonHelper::jsonVersionKey, QJsonValue::Double, true }, |
||||
{ _jsonMetadataTypesKey, QJsonValue::Array, true }, |
||||
}; |
||||
if (!JsonHelper::validateKeys(jsonObj, keyInfoList, errorString)) { |
||||
qCWarning(CompInfoGeneralLog) << "Metadata json validation failed: compid:" << compId << errorString; |
||||
return; |
||||
} |
||||
|
||||
int version = jsonObj[JsonHelper::jsonVersionKey].toInt(); |
||||
if (version != 1) { |
||||
qCWarning(CompInfoGeneralLog) << "Metadata json unsupported version" << version; |
||||
return; |
||||
} |
||||
|
||||
QJsonArray rgSupportedTypes = jsonObj[_jsonMetadataTypesKey].toArray(); |
||||
for (QJsonValue typeValue : rgSupportedTypes) { |
||||
int type = typeValue["type"].toInt(-1); |
||||
if (type == -1) |
||||
continue; |
||||
Uris uris; |
||||
uris.uriMetaData = typeValue["uri"].toString(); |
||||
uris.crcMetaData = typeValue["fileCrc"].toVariant().toLongLong(); // Note: can't use toInt()
|
||||
uris.crcMetaDataValid = typeValue.toObject().contains("fileCrc"); |
||||
uris.uriMetaDataFallback = typeValue["uriFallback"].toString(); |
||||
uris.crcMetaDataFallback = typeValue["fileCrcFallback"].toVariant().toLongLong(); |
||||
uris.crcMetaDataFallbackValid = typeValue.toObject().contains("fileCrcFallback"); |
||||
uris.uriTranslation = typeValue["translationUri"].toString(); |
||||
uris.crcTranslation = typeValue["translationFileCrc"].toVariant().toLongLong(); |
||||
uris.crcTranslationValid = typeValue.toObject().contains("translationFileCrc"); |
||||
uris.uriTranslationFallback = typeValue["translationUriFallback"].toString(); |
||||
uris.crcTranslationFallback = typeValue["translationFileCrcFallback"].toVariant().toLongLong(); |
||||
uris.crcTranslationFallbackValid = typeValue.toObject().contains("translationFileCrcFallback"); |
||||
_supportedTypes[(COMP_METADATA_TYPE)type] = uris; |
||||
qCDebug(CompInfoGeneralLog) << "Metadata type : uri : crc" << type << uris.uriMetaData << uris.crcMetaData; |
||||
} |
||||
} |
@ -1,65 +0,0 @@
@@ -1,65 +0,0 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#include "CompInfoVersion.h" |
||||
#include "JsonHelper.h" |
||||
#include "FactMetaData.h" |
||||
#include "FirmwarePlugin.h" |
||||
#include "FirmwarePluginManager.h" |
||||
#include "QGCApplication.h" |
||||
|
||||
#include <QStandardPaths> |
||||
#include <QJsonDocument> |
||||
#include <QJsonArray> |
||||
|
||||
QGC_LOGGING_CATEGORY(CompInfoVersionLog, "CompInfoVersionLog") |
||||
|
||||
const char* CompInfoVersion::_jsonSupportedCompMetadataTypesKey = "supportedCompMetadataTypes"; |
||||
|
||||
CompInfoVersion::CompInfoVersion(uint8_t compId, Vehicle* vehicle, QObject* parent) |
||||
: CompInfo (COMP_METADATA_TYPE_VERSION, compId, vehicle, parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void CompInfoVersion::setJson(const QString& metadataJsonFileName, const QString& /*translationJsonFileName*/) |
||||
{ |
||||
if (metadataJsonFileName.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
QString errorString; |
||||
QJsonDocument jsonDoc; |
||||
|
||||
if (!JsonHelper::isJsonFile(metadataJsonFileName, jsonDoc, errorString)) { |
||||
qCWarning(CompInfoVersionLog) << "Metadata json file open failed: compid:" << compId << errorString; |
||||
return; |
||||
} |
||||
QJsonObject jsonObj = jsonDoc.object(); |
||||
|
||||
QList<JsonHelper::KeyValidateInfo> keyInfoList = { |
||||
{ JsonHelper::jsonVersionKey, QJsonValue::Double, true }, |
||||
{ _jsonSupportedCompMetadataTypesKey, QJsonValue::Array, true }, |
||||
}; |
||||
if (!JsonHelper::validateKeys(jsonObj, keyInfoList, errorString)) { |
||||
qCWarning(CompInfoVersionLog) << "Metadata json validation failed: compid:" << compId << errorString; |
||||
return; |
||||
} |
||||
|
||||
int version = jsonObj[JsonHelper::jsonVersionKey].toInt(); |
||||
if (version != 1) { |
||||
qCWarning(CompInfoVersionLog) << "Metadata json unsupported version" << version; |
||||
return; |
||||
} |
||||
|
||||
QJsonArray rgSupportedTypes = jsonObj[_jsonSupportedCompMetadataTypesKey].toArray(); |
||||
for (QJsonValue typeValue: rgSupportedTypes) { |
||||
_supportedTypes.append(static_cast<COMP_METADATA_TYPE>(typeValue.toInt())); |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue