Compare commits
	
		
			7 Commits
		
	
	
		
			2.1.3
			...
			bad-neuena
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| aba38d2614 | |||
| 57d6b85f52 | |||
| 4f9c0422fc | |||
| a5b95d71b8 | |||
| fcbc8dcdc3 | |||
| ed99bae725 | |||
| 627d14204d | 
@@ -175,6 +175,8 @@ struct CALCULATE_LIBRARY_API CalcState {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CalcState &set(State s) { m_status = s; return *this; }
 | 
					    CalcState &set(State s) { m_status = s; return *this; }
 | 
				
			||||||
 | 
					    CalcState &setStatus(State s) { return set(s); }
 | 
				
			||||||
 | 
					    State getStatus() const { return m_status; }
 | 
				
			||||||
    CalcState &setDesc(QString s) { m_desc = s; return *this; }
 | 
					    CalcState &setDesc(QString s) { m_desc = s; return *this; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setAllowedTimeRange(QTime const &from, QTime const &until) {
 | 
					    void setAllowedTimeRange(QTime const &from, QTime const &until) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    switch(permitType) {
 | 
					    switch(permitType) {
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
        if (paymentMethodId == PaymentMethod::Progressive) {
 | 
					        if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
 | 
				
			||||||
            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
					            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
				
			||||||
        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
					        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
				
			||||||
            int const key = cfg->getPaymentOptions().pop_id;
 | 
					            int const key = cfg->getPaymentOptions().pop_id;
 | 
				
			||||||
@@ -134,7 +134,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
 | 
				
			|||||||
            if (pv) {
 | 
					            if (pv) {
 | 
				
			||||||
                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
					                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
				
			||||||
                if (paymentRate.size() > 0) {
 | 
					                if (paymentRate.size() > 0) {
 | 
				
			||||||
                    int const price = paymentRate.at(0).pra_price; // price is given per hour
 | 
					                    int const price = paymentRate.last().pra_price; // price is given per hour
 | 
				
			||||||
                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
					                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -428,14 +428,23 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        return calcState.set(CalcState::State::SUCCESS);
 | 
					        return calcState.set(CalcState::State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double cost = -1;
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
        double cost = Calculator::GetInstance().GetCostFromDuration(
 | 
					        if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) {
 | 
				
			||||||
 | 
					            calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time);
 | 
				
			||||||
 | 
					            if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
 | 
					                return calcState;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
				
			||||||
                        tariff,
 | 
					                        tariff,
 | 
				
			||||||
                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
                        start_parking_time,         // starting time
 | 
					                        start_parking_time,         // starting time
 | 
				
			||||||
                        end_parking_time,           // return value: end time
 | 
					                        end_parking_time,           // return value: end time
 | 
				
			||||||
                        netto_parking_time,         // minutes, netto
 | 
					                        netto_parking_time,         // minutes, netto
 | 
				
			||||||
                        false, prepaid);
 | 
					                        false, prepaid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        double minCost = tariff->getPaymentOptions().pop_min_price;
 | 
					        double minCost = tariff->getPaymentOptions().pop_min_price;
 | 
				
			||||||
        if (cost < minCost) {
 | 
					        if (cost < minCost) {
 | 
				
			||||||
            calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
 | 
					            calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
 | 
				
			||||||
@@ -445,8 +454,10 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        // DEBUG
 | 
					        // DEBUG
 | 
				
			||||||
        qCritical() << "               -> calculated cost (price->netto) =  " << cost;
 | 
					        qCritical() << "               -> calculated cost (price->netto) =  " << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        price->brutto = price->vat = price->vat_percentage = 0;
 | 
				
			||||||
        price->units = cost;
 | 
					        price->units = cost;
 | 
				
			||||||
        price->netto = cost;
 | 
					        price->netto = cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
					        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										186
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										186
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -37,10 +37,11 @@ extern "C" char* strptime(const char* s,
 | 
				
			|||||||
#define SZEGED                                  (0)
 | 
					#define SZEGED                                  (0)
 | 
				
			||||||
#define SCHOENAU_KOENIGSEE                      (0)
 | 
					#define SCHOENAU_KOENIGSEE                      (0)
 | 
				
			||||||
#define NEUHAUSER_KORNEUBURG                    (0)
 | 
					#define NEUHAUSER_KORNEUBURG                    (0)
 | 
				
			||||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU        (1)
 | 
					#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
				
			||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
					#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
				
			||||||
#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
					#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
				
			||||||
#define NEUHAUSER_KIRCHDORF                     (0)
 | 
					#define NEUHAUSER_KIRCHDORF                     (0)
 | 
				
			||||||
 | 
					#define BAD_NEUENAHR_AHRWEILER                  (1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KIRCHDORF==1
 | 
					#if NEUHAUSER_KIRCHDORF==1
 | 
				
			||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
					static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			||||||
@@ -159,6 +160,151 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main() {
 | 
					int main() {
 | 
				
			||||||
 | 
					#if BAD_NEUENAHR_AHRWEILER==1
 | 
				
			||||||
 | 
					    std::ifstream input;
 | 
				
			||||||
 | 
					    int pop_min_time;
 | 
				
			||||||
 | 
					    int pop_max_time;
 | 
				
			||||||
 | 
					    int pop_min_price;
 | 
				
			||||||
 | 
					    int pop_max_price;
 | 
				
			||||||
 | 
					    int pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int zone=1; zone < 2; ++zone) {
 | 
				
			||||||
 | 
					    //for (int t=6; t < 7; t+=20) {
 | 
				
			||||||
 | 
					        switch (zone) {
 | 
				
			||||||
 | 
					        case 1: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 6*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 2: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 5*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 3: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 6*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 4: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 4*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 5: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 6*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 6: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 4*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case 7: {
 | 
				
			||||||
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json");
 | 
				
			||||||
 | 
					            //pop_max_time = 4*60;
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        std::stringstream sstr;
 | 
				
			||||||
 | 
					        while(input >> sstr.rdbuf());
 | 
				
			||||||
 | 
					        std::string json(sstr.str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Configuration cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool isParsed = cfg.ParseJson(&cfg, json.c_str());
 | 
				
			||||||
 | 
					        cout << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (isParsed) {
 | 
				
			||||||
 | 
					            // test library functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg);
 | 
				
			||||||
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg);
 | 
				
			||||||
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg);
 | 
				
			||||||
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg);
 | 
				
			||||||
 | 
					            pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "        pop_min_time: " << pop_min_time;
 | 
				
			||||||
 | 
					            qCritical() << "        pop_max_time: " << pop_max_time;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_min_price: " << pop_min_price;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_max_price: " << pop_max_price;
 | 
				
			||||||
 | 
					            qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            static QList<int> const stepsConfigured
 | 
				
			||||||
 | 
					                = QList(std::initializer_list<int>{
 | 
				
			||||||
 | 
					                    20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //static QList<double> const cost
 | 
				
			||||||
 | 
					            //    = QList(std::initializer_list<double>{
 | 
				
			||||||
 | 
					            //        0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 500});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
				
			||||||
 | 
					            qCritical() << "TimeSteps" << timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (stepsConfigured != timeSteps) {
 | 
				
			||||||
 | 
					                qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
 | 
				
			||||||
 | 
					                return -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            struct price_t costs;
 | 
				
			||||||
 | 
					            double price1 = 0;
 | 
				
			||||||
 | 
					            double price2 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (int m=0; m < 1440; ++m) {
 | 
				
			||||||
 | 
					                start.setTime(QTime(0, 0, 0));
 | 
				
			||||||
 | 
					                start = start.addSecs(m*60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                qCritical() << "START" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //int Down = 0;
 | 
				
			||||||
 | 
					                //int Up = 1;
 | 
				
			||||||
 | 
					                // for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
				
			||||||
 | 
					                //    int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
				
			||||||
 | 
					                //    qCritical() << "nextTimeStep" << nextTimeStep;
 | 
				
			||||||
 | 
					                //
 | 
				
			||||||
 | 
					                //    int prevTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Down);
 | 
				
			||||||
 | 
					                //    qCritical() << "prevTimeStep" << prevTimeStep;
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
				
			||||||
 | 
					                    QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
 | 
				
			||||||
 | 
					                    if (cs.getStatus() != CalcState::State::SUCCESS) {
 | 
				
			||||||
 | 
					                        if (start.time().hour() >= 8 && start.time().hour() < 18) {
 | 
				
			||||||
 | 
					                            qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
 | 
				
			||||||
 | 
					                            exit(-1);
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            if (cs.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
 | 
					                                qCritical() << "CALC-STATE=" << QString(cs);
 | 
				
			||||||
 | 
					                                continue;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            qCritical() << "ERROR CALC-STATE-2=" << QString(cs);
 | 
				
			||||||
 | 
					                            exit(-1);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    price1 = costs.netto;
 | 
				
			||||||
 | 
					                    price2 = Calculator::GetInstance().GetCostFromDuration(&cfg, start, timeSteps.at(i));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (price1 != price2) {
 | 
				
			||||||
 | 
					                        qCritical() << "ERROR DIFFERENT PRICES" << price1 << price2;
 | 
				
			||||||
 | 
					                        exit(-1);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
 | 
				
			||||||
 | 
					                                << timeSteps.at(i) << "PRICE=" << price1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
 | 
				
			||||||
 | 
					                    //                                                                     start.toString(Qt::ISODate).toStdString().c_str(),
 | 
				
			||||||
 | 
					                    //                                                                     cost[i], false, true);
 | 
				
			||||||
 | 
					                    //qCritical() << "duration" << duration.c_str();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if SCHOENAU_KOENIGSEE==1
 | 
					#if SCHOENAU_KOENIGSEE==1
 | 
				
			||||||
    QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json");
 | 
					    QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
    //QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json");
 | 
					    //QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json");
 | 
				
			||||||
@@ -569,15 +715,16 @@ int main() {
 | 
				
			|||||||
        int Up = 1;
 | 
					        int Up = 1;
 | 
				
			||||||
        //compute_next_timestep(&cfg, )
 | 
					        //compute_next_timestep(&cfg, )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime const start = QDateTime::currentDateTime();
 | 
				
			||||||
        for (int i=0; i<timeSteps.size(); ++i) {
 | 
					        for (int i=0; i<timeSteps.size(); ++i) {
 | 
				
			||||||
            int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
					            int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
				
			||||||
            qCritical() << "nextTimeStep" << nextTimeStep;
 | 
					            qCritical() << "nextTimeStep" << nextTimeStep;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//            uint32_t price = calculator.GetPriceForTimeStep(&cfg, timeSteps.at(i));
 | 
					            uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i));
 | 
				
			||||||
//            uint32_t duration = calculator.GetDurationForPrice(&cfg, price);
 | 
					            uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
 | 
				
			||||||
//            qCritical() << "nextTimeStep relative to start:"
 | 
					            qCritical() << "nextTimeStep relative to start:"
 | 
				
			||||||
//                        << duration << start.addSecs(duration * 60)
 | 
					                        << duration << start.addSecs(duration * 60).toString(Qt::ISODate)
 | 
				
			||||||
//                        << "(price so far:" << price << ")";
 | 
					                        << "(price so far:" << price << ")";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -645,14 +792,13 @@ int main() {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KORNEUBURG==1
 | 
					#if NEUHAUSER_KORNEUBURG==1
 | 
				
			||||||
    std::ifstream input("/tmp/tariff_korneuburg.json");
 | 
					    std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
    int pop_max_time;
 | 
					    int pop_max_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::stringstream sstr;
 | 
					    std::stringstream sstr;
 | 
				
			||||||
    while(input >> sstr.rdbuf());
 | 
					    while(input >> sstr.rdbuf());
 | 
				
			||||||
    std::string json(sstr.str());
 | 
					    std::string json(sstr.str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Calculator calculator;
 | 
					 | 
				
			||||||
    Configuration cfg;
 | 
					    Configuration cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool isParsed = cfg.ParseJson(&cfg, json.c_str());
 | 
					    bool isParsed = cfg.ParseJson(&cfg, json.c_str());
 | 
				
			||||||
@@ -674,19 +820,19 @@ int main() {
 | 
				
			|||||||
                    QDateTime start = s.addSecs(offset * 60);
 | 
					                    QDateTime start = s.addSecs(offset * 60);
 | 
				
			||||||
                    //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
					                    //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
					                    double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
				
			||||||
                    //Q_ASSERT(cost == duration*2.5);
 | 
					                    //Q_ASSERT(cost == duration*2.5);
 | 
				
			||||||
                    //qCritical() << "";
 | 
					                    //qCritical() << "";
 | 
				
			||||||
                    //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                    //            << "end" << end.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                    //            << "duration" << duration
 | 
					 | 
				
			||||||
                    //            << "cost" << cost;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
 | 
					 | 
				
			||||||
                    //Q_ASSERT(cost == duration*2.5);
 | 
					 | 
				
			||||||
                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
                                << "cost" << cost
 | 
					                                << "end" << end.toString(Qt::ISODate)
 | 
				
			||||||
                                << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "cost" << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
 | 
				
			||||||
 | 
					                    //Q_ASSERT(cost == duration*2.5);
 | 
				
			||||||
 | 
					                    //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                    //            << "cost" << cost
 | 
				
			||||||
 | 
					                    //            << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -703,7 +849,7 @@ int main() {
 | 
				
			|||||||
    int pop_max_price;
 | 
					    int pop_max_price;
 | 
				
			||||||
    int pop_daily_card_price;
 | 
					    int pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int zone=6; zone < 7; ++zone) {
 | 
					    for (int zone=1; zone < 2; ++zone) {
 | 
				
			||||||
    //for (int t=6; t < 7; t+=20) {
 | 
					    //for (int t=6; t < 7; t+=20) {
 | 
				
			||||||
        switch (zone) {
 | 
					        switch (zone) {
 | 
				
			||||||
        case 1: {
 | 
					        case 1: {
 | 
				
			||||||
@@ -779,7 +925,7 @@ int main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // zone 1 (lila)
 | 
					                // zone 1 (lila)
 | 
				
			||||||
                QDateTime s(QDate(2023, 11, 30), QTime());
 | 
					                QDateTime s(QDate(2024, 3, 26), QTime());
 | 
				
			||||||
                QDateTime end;
 | 
					                QDateTime end;
 | 
				
			||||||
                int cnt = 1;
 | 
					                int cnt = 1;
 | 
				
			||||||
                if (zone == 1) {
 | 
					                if (zone == 1) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user