Start test case for Bad Neuenahr

This commit is contained in:
Gerhard Hoffmann 2024-04-08 13:53:29 +02:00
parent a5b95d71b8
commit 4f9c0422fc

View File

@ -38,9 +38,10 @@ extern "C" char* strptime(const char* s,
#define SCHOENAU_KOENIGSEE (0) #define SCHOENAU_KOENIGSEE (0)
#define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1) #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
#define NEUHAUSER_BILEXA_GALTUER (0) #define NEUHAUSER_BILEXA_GALTUER (0)
#define NEUHAUSER_KIRCHDORF (0) #define NEUHAUSER_KIRCHDORF (0)
#define BAD_NEUENAHR_AHRWEILER (1)
#if NEUHAUSER_KIRCHDORF==1 #if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) { static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -159,6 +160,151 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
#endif #endif
int main() { int main() {
#if BAD_NEUENAHR_AHRWEILER==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;
for (int zone=1; zone < 2; ++zone) {
//for (int t=6; t < 7; t+=20) {
switch (zone) {
case 1: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json");
//pop_max_time = 6*60;
} break;
case 2: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
//pop_max_time = 5*60;
} break;
case 3: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json");
//pop_max_time = 6*60;
} break;
case 4: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json");
//pop_max_time = 4*60;
} break;
case 5: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json");
//pop_max_time = 6*60;
} break;
case 6: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json");
//pop_max_time = 4*60;
} break;
case 7: {
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json");
//pop_max_time = 4*60;
} break;
default:
continue;
}
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) {
// test library functions
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;
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
static QList<int> const stepsConfigured
= QList(std::initializer_list<int>{
20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440});
//static QList<double> const cost
// = QList(std::initializer_list<double>{
// 0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 500});
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
qCritical() << "TimeSteps" << timeSteps;
if (stepsConfigured != timeSteps) {
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
return -1;
}
QDateTime start = QDateTime::currentDateTime();
struct price_t costs;
double price1 = 0;
double price2 = 0;
for (int m=0; m < 1440; ++m) {
start.setTime(QTime(0, 0, 0));
start = start.addSecs(m*60);
qCritical() << "START" << start.toString(Qt::ISODate);
//int Down = 0;
//int Up = 1;
// for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
// int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
// qCritical() << "nextTimeStep" << nextTimeStep;
//
// int prevTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Down);
// 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);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
if (cs.getStatus() != CalcState::State::SUCCESS) {
if (start.time().hour() >= 8 && start.time().hour() < 18) {
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
exit(-1);
} else {
if (cs.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
qCritical() << "CALC-STATE=" << QString(cs);
continue;
}
qCritical() << "ERROR CALC-STATE-2=" << QString(cs);
exit(-1);
}
}
price1 = costs.netto;
price2 = Calculator::GetInstance().GetCostFromDuration(&cfg, start, timeSteps.at(i));
if (price1 != price2) {
qCritical() << "ERROR DIFFERENT PRICES" << price1 << price2;
exit(-1);
}
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
<< timeSteps.at(i) << "PRICE=" << price1;
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
// start.toString(Qt::ISODate).toStdString().c_str(),
// cost[i], false, true);
//qCritical() << "duration" << duration.c_str();
}
}
}
}
#endif
#if SCHOENAU_KOENIGSEE==1 #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/tariff01.json");
//QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json"); //QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json");
@ -703,7 +849,7 @@ int main() {
int pop_max_price; int pop_max_price;
int pop_daily_card_price; int pop_daily_card_price;
for (int zone=6; zone < 7; ++zone) { for (int zone=1; zone < 2; ++zone) {
//for (int t=6; t < 7; t+=20) { //for (int t=6; t < 7; t+=20) {
switch (zone) { switch (zone) {
case 1: { case 1: {
@ -779,7 +925,7 @@ int main() {
{ {
// zone 1 (lila) // zone 1 (lila)
QDateTime s(QDate(2023, 11, 30), QTime()); QDateTime s(QDate(2024, 3, 26), QTime());
QDateTime end; QDateTime end;
int cnt = 1; int cnt = 1;
if (zone == 1) { if (zone == 1) {