Minor: Add some (commented-out) debug messages.

This commit is contained in:
Gerhard Hoffmann 2024-06-04 11:18:00 +02:00
parent 2d53224feb
commit 02f0500eac

View File

@ -628,12 +628,19 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) {
uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
if (cfg->isDayIncluded(businessHours, start)) {
if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
QTime(0, 0, 0), QTime(23, 59, 59));
}
int const weekdayId = start.date().dayOfWeek();
// qCritical() << DBG_HEADER
// << "weekdayId" << weekdayId
// << "count" << cfg->WeekDaysWorktime.count(weekdayId);
if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
@ -670,9 +677,14 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
}
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
// qCritical() << DBG_HEADER
// << "paymentOptionIndex" << paymentOptionIndex
// << "pop_carry_over" << pop_carry_over;
if (pop_carry_over == 1) {
qCritical() << DBG_HEADER
<< "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
// qCritical() << DBG_HEADER
// << "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range;
int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range;
@ -683,15 +695,29 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second;
ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second;
// qCritical() << DBG_HEADER
// << "startTime" << startTime.toString(Qt::ISODate);
if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) {
QDateTime sd = start;
sd.setTime(s.getTimeUntil());
// qCritical() << DBG_HEADER << "jumpFrom" << sd.toString(Qt::ISODate);
QDateTime ed = start.addDays(1);
ed.setTime(e.getTimeFrom());
// qCritical() << DBG_HEADER << "to" << ed.toString(Qt::ISODate);
int const jumpSecs = sd.secsTo(ed);
// qCritical() << DBG_HEADER << "jumpSecs" << jumpSecs;
QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs);
// qCritical() << DBG_HEADER << "new end" << end.toString(Qt::ISODate);
if (end.time() <= e.getTimeUntil()) {
qCritical() << DBG_HEADER
@ -701,13 +727,13 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
startTime, end.time());
} else {
errorStr = QString("endTime %1 exceeds [%2, %3))")
errorStr = QString("endTime %1 outside [%2, %3))")
.arg(end.toString(Qt::ISODate))
.arg(sd.toString(Qt::ISODate))
.arg(ed.toString(Qt::ISODate));
}
} else {
errorStr = QString("startTime %1 exceeds [%2, %3))")
errorStr = QString("startTime %1 outside [%2, %3))")
.arg(startTime.toString(Qt::ISODate))
.arg(s.getTimeFrom().toString(Qt::ISODate))
.arg(s.getTimeUntil().toString(Qt::ISODate));
@ -730,6 +756,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
}
}
qCritical() << DBG_HEADER << "errorStr" << errorStr;
return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr,
QTime(), QTime());
}