20 QStringLiteral(
":/json/PowerModulePresets.json"),
21 QStringLiteral(
"PowerModulePresets"), 1, 1, version,
errorString);
23 qCCritical(PowerModulePresetControllerLog) <<
errorString;
27 if (!root.value(QStringLiteral(
"powerModules")).isArray()) {
28 qCCritical(PowerModulePresetControllerLog) <<
"Missing or invalid 'powerModules' array";
32 static const QList<JsonHelper::KeyValidateInfo> keyInfo = {
33 {
"name", QJsonValue::String,
true },
34 {
"voltMult", QJsonValue::Double,
true },
35 {
"ampPerVolt", QJsonValue::Double,
true },
36 {
"ampOffset", QJsonValue::Double,
true },
39 const QJsonArray modules = root.value(QStringLiteral(
"powerModules")).toArray();
41 result.reserve(modules.size());
43 for (
int i = 0; i < modules.size(); ++i) {
44 if (!modules.at(i).isObject()) {
45 qCCritical(PowerModulePresetControllerLog) <<
"powerModules[" << i <<
"] is not an object";
48 const QJsonObject obj = modules.at(i).toObject();
52 qCCritical(PowerModulePresetControllerLog) <<
"powerModules[" << i <<
"]:" <<
errorString;
56 result.append(obj.toVariantMap());
QJsonObject openInternalQGCJsonFile(const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString)
returned error string if validation fails