Add addition parsing of ATBTimeRange.

This commit is contained in:
Gerhard Hoffmann 2024-02-15 16:13:28 +01:00
parent 2ec94121f7
commit 707ab1716b

View File

@ -56,12 +56,12 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
}
// Validate JSON, check if it's a JSON object
printf("%s", "JSON parsing has been successful\n");
qCritical() << "JSON parsing has been successful";
if (!document.IsObject()) {
printf("%s", "Error: not a (valid) JSON object\n");
return false;
}
printf("%s", "Valid JSON object identified\n");
qCritical() << "Valid JSON object identified";
// Validate JSON, check configuration members
if (!document.HasMember("Currency")
@ -77,7 +77,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
printf("%s", "Error: not a valid configuration JSON\n");
return false;
}
printf("%s", "Valid JSON configuration identified\n");
qCritical() << "Valid JSON configuration identified";
ATBCurrency Currency;
ATBDuration Duration;
@ -126,7 +126,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
continue;
}
printf(" -%s\n", mb_name);
qCritical() << " -" << mb_name;
// Get array for each JSON object member
auto mb_array = document[mb_name].GetArray();
@ -167,12 +167,32 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
if (k->value.IsString()) {
QTime timeRangeFrom = QTime::fromString(QString::fromStdString(k->value.GetString()), Qt::ISODate);
TimeRange.time_range_from = timeRangeFrom;
} else
if (k->value.IsInt()) {
int timeRangeFrom = k->value.GetInt();
TimeRange.time_range_from_in_minutes_from_start = timeRangeFrom;
}
} else
if (QString(inner_obj_name) == QString("time_range_to")) {
if (k->value.IsString()) {
QTime timeRangeTo = QTime::fromString(QString::fromStdString(k->value.GetString()), Qt::ISODate);
TimeRange.time_range_to = timeRangeTo;
} else
if (k->value.IsInt()) {
int timeRangeTo = k->value.GetInt();
TimeRange.time_range_to_in_minutes_from_start = timeRangeTo;
}
} else
if (QString(inner_obj_name) == QString("time_range_tbase_id")) {
if (k->value.IsInt()) {
int tbase = k->value.GetInt();
TimeRange.time_range_tbase_id = tbase;
}
} else
if (QString(inner_obj_name) == QString("time_range_payment_rate_id")) {
if (k->value.IsInt()) {
int ptype = k->value.GetInt();
TimeRange.time_range_payment_type_id = ptype;
}
}
break;
@ -451,7 +471,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
break;
case MemberType::TimeRangeType:
cfg->TimeRange.insert(pair<int, ATBTimeRange>(TimeRange.time_range_id, TimeRange));
// qCritical() << TimeRange;
//qCritical() << TimeRange;
break;
case MemberType::TimeStepConfigType:
cfg->TimeStepConfig.insert(pair<int, ATBTimeStepConfig>(TimeStepConfig.tsconfig_id, TimeStepConfig));