Compare commits
No commits in common. "aba38d26143555d1659d3dd9866e7ffa72f1742a" and "fcbc8dcdc31bc32610e20b69f6acbd341bdf5468" have entirely different histories.
aba38d2614
...
fcbc8dcdc3
@ -175,8 +175,6 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
}
|
||||
|
||||
CalcState &set(State s) { m_status = s; return *this; }
|
||||
CalcState &setStatus(State s) { return set(s); }
|
||||
State getStatus() const { return m_status; }
|
||||
CalcState &setDesc(QString s) { m_desc = s; return *this; }
|
||||
|
||||
void setAllowedTimeRange(QTime const &from, QTime const &until) {
|
||||
|
@ -125,7 +125,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||
if (paymentMethodId == PaymentMethod::Progressive) {
|
||||
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||
int const key = cfg->getPaymentOptions().pop_id;
|
||||
@ -428,23 +428,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
|
||||
double cost = -1;
|
||||
if (start_parking_time.isValid()) {
|
||||
if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) {
|
||||
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time);
|
||||
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
||||
return calcState;
|
||||
}
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time);
|
||||
} else {
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
start_parking_time, // starting time
|
||||
end_parking_time, // return value: end time
|
||||
netto_parking_time, // minutes, netto
|
||||
false, prepaid);
|
||||
}
|
||||
double minCost = tariff->getPaymentOptions().pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
|
||||
@ -454,10 +445,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
// DEBUG
|
||||
qCritical() << " -> calculated cost (price->netto) = " << cost;
|
||||
|
||||
price->brutto = price->vat = price->vat_percentage = 0;
|
||||
price->units = cost;
|
||||
price->netto = cost;
|
||||
|
||||
} else {
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
}
|
||||
|
152
main/main.cpp
152
main/main.cpp
@ -38,10 +38,9 @@ extern "C" char* strptime(const char* s,
|
||||
#define SCHOENAU_KOENIGSEE (0)
|
||||
#define NEUHAUSER_KORNEUBURG (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_KIRCHDORF (0)
|
||||
#define BAD_NEUENAHR_AHRWEILER (1)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@ -160,151 +159,6 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
#endif
|
||||
|
||||
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
|
||||
QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json");
|
||||
//QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json");
|
||||
@ -849,7 +703,7 @@ int main() {
|
||||
int pop_max_price;
|
||||
int pop_daily_card_price;
|
||||
|
||||
for (int zone=1; zone < 2; ++zone) {
|
||||
for (int zone=6; zone < 7; ++zone) {
|
||||
//for (int t=6; t < 7; t+=20) {
|
||||
switch (zone) {
|
||||
case 1: {
|
||||
@ -925,7 +779,7 @@ int main() {
|
||||
|
||||
{
|
||||
// zone 1 (lila)
|
||||
QDateTime s(QDate(2024, 3, 26), QTime());
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
QDateTime end;
|
||||
int cnt = 1;
|
||||
if (zone == 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user