Allow adjustment of the step list by a tolerance of 5 minutes per step

This commit is contained in:
Gerhard Hoffmann 2024-07-23 12:48:50 +02:00
parent da05d004dd
commit eb4ef0c3b5

View File

@ -410,13 +410,15 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
maxStep = stepList[1] - stepList[0];
}
int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
if (std::abs(stepList[0] - currentTimeMinutes) <= tolerance) {
for (int i=0; i < stepList.size(); ++i) {
if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) {
qCritical().noquote()
<< QString(" compute_next_timestep() correction stepList[0]=%1 -> %2:")
.arg(stepList[0]).arg(currentTimeMinutes);
stepList[0] = currentTimeMinutes;
<< QString(" compute_next_timestep() correction stepList[%1]=%2 -> %3:")
.arg(i).arg(stepList[0]).arg(currentTimeMinutes);
stepList[i] = currentTimeMinutes;
qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList;
}
}
int currentStepIndex = stepList.indexOf(currentTimeMinutes);