Compare commits

..

2 Commits

Author SHA1 Message Date
5598b02816 Make distinction base on PaymentMethod, not on some
other data contained in json-tariff-file.
2023-12-07 17:00:28 +01:00
548447af1f set -O option to calm down compiler because of FORTIFY_SOURCE=2 option 2023-12-07 17:00:03 +01:00
2 changed files with 26 additions and 9 deletions

View File

@ -2,7 +2,7 @@ TEMPLATE = lib
TARGET = mobilisis_calc
#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/mobilisis

View File

@ -97,11 +97,31 @@ 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)
{
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:
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
if (tariff->YearPeriod.size() == 0
&& tariff->SpecialDays.size() == 0
&& tariff->SpecialDaysWorktime.size() == 0)
if (paymentMethodId == PaymentMethod::Steps)
{
static const QList<int> stepList = calculator.GetTimeSteps(tariff);
@ -130,8 +150,8 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
return stepList[currentStepIndex - 1];
}
}
} else {
Configuration const *cfg = tariff;
} else
if (paymentMethodId == PaymentMethod::Linear) {
// currentTimeMinutes is the number of minutes actually used. This
// value is an offset from the start time and cannot be used as a
@ -139,9 +159,6 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
qCritical() << "compute_next_timestep() currentTimeMinutes:" << currentTimeMinutes;
// 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
int const minParkingTime = Utilities::getMinimalParkingTime(cfg, paymentMethodId);