Make distinction base on PaymentMethod, not on some
other data contained in json-tariff-file.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user