From 2a492475e32527fa4dd0d1f3beb151cee5e7de99 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 7 May 2024 16:21:36 +0200 Subject: [PATCH] Bad Neuenahr: Zone5 tests --- main/main.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index ab6f2f1..5b70bff 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -41,8 +41,8 @@ extern "C" char* strptime(const char* s, #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0) #define NEUHAUSER_BILEXA_GALTUER (0) #define NEUHAUSER_KIRCHDORF (0) -#define BAD_NEUENAHR_AHRWEILER (0) -#define NEUHAUSER_CHRISTOPH_REISEN (1) +#define BAD_NEUENAHR_AHRWEILER (1) +#define NEUHAUSER_CHRISTOPH_REISEN (0) #define NEUHAUSER_PERNEGG_AN_DER_MUR (0) #if NEUHAUSER_KIRCHDORF==1 @@ -372,34 +372,41 @@ int main() { int pop_carry_over; int pop_carry_over_time_range_id; - for (int zone=7; zone < 8; ++zone) { + for (int zone=5; zone < 6; ++zone) { //for (int t=6; t < 7; t+=20) { switch (zone) { case 1: { + // standard-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json"); //pop_max_time = 6*60; } break; case 2: { + // kuzzeit-1-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json"); //pop_max_time = 5*60; } break; case 3: { + // kuzzeit-2-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json"); //pop_max_time = 6*60; } break; case 4: { + // kuzzeit-3-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json"); //pop_max_time = 4*60; } break; case 5: { + // langzeit-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json"); //pop_max_time = 6*60; } break; case 6: { + // sondertarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json"); //pop_max_time = 4*60; } break; case 7: { + // wochenend-tarif input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json"); //pop_max_time = 4*60; } break; @@ -764,7 +771,63 @@ int main() { } } } - if (zone == 5) { + if (zone == 5) { // langzeit-tarif + 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() << zone << " pop_min_time: " << pop_min_time; + qCritical() << zone << " pop_max_time: " << pop_max_time; + qCritical() << zone << " pop_min_price: " << pop_min_price; + qCritical() << zone << " pop_max_price: " << pop_max_price; + qCritical() << zone << "pop_daily_card_price: " << pop_daily_card_price; + + static QList const stepsConfigured + = QList(std::initializer_list{ + 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440, 4320, 10080 + }); + + static QList const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg); + qCritical() << "( TimeSteps :" << __LINE__ << ")" << timeSteps; + + if (stepsConfigured != timeSteps) { + qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured; + return -1; + } + + bool fail; + QDateTime start = QDateTime::currentDateTime(); + + int paymentOptionIndex = cfg.getPaymentOptionIndex(start); + if (paymentOptionIndex != -1) { + QDateTime end; + struct price_t price; + + qCritical() << "paymentOptionIndex" << paymentOptionIndex; + + QList::const_iterator step; + int i = 0; + for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) { + if (++i < 16) continue; + + double cost = 0; + CalcState cs; + + if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) { + cost = price.netto; + qCritical() << "step" << *step << ": cost" << cost; + } else { + if (fail == false) { + qCritical() << "<<>> cs =" << QString(cs); + } + } + exit(0); + } + } else { + qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex; + } } if (zone == 6) { // sondertarif: 24h ticket wohnmobile @@ -815,7 +878,6 @@ int main() { qCritical() << zone << " pop_max_price: " << pop_max_price; qCritical() << zone << "pop_daily_card_price: " << pop_daily_card_price; - static QList const stepsConfigured = QList(std::initializer_list{ 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440}); @@ -834,10 +896,23 @@ int main() { QDateTime start = QDateTime::currentDateTime(); + // testing + start.setDate(QDate(2024, 5, 5)); + start.setTime(QTime(16, 0, 0)); + struct price_t costs; double price1 = 0; double price2 = 0; + CalcState cs; + for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) { + QDateTime end = start.addSecs(timeSteps.at(i)*60); + cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs); + qCritical() << endl; + } + + exit(0); + for (int m=0; m < 1440; ++m) { start.setTime(QTime(0, 0, 0)); start = start.addSecs(m*60); @@ -854,8 +929,6 @@ int main() { // qCritical() << "prevTimeStep" << prevTimeStep; //} - CalcState cs; - for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) { QDateTime end = start.addSecs(timeSteps.at(i)*60);