Merge branch 'kleipeda-experimental' of /home/siegert/atbfs01entwicklung/Elektronik/PTU/git_bare_repos/libmobilisis-calc into kleipeda-experimental

This commit is contained in:
Siegfried Siegert 2024-07-30 10:02:57 +02:00
commit 8fff7a76f6
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
6 changed files with 272 additions and 242 deletions

View File

@ -40,12 +40,12 @@ public:
}
void ResetTimeSteps(int paymentOptionIndex) {
if (m_timeSteps.size() > 0) {
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
m_timeSteps[paymentOptionIndex].clear();
}
}
QList<int> timeSteps(int paymentOptionIndex=0) const {
if (m_timeSteps.size() > 0) {
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
return m_timeSteps[paymentOptionIndex];
}
return QList<int>();
@ -133,10 +133,10 @@ private:
int durationMinutes);
//
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex=0) const;
uint32_t GetPriceForStep(Configuration *cfg, int step) const {
return GetPriceForTimeStep(cfg, step);
}
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const;
//uint32_t GetPriceForStep(Configuration *cfg, int step) const {
// return GetPriceForTimeStep(cfg, step, 0);
//}
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
uint32_t GetStepForPrice(Configuration *cfg, int price) const {
return GetDurationForPrice(cfg, price);

View File

@ -48,12 +48,13 @@ public:
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
using TariffDurationType = std::multimap<int, ATBDuration>;
ATBProject project;
ATBCurrency Currency;
ATBDuration duration;
multimap<int, ATBDuration> Duration;
TariffDurationType Duration;
multimap<int, ATBPaymentMethod> PaymentMethod;
multimap<int, ATBPaymentRate> PaymentRate;
SpecialDaysWorktimeType SpecialDaysWorktime;

View File

@ -211,8 +211,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
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
int pop_min_time = get_minimal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
int pop_max_time = get_maximal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
if (pop_max_time >= pop_min_time) {
*productStart = start;
*productEnd = start.addSecs(pop_max_time*60);
@ -315,10 +315,20 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
break;
case PERMIT_TYPE::DAY_TICKET_PKW:
break;
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
break;
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
break;
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
if (po.has_value()) {
ATBPaymentOption option = po.value();
return option.pop_max_price;
}
} break;
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
if (po.has_value()) {
ATBPaymentOption option = po.value();
return option.pop_max_price;
}
} break;
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
break;
default: ;
@ -420,15 +430,16 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
if (!paymentOption.has_value()) {
return currentTimeMinutes;
}
// FIXME
//std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
//if (!paymentOption.has_value()) {
// qCritical() << " compute_next_timestep() ERROR";
// return currentTimeMinutes;
//}
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
qCritical() << " compute_next_timestep() payment option index: " << paymentOptionIndex;
Configuration const *cfg = tariff;
// compute payment method id (e.g. Linear=3, Steps=4)
@ -500,6 +511,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
return currentTimeMinutes;
}
else {
qCritical() << " compute_next_timestep() return next time step:" << stepList[currentStepIndex + 1];
return stepList[currentStepIndex + 1];
}
}
@ -509,6 +521,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
return currentTimeMinutes;
}
else {
qCritical() << " compute_next_timestep() return next time step:" << stepList[currentStepIndex - 1];
return stepList[currentStepIndex - 1];
}
}
@ -553,6 +566,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
time_t end_parking_time, // netto time in minutes
struct price_t *price,
PermitType permitType) { // permitType maps to product
CalcState calcState;
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
@ -620,7 +634,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
{
CalcState calcState;
int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
@ -632,7 +646,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
<< " netto_parking_time: " << netto_parking_time << endl
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
<< " minMin: " << minMin << endl
<< " maxMin: " << maxMin;
<< " maxMin: " << maxMin
<< " permitType: " << permitType.toString();
if (netto_parking_time < 0) {

View File

@ -155,8 +155,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
}
// TODO: man braucht den richtigen Index
int paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
@ -174,10 +174,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
// int const pop_pre_paid = 1;
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
if (prepaid) {
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
// no limits on pre-pay-option, i.e. pre-pay-ranges are exactly
// the complements of operational-ranges
@ -185,7 +185,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
// in this case, adapt inputDate accordingly.
#define DEBUG_GET_DURATION_FROM_COST 1
#define DEBUG_GET_DURATION_FROM_COST 0
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
@ -240,23 +240,22 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
// inputDate is now located in a valid operational-working-range
// find this working-time-range
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
qCritical() << __func__ << __LINE__ << pwd_period_day_in_week_id;
qCritical() << __func__ << __LINE__ << cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id);
//qCritical() << __func__ << __LINE__ << pwd_period_day_in_week_id;
//qCritical() << __func__ << __LINE__ << cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id);
if (cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id) == 0) {
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
qCritical() << __func__ << __LINE__;
return "";
}
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
QTime current_working_time_from;
QTime current_working_time_to;
@ -278,7 +277,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
qCritical() << __func__ << __LINE__;
return "";
}
@ -287,8 +285,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
#endif
qCritical() << __func__ << __LINE__;
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
// int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
int price = 0;
@ -306,7 +302,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
price = pra_price;
}
qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
@ -318,44 +314,23 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
new_price += pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
if (new_price <= cost) {
duration_previous = durationUnit;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
} else {
found = true;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
QString s = inputDate.toString(Qt::ISODate);
QDateTime d(QDateTime::fromString(s, Qt::ISODate));
d = d.addSecs(duration_previous * 60);
qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
//qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
return d.toString(Qt::ISODate).toStdString();
}
}
//if (price < cost) {
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << duration;
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << duration.pun_duration;
// QString s = inputDate.toString(Qt::ISODate);
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << s;
// QDateTime d(QDateTime::fromString(s, Qt::ISODate));
// d = d.addSecs(duration.pun_duration * 60);
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
// return d.toString(Qt::ISODate).toStdString();
//
// }
//if (pop_accumulate_durations) {
// durationInSecs += duration.pun_duration * 60;
//} else {
durationInSecs = duration.pun_duration * 60;
// durationInSecs -= 720 * 60;
//}
if ((double)price == cost) {
qCritical() << DBG_HEADER;
QDateTime current_working_date_time_to = inputDate;
current_working_date_time_to.setTime(current_working_time_to);
@ -404,23 +379,23 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
}
qCritical() << DBG_HEADER << "DAYS" << days;
qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
//qCritical() << DBG_HEADER << "DAYS" << days;
//qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
//qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
QDateTime upper = inputDate.addDays(days);
upper.setTime(next_working_time_from);
qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
QDateTime lower = inputDate;
lower.setTime(current_working_time_to);
qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
// inputDate = inputDate.addSecs(lower.secsTo(upper));
qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
inputDate = inputDate.addSecs(durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
@ -451,21 +426,19 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
qCritical() << __func__ << __LINE__;
QString const &s = inputDate.toString(Qt::ISODate);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << s;
#endif
qCritical() << __func__ << __LINE__ << s;
return s.toStdString();
} // if ((double)price == cost) {
else {
qCritical() << DBG_HEADER;
//qCritical() << DBG_HEADER;
}
} else {
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
}
}
@ -919,7 +892,7 @@ uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
int paymentOptionIndex) const {
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
// special days, nonstop.
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps ||
@ -936,7 +909,7 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
int paymentOptionIndex) const {
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
if (paymentMethodId == PaymentMethod::Steps ||
paymentMethodId == PaymentMethod::Degressive) {
@ -954,8 +927,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
int netto_parking_time,
int paymentOptionIndex) {
qCritical() << DBG_HEADER << "start" << start.toString(Qt::ISODate)
<< "paymentOptionIndex" << paymentOptionIndex;
//qCritical() << DBG_HEADER << "start" << start.toString(Qt::ISODate)
// << "paymentOptionIndex" << paymentOptionIndex;
// TODO: wieder entfernen
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", QTime(), QTime());
@ -2254,8 +2227,6 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
@ -2278,7 +2249,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
// for instance: until 13.59: price 8, from 14:00: price 5, then for the next day: 8
// for the following days: 8 euros
qCritical() << "(" << __func__ << ":" << __LINE__ << ") degressive";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") degressive:";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
m_timeSteps[paymentOptionIndex].clear();
// lookup pop_next_id in worktimes;
@ -2286,121 +2258,82 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
if (w.has_value()) {
QVector<ATBWeekDaysWorktime> const &vec = w.value();
if (pop_carry_over) {
for (int i = 0; i < vec.size(); ++i) {
QTime const &from = QTime::fromString(QString::fromStdString(vec[i].pwd_time_from), Qt::ISODate);
QString const &toStr = QString::fromStdString(vec[i].pwd_time_to);
if (pop_carry_over == false) {
for (int i = 1; i <= vec.size(); ++i) {
QTime const &from = QTime::fromString(QString::fromStdString(vec[i-1].pwd_time_from), Qt::ISODate);
QString const &toStr = QString::fromStdString(vec[i-1].pwd_time_to);
QTime const &to = QTime::fromString(toStr, Qt::ISODate);
int weekDayId = vec[i].pwd_period_day_in_week_id;
int weekDayId = vec[i-1].pwd_period_day_in_week_id;
if (start.date().dayOfWeek() == weekDayId) {
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
if (start.time() >= from) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
if (start.time() < to) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
int runtimeInMinutes = (start.time().secsTo(to) / 60);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
int pop_id = vec[i].pwd_pop_id;
int pwd_id = vec[i].pwd_id;
int pop_next_id = vec[i].pwd_next_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
// int const price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
search->second = duration;
}
}
if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) {
// on the same day
start.setTime(to);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
} else {
// on the next day
start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate));
start = start.addDays(1);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
}
while ((s.secsTo(start) / 60) < 5000) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
pop_id = vec[i].pwd_pop_id;
pwd_id = vec[i].pwd_id;
pop_next_id = vec[i].pwd_next_id;
runtimeInMinutes += (start.time().secsTo(to) / 60);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pwd_id " << pwd_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id " << pop_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_next_id " << pop_next_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep" << nextTimeStep;
// ATBPaymentOption o = cfg->getPaymentOptionForId();
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX pop" << pop_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX index" << paymentOptionIndex;
#if 0
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX durationId" << durationId;
// int const price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX durationId" << runtimeInMinutes;
search->second = duration;
}
}
#endif
if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) {
// on the same day
start.setTime(to);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
} else {
// on the next day
start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate));
start = start.addDays(1);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
}
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") until" << s.secsTo(start) / 60;
}
break;
if (start.time() >= from && start.time() < to) {
int runtimeInMinutes = (start.time().secsTo(to) / 60);
if (to.hour() == 23 && to.minute() == 59) {
runtimeInMinutes += 1;
}
}
}
}
}
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
int pop_id = vec[i-1].pwd_pop_id;
// int pwd_id = vec[i-1].pwd_id;
// int pwd_next_id = vec[i-1].pwd_next_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
int price = -1;
int durationId = -1;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
durationId = itr->second.pra_payment_unit_id;
price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
search->second = duration;
break;
}
}
if (price >= 0 && durationId >= 0) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
if (durationId == itr->second.pra_payment_unit_id) {
itr->second.pra_price = price;
break;
}
}
}
break;
} // if (start.time() >= from && start.time() < to) {
} // if (start.date().dayOfWeek() == weekDayId) {
} // for (int i = 1; i <= vec.size(); ++i) {
// show content:
for (Configuration::TariffDurationType::const_iterator it = cfg->Duration.cbegin();
it != cfg->Duration.cend();
++it) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
<< (*it).first << " => " << (*it).second;
}
} // if (pop_carry_over == false) {
} // if (w.has_value()) {
} else {
uint16_t timeStepCompensation = 0;
@ -2477,10 +2410,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
}
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
if (DBG_LEVEL >= DBG_DEBUG) {
//if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
}
//}
m_timeSteps[paymentOptionIndex].clear();
@ -2488,9 +2421,9 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
if (prepaidStart) {
start = prepaidStart.value();
//if (DBG_LEVEL >= DBG_DEBUG) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
//}
}
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
}
@ -2511,7 +2444,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
QDateTime nextTimeStep = start;
int runtimeInMinutes = 0;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
@ -2527,12 +2460,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
// int const price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
@ -2549,7 +2482,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
break;
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
if (ipolCheck) {
@ -2610,10 +2543,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
} else
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
if (paymentOptionIndex == 1) { // testing TODO: muss in die payment options hinein
if (runtimeInMinutes == 0) {
@ -2622,6 +2555,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
duration.pun_duration = runtimeInMinutes;
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
search->second = duration;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
continue;
}
}
@ -2641,8 +2575,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
continue;
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
QDateTime s = start.addSecs(runtimeInMinutes * 60);
int const minutes = s.time().secsTo(carryOverStart) / 60;
@ -2666,8 +2599,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
runtimeInMinutes += duration.pun_duration;
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
// TOOO: truncate-flag == false
if (nextTimeStep.time() > carryOverStart) {
@ -2676,23 +2609,23 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
nextTimeStep.setTime(carryOverStart);
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
runtimeInMinutes += (backTime + carryOverDuration);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
} else
if (nextTimeStep.time() < carryOverStart) {
int const forwardTime = nextTimeStep.time().secsTo(carryOverStart) / 60;
runtimeInMinutes += forwardTime;
nextTimeStep.setTime(carryOverStart);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
}
//if (DBG_LEVEL >= DBG_DEBUG) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
//}
}
duration.pun_duration = runtimeInMinutes;
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
@ -2764,8 +2697,9 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
uint32_t price = 0;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
{
@ -2774,13 +2708,8 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
Q_ASSERT(pun_id == payment_unit_id);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(1)->second.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(2)->second.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(3)->second.pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
//int const pun_duration = cfg->Duration.find(2)->second.pun_duration;
@ -2790,11 +2719,11 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
price = (uint32_t)(itr->second.pra_price);
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
if (timeStep == pun_duration) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
@ -2809,9 +2738,7 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
int const pop_id = cfg->getPaymentOptions().pop_id;
int const pop_accumulate_prices = cfg->getPaymentOptions().pop_accumulate_prices;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
int new_price = 0;
uint32_t duration = 0;
@ -2834,19 +2761,19 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
if (pop_accumulate_prices) {
new_price += pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
if (new_price <= price) {
duration_previous = durationUnit;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
return duration_previous;
}
}
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration" << duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration" << duration << "for price" << price;
return duration;
}

