Compare commits
	
		
			8 Commits
		
	
	
		
			2.3.99-23
			...
			remotes/or
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 49f016cc98 | |||
| 41a09d882d | |||
| 5cfca87f3e | |||
| 1f6606f382 | |||
| 4b9a4319b3 | |||
| 5e673788b4 | |||
| 7e2f40a7b5 | |||
| 44e2ce24a3 | 
@@ -61,6 +61,28 @@ struct ATBTariffCarryOver {
 | 
			
		||||
        return QString("ERROR unknown carry over application: %1").arg(static_cast<int>(m_carryOverIf));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int computeMinutesUntilCarryOverEnd(QDateTime const &dt) {
 | 
			
		||||
        int minutes = 0;
 | 
			
		||||
        QString end = m_range.m_end.toString(Qt::ISODate);
 | 
			
		||||
        if (end == "24:00:00") {
 | 
			
		||||
            QDateTime t = dt.addDays(1);
 | 
			
		||||
            t.setTime(QTime(0,0,0));
 | 
			
		||||
            minutes = dt.secsTo(t) / 60;
 | 
			
		||||
        } else {
 | 
			
		||||
            QDateTime t(dt);
 | 
			
		||||
            t.setTime(QTime::fromString(end, Qt::ISODate));
 | 
			
		||||
            minutes = dt.secsTo(t) / 60;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (minutes < 0 || minutes > m_range.m_duration) {
 | 
			
		||||
            minutes = 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // qCritical() << __func__ << ":" << __LINE__ << "minutes" << minutes;
 | 
			
		||||
 | 
			
		||||
        return minutes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    friend QDebug operator<<(QDebug debug, ATBTariffCarryOver const &co) {
 | 
			
		||||
        QDebugStateSaver saver(debug);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								library/include/mobilisis/tariff_comp_state.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								library/include/mobilisis/tariff_comp_state.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
#ifndef TARIFF_COMP_STATE_H_INCLUDED
 | 
			
		||||
#define TARIFF_COMP_STATE_H_INCLUDED
 | 
			
		||||
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
 | 
			
		||||
struct TariffCompState {
 | 
			
		||||
    QDateTime const m_start;
 | 
			
		||||
    int m_nettoParkingTimeTotal = 0;
 | 
			
		||||
    int m_bruttoParkingTimeTotal = 0;
 | 
			
		||||
    int m_priceTotal = 0;
 | 
			
		||||
 | 
			
		||||
    explicit TariffCompState(QDateTime start)
 | 
			
		||||
        : m_start(std::move(start))
 | 
			
		||||
        , m_nettoParkingTimeTotal(0)
 | 
			
		||||
        , m_bruttoParkingTimeTotal(0)
 | 
			
		||||
        , m_priceTotal(0) {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TARIFF_COMP_STATE_H_INCLUDED
 | 
			
		||||
							
								
								
									
										29
									
								
								library/include/mobilisis/tariff_comp_step.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								library/include/mobilisis/tariff_comp_step.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
#ifndef TARIFF_COMP_STEP_H_INCLUDED
 | 
			
		||||
#define TARIFF_COMP_STEP_H_INCLUDED
 | 
			
		||||
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
#include "tariff_comp_state.h"
 | 
			
		||||
 | 
			
		||||
class TariffCompStep {
 | 
			
		||||
    int m_duration;
 | 
			
		||||
    QDateTime const m_start;
 | 
			
		||||
    QDateTime const m_end;
 | 
			
		||||
    uint64_t const m_handle;
 | 
			
		||||
    TariffCompState m_compState;
 | 
			
		||||
 | 
			
		||||
    uint64_t hash();
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit TariffCompStep(int duration, QDateTime start, QDateTime end, TariffCompState &compState)
 | 
			
		||||
        : m_duration(duration)
 | 
			
		||||
        , m_start(std::move(start))
 | 
			
		||||
        , m_end(std::move(end))
 | 
			
		||||
        , m_handle(hash())
 | 
			
		||||
        , m_compState(compState) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint64_t handle() { return m_handle; }
 | 
			
		||||
    uint64_t handle() const { return m_handle; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TARIFF_COMP_STEP_H_INCLUDED
 | 
			
		||||
@@ -34,6 +34,13 @@ struct TimeRange {
 | 
			
		||||
        m_duration = timeRange.m_duration;
 | 
			
		||||
        return *this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TimeRange &operator=(TimeRange const &timeRange) {
 | 
			
		||||
        m_start = timeRange.m_start;
 | 
			
		||||
        m_end = timeRange.m_end;
 | 
			
		||||
        m_duration = timeRange.m_duration;
 | 
			
		||||
        return *this;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TIME_RANGE_H_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,8 @@ SOURCES += \
 | 
			
		||||
    src/calculate_price.cpp \
 | 
			
		||||
    src/ticket.cpp \
 | 
			
		||||
    src/tariff_global_defines.cpp \
 | 
			
		||||
    src/atb_time.cpp
 | 
			
		||||
    src/atb_time.cpp \
 | 
			
		||||
    src/tariff_comp_step.cpp
 | 
			
		||||
 | 
			
		||||
HEADERS += \
 | 
			
		||||
	include/mobilisis/calculator_functions.h \
 | 
			
		||||
@@ -93,7 +94,9 @@ HEADERS += \
 | 
			
		||||
    include/mobilisis/tariff_global_defines.h \
 | 
			
		||||
    include/mobilisis/atb_time.h \
 | 
			
		||||
    include/mobilisis/tariff_service.h \
 | 
			
		||||
    include/mobilisis/tariff_out_of_service.h
 | 
			
		||||
    include/mobilisis/tariff_out_of_service.h \
 | 
			
		||||
    include/mobilisis/tariff_comp_state.h \
 | 
			
		||||
    include/mobilisis/tariff_comp_step.h
 | 
			
		||||
 | 
			
		||||
OTHER_FILES += src/main.cpp \
 | 
			
		||||
    ../tariffs/tariff_korneuburg.json \
 | 
			
		||||
 
 | 
			
		||||
@@ -458,7 +458,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
                                                        arg(cost).arg(nettoParktimeForCost);
 | 
			
		||||
 | 
			
		||||
    int cnt = 0;
 | 
			
		||||
    while (++cnt < 1000 && netto_parking_time_in_minutes < nettoParktimeForCost) {
 | 
			
		||||
    while (++cnt < 10 && netto_parking_time_in_minutes < nettoParktimeForCost) {
 | 
			
		||||
        // qCritical() << __func__ << ":" << __LINE__ << "cnt [" << cnt;
 | 
			
		||||
 | 
			
		||||
        brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
			
		||||
@@ -555,8 +555,9 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
                       .arg(free_parking_time_in_minutes);
 | 
			
		||||
 | 
			
		||||
        if (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, dt)) {
 | 
			
		||||
            TimeRange const &carryOverTimeRange = co.value().m_range;
 | 
			
		||||
            free_parking_time_in_minutes += carryOverTimeRange.m_duration;
 | 
			
		||||
            int minutes = co.value().computeMinutesUntilCarryOverEnd(dt);
 | 
			
		||||
            if (minutes > 0) {
 | 
			
		||||
                free_parking_time_in_minutes += minutes;
 | 
			
		||||
 | 
			
		||||
                brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
			
		||||
                dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
 | 
			
		||||
@@ -569,6 +570,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
                               .arg(netto_parking_time_in_minutes)
 | 
			
		||||
                               .arg(free_parking_time_in_minutes);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (std::optional<ATBTariffService> serv = getService(cfg, dt)) {
 | 
			
		||||
            TimeRange const &serviceTimeRange = serv.value().m_range;
 | 
			
		||||
@@ -577,6 +579,8 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
                int rest_parking_time_in_minutes = nettoParktimeForCost - netto_parking_time_in_minutes;
 | 
			
		||||
                ATBTime t(dt.time().hour(), dt.time().minute(), 0, 0);
 | 
			
		||||
                int timeToServiceEnd = t.secsTo(serviceTimeRange.m_end.toString(Qt::ISODate)) / 60;
 | 
			
		||||
 | 
			
		||||
                // TODO: wohl aehnlich wie carry-over zu behandlen
 | 
			
		||||
                if (serviceTimeRange.m_duration > 0) {
 | 
			
		||||
                    if (timeToServiceEnd < rest_parking_time_in_minutes) {
 | 
			
		||||
                        netto_parking_time_in_minutes += timeToServiceEnd;
 | 
			
		||||
@@ -601,20 +605,41 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
        // qCritical() << __func__ << ":" << __LINE__ << "cnt" << cnt << "]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (cnt >= 1000) {
 | 
			
		||||
    if (cnt >= 10) {
 | 
			
		||||
        qCritical() << __func__ << ":" << __LINE__ << "BREAK";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // configure if last carry-over ranges shall be added to ticket-end-time
 | 
			
		||||
    dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
 | 
			
		||||
 | 
			
		||||
    cnt = 0;
 | 
			
		||||
    while (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, inputDate.addSecs(brutto_parking_time_in_minutes * 60))) {
 | 
			
		||||
        if (++cnt > 5) {
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "BREAK";
 | 
			
		||||
    QVector<TimeRange> timeRanges;
 | 
			
		||||
    while (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, dt)) {
 | 
			
		||||
        if (++cnt > 10) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        TimeRange const &carryOverTimeRange = co.value().m_range;
 | 
			
		||||
        free_parking_time_in_minutes += carryOverTimeRange.m_duration;
 | 
			
		||||
        if (!timeRanges.isEmpty()) {
 | 
			
		||||
            if (timeRanges.last().m_end != carryOverTimeRange.m_start) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        timeRanges.push_back(carryOverTimeRange);
 | 
			
		||||
 | 
			
		||||
        int minutes = co.value().computeMinutesUntilCarryOverEnd(dt);
 | 
			
		||||
        if (minutes > 0) {
 | 
			
		||||
            free_parking_time_in_minutes += co.value().computeMinutesUntilCarryOverEnd(dt);
 | 
			
		||||
            brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
			
		||||
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << QString("%1 (%2): brutto: %3 = netto: %4 + free: %5")
 | 
			
		||||
                           .arg(dt.toString(Qt::ISODate))
 | 
			
		||||
                           .arg(weekDay)
 | 
			
		||||
                           .arg(brutto_parking_time_in_minutes)
 | 
			
		||||
                           .arg(netto_parking_time_in_minutes)
 | 
			
		||||
                           .arg(free_parking_time_in_minutes);
 | 
			
		||||
 | 
			
		||||
            dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
 | 
			
		||||
        } else break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								library/src/tariff_comp_step.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								library/src/tariff_comp_step.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
#include "tariff_comp_step.h"
 | 
			
		||||
 | 
			
		||||
#include <QByteArray>
 | 
			
		||||
#include <QCryptographicHash>
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
uint64_t TariffCompStep::hash() {
 | 
			
		||||
    QString const str(QString("%1%2%3").arg(m_duration).arg(m_start.toString(Qt::ISODate)).arg(m_end.toString(Qt::ISODate)));
 | 
			
		||||
    QByteArray const hash = QCryptographicHash::hash(
 | 
			
		||||
      QByteArray::fromRawData(reinterpret_cast<char const*>(str.utf16()), str.length()*2),
 | 
			
		||||
      QCryptographicHash::Md5
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    uint64_t const &i = hash.left(8).toULongLong(nullptr, 16);
 | 
			
		||||
    uint64_t const &j = hash.right(8).toULongLong(nullptr, 16);
 | 
			
		||||
    return i ^ j;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										172
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										172
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -42,8 +42,8 @@ extern "C" char* strptime(const char* s,
 | 
			
		||||
#define NEUHAUSER_KORNEUBURG                    (0)
 | 
			
		||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
			
		||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
			
		||||
#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
			
		||||
#define BAD_NEUENAHR_AHRWEILER                  (1)
 | 
			
		||||
#define NEUHAUSER_BILEXA_GALTUER                (1)
 | 
			
		||||
#define BAD_NEUENAHR_AHRWEILER                  (0)
 | 
			
		||||
#define NEUHAUSER_CHRISTOPH_REISEN              (0)
 | 
			
		||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR            (0)
 | 
			
		||||
#define NEUHAUSER_STOCKERAU                     (0)
 | 
			
		||||
@@ -52,6 +52,8 @@ extern "C" char* strptime(const char* s,
 | 
			
		||||
#define SCHNALS_LEITER_KIRCHL                   (0)
 | 
			
		||||
#define SCHNALS_STAUMAUER                       (SCHNALS_LEITER_KIRCHL)
 | 
			
		||||
#define VALSER_ALM                              (0)
 | 
			
		||||
#define NEUHAUSER_FORCHACH                      (0)
 | 
			
		||||
#define STADT_WEIDEN                            (0)
 | 
			
		||||
 | 
			
		||||
#if NEUHAUSER_KIRCHDORF==1
 | 
			
		||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
			
		||||
@@ -220,10 +222,17 @@ int main() {
 | 
			
		||||
    //  490         "pra_price":"840"
 | 
			
		||||
    //>>491     }
 | 
			
		||||
 | 
			
		||||
    //for (int i = 1; i < 85; ++i) {
 | 
			
		||||
    //printf("{\n    \"\pra_payment_option_id\": 1049,\n    \"\pra_payment_unit_id\": %d,\n    \"pra_price\": %d\n},\n",
 | 
			
		||||
    //       i, i*10);
 | 
			
		||||
    // {
 | 
			
		||||
    //      "pun_duration": 0,
 | 
			
		||||
    //      "pun_id": 0,
 | 
			
		||||
    //      "pun_label": "0 min"
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    //for (int i = 0; i <= 140; ++i) {
 | 
			
		||||
    //printf("{\n    \"\pun_duration\": %d,\n    \"\pun_id\": %d,\n    \"pun_label\": \"%d min\"\n},\n",
 | 
			
		||||
    //       i*6, i, i*6);
 | 
			
		||||
    //}
 | 
			
		||||
 | 
			
		||||
    //return 0;
 | 
			
		||||
#if 0
 | 
			
		||||
    MessageHelper msgHelp;
 | 
			
		||||
@@ -1386,6 +1395,29 @@ int main() {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#if NEUHAUSER_FORCHACH==1
 | 
			
		||||
    std::ifstream input;
 | 
			
		||||
    input.open("/opt/ptu5/opt/customer_749/etc/psa_tariff/tariff01.json");
 | 
			
		||||
 | 
			
		||||
    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) {
 | 
			
		||||
        compute_product_price(&cfg, PermitType(PERMIT_TYPE::DAY_TICKET_PKW));
 | 
			
		||||
        compute_product_price(&cfg, PermitType(PERMIT_TYPE::DAY_TICKET_CAMPER));
 | 
			
		||||
 | 
			
		||||
        QDateTime start = QDateTime::currentDateTime();
 | 
			
		||||
        QDateTime ticketEndTime;
 | 
			
		||||
        compute_duration_for_daily_ticket(&cfg, start, ticketEndTime, PermitType(PERMIT_TYPE::DAY_TICKET));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#if BAD_NEUENAHR_AHRWEILER==1
 | 
			
		||||
    std::ifstream input;
 | 
			
		||||
@@ -2649,7 +2681,7 @@ int main() {
 | 
			
		||||
        int Up = 1;
 | 
			
		||||
        //compute_next_timestep(&cfg, )
 | 
			
		||||
 | 
			
		||||
        QDateTime const start = QDateTime::currentDateTime();
 | 
			
		||||
        QDateTime const start = QDateTime::fromString("2024-10-13T12:00:00");
 | 
			
		||||
        int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
 | 
			
		||||
 | 
			
		||||
        if (paymentOptionIndex < 0) {
 | 
			
		||||
@@ -2661,7 +2693,7 @@ int main() {
 | 
			
		||||
        QSet<uint32_t> const prices{700, 1400, 2100, 2800, 3500, 4200, 4900};
 | 
			
		||||
 | 
			
		||||
        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, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
			
		||||
            qCritical() << "nextTimeStep" << nextTimeStep;
 | 
			
		||||
 | 
			
		||||
            uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
 | 
			
		||||
@@ -2761,6 +2793,66 @@ int main() {
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if STADT_WEIDEN==1
 | 
			
		||||
    std::ifstream input("/opt/ptu5/opt/customer_6/etc/psa_tariff/tariff01.json");
 | 
			
		||||
    int pop_max_time;
 | 
			
		||||
 | 
			
		||||
    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) {
 | 
			
		||||
        qCritical() << __func__ << ":" << __LINE__ << "parsed";
 | 
			
		||||
 | 
			
		||||
        QDateTime s(QDate(2024, 10, 14), QTime());
 | 
			
		||||
        QDateTime end;
 | 
			
		||||
 | 
			
		||||
        static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
			
		||||
        qCritical() << "TimeSteps" << timeSteps;
 | 
			
		||||
 | 
			
		||||
        int offset = 1150;
 | 
			
		||||
        QDateTime start = s.addSecs(offset * 60);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        CalcState cs;
 | 
			
		||||
#if 0
 | 
			
		||||
        struct price_t costs;
 | 
			
		||||
        for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
			
		||||
            QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
			
		||||
 | 
			
		||||
            // if (i != 2) continue;
 | 
			
		||||
 | 
			
		||||
            cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
			
		||||
            int price1 = costs.netto;
 | 
			
		||||
 | 
			
		||||
            qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
 | 
			
		||||
                        << timeSteps.at(i) << "ZZZZZZZZZZZZZ PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
 | 
			
		||||
        }
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
        double cost = 220;
 | 
			
		||||
        qCritical() << "XXXXXXXX START" << start.toString(Qt::ISODate) << "cost" << cost;
 | 
			
		||||
 | 
			
		||||
        cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
 | 
			
		||||
                                                 PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
			
		||||
            qCritical() << __LINE__ << cs.toString()
 | 
			
		||||
                        << "START" << start.toString(Qt::ISODate)
 | 
			
		||||
                        << "<duration" << start.secsTo(end) / 60
 | 
			
		||||
                        << "cost" << cost
 | 
			
		||||
                        << "> end" << end.toString(Qt::ISODate);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#endif // STADT WEIDEN
 | 
			
		||||
 | 
			
		||||
#if NEUHAUSER_KORNEUBURG==1
 | 
			
		||||
    std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
 | 
			
		||||
    int pop_max_time;
 | 
			
		||||
@@ -2780,24 +2872,62 @@ int main() {
 | 
			
		||||
            bool nextDay = false;
 | 
			
		||||
            bool prePaid = true;
 | 
			
		||||
            // zone 1 (lila)
 | 
			
		||||
            QDateTime s(QDate(2023, 11, 30), QTime());
 | 
			
		||||
            QDateTime s(QDate(2024, 10, 8), QTime());
 | 
			
		||||
            QDateTime end;
 | 
			
		||||
 | 
			
		||||
            static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
			
		||||
            qCritical() << "TimeSteps" << timeSteps;
 | 
			
		||||
 | 
			
		||||
            for (int duration = 30; duration <= pop_max_time; duration += 5) {
 | 
			
		||||
                for (int offset = 420; offset < 1140; ++offset) {
 | 
			
		||||
                    if (offset > 720 && offset < 840) {
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                int offset = 600;
 | 
			
		||||
                //for (int offset = 720; offset < 601; ++offset) {
 | 
			
		||||
                    //if (offset > 720 && offset < 840) {
 | 
			
		||||
                    //    continue;
 | 
			
		||||
                    //}
 | 
			
		||||
                    QDateTime start = s.addSecs(offset * 60);
 | 
			
		||||
                    //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                    double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
			
		||||
                    CalcState cs;
 | 
			
		||||
#if 1
 | 
			
		||||
                    struct price_t costs;
 | 
			
		||||
                    for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
			
		||||
                        QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
			
		||||
 | 
			
		||||
                        // if (i != 2) continue;
 | 
			
		||||
 | 
			
		||||
                        cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
			
		||||
                        int price1 = costs.netto;
 | 
			
		||||
 | 
			
		||||
                        qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
 | 
			
		||||
                                    << timeSteps.at(i) << "ZZZZZZZZZZZZZ PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
 | 
			
		||||
                    }
 | 
			
		||||
                    exit(0);
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
                    double cost = 360;
 | 
			
		||||
                    qCritical() << "XXXXXXXX START" << start.toString(Qt::ISODate) << "cost" << cost;
 | 
			
		||||
                    QDateTime end;
 | 
			
		||||
 | 
			
		||||
                    cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
 | 
			
		||||
                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
			
		||||
                        qCritical() << __LINE__ << cs.toString()
 | 
			
		||||
                                    << "START" << start.toString(Qt::ISODate)
 | 
			
		||||
                                    << "<duration" << start.secsTo(end) / 60
 | 
			
		||||
                                    << "cost" << cost
 | 
			
		||||
                                    << "> end" << end.toString(Qt::ISODate);
 | 
			
		||||
                    //}
 | 
			
		||||
 | 
			
		||||
                    exit(0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                    //double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
			
		||||
                    //Q_ASSERT(cost == duration*2.5);
 | 
			
		||||
                    //qCritical() << "";
 | 
			
		||||
                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
			
		||||
                                << "end" << end.toString(Qt::ISODate)
 | 
			
		||||
                                << "duration" << duration
 | 
			
		||||
                                << "cost" << cost;
 | 
			
		||||
 | 
			
		||||
                    //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
			
		||||
                    //            << "end" << end.toString(Qt::ISODate)
 | 
			
		||||
                    //            << "duration" << duration
 | 
			
		||||
                    //            << "cost" << cost;
 | 
			
		||||
#if 0
 | 
			
		||||
                    switch(duration) {
 | 
			
		||||
                    case 30:
 | 
			
		||||
                        if (cost == 60.0) {
 | 
			
		||||
@@ -2961,15 +3091,17 @@ int main() {
 | 
			
		||||
                                    << "cost" << cost;
 | 
			
		||||
                        exit(-1);
 | 
			
		||||
                    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                    //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;
 | 
			
		||||
                }
 | 
			
		||||
                //}
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
            Configuration::SpecialDaysType specialDays = cfg.SpecialDays;
 | 
			
		||||
            for (Configuration::SpecialDaysType::const_iterator it = specialDays.cbegin();
 | 
			
		||||
                 it != specialDays.cend(); ++it) {
 | 
			
		||||
@@ -2990,7 +3122,7 @@ int main() {
 | 
			
		||||
                            << "duration" << duration
 | 
			
		||||
                            << "cost" << cost;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user