(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
|
// 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)
|
||||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
switch (paymentMethodId) {
|
switch (paymentMethodId) {
|
||||||
case PaymentMethod::Progressive:
|
case PaymentMethod::Progressive:
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId: Progressive";
|
qCritical() << " compute_next_timestep() paymentMethodId: Progressive";
|
||||||
break;
|
break;
|
||||||
case PaymentMethod::Degressive:
|
case PaymentMethod::Degressive:
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
||||||
break;
|
break;
|
||||||
case PaymentMethod::Linear:
|
case PaymentMethod::Linear:
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
||||||
break;
|
break;
|
||||||
case PaymentMethod::Steps:
|
case PaymentMethod::Steps:
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
||||||
break;
|
break;
|
||||||
case PaymentMethod::Undefined:
|
case PaymentMethod::Undefined:
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
||||||
break;
|
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
|
// 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);
|
||||||
|
|
||||||
|
qCritical() << " compute_next_timestep() firstDurationStep:" << firstDurationStep;
|
||||||
|
|
||||||
int nextTimeStep = currentTimeMinutes + firstDurationStep;
|
int nextTimeStep = currentTimeMinutes + firstDurationStep;
|
||||||
|
|
||||||
if (currentTimeMinutes >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
if (currentTimeMinutes >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
||||||
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
||||||
return nextTimeStep;
|
return nextTimeStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user