diff --git a/main/main.cpp b/main/main.cpp index 7e3638a..37829ae 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -51,6 +51,7 @@ extern "C" char* strptime(const char* s, #define SEXTEN (0) #define SCHNALS_LEITER_KIRCHL (1) #define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL) +#define VALSER_ALM (0) #if NEUHAUSER_KIRCHDORF==1 static bool test_neuhauser_kirchdorf(int step, double cost) { @@ -717,7 +718,7 @@ int main() { } //for (int minutes = 0; minutes < 1440; ++minutes) { - for (int minutes = 420; minutes <= 420; minutes += 1) { + for (int minutes = 1020; minutes <= 1020; minutes += 1) { QDateTime start = s.addSecs(minutes * 60); qCritical() << "start" << start.toString(Qt::ISODate); @@ -736,6 +737,24 @@ int main() { effectiveStart.setTime(QTime(7, 0, 0)); // next day } +#if 1 + for (int i = 200; i <= 200; i += 10) { + cost = i; + + if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value + } + + if (!cs) { + qCritical() << "ERROR CalcState" << cs.toString() << endl; + } else { +// qCritical() << cs.toString(); + } + + qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost + << "> end" << end.toString(Qt::ISODate); + + } +#else for (int i = 700; i <= 1400; i += 700) { //for (int i = 2100; i <= 2100; i += 10) { cost = i; @@ -752,19 +771,205 @@ int main() { qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost << "> end" << end.toString(Qt::ISODate); } - for (int i = 60; i <= 60; i += 6) { +#endif +#if 0 + + start = QDateTime::currentDateTime(); + start.setTime(QTime(9, 57, 0)); + + for (int i = 66; i <= 66; i += 6) { QDateTime end; struct price_t price; - cs = compute_price_for_parking_ticket(&cfg, start, 60, end, &price); + cs = compute_price_for_parking_ticket(&cfg, start, i, end, &price); - qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate); + qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate) + << "price" << price.netto; } +#endif } } } #endif +#if VALSER_ALM==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; + + int zone = 2; + + if (zone == 1) { + input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json"); + } + if (zone == 2) { + input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json"); + } + if (zone == 3) { + input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.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; + + //QDateTime start = QDateTime::currentDateTime(); + //start.setTime(QTime(12, 0, 0)); + //QList timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start); + //qCritical() << "TimeSteps" << timeSteps; + //return 0; + + if (zone == 2) { + //int minParkingTime = get_minimal_parkingtime(&cfg); + QList timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg); + qCritical() << timeSteps; + int Down = 0; + int Up = 1; + + QDateTime const start = QDateTime::currentDateTime(); + int paymentOptionIndex = cfg.getPaymentOptionIndex(start); + + if (paymentOptionIndex < 0) { + qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex + << "< 0 for start" << start.toString(Qt::ISODate); + exit(-1); + } + + QSet const prices{600, 1200, 1800, 2400, 3000, 3600, 4200}; + + + for (int i=0; i