Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88e92dddb9 | |||
| 0f05a1a784 | |||
| 2d696941a5 | |||
| 5598b02816 | |||
| 548447af1f |
+1
-1
@@ -2,7 +2,7 @@ TEMPLATE = lib
|
|||||||
TARGET = mobilisis_calc
|
TARGET = mobilisis_calc
|
||||||
#CONFIG += staticlib
|
#CONFIG += staticlib
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -std=c++17 -g -O0
|
QMAKE_CXXFLAGS += -std=c++17 -g -O
|
||||||
|
|
||||||
INCLUDEPATH += $$_PRO_FILE_PWD_/include
|
INCLUDEPATH += $$_PRO_FILE_PWD_/include
|
||||||
INCLUDEPATH += $$_PRO_FILE_PWD_/include/mobilisis
|
INCLUDEPATH += $$_PRO_FILE_PWD_/include/mobilisis
|
||||||
|
|||||||
@@ -97,11 +97,32 @@ 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;
|
||||||
|
|
||||||
|
// 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";
|
||||||
|
break;
|
||||||
|
case PaymentMethod::Degressive:
|
||||||
|
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
||||||
|
break;
|
||||||
|
case PaymentMethod::Linear:
|
||||||
|
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
||||||
|
break;
|
||||||
|
case PaymentMethod::Steps:
|
||||||
|
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
||||||
|
break;
|
||||||
|
case PaymentMethod::Undefined:
|
||||||
|
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// use tariff with structure as for instance Schnau, Koenigsee:
|
// use tariff with structure as for instance Schnau, Koenigsee:
|
||||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||||
if (tariff->YearPeriod.size() == 0
|
if (paymentMethodId == PaymentMethod::Steps)
|
||||||
&& tariff->SpecialDays.size() == 0
|
|
||||||
&& tariff->SpecialDaysWorktime.size() == 0)
|
|
||||||
{
|
{
|
||||||
static const QList<int> stepList = calculator.GetTimeSteps(tariff);
|
static const QList<int> stepList = calculator.GetTimeSteps(tariff);
|
||||||
|
|
||||||
@@ -130,33 +151,32 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
return stepList[currentStepIndex - 1];
|
return stepList[currentStepIndex - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
Configuration const *cfg = tariff;
|
if (paymentMethodId == PaymentMethod::Linear) {
|
||||||
|
|
||||||
// currentTimeMinutes is the number of minutes actually used. This
|
// currentTimeMinutes is the number of minutes actually used. This
|
||||||
// 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;
|
||||||
|
|
||||||
// compute payment method id (e.g. Linear=3, Steps=4)
|
|
||||||
PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
|
||||||
qCritical() << " compute_next_timestep() paymentMethodId:" << paymentMethodId;
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
qCritical() << " compute_next_timestep() nextTimeStep:" << nextTimeStep;
|
int const nextTimeStep = currentTimeMinutes + firstDurationStep;
|
||||||
|
|
||||||
|
if (nextTimeStep >= minParkingTime && nextTimeStep <= maxParkingTime) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user