From f0dca3917c14dec4705ad7848ee3c389f43faa77 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 5 Jun 2024 17:05:19 +0200 Subject: [PATCH] Start test-case for Neuhauser/Stockerau/748w --- main/main.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/main/main.cpp b/main/main.cpp index e9a9e15..a63f691 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -36,7 +36,7 @@ extern "C" char* strptime(const char* s, #include "calculator_functions.h" #include "calculate_price.h" -#define SZEGED (1) +#define SZEGED (0) #define SCHOENAU_KOENIGSEE (0) #define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0) @@ -45,6 +45,7 @@ extern "C" char* strptime(const char* s, #define BAD_NEUENAHR_AHRWEILER (0) #define NEUHAUSER_CHRISTOPH_REISEN (0) #define NEUHAUSER_PERNEGG_AN_DER_MUR (0) +#define NEUHAUSER_STOCKERAU (1) #if NEUHAUSER_KIRCHDORF==1 static bool test_neuhauser_kirchdorf(int step, double cost) { @@ -164,8 +165,79 @@ static bool test_neuhauser_kirchdorf(int step, double cost) { } #endif +#include int main() { +#if NEUHAUSER_STOCKERAU==1 + std::ifstream input; + int pop_min_time; + int pop_max_time; + int pop_min_price; + int pop_max_price; + int pop_daily_card_price; + + input.open("/opt/ptu5/opt/customer_748/etc/psa_tariff/tariff01.json"); + + std::stringstream sstr; + while(input >> sstr.rdbuf()); + std::string json(sstr.str()); + + Configuration cfg; + + bool isParsed = cfg.ParseJson(&cfg, json.c_str()); + cout << endl; + + if (isParsed) { + pop_min_time = get_minimal_parkingtime(&cfg); + pop_max_time = get_maximal_parkingtime(&cfg); + pop_min_price = get_minimal_parkingprice(&cfg); + pop_max_price = get_maximal_parkingprice(&cfg); + pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price; + + qCritical() << " pop_min_time: " << pop_min_time; + qCritical() << " pop_max_time: " << pop_max_time; + qCritical() << " pop_min_price: " << pop_min_price; + qCritical() << " pop_max_price: " << pop_max_price; + + // tests: + // 1: Mon-Freitag: jeweils + // start 0-8.00 + // start 8.00-12.00 + // start 12.00-13.30 + // start 13.30-18.00 + // start 18.00-24.00 + // alle kosten durchspielen + // 2. samstag + // start 0-8.00 + // start 8.00-12.00 + // start nach 12.00 + // 2. sonntag + + //QDateTime s(QDate(2024, 5, 27), QTime()); // monday + //QDateTime s(QDate(2024, 5, 28), QTime()); // tuesday + //QDateTime s(QDate(2024, 5, 29), QTime()); // wednesday + //QDateTime s(QDate(2024, 5, 30), QTime()); // thursday + + QDateTime s(QDate(2024, 5, 31), QTime()); // friday + QDateTime end; + QDateTime start = s.addSecs(7*60*60); + + CalcState cs; + for (int i = 600; i <= 600; i += 10) { + // for (int i = 70; i <= 70; i += 10) { + double cost = i; + if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value + qCritical() << "start" << start.toString(Qt::ISODate); + qCritical() << " cost" << cost; + qCritical() << " end" << end.toString(Qt::ISODate) << endl; + } else { + qCritical() << "ERROR CalcState" << cs.toString(); + } + } + } + +#endif + #if NEUHAUSER_PERNEGG_AN_DER_MUR==1 std::ifstream input; int pop_min_time;