Compare commits
No commits in common. "33f43fb83d15ad58477e7560e6d2391448dabd4d" and "c7623429d92bcf622b1c30b93d2ff0610a6e2ce6" have entirely different histories.
33f43fb83d
...
c7623429d9
@ -197,11 +197,11 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
|
||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
|
||||
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
|
||||
int paymentOptionIndex=0);
|
||||
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
|
||||
PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
|
||||
int paymentOptionIndex=0);
|
||||
|
||||
|
@ -39,8 +39,6 @@ public:
|
||||
using SpecialDaysType = std::multimap<int, ATBSpecialDays>;
|
||||
using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>;
|
||||
using TimeRangeType = std::multimap<int, ATBTimeRange>;
|
||||
using TariffProductType = std::multimap<int, ATBTariffProduct>;
|
||||
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
||||
|
||||
ATBProject project;
|
||||
ATBCurrency Currency;
|
||||
@ -54,13 +52,13 @@ public:
|
||||
multimap<int, ATBWeekDays> WeekDays;
|
||||
multimap<int, ATBPeriodYear> YearPeriod;
|
||||
multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
|
||||
ATBPaymentOptionType PaymentOption;
|
||||
multimap<int, ATBPaymentOption> PaymentOption;
|
||||
multimap<int, ATBDailyTicket> DailyTicket;
|
||||
TimeRangeType TimeRange;
|
||||
multimap<int, ATBTimeStepConfig> TimeStepConfig;
|
||||
multimap<int, ATBTimeBase> TimeBase;
|
||||
multimap<int, ATBCustomer> Customer;
|
||||
TariffProductType TariffProduct;
|
||||
multimap<int, ATBTariffProduct> TariffProduct;
|
||||
|
||||
/// <summary>
|
||||
/// Parse JSON string
|
||||
@ -88,7 +86,6 @@ public:
|
||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
|
||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
|
||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
|
||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
|
||||
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
|
||||
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include <string>
|
||||
#include <cinttypes>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
class ATBPaymentOption
|
||||
{
|
||||
public:
|
||||
@ -49,14 +47,6 @@ public:
|
||||
int pop_daily_card_price;
|
||||
uint64_t pop_business_hours;
|
||||
int pop_time_step_config;
|
||||
|
||||
struct ATBMaxDateTime {
|
||||
int direction;
|
||||
uint8_t week;
|
||||
uint8_t day;
|
||||
QTime time;
|
||||
} pop_min_date_time,
|
||||
pop_max_date_time;
|
||||
};
|
||||
|
||||
#endif // PAYMENT_OPT_H_INCLUDED
|
||||
|
@ -24,7 +24,6 @@
|
||||
#define _ONLY_OPEN_FOR_BUSINESS_DAYS_ (uint64_t)(1ULL << 16) /* verkaufsoffen */
|
||||
#define _WITH_RESTRICTED_HOURS_ (uint64_t)(1ULL << 17)
|
||||
#define _ALL_DAYS_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_ALL_DAYS_))
|
||||
#define _WEEKEND_WITH_RESTRICTED_HOURS_ ((_WITH_RESTRICTED_HOURS_|_FRI_|_SAT_|_SUN_))
|
||||
#define _NOT_DEFINED_ (uint64_t)(~0ULL)
|
||||
|
||||
enum BusinessHours : std::uint64_t
|
||||
@ -58,7 +57,6 @@ enum BusinessHours : std::uint64_t
|
||||
ONLY_WEEKEND = _ONLY_WEEKEND_,
|
||||
ONLY_OPEN_FOR_BUSINESS_DAYS = _ONLY_OPEN_FOR_BUSINESS_DAYS_,
|
||||
ALL_DAYS_WITH_RESTRICTED_HOURS = _ALL_DAYS_WITH_RESTRICTED_HOURS_,
|
||||
WEEKEND_WITH_RESTRICTED_HOURS = _WEEKEND_WITH_RESTRICTED_HOURS_,
|
||||
NOT_DEFINED = _NOT_DEFINED_
|
||||
};
|
||||
|
||||
|
@ -4,16 +4,15 @@
|
||||
#include <QString>
|
||||
|
||||
enum class PERMIT_TYPE : quint8 {
|
||||
SHORT_TERM_PARKING=0,
|
||||
DAY_TICKET=1,
|
||||
SZEGED_START=2,
|
||||
SZEGED_STOP=3,
|
||||
DAY_TICKET_ADULT=4,
|
||||
DAY_TICKET_TEEN=5,
|
||||
DAY_TICKET_CHILD=6,
|
||||
INVALID=7,
|
||||
FOOD_STAMP=8,
|
||||
TWENTY_FOUR_HOURS_TICKET=9
|
||||
SHORT_TERM_PARKING,
|
||||
DAY_TICKET,
|
||||
SZEGED_START,
|
||||
SZEGED_STOP,
|
||||
DAY_TICKET_ADULT,
|
||||
DAY_TICKET_TEEN,
|
||||
DAY_TICKET_CHILD,
|
||||
FOOD_STAMP,
|
||||
INVALID
|
||||
};
|
||||
|
||||
struct PermitType {
|
||||
@ -46,9 +45,6 @@ struct PermitType {
|
||||
case 7:
|
||||
m_permitType = PERMIT_TYPE::FOOD_STAMP;
|
||||
break;
|
||||
case 8:
|
||||
m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
|
||||
break;
|
||||
default:
|
||||
m_permitType = PERMIT_TYPE::INVALID;
|
||||
}
|
||||
@ -78,8 +74,6 @@ struct PermitType {
|
||||
return 6;
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return 7;
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||
return 8;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -87,64 +81,52 @@ struct PermitType {
|
||||
|
||||
}
|
||||
|
||||
QString toString() {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
return QString("DAY_TICKET_ADULT");
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
return QString("DAY_TICKET_CHILD");
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return QString("DAY_TICKET_TEEN");
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return QString("SHORT_TERM_PARKING");
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||
return QString("TWENTY_FOUR_HOURS_TICKET");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QString("INVALID");
|
||||
}
|
||||
|
||||
QString toString() const {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
return QString("DAY_TICKET_ADULT");
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
return QString("DAY_TICKET_CHILD");
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return QString("DAY_TICKET_TEEN");
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return QString("SHORT_TERM_PARKING");
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||
return QString("TWENTY_FOUR_HOURS_TICKET");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QString("INVALID");
|
||||
}
|
||||
|
||||
operator QString () {
|
||||
return toString();
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
return QString("DAY_TICKET_ADULT");
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
return QString("DAY_TICKET_CHILD");
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return QString("DAY_TICKET_TEEN");
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return QString("SHORT_TERM_PARKING");
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QString("INVALID");
|
||||
}
|
||||
|
||||
operator QString () const {
|
||||
return toString();
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
return QString("DAY_TICKET_ADULT");
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
return QString("DAY_TICKET_CHILD");
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return QString("DAY_TICKET_TEEN");
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return QString("SHORT_TERM_PARKING");
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QString("INVALID");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@ QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
int minTime = 0;
|
||||
@ -33,14 +33,14 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
// for each new sell-procedure, recomute the timesteps. implicitly, set
|
||||
// the minimal parking time.
|
||||
Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
|
||||
Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
|
||||
Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex);
|
||||
minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
|
||||
}
|
||||
|
||||
return minTime;
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
int maxTime = 0;
|
||||
@ -59,7 +59,6 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
}
|
||||
|
||||
return maxTime;
|
||||
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
@ -157,28 +156,6 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
return product_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
||||
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
|
||||
if (products) {
|
||||
int product_price = 0;
|
||||
QVector<ATBTariffProduct> product = products.value();
|
||||
|
||||
if (product.size() > 0) {
|
||||
if (productStart && productEnd) {
|
||||
int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
|
||||
int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
|
||||
if (pop_max_time >= pop_min_time) {
|
||||
*productStart = start;
|
||||
*productEnd = start.addSecs(pop_max_time*60);
|
||||
product_price = product[0].getProductPrice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return product_price;
|
||||
}
|
||||
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
/// <inheritdoc/>
|
||||
MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
||||
@ -437,62 +436,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) {
|
||||
this->currentPaymentOptions.last().pop_time_step_config = k->value.GetInt();
|
||||
} else if ((strcmp(inner_obj_name, "pop_min_date_time") == 0)
|
||||
|| (strcmp(inner_obj_name, "pop_max_date_time") == 0)) {
|
||||
if (k->value.IsString()) { // -w0dFriT16:20:00 or +w0dMonT00:00:00
|
||||
static const QRegularExpression re(R"(([+-])w([0-9]+)d([A-Za-z]{3})T([0-9]{2}:[0-9]{2}:[0-9]{2}))");
|
||||
QString const &s = QString::fromStdString(k->value.GetString());
|
||||
QRegularExpressionMatch match = re.match(s);
|
||||
if (match.hasMatch()) {
|
||||
ATBPaymentOption::ATBMaxDateTime dt;
|
||||
int lastCaptured = match.lastCapturedIndex();
|
||||
if (lastCaptured == 4) {
|
||||
dt.direction = (match.captured(1) == "-") ? -1 : +1;
|
||||
|
||||
bool ok;
|
||||
uint8_t week = match.captured(2).toUInt(&ok);
|
||||
if (ok) {
|
||||
dt.week = week;
|
||||
}
|
||||
|
||||
QString const &day = match.captured(3);
|
||||
if (day.compare("Mon", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Monday;
|
||||
} else if (day.compare("Tue", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Tuesday;
|
||||
} else if (day.compare("Wed", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Wednesday;
|
||||
} else if (day.compare("Thu", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Thursday;
|
||||
} else if (day.compare("Fri", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Friday;
|
||||
} else if (day.compare("Sat", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Saturday;
|
||||
} else if (day.compare("Sun", Qt::CaseInsensitive) == 0) {
|
||||
dt.day = (int)Qt::Sunday;
|
||||
}
|
||||
|
||||
QTime t = QTime::fromString(match.captured(4), Qt::ISODate);
|
||||
if (t.isValid()) {
|
||||
dt.time = t;
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "DAY" << dt.day;
|
||||
qCritical() << "DIR" << dt.direction;
|
||||
qCritical() << "week" << dt.week;
|
||||
qCritical() << "DIR" << dt.time;
|
||||
|
||||
if (strcmp(inner_obj_name, "pop_min_date_time") == 0) {
|
||||
this->currentPaymentOptions.last().pop_min_date_time = dt;
|
||||
} else
|
||||
if (strcmp(inner_obj_name, "pop_max_date_time") == 0) {
|
||||
this->currentPaymentOptions.last().pop_max_date_time = dt;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MemberType::DurationType:
|
||||
@ -640,7 +583,7 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
if (sd.ped_id != 0) {
|
||||
for (int opt=0; opt < numOptions; ++opt) {
|
||||
uint64_t const pop_id = getPaymentOptions(opt).pop_id;
|
||||
if (pop_id == (uint64_t)sd.ped_payment_option_id) {
|
||||
if (pop_id == sd.ped_payment_option_id) {
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
@ -774,39 +717,13 @@ Configuration::getTariffProductForAllKeys() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBTariffProduct>>
|
||||
Configuration::getTariffProductForProductTypeName(QString const &permitTypeName) const {
|
||||
QVector<ATBTariffProduct> products;
|
||||
std::optional<QVector<ATBTariffProduct>> value;
|
||||
|
||||
products.clear();
|
||||
|
||||
for(const auto &product: this->TariffProduct) {
|
||||
ATBTariffProduct const &v = product.second;
|
||||
if (v.m_tariff_product_name == permitTypeName) {
|
||||
products.append(v);
|
||||
}
|
||||
}
|
||||
|
||||
if (products.size() > 0) {
|
||||
value = value.value_or(products);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBTariffProduct>>
|
||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
|
||||
QString permitTypeName(permitType);
|
||||
return getTariffProductForProductTypeName(permitTypeName);
|
||||
|
||||
/*
|
||||
QVector<ATBTariffProduct> products;
|
||||
std::optional<QVector<ATBTariffProduct>> value;
|
||||
|
||||
products.clear();
|
||||
|
||||
|
||||
for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) {
|
||||
products.append(it->second);
|
||||
}
|
||||
@ -816,7 +733,6 @@ Configuration::getTariffProductForProductId(PermitType permitType) const {
|
||||
}
|
||||
|
||||
return value;
|
||||
*/
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBTariffProduct>>
|
||||
|
216
main/main.cpp
216
main/main.cpp
@ -37,11 +37,11 @@ extern "C" char* strptime(const char* s,
|
||||
#define SZEGED (0)
|
||||
#define SCHOENAU_KOENIGSEE (0)
|
||||
#define NEUHAUSER_KORNEUBURG (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_KIRCHDORF (0)
|
||||
#define BAD_NEUENAHR_AHRWEILER (1)
|
||||
#define BAD_NEUENAHR_AHRWEILER (0)
|
||||
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||
|
||||
@ -366,7 +366,7 @@ int main() {
|
||||
int pop_carry_over;
|
||||
int pop_carry_over_time_range_id;
|
||||
|
||||
for (int zone=6; zone < 7; ++zone) {
|
||||
for (int zone=2; zone < 3; ++zone) {
|
||||
//for (int t=6; t < 7; t+=20) {
|
||||
switch (zone) {
|
||||
case 1: {
|
||||
@ -589,216 +589,6 @@ int main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (zone == 3) {
|
||||
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});
|
||||
|
||||
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
if (stepsConfigured != timeSteps) {
|
||||
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool fail;
|
||||
QDateTime start;
|
||||
|
||||
for (int i=0; i < 5; ++i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
|
||||
fail = false;
|
||||
break;
|
||||
case 1:
|
||||
start = QDateTime(QDate(2024, 4, 21), QTime(16, 0, 0)); // sunday
|
||||
fail = false;
|
||||
break;
|
||||
case 2:
|
||||
start = QDateTime(QDate(2024, 4, 22), QTime(8, 0, 0)); // monday
|
||||
fail = false;
|
||||
break;
|
||||
case 3:
|
||||
start = QDateTime(QDate(2024, 4, 23), QTime(17, 30, 0)); // tuesday
|
||||
fail = true;
|
||||
break;
|
||||
case 4:
|
||||
start = QDateTime(QDate(2024, 4, 24), QTime(7, 30, 0)); // wednesday
|
||||
fail = true;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
|
||||
//start = QDateTime::currentDateTime();
|
||||
QList<int> timeSteps;
|
||||
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
||||
if (paymentOptionIndex != -1) {
|
||||
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
||||
timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, paymentOptionIndex);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
QList<int>::const_iterator step;
|
||||
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
||||
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
if (fail == false) {
|
||||
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (zone == 4) {
|
||||
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});
|
||||
|
||||
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
if (stepsConfigured != timeSteps) {
|
||||
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool fail;
|
||||
QDateTime start;
|
||||
|
||||
for (int i=4; i < 5; ++i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
|
||||
fail = false;
|
||||
break;
|
||||
case 1:
|
||||
start = QDateTime(QDate(2024, 4, 21), QTime(16, 0, 0)); // sunday
|
||||
fail = false;
|
||||
break;
|
||||
case 2:
|
||||
start = QDateTime(QDate(2024, 4, 22), QTime(8, 0, 0)); // monday
|
||||
fail = false;
|
||||
break;
|
||||
case 3:
|
||||
start = QDateTime(QDate(2024, 4, 23), QTime(17, 30, 0)); // tuesday
|
||||
fail = true;
|
||||
break;
|
||||
case 4:
|
||||
start = QDateTime(QDate(2024, 4, 24), QTime(7, 30, 0)); // wednesday
|
||||
fail = true;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
|
||||
//start = QDateTime::currentDateTime();
|
||||
QList<int> timeSteps;
|
||||
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
||||
if (paymentOptionIndex != -1) {
|
||||
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
||||
timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, paymentOptionIndex);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
QList<int>::const_iterator step;
|
||||
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
||||
|
||||
double cost = 0;
|
||||
CalcState cs;
|
||||
|
||||
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
|
||||
cost = price.netto;
|
||||
qCritical() << "step" << *step << ": cost" << cost;
|
||||
} else {
|
||||
if (fail == false) {
|
||||
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (zone == 5) {
|
||||
|
||||
}
|
||||
if (zone == 6) { // sondertarif: 24h ticket wohnmobile
|
||||
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;
|
||||
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
start.setTime(QTime(0, 0, 0));
|
||||
|
||||
for (int i=0; i<1440; ++i) {
|
||||
|
||||
QDateTime productStart;
|
||||
QDateTime productEnd;
|
||||
|
||||
int v = compute_product_price(&cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET, start, &productStart, &productEnd);
|
||||
if (v != 800) {
|
||||
qCritical() << "ERROR [" << i << "]" << "price 24h-ticket"
|
||||
<< v << productStart.toString(Qt::ISODate)
|
||||
<< productEnd.toString(Qt::ISODate);
|
||||
exit(-1);
|
||||
} else {
|
||||
qCritical() << v << productStart.toString(Qt::ISODate)
|
||||
<< productEnd.toString(Qt::ISODate);
|
||||
|
||||
}
|
||||
start = start.addSecs(60);
|
||||
}
|
||||
}
|
||||
if (zone == 7) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user