Compare commits
5 Commits
62c52fd580
...
5131892744
Author | SHA1 | Date | |
---|---|---|---|
5131892744 | |||
6d6615b81e | |||
eafbfd60c3 | |||
41fc924a7c | |||
cbcf8391b3 |
@ -36,10 +36,11 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
int paymentOptionIndex) {
|
||||
int minTime = 0;
|
||||
|
||||
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
||||
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
|
||||
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
@ -723,9 +724,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||
//Q_UNUSED(tlist);
|
||||
|
||||
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
|
||||
// netto_parking_time = minMin;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_price_for_parking_ticket() " << endl
|
||||
<< " paymentOptionIndex: " << paymentOptionIndex << endl
|
||||
@ -733,8 +739,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
<< " netto_parking_time: " << netto_parking_time << endl
|
||||
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
|
||||
<< " minMin: " << minMin << endl
|
||||
<< " maxMin: " << maxMin
|
||||
<< " prepaid: " << prepaid
|
||||
<< " maxMin: " << maxMin << endl
|
||||
<< " prepaid: " << prepaid << endl
|
||||
<< " permitType: " << permitType.toString();
|
||||
|
||||
if (netto_parking_time < 0) {
|
||||
@ -743,14 +749,17 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
start_parking_time.toString(Qt::ISODate)));
|
||||
return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
|
||||
}
|
||||
|
||||
if (netto_parking_time > maxMin) {
|
||||
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
|
||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||
}
|
||||
|
||||
if (netto_parking_time < minMin) {
|
||||
calcState.setDesc(QString("duration=%1, minMin=%2").arg(netto_parking_time).arg(minMin));
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_TIME);
|
||||
}
|
||||
|
||||
if (netto_parking_time == 0) {
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
@ -768,15 +777,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
return calcState;
|
||||
}
|
||||
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
Q_UNUSED(tlist);
|
||||
|
||||
// compute cost (price)
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
|
||||
|
||||
int weekDay = start_parking_time.date().dayOfWeek();
|
||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
||||
|
||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||
if (yperiod.has_value()) {
|
||||
@ -805,13 +811,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
} else
|
||||
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
||||
effectiveStartTime.setTime(p.static_start);
|
||||
effectiveStartTime == effectiveStartTime.addSecs(carryOverDuration * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle carry over
|
||||
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
||||
if (netto_parking_time > minutesUntilCarryOver) {
|
||||
if (netto_parking_time >= minutesUntilCarryOver) {
|
||||
int const rest = netto_parking_time - minutesUntilCarryOver;
|
||||
QDateTime s(effectiveStartTime);
|
||||
s = s.addSecs(minutesUntilCarryOver * 60);
|
||||
|
@ -339,8 +339,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||
#endif
|
||||
//qCritical() << __func__ << __LINE__;
|
||||
|
||||
// inputDate is now located in a valid operational-working-range
|
||||
// find this working-time-range
|
||||
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
|
||||
@ -354,8 +352,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
return "";
|
||||
}
|
||||
|
||||
//qCritical() << __func__ << __LINE__;
|
||||
|
||||
QTime current_working_time_from;
|
||||
QTime current_working_time_to;
|
||||
|
||||
@ -1013,12 +1009,14 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
|
||||
int paymentOptionIndex) const {
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
// qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
|
||||
if (paymentMethodId == PaymentMethod::Steps ||
|
||||
paymentMethodId == PaymentMethod::Degressive) {
|
||||
int const timeStepInMinutes = start.secsTo(end) / 60;
|
||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, start);
|
||||
qCritical() << DBG_HEADER << " start" << start.toString(Qt::ISODate);
|
||||
qCritical() << DBG_HEADER << " end" << end.toString(Qt::ISODate);
|
||||
qCritical() << DBG_HEADER << "timeStepList" << timeStepInMinutes << tlist;
|
||||
qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
|
||||
|
||||
@ -2527,10 +2525,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
//if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
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();
|
||||
|
||||
@ -2554,7 +2552,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation end:" << interpolationEnd.toString(Qt::ISODate);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
}
|
||||
|
||||
// int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||
@ -2582,7 +2580,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||
// int const price = itr->second.pra_price;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
@ -2606,7 +2604,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
ATBInterpolation interpolation = ipolCheck.value();
|
||||
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_PRICE) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_intnerpolation_id:" << duration.pun_interpolation_id;
|
||||
|
||||
interpolation.dynamic_start = start.time();
|
||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||
@ -2661,6 +2660,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
//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;
|
||||
@ -2673,6 +2673,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_min_time" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2749,7 +2750,6 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
||||
cfg->Duration.erase(search);
|
||||
}
|
||||
}
|
||||
@ -2783,7 +2783,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||
@ -2816,9 +2816,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
uint32_t price = 0;
|
||||
int pun_duration = 0;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_accumulate_prices" << pop_accumulate_prices;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_accumulate_durations" << pop_accumulate_durations;
|
||||
}
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
@ -2843,6 +2847,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
||||
|
@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
|
||||
#define NEUHAUSER_STOCKERAU (0)
|
||||
#define KLEIPEDA_LITAUEN (0)
|
||||
#define SEXTEN (0)
|
||||
#define SCHNALS_LEITER_KIRCHL (0)
|
||||
#define SCHNALS_LEITER_KIRCHL (1)
|
||||
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||
#define VALSER_ALM (1)
|
||||
#define VALSER_ALM (0)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@ -575,8 +575,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_505/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());
|
||||
@ -588,10 +588,13 @@ int main() {
|
||||
cout << endl;
|
||||
|
||||
if (isParsed) {
|
||||
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);
|
||||
//PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||
PermitType permitType(PERMIT_TYPE::DAY_TICKET_PKW);
|
||||
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, permitType);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, permitType);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, permitType);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, permitType);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time: " << pop_min_time;
|
||||
@ -649,10 +652,10 @@ int main() {
|
||||
}
|
||||
|
||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||
for (int minutes = 1020; minutes <= 1020; minutes += 1) {
|
||||
for (int minutes = 480; minutes <= 480; minutes += 1) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
QDateTime effectiveStart = start;
|
||||
|
||||
@ -669,8 +672,7 @@ int main() {
|
||||
}
|
||||
|
||||
#if 0
|
||||
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||
for (int i = 200; i <= 200; i += 10) {
|
||||
for (int i = 700; i <= 1400; i += 700) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
||||
@ -682,38 +684,20 @@ int main() {
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
// << "> end" << end.toString(Qt::ISODate);
|
||||
|
||||
}
|
||||
#else
|
||||
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, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) { // return value
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
// qCritical() << cs.toString();
|
||||
}
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||
<< "> end" << end.toString(Qt::ISODate);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
|
||||
start = QDateTime::currentDateTime();
|
||||
start.setTime(QTime(9, 57, 0));
|
||||
//start.setTime(QTime(9, 57, 0));
|
||||
|
||||
for (int i = 66; i <= 66; i += 6) {
|
||||
for (int netto_parking_time = 60; netto_parking_time <= 60; netto_parking_time += 60) {
|
||||
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, i, end, &price);
|
||||
cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true);
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
|
||||
<< "price" << price.netto;
|
||||
|
Loading…
Reference in New Issue
Block a user