GetTimeSteps():
updated as well for Schnals (505). Still to be tested.
This commit is contained in:
parent
b5804408f4
commit
ba8e2786fc
@ -2116,8 +2116,11 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
|||||||
|
|
||||||
#define DEBUG_GET_TIME_STEPS (1)
|
#define DEBUG_GET_TIME_STEPS (1)
|
||||||
|
|
||||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
|
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||||
|
QDateTime const &s) const {
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_timeSteps.size() > paymentOptionIndex) {
|
if (m_timeSteps.size() > paymentOptionIndex) {
|
||||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||||
@ -2127,9 +2130,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
m_timeSteps.push_back(QList<int>());
|
m_timeSteps.push_back(QList<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime start = QDateTime::currentDateTime();
|
QDateTime start = s;
|
||||||
//start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
|
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||||
start.setTime(QTime(7, start.time().minute(), 0));
|
|
||||||
|
|
||||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||||
@ -2138,10 +2140,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
|
|
||||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
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__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||||
@ -2155,25 +2161,34 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
} else {
|
} else {
|
||||||
uint16_t timeStepCompensation = 0;
|
uint16_t timeStepCompensation = 0;
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
||||||
|
}
|
||||||
|
|
||||||
if (pop_carry_over) {
|
if (pop_carry_over) {
|
||||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
||||||
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||||
|
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
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;
|
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range id:" << pop_carry_over_time_range_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range id:" << pop_carry_over_time_range_id;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over option id:" << pop_carry_over_time_range_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over option id:" << pop_carry_over_time_range_id;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||||
|
}
|
||||||
|
|
||||||
int weekDay = start.date().dayOfWeek();
|
int weekDay = start.date().dayOfWeek();
|
||||||
QTime const carryOverStart = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
QTime const carryOverStart = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||||
QTime const carryOverEnd = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
|
QTime const carryOverEnd = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
|
||||||
|
int const carryOverDuration = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over end:" << carryOverEnd.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over end:" << carryOverEnd.toString(Qt::ISODate);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: reparieren
|
// TODO: reparieren
|
||||||
|
|
||||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||||
@ -2219,8 +2234,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||||
|
}
|
||||||
|
|
||||||
m_timeSteps[paymentOptionIndex].clear();
|
m_timeSteps[paymentOptionIndex].clear();
|
||||||
|
|
||||||
@ -2228,7 +2245,9 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
|
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
|
||||||
if (prepaidStart) {
|
if (prepaidStart) {
|
||||||
start = prepaidStart.value();
|
start = prepaidStart.value();
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||||
}
|
}
|
||||||
@ -2237,13 +2256,18 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
std::optional<QDateTime> interpolationEndDate = cfg->getInterpolationEnd(start, paymentOptionIndex);
|
std::optional<QDateTime> interpolationEndDate = cfg->getInterpolationEnd(start, paymentOptionIndex);
|
||||||
if (interpolationEndDate) {
|
if (interpolationEndDate) {
|
||||||
interpolationEnd = interpolationEndDate.value();
|
interpolationEnd = interpolationEndDate.value();
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||||
}
|
}
|
||||||
|
|
||||||
int const start_time = start.time().hour() * 60 + start.time().minute();
|
// int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||||
QDateTime nextTimeStep = start;
|
QDateTime nextTimeStep = start;
|
||||||
|
int runtimeInMinutes = 0;
|
||||||
|
|
||||||
|
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||||
|
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
@ -2252,6 +2276,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
auto search = cfg->Duration.find(durationId);
|
auto search = cfg->Duration.find(durationId);
|
||||||
if (search != cfg->Duration.end()) {
|
if (search != cfg->Duration.end()) {
|
||||||
ATBDuration duration = search->second;
|
ATBDuration duration = search->second;
|
||||||
|
ATBDuration &previous = search->second;
|
||||||
|
|
||||||
if (duration.pun_interpolation_id == -1) {
|
if (duration.pun_interpolation_id == -1) {
|
||||||
|
|
||||||
@ -2271,118 +2296,102 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
interpolation.dynamic_start = start.time();
|
interpolation.dynamic_start = start.time();
|
||||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||||
|
|
||||||
int const end_time = interpolation.dynamic_end.hour() * 60 + interpolation.dynamic_end.minute();
|
// int const end_time = interpolation.dynamic_end.hour() * 60 + interpolation.dynamic_end.minute();
|
||||||
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolationEnd.toString(Qt::ISODate);
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
||||||
|
|
||||||
QDateTime carryOver = start;
|
|
||||||
carryOver.setTime(interpolation.dynamic_end);
|
|
||||||
|
|
||||||
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
nextTimeStep = nextTimeStep.addSecs(duration.pun_duration * 60);
|
runtimeInMinutes += duration.pun_duration;
|
||||||
|
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||||
|
|
||||||
|
if (nextTimeStep.time() > carryOverStart) {
|
||||||
|
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
||||||
|
runtimeInMinutes -= backTime;
|
||||||
|
nextTimeStep.setTime(carryOverStart);
|
||||||
|
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
|
||||||
|
runtimeInMinutes += (backTime + carryOverDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
// int nextTimeStep = start_time + duration.pun_duration;
|
|
||||||
//int rest = end_time - nextTimeStep;
|
|
||||||
int rest = nextTimeStep.secsTo(interpolationEnd);
|
int rest = nextTimeStep.secsTo(interpolationEnd);
|
||||||
if (nextTimeStep <= interpolationEnd) {
|
if (nextTimeStep <= interpolationEnd) {
|
||||||
|
if (rest > 0 && rest < duration.pun_duration) {
|
||||||
if (durationId == 1) {
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO TODO:" << rest;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") rest minutes:" << rest;
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
// last time step before switching to dayticket (see Schnals 505/506)
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
//if (duration.pun_duration > 0) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
// m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int const timeStep = start.secsTo(nextTimeStep) / 60;
|
|
||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step:" << timeStep;
|
|
||||||
|
|
||||||
//if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
|
||||||
// << 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() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
|
||||||
|
|
||||||
// set dynamic minimal parking time
|
|
||||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep;
|
|
||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
|
||||||
|
|
||||||
duration.pun_duration = timeStep;
|
|
||||||
timeStepCompensation = start.secsTo(interpolationEnd) / 60;
|
|
||||||
|
|
||||||
if (duration.pun_duration > 0) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
|
||||||
// timeStepComp: added to (otherwise static) time-steps
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration_max:" << duration.pun_duration_max;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration:" << duration.pun_duration;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
// duration.pun_duration = nextTimeStep;
|
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
||||||
|
|
||||||
// HIER WEITER
|
|
||||||
|
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
|
||||||
QTime nextTime(0, 0, 0);
|
|
||||||
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (duration.pun_duration > 0) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
duration.pun_duration = runtimeInMinutes;
|
||||||
if (rest > 0) {
|
|
||||||
// last time step before swicthing to dayticket (see Schnals 505/506)
|
|
||||||
duration.pun_duration = duration.pun_duration_max;
|
|
||||||
|
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
QTime nextTime(0, 0, 0);
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||||
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun id:" << duration.pun_id;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (duration.pun_duration > 0) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg->Duration.erase(search);
|
|
||||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
|
||||||
|
|
||||||
|
search->second = duration;
|
||||||
} else
|
} else
|
||||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||||
|
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
QDateTime s = start.addSecs(runtimeInMinutes * 60);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
int const minutes = s.time().secsTo(carryOverStart) / 60;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration_max:" << duration.pun_duration_max;
|
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes:" << minutes;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") s:" << s.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
if (minutes > 0) {
|
||||||
|
runtimeInMinutes += minutes;
|
||||||
|
previous.pun_duration += minutes;
|
||||||
|
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||||
|
m_timeSteps[paymentOptionIndex].last() += minutes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (0):" << runtimeInMinutes;
|
||||||
|
|
||||||
|
runtimeInMinutes += duration.pun_duration;
|
||||||
|
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||||
|
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
// TOOO: truncate-flag == false
|
||||||
|
if (nextTimeStep.time() > carryOverStart) {
|
||||||
|
int const backTime = carryOverStart.secsTo(nextTimeStep.time());
|
||||||
|
runtimeInMinutes -= backTime;
|
||||||
|
nextTimeStep.setTime(carryOverStart);
|
||||||
|
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
|
||||||
|
runtimeInMinutes += (backTime + carryOverDuration);
|
||||||
|
} else
|
||||||
|
if (nextTimeStep.time() < carryOverStart) {
|
||||||
|
int const forwardTime = nextTimeStep.time().secsTo(carryOverStart) / 60;
|
||||||
|
runtimeInMinutes += forwardTime;
|
||||||
|
nextTimeStep.setTime(carryOverStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||||
#endif
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
duration.pun_duration += start_time + timeStepCompensation;
|
duration.pun_duration = runtimeInMinutes;
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
|
search->second = duration;
|
||||||
cfg->Duration.erase(search);
|
|
||||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
|
||||||
} else {
|
} else {
|
||||||
cfg->Duration.erase(search);
|
cfg->Duration.erase(search);
|
||||||
}
|
}
|
||||||
@ -2417,18 +2426,19 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||||
|
|
||||||
#if DEBUG_GET_TIME_STEPS==1
|
|
||||||
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||||
QDateTime nextTime = start;
|
QDateTime nextTime = s;
|
||||||
nextTime.setTime(QTime(0, 0, 0));
|
// nextTime.setTime(QTime(0, 0, 0));
|
||||||
nextTime = nextTime.addSecs(m_timeSteps[paymentOptionIndex][i] * 60);
|
int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
|
||||||
|
nextTime = nextTime.addSecs(secs);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
||||||
<< i << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
<< i << secs << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return m_timeSteps[paymentOptionIndex];
|
return m_timeSteps[paymentOptionIndex];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user