From 76bb1eb56a1b35a960e13ebc2a03dc6d8251b992 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 24 Apr 2024 09:54:29 +0200 Subject: [PATCH] Minor: small changes for tests of SCHOENAU --- main/main.cpp | 68 +++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index baa9b66..58aafc5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -35,7 +35,7 @@ extern "C" char* strptime(const char* s, #include "calculate_price.h" #define SZEGED (0) -#define SCHOENAU_KOENIGSEE (0) +#define SCHOENAU_KOENIGSEE (1) #define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0) @@ -43,7 +43,7 @@ extern "C" char* strptime(const char* s, #define NEUHAUSER_KIRCHDORF (0) #define BAD_NEUENAHR_AHRWEILER (0) #define NEUHAUSER_CHRISTOPH_REISEN (0) -#define NEUHAUSER_PERNEGG_AN_DER_MUR (1) +#define NEUHAUSER_PERNEGG_AN_DER_MUR (0) int main() { #if NEUHAUSER_PERNEGG_AN_DER_MUR==1 @@ -475,44 +475,54 @@ int main() { #endif #if SCHOENAU_KOENIGSEE==1 - //QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json"); - QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json"); + for (int zone=1; zone < 3; ++zone) { + std::ifstream input; - std::ifstream input(f.toUtf8().constData()); + if (zone == 1) { + input.open("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json"); + } + if (zone == 2) { + input.open("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json"); + } - std::stringstream sstr; - while(input >> sstr.rdbuf()); - std::string json(sstr.str()); + qCritical() << "--------------------"; + qCritical() << " ZONE" << zone; + qCritical() << "--------------------"; - Configuration cfg; + std::stringstream sstr; + while(input >> sstr.rdbuf()); + std::string json(sstr.str()); - bool isParsed = cfg.ParseJson(&cfg, json.c_str()); - cout << endl; + Configuration cfg; - if (isParsed) { - qCritical() << "parsed" << f; + bool isParsed = cfg.ParseJson(&cfg, json.c_str()); + cout << endl; - int minParkingTime = get_minimal_parkingtime(&cfg); - qCritical() << "minimal_parking_time" << minParkingTime; + if (isParsed) { + // qCritical() << "parsed zone" << zone << "file"; - QDateTime start = QDateTime::currentDateTime(); + int minParkingTime = get_minimal_parkingtime(&cfg); + qCritical() << "minimal_parking_time" << minParkingTime; - // zone 1 - //int timeSteps[] = {60, 180, 1440, 2880, 4320, 5670, 7200, 8640, 10080, 11520, 12960, 14400}; + QDateTime start = QDateTime::currentDateTime(); - static QList const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg); - qCritical() << "TimeSteps" << timeSteps; + // zone 1 + //int timeSteps[] = {60, 180, 1440, 2880, 4320, 5670, 7200, 8640, 10080, 11520, 12960, 14400}; - for (int i = 0 ; i < timeSteps.size(); ++i) { - QDateTime end = start.addSecs(timeSteps.at(i)*60); + static QList const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg); + qCritical() << "TimeSteps" << timeSteps; - double price = Calculator::GetInstance().GetCostFromDuration( - &cfg, - start, - timeSteps.at(i)); - qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i) - << "(" << timeSteps.at(i)/60 << "h)" - << "price=" << price; + for (int i = 0 ; i < timeSteps.size(); ++i) { + QDateTime end = start.addSecs(timeSteps.at(i)*60); + + double price = Calculator::GetInstance().GetCostFromDuration( + &cfg, + start, + timeSteps.at(i)); + qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i) + << "(" << timeSteps.at(i)/60 << "h)" + << "price=" << price; + } } } #endif