Minor: removed debug output

This commit is contained in:
Gerhard Hoffmann 2024-07-29 11:30:00 +02:00
parent 4f2c33cdc2
commit 9f4affca5a

View File

@ -155,8 +155,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
}
// TODO: man braucht den richtigen Index
int paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
@ -174,10 +174,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
// int const pop_pre_paid = 1;
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
if (prepaid) {
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
// no limits on pre-pay-option, i.e. pre-pay-ranges are exactly
// the complements of operational-ranges
@ -185,7 +185,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 0
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
#endif
@ -240,23 +240,22 @@ 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__;
//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();
qCritical() << __func__ << __LINE__ << pwd_period_day_in_week_id;
qCritical() << __func__ << __LINE__ << cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id);
//qCritical() << __func__ << __LINE__ << pwd_period_day_in_week_id;
//qCritical() << __func__ << __LINE__ << cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id);
if (cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id) == 0) {
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
qCritical() << __func__ << __LINE__;
return "";
}
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
QTime current_working_time_from;
QTime current_working_time_to;
@ -278,7 +277,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
qCritical() << DBG_HEADER
<< "ERROR" << inputDate.toString(Qt::ISODate)
<< "NOT IN VALID WORKING TIME-RANGE";
qCritical() << __func__ << __LINE__;
return "";
}
@ -287,8 +285,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
#endif
qCritical() << __func__ << __LINE__;
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;
@ -306,7 +302,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
price = pra_price;
}
qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
@ -318,44 +314,23 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
new_price += pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
if (new_price <= cost) {
duration_previous = durationUnit;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
} else {
found = true;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
QString s = inputDate.toString(Qt::ISODate);
QDateTime d(QDateTime::fromString(s, Qt::ISODate));
d = d.addSecs(duration_previous * 60);
qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
//qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
return d.toString(Qt::ISODate).toStdString();
}
}
//if (price < cost) {
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << duration;
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << duration.pun_duration;
// QString s = inputDate.toString(Qt::ISODate);
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << s;
// QDateTime d(QDateTime::fromString(s, Qt::ISODate));
// d = d.addSecs(duration.pun_duration * 60);
// qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
// return d.toString(Qt::ISODate).toStdString();
//
// }
//if (pop_accumulate_durations) {
// durationInSecs += duration.pun_duration * 60;
//} else {
durationInSecs = duration.pun_duration * 60;
// durationInSecs -= 720 * 60;
//}
if ((double)price == cost) {
qCritical() << DBG_HEADER;
QDateTime current_working_date_time_to = inputDate;
current_working_date_time_to.setTime(current_working_time_to);
@ -404,23 +379,23 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
}
qCritical() << DBG_HEADER << "DAYS" << days;
qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
//qCritical() << DBG_HEADER << "DAYS" << days;
//qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
//qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
QDateTime upper = inputDate.addDays(days);
upper.setTime(next_working_time_from);
qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
QDateTime lower = inputDate;
lower.setTime(current_working_time_to);
qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
// inputDate = inputDate.addSecs(lower.secsTo(upper));
qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
inputDate = inputDate.addSecs(durationInSecs);
#if DEBUG_GET_DURATION_FROM_COST==1
@ -451,21 +426,19 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
}
qCritical() << __func__ << __LINE__;
QString const &s = inputDate.toString(Qt::ISODate);
#if DEBUG_GET_DURATION_FROM_COST==1
qCritical() << DBG_HEADER << "TICKET-END" << s;
#endif
qCritical() << __func__ << __LINE__ << s;
return s.toStdString();
} // if ((double)price == cost) {
else {
qCritical() << DBG_HEADER;
//qCritical() << DBG_HEADER;
}
} else {
qCritical() << __func__ << __LINE__;
//qCritical() << __func__ << __LINE__;
}
}
@ -2254,8 +2227,6 @@ 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);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
@ -2527,12 +2498,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
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);
@ -2549,7 +2520,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
break;
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
if (ipolCheck) {
@ -2610,10 +2581,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
} else
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
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;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
//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;
if (paymentOptionIndex == 1) { // testing TODO: muss in die payment options hinein
if (runtimeInMinutes == 0) {
@ -2630,10 +2601,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
if (runtimeInMinutes == 0) {
if (start.time() < carryOverStart) {
runtimeInMinutes = start.time().secsTo(carryOverStart) / 60;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
duration.pun_duration = runtimeInMinutes;
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
search->second = duration;
@ -2641,8 +2612,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
continue;
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
QDateTime s = start.addSecs(runtimeInMinutes * 60);
int const minutes = s.time().secsTo(carryOverStart) / 60;
@ -2666,8 +2636,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
runtimeInMinutes += duration.pun_duration;
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
// TOOO: truncate-flag == false
if (nextTimeStep.time() > carryOverStart) {
@ -2676,23 +2646,23 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
nextTimeStep.setTime(carryOverStart);
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
runtimeInMinutes += (backTime + carryOverDuration);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
} else
if (nextTimeStep.time() < carryOverStart) {
int const forwardTime = nextTimeStep.time().secsTo(carryOverStart) / 60;
runtimeInMinutes += forwardTime;
nextTimeStep.setTime(carryOverStart);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
}
//if (DBG_LEVEL >= DBG_DEBUG) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
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;
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
@ -2764,8 +2734,8 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
uint32_t price = 0;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
{
@ -2774,13 +2744,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
Q_ASSERT(pun_id == payment_unit_id);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(1)->second.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(2)->second.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(3)->second.pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(1)->second.pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(2)->second.pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(3)->second.pun_duration;
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
//int const pun_duration = cfg->Duration.find(2)->second.pun_duration;
@ -2790,11 +2760,11 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
price = (uint32_t)(itr->second.pra_price);
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
if (timeStep == pun_duration) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
@ -2809,9 +2779,7 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
int const pop_id = cfg->getPaymentOptions().pop_id;
int const pop_accumulate_prices = cfg->getPaymentOptions().pop_accumulate_prices;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
int new_price = 0;
uint32_t duration = 0;
@ -2834,19 +2802,19 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
if (pop_accumulate_prices) {
new_price += pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
if (new_price <= price) {
duration_previous = durationUnit;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
return duration_previous;
}
}
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration" << duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration" << duration << "for price" << price;
return duration;
}