updated some tests
This commit is contained in:
parent
b71c979a91
commit
e4ce14da3f
101
main/main.cpp
101
main/main.cpp
@ -41,8 +41,8 @@ extern "C" char* strptime(const char* s,
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_KIRCHDORF (0)
|
||||
#define BAD_NEUENAHR_AHRWEILER (1)
|
||||
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
||||
#define BAD_NEUENAHR_AHRWEILER (0)
|
||||
#define NEUHAUSER_CHRISTOPH_REISEN (1)
|
||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
@ -216,6 +216,9 @@ int main() {
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< 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);
|
||||
@ -316,7 +319,10 @@ int main() {
|
||||
#endif
|
||||
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
//start.setTime(QTime(0, 0, 0));
|
||||
start.setTime(QTime(10, 2, 30));
|
||||
start.setDate(QDate(2024, 5, 5));
|
||||
|
||||
// 2024-05-05 10:02:30
|
||||
|
||||
struct price_t costs;
|
||||
double const cost[] = {600, 700, 800, 1600, 2400, 3000, 3600};
|
||||
@ -366,7 +372,7 @@ int main() {
|
||||
int pop_carry_over;
|
||||
int pop_carry_over_time_range_id;
|
||||
|
||||
for (int zone=6; zone < 7; ++zone) {
|
||||
for (int zone=7; zone < 8; ++zone) {
|
||||
//for (int t=6; t < 7; t+=20) {
|
||||
switch (zone) {
|
||||
case 1: {
|
||||
@ -797,7 +803,94 @@ int main() {
|
||||
}
|
||||
}
|
||||
if (zone == 7) {
|
||||
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() << zone << " pop_min_time: " << pop_min_time;
|
||||
qCritical() << zone << " pop_max_time: " << pop_max_time;
|
||||
qCritical() << zone << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << zone << " pop_max_price: " << pop_max_price;
|
||||
qCritical() << zone << "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 :" << __LINE__ << ")" << 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user