Compare commits
7 Commits
3503306637
...
40440e28d3
Author | SHA1 | Date | |
---|---|---|---|
40440e28d3 | |||
ba8e2786fc | |||
b5804408f4 | |||
f7be0e471a | |||
45694106a7 | |||
6d125c65fe | |||
1c86e1ac40 |
@ -91,8 +91,10 @@ public:
|
||||
// helper function to find time steps for a tariff with PaymentMethod::Steps
|
||||
// (e.g. Schoenau/Koenigsee)
|
||||
//
|
||||
QList<int> &GetTimeSteps(Configuration *cfg, int paymentOptionIndex=0) const;
|
||||
QList<int> GetSteps(Configuration *cfg, int paymentOptionIndex=0) const { return GetTimeSteps(cfg, paymentOptionIndex); }
|
||||
QList<int> &GetTimeSteps(Configuration *cfg, int paymentOptionIndex=0, QDateTime const &start = QDateTime::currentDateTime()) const;
|
||||
QList<int> GetSteps(Configuration *cfg, int paymentOptionIndex=0, QDateTime const &start = QDateTime::currentDateTime()) const {
|
||||
return GetTimeSteps(cfg, paymentOptionIndex, start);
|
||||
}
|
||||
|
||||
QList<int> GetPriceSteps(Configuration *cfg) const;
|
||||
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
pop_carry_over_option_id = -1;
|
||||
pop_prepaid_option_id = -1;
|
||||
pop_truncate_last_interpolation_step = false;
|
||||
pop_accumulate_prices = false;
|
||||
pop_accumulate_durations = false;
|
||||
pop_carry_over_target = false;
|
||||
pop_carry_over_time_range_id = -1;
|
||||
pop_carry_over_start_time_range = -1;
|
||||
@ -57,6 +59,8 @@ public:
|
||||
int pop_daily_card_price;
|
||||
uint64_t pop_business_hours;
|
||||
int pop_time_step_config;
|
||||
bool pop_accumulate_prices;
|
||||
bool pop_accumulate_durations;
|
||||
|
||||
struct ATBMaxDateTime {
|
||||
int direction;
|
||||
|
@ -127,8 +127,13 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
// Get input date
|
||||
QDateTime inputDate = QDateTime::fromString(startDatetimePassed,Qt::ISODate);
|
||||
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
//qCritical() << DBG_HEADER << " start" << inputDate.toString(Qt::ISODate);
|
||||
//qCritical() << DBG_HEADER << "paymentMethodId" << static_cast<int>(paymentMethodId);
|
||||
|
||||
Calculator::GetInstance().GetTimeSteps(cfg, 0, inputDate);
|
||||
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (tariffIs24_7(cfg)) {
|
||||
// use tariff with structure as for instance Schoenau, Koenigsee:
|
||||
@ -171,7 +176,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
// in this case, adapt inputDate accordingly.
|
||||
|
||||
|
||||
//#define DEBUG_GET_DURATION_FROM_COST 1
|
||||
// #define DEBUG_GET_DURATION_FROM_COST 1
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||
#endif
|
||||
@ -262,24 +267,41 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
|
||||
#endif
|
||||
|
||||
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
int price = 0;
|
||||
int durationInSecs = 0;
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const pra_price = itr->second.pra_price;
|
||||
if ((double)pra_price == cost) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
// found now the duration in minutes
|
||||
// check if we are still inside the working-time-range
|
||||
ATBDuration duration = search->second;
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
if (pop_accumulate_prices) {
|
||||
price += pra_price;
|
||||
} else {
|
||||
price = pra_price;
|
||||
}
|
||||
|
||||
int durationInSecs = duration.pun_duration * 60;
|
||||
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
// found now the duration in minutes
|
||||
// check if we are still inside the working-time-range
|
||||
ATBDuration duration = search->second;
|
||||
//if (pop_accumulate_durations) {
|
||||
// durationInSecs += duration.pun_duration * 60;
|
||||
//} else {
|
||||
durationInSecs = duration.pun_duration * 60;
|
||||
//}
|
||||
|
||||
if ((double)price == cost) {
|
||||
QDateTime current_working_date_time_to = inputDate;
|
||||
current_working_date_time_to.setTime(current_working_time_to);
|
||||
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
|
||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
|
||||
qCritical() << DBG_HEADER << " DURATION ID" << duration.pun_id;
|
||||
qCritical() << DBG_HEADER << "DURATION IN MINUTES" << durationInSecs / 60;
|
||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << durationInSecs;
|
||||
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
||||
<< current_working_date_time_to.toString(Qt::ISODate);
|
||||
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
|
||||
@ -363,7 +385,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
#endif
|
||||
|
||||
return s.toStdString();
|
||||
}
|
||||
} // if ((double)price == cost) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -2094,8 +2116,11 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
||||
|
||||
#define DEBUG_GET_TIME_STEPS (1)
|
||||
|
||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
QDateTime const &s) const {
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
}
|
||||
|
||||
if (m_timeSteps.size() > paymentOptionIndex) {
|
||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||
@ -2105,9 +2130,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
m_timeSteps.push_back(QList<int>());
|
||||
}
|
||||
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
//start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
|
||||
start.setTime(QTime(7, start.time().minute(), 0));
|
||||
QDateTime start = s;
|
||||
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||
@ -2117,9 +2141,13 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
||||
}
|
||||
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||
@ -2133,25 +2161,34 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
} else {
|
||||
uint16_t timeStepCompensation = 0;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
||||
}
|
||||
|
||||
if (pop_carry_over) {
|
||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
||||
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range id:" << pop_carry_over_time_range_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over option id:" << pop_carry_over_time_range_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range id:" << pop_carry_over_time_range_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over option id:" << pop_carry_over_time_range_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
int weekDay = start.date().dayOfWeek();
|
||||
QTime const carryOverStart = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||
QTime const carryOverEnd = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
|
||||
int const carryOverDuration = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over end:" << carryOverEnd.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over end:" << carryOverEnd.toString(Qt::ISODate);
|
||||
// TODO: reparieren
|
||||
|
||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||
@ -2197,8 +2234,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
}
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
|
||||
@ -2206,7 +2245,9 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
|
||||
if (prepaidStart) {
|
||||
start = prepaidStart.value();
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
}
|
||||
@ -2215,13 +2256,18 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
std::optional<QDateTime> interpolationEndDate = cfg->getInterpolationEnd(start, paymentOptionIndex);
|
||||
if (interpolationEndDate) {
|
||||
interpolationEnd = interpolationEndDate.value();
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
}
|
||||
|
||||
int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||
// int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||
QDateTime nextTimeStep = start;
|
||||
int runtimeInMinutes = 0;
|
||||
|
||||
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
@ -2230,6 +2276,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
ATBDuration duration = search->second;
|
||||
ATBDuration &previous = search->second;
|
||||
|
||||
if (duration.pun_interpolation_id == -1) {
|
||||
|
||||
@ -2249,118 +2296,102 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
interpolation.dynamic_start = start.time();
|
||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||
|
||||
int const end_time = interpolation.dynamic_end.hour() * 60 + interpolation.dynamic_end.minute();
|
||||
// int const end_time = interpolation.dynamic_end.hour() * 60 + interpolation.dynamic_end.minute();
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolationEnd.toString(Qt::ISODate);
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
||||
|
||||
QDateTime carryOver = start;
|
||||
carryOver.setTime(interpolation.dynamic_end);
|
||||
|
||||
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
|
||||
nextTimeStep = nextTimeStep.addSecs(duration.pun_duration * 60);
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
||||
runtimeInMinutes -= backTime;
|
||||
nextTimeStep.setTime(carryOverStart);
|
||||
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
|
||||
runtimeInMinutes += (backTime + carryOverDuration);
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||
}
|
||||
|
||||
// int nextTimeStep = start_time + duration.pun_duration;
|
||||
//int rest = end_time - nextTimeStep;
|
||||
int rest = nextTimeStep.secsTo(interpolationEnd);
|
||||
if (nextTimeStep <= interpolationEnd) {
|
||||
|
||||
if (durationId == 1) {
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
||||
#endif
|
||||
|
||||
int const timeStep = start.secsTo(nextTimeStep) / 60;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step:" << timeStep;
|
||||
|
||||
//if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
||||
// .arg(timeStep).arg(duration.pun_duration_min)
|
||||
// .arg(timeStep).arg(duration.pun_duration_max);
|
||||
// break;
|
||||
if (rest > 0 && rest < duration.pun_duration) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO TODO:" << rest;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") rest minutes:" << rest;
|
||||
// last time step before switching to dayticket (see Schnals 505/506)
|
||||
//if (duration.pun_duration > 0) {
|
||||
// m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
//}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
|
||||
// set dynamic minimal parking time
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
|
||||
duration.pun_duration = timeStep;
|
||||
timeStepCompensation = start.secsTo(interpolationEnd) / 60;
|
||||
|
||||
if (duration.pun_duration > 0) {
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
}
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
// timeStepComp: added to (otherwise static) time-steps
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration_max:" << duration.pun_duration_max;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
||||
#endif
|
||||
} else {
|
||||
// duration.pun_duration = nextTimeStep;
|
||||
|
||||
// HIER WEITER
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
QTime nextTime(0, 0, 0);
|
||||
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
||||
#endif
|
||||
|
||||
if (duration.pun_duration > 0) {
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
if (rest > 0) {
|
||||
// last time step before swicthing to dayticket (see Schnals 505/506)
|
||||
duration.pun_duration = duration.pun_duration_max;
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
QTime nextTime(0, 0, 0);
|
||||
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
#endif
|
||||
|
||||
if (duration.pun_duration > 0) {
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
cfg->Duration.erase(search);
|
||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
|
||||
search->second = duration;
|
||||
} else
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration_max:" << duration.pun_duration_max;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
||||
#endif
|
||||
QDateTime s = start.addSecs(runtimeInMinutes * 60);
|
||||
int const minutes = s.time().secsTo(carryOverStart) / 60;
|
||||
|
||||
duration.pun_duration += start_time + timeStepCompensation;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes:" << minutes;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") s:" << s.toString(Qt::ISODate);
|
||||
|
||||
if (minutes > 0) {
|
||||
runtimeInMinutes += minutes;
|
||||
previous.pun_duration += minutes;
|
||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
||||
m_timeSteps[paymentOptionIndex].last() += minutes;
|
||||
}
|
||||
}
|
||||
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (0):" << runtimeInMinutes;
|
||||
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||
|
||||
// TOOO: truncate-flag == false
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time());
|
||||
runtimeInMinutes -= backTime;
|
||||
nextTimeStep.setTime(carryOverStart);
|
||||
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
|
||||
runtimeInMinutes += (backTime + carryOverDuration);
|
||||
} else
|
||||
if (nextTimeStep.time() < carryOverStart) {
|
||||
int const forwardTime = nextTimeStep.time().secsTo(carryOverStart) / 60;
|
||||
runtimeInMinutes += forwardTime;
|
||||
nextTimeStep.setTime(carryOverStart);
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||
}
|
||||
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
|
||||
cfg->Duration.erase(search);
|
||||
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||
search->second = duration;
|
||||
} else {
|
||||
cfg->Duration.erase(search);
|
||||
}
|
||||
@ -2395,18 +2426,19 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
|
||||
#if DEBUG_GET_TIME_STEPS==1
|
||||
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||
QDateTime nextTime = start;
|
||||
nextTime.setTime(QTime(0, 0, 0));
|
||||
nextTime = nextTime.addSecs(m_timeSteps[paymentOptionIndex][i] * 60);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
||||
<< i << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
||||
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||
QDateTime nextTime = s;
|
||||
// nextTime.setTime(QTime(0, 0, 0));
|
||||
int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
|
||||
nextTime = nextTime.addSecs(secs);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
||||
<< i << secs << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_timeSteps[paymentOptionIndex];
|
||||
}
|
||||
|
@ -602,6 +602,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
|
||||
this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
|
||||
} else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
|
||||
this->currentPaymentOptions.last().pop_accumulate_prices = k->value.GetBool();
|
||||
} else if (strcmp(inner_obj_name, "pop_accumulate_durations") == 0) {
|
||||
this->currentPaymentOptions.last().pop_accumulate_durations = k->value.GetBool();
|
||||
} else if (strcmp(inner_obj_name, "pop_carry_over_option_id") == 0) {
|
||||
this->currentPaymentOptions.last().pop_carry_over_option_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_carry_over") == 0) {
|
||||
@ -834,6 +838,7 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
|
||||
std::optional<QDateTime> value = std::nullopt;
|
||||
|
||||
QDateTime interpolationEndTime = start;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed interpol end:" << interpolationEndTime.toString(Qt::ISODate);
|
||||
|
||||
int price = 0;
|
||||
|
||||
@ -918,8 +923,8 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") price:" << price;
|
||||
|
||||
if (price >= interpolation.dynamic_until_price) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price:" << price;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed interpol endr:" << interpolationEndTime.toString(Qt::ISODate);
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") price:" << price;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed interpol end:" << interpolationEndTime.toString(Qt::ISODate);
|
||||
value = value.value_or(interpolationEndTime);
|
||||
break;
|
||||
}
|
||||
|
@ -643,8 +643,8 @@ int main() {
|
||||
int pop_max_price;
|
||||
int pop_daily_card_price;
|
||||
|
||||
input.open("/home/linux/customer_505/etc/psa_tariff/tariff01.json");
|
||||
//input.open("/opt/ptu5/opt/customer_506/etc/psa_tariff/tariff01.json");
|
||||
//input.open("/home/linux/customer_505/etc/psa_tariff/tariff01.json");
|
||||
input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
||||
|
||||
std::stringstream sstr;
|
||||
while(input >> sstr.rdbuf());
|
||||
@ -675,10 +675,12 @@ int main() {
|
||||
//}
|
||||
//return 0;
|
||||
|
||||
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << "TimeSteps" << timeSteps;
|
||||
//QDateTime start = QDateTime::currentDateTime();
|
||||
//start.setTime(QTime(18, 0, 0));
|
||||
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
||||
//qCritical() << "TimeSteps" << timeSteps;
|
||||
|
||||
return 0;
|
||||
//return 0;
|
||||
|
||||
CalcState cs;
|
||||
double cost;
|
||||
@ -687,7 +689,7 @@ int main() {
|
||||
|
||||
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
|
||||
for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
|
||||
QDateTime s(QDate(2024, 7, 14 + day), QTime());
|
||||
QDateTime s(QDate(2024, 7, 21 + day), QTime(0, 0, 0));
|
||||
QDateTime end;
|
||||
|
||||
switch (day) {
|
||||
@ -715,66 +717,30 @@ int main() {
|
||||
}
|
||||
|
||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
for (int minutes = 480; minutes < 480; minutes += 1) {
|
||||
for (int minutes = 420; minutes <= 420; minutes += 1) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
QDateTime effectiveStart = start;
|
||||
|
||||
// hier sollte man auch testen was passiert, falls man ausserhalb
|
||||
// der verkaufsdaten steht
|
||||
if (start.time() < QTime(8, 0, 0)) {
|
||||
effectiveStart.setTime(QTime(8, 0, 0));
|
||||
if (start.time() < QTime(7, 0, 0)) {
|
||||
effectiveStart.setTime(QTime(7, 0, 0));
|
||||
} else
|
||||
if (start.time() <= QTime(19, 0, 0)) {
|
||||
if (start.time() <= QTime(20, 0, 0)) {
|
||||
effectiveStart = start;
|
||||
} else {
|
||||
effectiveStart = start.addDays(1);
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
effectiveStart.setTime(QTime(7, 0, 0)); // next day
|
||||
}
|
||||
|
||||
for (int i = 10; i <= 10; i += 10) {
|
||||
for (int i = 700; i <= 1400; i += 700) {
|
||||
//for (int i = 2100; i <= 2100; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
durationInMinutes += (i/10) * 4;
|
||||
}
|
||||
offsetInMinutes = 0;
|
||||
|
||||
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
|
||||
if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
|
||||
offsetInMinutes = 780; // 19:00 -> 8:00
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
i += 20;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||
|
||||
if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
|
||||
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << "| cost ............................." << cost;
|
||||
qCritical() << "| durationInMinutes ................" << durationInMinutes
|
||||
<< "(" << (durationInMinutes - 60) << "+ 60 )";
|
||||
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
@ -783,17 +749,16 @@ int main() {
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
|
||||
#if 0
|
||||
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||
qCritical() << __LINE__ << "cost ............................." << cost;
|
||||
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
|
||||
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
}
|
||||
for (int i = 60; i <= 60; i += 6) {
|
||||
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, 60, end, &price);
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user