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