compute_next_timestep(): allow some tolerance for first time-step
This commit is contained in:
parent
d7e185006f
commit
c153652b3d
@ -372,8 +372,31 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||||
(paymentMethodId == PaymentMethod::Progressive))
|
(paymentMethodId == PaymentMethod::Progressive))
|
||||||
{
|
{
|
||||||
const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||||
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
int const size = stepList.size();
|
||||||
|
if (size == 0) {
|
||||||
|
qCritical() << "compute_next_timestep() *ERROR empty step-list*";
|
||||||
|
return currentTimeMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " compute_next_timestep() first time step:" << stepList[0];
|
||||||
|
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
||||||
|
qCritical() << " compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
|
||||||
|
|
||||||
|
// consider time shift: the step-list might have been computed at a
|
||||||
|
// slightly different time point
|
||||||
|
int maxStep = -1;
|
||||||
|
if (size >= 2) {
|
||||||
|
maxStep = stepList[1] - stepList[0];
|
||||||
|
}
|
||||||
|
int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
|
||||||
|
if (std::abs(stepList[0] - currentTimeMinutes) <= tolerance) {
|
||||||
|
qCritical().noquote()
|
||||||
|
<< QString(" compute_next_timestep() correction stepList[0]=%1 -> %2:")
|
||||||
|
.arg(stepList[0]).arg(currentTimeMinutes);
|
||||||
|
stepList[0] = currentTimeMinutes;
|
||||||
|
qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList;
|
||||||
|
}
|
||||||
|
|
||||||
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user