Compare commits

...

4 Commits

4 changed files with 38 additions and 12 deletions

View File

@ -9,6 +9,7 @@ public:
: pun_id(0)
, pun_label("")
, pun_duration(0)
, pun_duration_saved(0)
, pun_duration_min(0)
, pun_duration_max(0)
, pun_interpolation_id(-1) {
@ -21,6 +22,7 @@ public:
<< " pun_id: " << td.pun_id << "\n"
<< " pun_label: " << QString::fromStdString(td.pun_label) << "\n"
<< " pun_duration: " << td.pun_duration << "\n"
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
<< " pun_duration_min: " << td.pun_duration_min << "\n"
<< " pun_duration_max: " << td.pun_duration_max << "\n"
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
@ -31,6 +33,7 @@ public:
int pun_id;
std::string pun_label;
int pun_duration;
int pun_duration_saved;
int pun_duration_min;
int pun_duration_max;
int pun_interpolation_id;

View File

@ -410,13 +410,15 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
maxStep = stepList[1] - stepList[0];
}
int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
if (std::abs(stepList[0] - currentTimeMinutes) <= tolerance) {
for (int i=0; i < stepList.size(); ++i) {
if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) {
qCritical().noquote()
<< QString(" compute_next_timestep() correction stepList[0]=%1 -> %2:")
.arg(stepList[0]).arg(currentTimeMinutes);
stepList[0] = currentTimeMinutes;
<< QString(" compute_next_timestep() correction stepList[%1]=%2 -> %3:")
.arg(i).arg(stepList[0]).arg(currentTimeMinutes);
stepList[i] = currentTimeMinutes;
qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList;
}
}
int currentStepIndex = stepList.indexOf(currentTimeMinutes);

View File

@ -2123,9 +2123,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
if (m_timeSteps.size() > paymentOptionIndex) {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
return m_timeSteps[paymentOptionIndex];
}
//if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
// return m_timeSteps[paymentOptionIndex];
//}
// recompute time steps
m_timeSteps[paymentOptionIndex].clear();
} else {
m_timeSteps.push_back(QList<int>());
}
@ -2252,6 +2257,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
}
// TODO: check if needed
QDateTime interpolationEnd;
std::optional<QDateTime> interpolationEndDate = cfg->getInterpolationEnd(start, paymentOptionIndex);
if (interpolationEndDate) {
@ -2269,6 +2275,18 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
// TODO: auslagern
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = duration.pun_duration_saved;
search->second = duration;
}
}
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
// int const price = itr->second.pra_price;
@ -2324,7 +2342,6 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
int rest = nextTimeStep.secsTo(interpolationEnd);
if (nextTimeStep <= interpolationEnd) {
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) {
@ -2426,6 +2443,8 @@ 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;

View File

@ -691,8 +691,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
case MemberType::DurationType:
if (strcmp(inner_obj_name, "pun_id") == 0) Duration.pun_id = k->value.GetInt();
else if (strcmp(inner_obj_name, "pun_label") == 0) Duration.pun_label = k->value.GetString();
else if (strcmp(inner_obj_name, "pun_duration") == 0) Duration.pun_duration = k->value.GetDouble();
else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
else if (strcmp(inner_obj_name, "pun_duration") == 0) {
Duration.pun_duration = k->value.GetDouble();
Duration.pun_duration_saved = Duration.pun_duration;
} else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
break;