Add test cases for muehlbach

This commit is contained in:
Gerhard Hoffmann 2024-08-13 14:38:37 +02:00
parent 2c2fd3845b
commit 19032349ae

View File

@ -49,9 +49,10 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_STOCKERAU (0)
#define KLEIPEDA_LITAUEN (0)
#define SEXTEN (0)
#define SCHNALS_LEITER_KIRCHL (1)
#define SCHNALS_LEITER_KIRCHL (0)
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
#define VALSER_ALM (0)
#define FUCHS_MUEHLBACH (1)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -708,6 +709,134 @@ int main() {
}
#endif
#if FUCHS_MUEHLBACH==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("/home/linux/customer_504/etc/psa_tariff/tariff01.json");
//input.open("/opt/ptu5/opt/customer_505/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) {
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
pop_min_time = get_minimal_parkingtime(&cfg, permitType);
pop_max_time = get_maximal_parkingtime(&cfg, permitType);
pop_min_price = get_minimal_parkingprice(&cfg, permitType);
pop_max_price = get_maximal_parkingprice(&cfg, permitType);
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;
CalcState cs;
double cost;
int durationInMinutes = 0;
int offsetInMinutes = 0;
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
QDateTime s(QDate(2024, 7, 21 + day), QTime(0, 0, 0));
QDateTime end;
switch (day) {
case (int)Qt::Monday:
qCritical() << "Monday";
break;
case (int)Qt::Tuesday:
qCritical() << "Tuesday";
break;
case (int)Qt::Wednesday:
qCritical() << "Wednesday";
break;
case (int)Qt::Thursday:
qCritical() << "Thursday";
break;
case (int)Qt::Friday:
qCritical() << "Friday";
break;
case (int)Qt::Saturday:
qCritical() << "Saturday";
break;
case (int)Qt::Sunday:
qCritical() << "Sunday";
break;
}
//for (int minutes = 0; minutes < 1440; ++minutes) {
for (int minutes = 420; minutes <= 420; minutes += 1) {
QDateTime start = s.addSecs(minutes * 60);
//qCritical() << "start" << start.toString(Qt::ISODate);
QDateTime effectiveStart = start;
// hier sollte man auch testen was passiert, falls man ausserhalb
// der verkaufsdaten steht
if (start.time() < QTime(7, 0, 0)) {
effectiveStart.setTime(QTime(7, 0, 0));
} else
if (start.time() <= QTime(20, 0, 0)) {
effectiveStart = start;
} else {
effectiveStart = start.addDays(1);
effectiveStart.setTime(QTime(7, 0, 0)); // next day
}
// #if 0
qCritical() << "";
qCritical() << "compute_duration_for_parking_ticket";
qCritical() << "===================================";
for (int i = 0; i <= 600; i += 10) {
cost = i;
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // 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
qCritical() << "";
qCritical() << "compute_price_for_parking_ticket";
qCritical() << "================================";
for (int netto_parking_time = 180; netto_parking_time <= (180 + 720*3); netto_parking_time += 36) {
QDateTime end;
struct price_t price;
cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true);
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;