Add test cases
This commit is contained in:
parent
b19cfd693c
commit
2a3ff30e66
213
main/main.cpp
213
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<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
||||
//qCritical() << "TimeSteps" << timeSteps;
|
||||
//return 0;
|
||||
|
||||
if (zone == 2) {
|
||||
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
QList<int> 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<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
||||
|
||||
|
||||
for (int i=0; i<timeSteps.size(); ++i) {
|
||||
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
||||
qCritical() << "nextTimeStep" << nextTimeStep;
|
||||
|
||||
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
|
||||
|
||||
qCritical() << "price for" << timeSteps.at(i) << ": " << price;
|
||||
|
||||
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
||||
|
||||
qCritical() << "duration for price" << price << "duration: " << duration;
|
||||
|
||||
if (!prices.contains(price)) {
|
||||
qCritical() << "ERROR nextTimeStep relative to start:"
|
||||
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||
<< "(price so far:" << price << ")";
|
||||
exit(-1);
|
||||
}
|
||||
qCritical() << "nextTimeStep relative to start:"
|
||||
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||
<< "(price so far:" << price << ")";
|
||||
|
||||
}
|
||||
}
|
||||
if (zone == 3) {
|
||||
int price;
|
||||
QDateTime productStart;
|
||||
QDateTime productEnd;
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
|
||||
#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;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_STOCKERAU==1
|
||||
std::ifstream input;
|
||||
int pop_min_time;
|
||||
|
Loading…
Reference in New Issue
Block a user