test for valser alm (fane)

This commit is contained in:
Gerhard Hoffmann 2024-07-30 15:24:52 +02:00
parent 52b7c2390a
commit 7233bc55c2
2 changed files with 60 additions and 84 deletions

View File

@ -801,7 +801,7 @@ int main() {
int pop_max_price;
int pop_daily_card_price;
int zone = 1;
int zone = 3;
if (zone == 1) {
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
@ -824,7 +824,7 @@ int main() {
if (isParsed) {
if (zone == 1) {
if (zone == 1 || zone == 3) {
/*
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
@ -848,7 +848,8 @@ int main() {
qCritical() << " pop_min_price_bus: " << pop_min_price;
qCritical() << " pop_max_price_bus: " << pop_max_price;
*/
} else {
}
if (zone == 2) {
pop_min_time = get_minimal_parkingtime(&cfg);
pop_max_time = get_maximal_parkingtime(&cfg);
pop_min_price = get_minimal_parkingprice(&cfg);
@ -897,7 +898,7 @@ int main() {
//qCritical() << calcState.toString();
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)6000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
(double)9000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
}
@ -957,89 +958,62 @@ int main() {
#endif
}
if (zone == 3) {
int price;
QDateTime productStart;
QDateTime productEnd;
QDateTime start = QDateTime::currentDateTime();
//QDateTime xx(QDateTime::fromString("2024-07-31T00:00:00", Qt::ISODate));
//xx = xx.addSecs(-60); // --> "2024-07-30T23:59:00"
//qCritical() << xx.toString(Qt::ISODate);
#if 0
start.setTime(QTime(0, 0, 0));
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
qCritical() << QString("line=%1 price (%2) :")
.arg(__LINE__)
.arg(start.time().toString(Qt::ISODate)) << price;
//QDateTime s(QDateTime::currentDateTime());
//s.setTime(QTime(12, 0, 0));
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, s);
//qCritical() << timeSteps;
int Down = 0;
int Up = 1;
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
QDateTime const start = QDateTime::currentDateTime();
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
start.setTime(QTime(14, 0, 0));
productStart = productEnd = QDateTime();
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
qCritical() << QString("line=%1 price (%2-%3) :")
.arg(__LINE__)
.arg(productStart.time().toString(Qt::ISODate))
.arg(productEnd.time().toString(Qt::ISODate))
<< price;
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__)
<< price;
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
qCritical() << QString("line=%1 price:").arg(__LINE__) << price;
start.setTime(QTime(15, 0, 0));
productStart = productEnd = QDateTime();
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
qCritical() << QString("line=%1 price (%2-%3) :")
.arg(__LINE__)
.arg(productStart.time().toString(Qt::ISODate))
.arg(productEnd.time().toString(Qt::ISODate))
<< price;
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
start.setTime(QTime(16, 0, 0));
productStart = productEnd = QDateTime();
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
qCritical() << QString("line=%1 price (%2-%3) :")
.arg(__LINE__)
.arg(productStart.time().toString(Qt::ISODate))
.arg(productEnd.time().toString(Qt::ISODate))
<< price;
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
start.setTime(QTime(17, 0, 0));
productStart = productEnd = QDateTime();
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
qCritical() << QString("line=%1 price (%2-%3) :")
.arg(__LINE__)
.arg(productStart.time().toString(Qt::ISODate))
.arg(productEnd.time().toString(Qt::ISODate))
<< price;
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
#else
for (int h = 0; h < 24; ++h) {
start.setTime(QTime(h, 0, 0));
productStart = productEnd = QDateTime();
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
qCritical() << QString("line=%1 %2 price (%3-%4) :")
.arg(__LINE__)
.arg(start.time().toString(Qt::ISODate))
.arg(productStart.time().toString(Qt::ISODate))
.arg(productEnd.time().toString(Qt::ISODate))
<< price;
if (paymentOptionIndex != 0) {
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
<< "< 0 for start" << start.toString(Qt::ISODate);
exit(-1);
}
//QSet<uint32_t> const prices1{800, 1600, 2400, 3200, 4000, 4800, 5600};
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
QDateTime end;
CalcState calcState;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(12, 0, 0));
int minimal_parking_price = get_minimal_parkingprice(&cfg,
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
paymentOptionIndex, s);
qCritical() << "minimal parking price" << minimal_parking_price;
for (int i = 0; i < 8; ++i) {
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)minimal_parking_price + i*800,
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
}
s.setTime(QTime(15, 0, 0));
minimal_parking_price = get_minimal_parkingprice(&cfg,
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
paymentOptionIndex, s);
qCritical() << "minimal parking price" << minimal_parking_price;
for (int i = 0; i < 8; ++i) {
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)minimal_parking_price + i*800,
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
}
#endif
}
}
#endif

View File

@ -30,7 +30,9 @@ SOURCES += main.cpp
# HEADERS +=
OTHER_FILES += \
/home/linux/customer_505/etc/psa_tariff/tariff01.json
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json \
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json \
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json