|
|
@@ -97,6 +97,7 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
|
|
|
// UpDown 1 -> up; 0 -> down
|
|
|
|
// UpDown 1 -> up; 0 -> down
|
|
|
|
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown)
|
|
|
|
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
|
|
|
Configuration const *cfg = tariff;
|
|
|
|
Configuration const *cfg = tariff;
|
|
|
|
|
|
|
|
|
|
|
|
// compute payment method id (e.g. Linear=3, Steps=4)
|
|
|
|
// compute payment method id (e.g. Linear=3, Steps=4)
|
|
|
@@ -157,22 +158,24 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|
|
|
// value is an offset from the start time and cannot be used as a
|
|
|
|
// value is an offset from the start time and cannot be used as a
|
|
|
|
// QDateTime.
|
|
|
|
// QDateTime.
|
|
|
|
|
|
|
|
|
|
|
|
qCritical() << "compute_next_timestep() currentTimeMinutes:" << currentTimeMinutes;
|
|
|
|
qCritical() << "compute_next_timestep() up/down (1=up, 0=down):" << UpDown;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get minimal and maximal parking times
|
|
|
|
// get minimal and maximal parking times
|
|
|
|
int const minParkingTime = Utilities::getMinimalParkingTime(cfg, paymentMethodId);
|
|
|
|
int const minParkingTime = Utilities::getMinimalParkingTime(cfg, paymentMethodId);
|
|
|
|
int const maxParkingTime = Utilities::getMaximalParkingTime(cfg, paymentMethodId);
|
|
|
|
int const maxParkingTime = Utilities::getMaximalParkingTime(cfg, paymentMethodId);
|
|
|
|
|
|
|
|
|
|
|
|
qCritical() << " compute_next_timestep() maxParkingTime:" << paymentMethodId;
|
|
|
|
qCritical() << " compute_next_timestep() maxParkingTime:" << maxParkingTime;
|
|
|
|
qCritical() << " compute_next_timestep() minParkingTime:" << paymentMethodId;
|
|
|
|
qCritical() << " compute_next_timestep() minParkingTime:" << minParkingTime;
|
|
|
|
|
|
|
|
|
|
|
|
// use the first (i.e. main duration step contained in the tariff json-file)
|
|
|
|
// use the first (i.e. main duration step contained in the tariff json-file)
|
|
|
|
int firstDurationStep = Utilities::getFirstDurationStep(cfg, paymentMethodId);
|
|
|
|
int firstDurationStep = Utilities::getFirstDurationStep(cfg, paymentMethodId);
|
|
|
|
qCritical() << " compute_next_timestep() firstDurationStep:" << paymentMethodId;
|
|
|
|
firstDurationStep = ((UpDown == 1) ? firstDurationStep : -firstDurationStep);
|
|
|
|
|
|
|
|
|
|
|
|
int nextTimeStep = currentTimeMinutes + firstDurationStep;
|
|
|
|
qCritical() << " compute_next_timestep() firstDurationStep:" << firstDurationStep;
|
|
|
|
if (currentTimeMinutes >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
|
|
|
|
|
|
|
|
|
|
|
int const nextTimeStep = currentTimeMinutes + firstDurationStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nextTimeStep >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
|
|
|
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
|
|
|
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
|
|
|
return nextTimeStep;
|
|
|
|
return nextTimeStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|