GetTimeSteps(): use pop_accumulate_durations to properly compute time steps

such that following functions comuting a price have the same behaviour.
This commit is contained in:
Gerhard Hoffmann 2024-08-13 15:04:13 +02:00
parent 77ca6a4736
commit b303a59964

View File

@ -1452,8 +1452,8 @@ CalcState Calculator::isParkingAllowed(Configuration const *cfg,
int netto_parking_time,
int paymentOptionIndex) {
qCritical() << DBG_HEADER << "CHECK IF PARKING IS ALLOWED AT"
<< start.toString(Qt::ISODate) << "...";
//qCritical() << DBG_HEADER << "CHECK IF PARKING IS ALLOWED AT"
// << start.toString(Qt::ISODate) << "...";
CalcState cs;
@ -2681,6 +2681,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
std::optional<QDateTime> prepaidStart = cfg->prepaidStart(start, pop_prepaid_option_id);
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
if (prepaidStart) {
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid start value:" << prepaidStart.value().toString(Qt::ISODate);
start = prepaidStart.value();
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
@ -2698,9 +2700,11 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
}
} else {
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
}
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
// int const start_time = start.time().hour() * 60 + start.time().minute();
QDateTime nextTimeStep = start;
int runtimeInMinutes = 0;
@ -2743,7 +2747,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) {
@ -2764,11 +2768,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
bool pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
runtimeInMinutes += duration.pun_duration;
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
if (nextTimeStep.time() > carryOverStart) {
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
@ -2793,17 +2798,19 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
//}
} else {
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") :" << m_timeSteps[paymentOptionIndex];
}
}
duration.pun_duration = runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
search->second = duration;
if (pop_accumulate_durations == false) {
duration.pun_duration = runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
search->second = duration;
}
} else
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" ;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
@ -2895,7 +2902,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
search->second = duration;
} else {
} else { // if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
cfg->Duration.erase(search);
}
}
@ -3002,7 +3009,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
}
if (timeStep == pun_duration) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
return price;
}
}
@ -3014,7 +3021,9 @@ 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;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
int new_price = 0;
uint32_t duration = 0;