(1) Fix debug output.
(2) Use UpDown-Argument for calculation of next tiem step.
This commit is contained in:
parent
2d696941a5
commit
0f05a1a784
@ -97,25 +97,26 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
||||
// UpDown 1 -> up; 0 -> down
|
||||
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;
|
||||
|
||||
// compute payment method id (e.g. Linear=3, Steps=4)
|
||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
switch (paymentMethodId) {
|
||||
case PaymentMethod::Progressive:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Progressive";
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Progressive";
|
||||
break;
|
||||
case PaymentMethod::Degressive:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
||||
break;
|
||||
case PaymentMethod::Linear:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
||||
break;
|
||||
case PaymentMethod::Steps:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
||||
break;
|
||||
case PaymentMethod::Undefined:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -157,23 +158,25 @@ 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
|
||||
// QDateTime.
|
||||
|
||||
qCritical() << "compute_next_timestep() currentTimeMinutes:" << currentTimeMinutes;
|
||||
|
||||
qCritical() << "compute_next_timestep() up/down (1=up, 0=down):" << UpDown;
|
||||
|
||||
// get minimal and maximal parking times
|
||||
int const minParkingTime = Utilities::getMinimalParkingTime(cfg, paymentMethodId);
|
||||
int const maxParkingTime = Utilities::getMaximalParkingTime(cfg, paymentMethodId);
|
||||
|
||||
qCritical() << " compute_next_timestep() maxParkingTime:" << paymentMethodId;
|
||||
qCritical() << " compute_next_timestep() minParkingTime:" << paymentMethodId;
|
||||
qCritical() << " compute_next_timestep() maxParkingTime:" << maxParkingTime;
|
||||
qCritical() << " compute_next_timestep() minParkingTime:" << minParkingTime;
|
||||
|
||||
// use the first (i.e. main duration step contained in the tariff json-file)
|
||||
int firstDurationStep = Utilities::getFirstDurationStep(cfg, paymentMethodId);
|
||||
qCritical() << " compute_next_timestep() firstDurationStep:" << paymentMethodId;
|
||||
firstDurationStep = ((UpDown == 1) ? firstDurationStep : -firstDurationStep);
|
||||
|
||||
qCritical() << " compute_next_timestep() firstDurationStep:" << firstDurationStep;
|
||||
|
||||
int nextTimeStep = currentTimeMinutes + firstDurationStep;
|
||||
|
||||
if (currentTimeMinutes >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
||||
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
||||
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
||||
return nextTimeStep;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user