Compare commits
2 Commits
5598b02816
...
0f05a1a784
Author | SHA1 | Date | |
---|---|---|---|
0f05a1a784 | |||
2d696941a5 |
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,15 @@ uint32_t Utilities::getMinimalParkingPrice(Configuration const *cfg, PaymentMeth
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
|
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
|
||||||
int popId = cfg->PaymentOption.find(methodId)->second.pop_id;
|
|
||||||
int punId = cfg->PaymentRate.find(popId)->second.pra_payment_unit_id;
|
int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
|
||||||
return cfg->Duration.find(punId)->second.pun_id;
|
int const punId = cfg->PaymentRate.find(popId)->second.pra_payment_unit_id;
|
||||||
|
uint32_t const firstDurationStep= cfg->Duration.find(punId)->second.pun_duration;
|
||||||
|
|
||||||
|
qCritical() << "getFirstDurationStep() payment-method-id:" << (int)methodId;
|
||||||
|
qCritical() << "getFirstDurationStep() pop-id:" << popId;
|
||||||
|
qCritical() << "getFirstDurationStep() pun-id:" << punId;
|
||||||
|
qCritical() << "getFirstDurationStep() first-step:" << firstDurationStep;
|
||||||
|
|
||||||
|
return firstDurationStep;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user