GetTimeSteps(): adapt for progressive tariff (e.g. neuhauser/kirchdorf).
Compute timesteps according to tariff01.json file.
This commit is contained in:
parent
81d515eb7f
commit
102607b71f
@ -584,7 +584,6 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
|
||||
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
||||
|
||||
|
||||
if (current.time() >= to) {
|
||||
continue; // try to use next available work-time
|
||||
} else
|
||||
@ -1167,6 +1166,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
||||
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
||||
|
||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " start parking time:" << start.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " payment option id:" << pop_id;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "payment option carry over:" << pop_carry_over;
|
||||
@ -1174,63 +1175,71 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||
|
||||
uint16_t timeStepCompensation = 0;
|
||||
if (paymentMethodId == PaymentMethod::Progressive) { // e.g. neuhauser kirchdorf (743)
|
||||
std::size_t const s = cfg->TimeRange.size();
|
||||
for (std::size_t id = 1; id <= s; ++id) {
|
||||
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
||||
m_timeSteps.append(step);
|
||||
}
|
||||
} else {
|
||||
uint16_t timeStepCompensation = 0;
|
||||
|
||||
if (pop_carry_over) {
|
||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions().pop_carry_over_time_range_id;
|
||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||
if (pop_carry_over) {
|
||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions().pop_carry_over_time_range_id;
|
||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||
|
||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
ATBDuration duration = search->second;
|
||||
if (durationId == 1) {
|
||||
QDateTime carryOver = start;
|
||||
carryOver = carryOver.addDays(1);
|
||||
carryOver.setTime(QTime(0, 0, 0));
|
||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
ATBDuration duration = search->second;
|
||||
if (durationId == 1) {
|
||||
QDateTime carryOver = start;
|
||||
carryOver = carryOver.addDays(1);
|
||||
carryOver.setTime(QTime(0, 0, 0));
|
||||
|
||||
int const timeStep = std::ceil(start.secsTo(carryOver) / 60.0);
|
||||
if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
||||
qCritical()
|
||||
<< QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
||||
.arg(timeStep).arg(duration.pun_duration_min)
|
||||
.arg(timeStep).arg(duration.pun_duration_max);
|
||||
break;
|
||||
int const timeStep = std::ceil(start.secsTo(carryOver) / 60.0);
|
||||
if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
||||
qCritical()
|
||||
<< QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
||||
.arg(timeStep).arg(duration.pun_duration_min)
|
||||
.arg(timeStep).arg(duration.pun_duration_max);
|
||||
break;
|
||||
}
|
||||
qCritical() << __PRETTY_FUNCTION__ << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
// set dynamic minimal parking time
|
||||
cfg->getPaymentOptions().pop_min_time = timeStep;
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
duration.pun_duration = timeStep;
|
||||
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||
m_timeSteps << duration.pun_duration;
|
||||
} else {
|
||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||
m_timeSteps << duration.pun_duration;;
|
||||
}
|
||||
qCritical() << __PRETTY_FUNCTION__ << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
// set dynamic minimal parking time
|
||||
cfg->getPaymentOptions().pop_min_time = timeStep;
|
||||
cfg->Duration.erase(search);
|
||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
duration.pun_duration = timeStep;
|
||||
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||
m_timeSteps << duration.pun_duration;
|
||||
} else {
|
||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||
m_timeSteps << duration.pun_duration;;
|
||||
} else { // if (search != cfg->Duration.end()) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
cfg->Duration.erase(search);
|
||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||
|
||||
} else { // if (search != cfg->Duration.end()) {
|
||||
// TODO
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
// TODO
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
||||
// TODO
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
||||
} else { // if (pop_carry_over) {
|
||||
// TODO
|
||||
}
|
||||
} else { // if (pop_carry_over) {
|
||||
// TODO
|
||||
}
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::STATIC";
|
||||
|
Loading…
Reference in New Issue
Block a user