GetTimeSteps(): compute minimal parking time and set pop_min_time.
This commit is contained in:
parent
15700a363d
commit
33731faba9
@ -695,14 +695,23 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
|
||||
cost, Ticket::s[VALID]);
|
||||
}
|
||||
|
||||
QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
QList<int> timeSteps;
|
||||
QList<int> Calculator::GetTimeSteps(Configuration *cfg, quint64 startInMinutes) const {
|
||||
static QList<int> timeSteps;
|
||||
|
||||
if (timeSteps.size() == 0) {
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
||||
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
||||
|
||||
qCritical() << " payment option id:" << pop_id;
|
||||
qCritical() << " payment option carry over:" << pop_carry_over;
|
||||
qCritical() << "payment option time step config:" << pop_time_step_config;
|
||||
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||
QDateTime start;
|
||||
start.setSecsSinceEpoch(startInMinutes * 60);
|
||||
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;
|
||||
@ -716,14 +725,11 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
if (search != cfg->Duration.end()) {
|
||||
ATBDuration duration = search->second;
|
||||
if (durationId == 1) {
|
||||
//duration.pun_duration_min = search->second.pun_duration_min;
|
||||
//duration.pun_duration_max = search->second.pun_duration_max;
|
||||
|
||||
QDateTime carryOver = m_start;
|
||||
QDateTime carryOver = start;
|
||||
carryOver = carryOver.addDays(1);
|
||||
carryOver.setTime(QTime(0, 0, 0));
|
||||
|
||||
int const timeStep = std::ceil(m_start.secsTo(carryOver) / 60.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)")
|
||||
@ -731,11 +737,18 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
.arg(timeStep).arg(duration.pun_duration_max);
|
||||
break;
|
||||
}
|
||||
qCritical() << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
// set dynamic minimal parking time
|
||||
cfg->getPaymentOptions().pop_min_time = timeStep;
|
||||
|
||||
qCritical() << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
duration.pun_duration = timeStep;
|
||||
m_timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||
timeSteps << duration.pun_duration;
|
||||
} else {
|
||||
duration.pun_duration = duration.pun_duration_max - m_timeStepCompensation;
|
||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||
timeSteps << duration.pun_duration;;
|
||||
}
|
||||
|
||||
@ -763,6 +776,7 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
timeSteps << durationUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return timeSteps;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user