View File

@ -882,7 +882,7 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
ATBInterpolation interpolation = ipolCheck.value();
switch (duration.pun_interpolation_id) {
case static_cast<int>(ATBInterpolation::NO_INTERPOLATION):
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
break;
case static_cast<int>(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES):
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
@ -987,6 +987,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
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) {
qCritical() << __func__ << __LINE__ << opt;
return opt;
}
}
@ -1026,6 +1029,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
}
if ((pop_business_hours & p) == p) {
qCritical() << __func__ << __LINE__ << opt;
return opt;
}
}
@ -1148,6 +1154,7 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
if (paymentOptions) {
QVector<ATBPaymentOption> const vec = paymentOptions.value();
PermitType const p(permitType);
for (int i = 0; i < vec.size(); ++i) {
if (vec[i].pop_product_name == p.toString()) {
return i;
@ -1161,8 +1168,11 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
if (paymentOptions) {
QVector<ATBPaymentOption> const vec = paymentOptions.value();
PermitType const p(permitType);
for (int i = 0; i < vec.size(); ++i) {
if (vec[i].pop_product_name == p.toString()) {
return i;
@ -1310,11 +1320,14 @@ Configuration::getPaymentOptionsForAllKeys() const {
return value;
}
// TODO: umbenennen: getPaymentOptionForPermitType
std::optional<ATBPaymentOption>
Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
return getPaymentOptionForKey(static_cast<int>(permitType));
}
// TODO: umbenennen: getPaymentOptionForPermitType
std::optional<ATBPaymentOption>
Configuration::getPaymentOptionForKey(int permitType) const {
std::optional<ATBPaymentOption> value;
@ -1331,6 +1344,7 @@ Configuration::getPaymentOptionForKey(int permitType) const {
return value;
}
// TODO: umbenennen: getPaymentOptionForPermitType
std::optional<ATBPaymentOption>
Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);

View File

@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_STOCKERAU (0)
#define KLEIPEDA_LITAUEN (0)
#define SEXTEN (0)
#define SCHNALS_LEITER_KIRCHL (1)
#define SCHNALS_LEITER_KIRCHL (0)
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
#define VALSER_ALM (0)
#define VALSER_ALM (1)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -801,7 +801,7 @@ int main() {
int pop_max_price;
int pop_daily_card_price;
int zone = 2;
int zone = 1;
if (zone == 1) {
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
@ -823,22 +823,84 @@ int main() {
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;
if (zone == 1) {
/*
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);
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
qCritical() << " pop_min_time_pkw: " << pop_min_time;
qCritical() << " pop_max_time_pkw: " << pop_max_time;
qCritical() << " pop_min_price_pkw: " << pop_min_price;
qCritical() << " pop_max_price_pkw: " << pop_max_price;
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
qCritical() << " pop_min_time_bus: " << pop_min_time;
qCritical() << " pop_max_time_bus: " << pop_max_time;
qCritical() << " pop_min_price_bus: " << pop_min_price;
qCritical() << " pop_max_price_bus: " << pop_max_price;
*/
} else {
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 == 1) {
//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_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
QDateTime end;
CalcState calcState;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(12, 0, 0));
//calcState = compute_duration_for_parking_ticket(&cfg, s,
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
//qCritical() << end.toString(Qt::ISODate);
//qCritical() << calcState.toString();
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)6000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
}
if (zone == 2) {
//int minParkingTime = get_minimal_parkingtime(&cfg);
@ -858,6 +920,16 @@ int main() {
QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
QDateTime end;
CalcState calcState;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(18, 0, 0));
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
#if 0
for (int i=0; i<timeSteps.size(); ++i) {
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
@ -882,6 +954,7 @@ int main() {
<< "(price so far:" << price << ")";
}
#endif
}
if (zone == 3) {
int price;