Added tests for Schnals
This commit is contained in:
parent
02927be9c9
commit
e5d23d8022
186
main/main.cpp
186
main/main.cpp
@ -48,7 +48,9 @@ extern "C" char* strptime(const char* s,
|
||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||
#define NEUHAUSER_STOCKERAU (0)
|
||||
#define KLEIPEDA_LITAUEN (0)
|
||||
#define SEXTEN (1)
|
||||
#define SEXTEN (0)
|
||||
#define SCHNALS_LEITER_KIRCHL (1)
|
||||
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@ -209,8 +211,20 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
|
||||
|
||||
int main() {
|
||||
#if 0
|
||||
|
||||
|
||||
//487 {
|
||||
// 488 "pra_payment_option_id": 1049,
|
||||
// 489 "pra_payment_unit_id": 84,
|
||||
// 490 "pra_price":"840"
|
||||
//>>491 }
|
||||
|
||||
//for (int i = 1; i < 85; ++i) {
|
||||
//printf("{\n \"\pra_payment_option_id\": 1049,\n \"\pra_payment_unit_id\": %d,\n \"pra_price\": %d\n},\n",
|
||||
// i, i*10);
|
||||
//}
|
||||
//return 0;
|
||||
#if 0
|
||||
MessageHelper msgHelp;
|
||||
// msgHelp.createLoginMessageChunksToSend(0x02);
|
||||
msgHelp.createAuthorizeMessageChunksToSend(0x02);
|
||||
@ -537,10 +551,10 @@ int main() {
|
||||
*/
|
||||
|
||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
for (int minutes = 480; minutes < 481; minutes += 1) {
|
||||
for (int minutes = 0; minutes < 1440; minutes += 1) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
QDateTime effectiveStart = start;
|
||||
|
||||
@ -554,14 +568,15 @@ int main() {
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
}
|
||||
|
||||
for (int i = 100; i <= 100; i += 10) {
|
||||
for (int i = 10; i <= 400; i += 10) {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
|
||||
|
||||
qCritical() << "end" << end.toString(Qt::ISODate);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
@ -599,7 +614,7 @@ int main() {
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
qCritical() << cs.toString();
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -620,6 +635,163 @@ int main() {
|
||||
|
||||
#endif
|
||||
|
||||
#if (SCHNALS_LEITER_KIRCHL==1 || SCHNALS_STAUMAUER==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_505/etc/psa_tariff/tariff01.json");
|
||||
//input.open("/opt/ptu5/opt/customer_506/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;
|
||||
|
||||
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
return 0;
|
||||
|
||||
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, 14 + day), QTime());
|
||||
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(8, 0, 0)) {
|
||||
effectiveStart.setTime(QTime(8, 0, 0));
|
||||
} else
|
||||
if (start.time() <= QTime(19, 0, 0)) {
|
||||
effectiveStart = start;
|
||||
} else {
|
||||
effectiveStart = start.addDays(1);
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
}
|
||||
|
||||
for (int i = 10; i <= 400; i += 10) {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
durationInMinutes += (i/10) * 4;
|
||||
}
|
||||
offsetInMinutes = 0;
|
||||
|
||||
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
|
||||
if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
|
||||
offsetInMinutes = 780; // 19:00 -> 8:00
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
i += 20;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||
|
||||
if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
|
||||
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << "| cost ............................." << cost;
|
||||
qCritical() << "| durationInMinutes ................" << durationInMinutes
|
||||
<< "(" << (durationInMinutes - 60) << "+ 60 )";
|
||||
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
|
||||
#if 0
|
||||
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "cost ............................." << cost;
|
||||
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
|
||||
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_STOCKERAU==1
|
||||
std::ifstream input;
|
||||
int pop_min_time;
|
||||
|
Loading…
Reference in New Issue
Block a user