Merge branch 'fuchs-muehlbach' of git.mimbach49.de:GerhardHoffmann/MOBILISIS-Calculator into fuchs-muehlbach

This commit is contained in:
Siegfried Siegert 2024-08-19 12:41:02 +02:00
commit 96aad6b797
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
5 changed files with 279 additions and 156 deletions

View File

@ -1,6 +1,7 @@
#include <string>
#include <QDebug>
#include <QDateTime>
class ATBDuration
{
@ -16,7 +17,10 @@ public:
, pun_netto(false)
, pun_brutto(false)
, pun_fixed(false)
, pun_requires_change(false)
, pun_mutable(false)
, pun_round_to_next_24h_boundary(false)
, pun_round_to_prev_24h_boundary(false)
, pun_align_with_timepoint(QDateTime())
, pun_next_step_correction(0) {
}
@ -24,17 +28,20 @@ public:
QDebugStateSaver saver(debug);
debug.nospace()
<< " 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_netto: " << td.pun_netto << "\n"
<< " pun_brutto: " << td.pun_brutto << "\n"
<< " pun_fixed: " << td.pun_fixed << "\n"
<< " pun_requires_change: " << td.pun_requires_change << "\n"
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
<< " 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"
<< " pun_netto: " << td.pun_netto << "\n"
<< " pun_brutto: " << td.pun_brutto << "\n"
<< " pun_fixed: " << td.pun_fixed << "\n"
<< " pun_mutable: " << td.pun_mutable << "\n"
<< "pun_round_to_next_24h_boundary: " << td.pun_round_to_next_24h_boundary << "\n"
<< "pun_round_to_prev_24h_boundary: " << td.pun_round_to_prev_24h_boundary << "\n"
<< " pun_align_with_timepoint: " << td.pun_align_with_timepoint << endl;
return debug;
}
@ -49,6 +56,9 @@ public:
bool pun_netto; // the timestep expressed by this duration is a netto timestep
bool pun_brutto; // the timestep expressed by this duration is a brutto timestep
bool pun_fixed; // the value given in tariff-file is fixed (constant)
bool pun_requires_change; // the value has to be changes (controlled by other parameters)
bool pun_mutable; // the value could change
bool pun_round_to_next_24h_boundary;
bool pun_round_to_prev_24h_boundary;
QDateTime pun_align_with_timepoint;
int pun_next_step_correction;
};

View File

@ -923,12 +923,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
bool const nextDay = false;
// DEBUG
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "compute_duration_for_parking_ticket(2): ";
qCritical() << " payment option index: " << paymentOptionIndex;
qCritical() << " prepaid: " << prepaid;
qCritical() << " price: " << price;
}
// if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "\ncompute_duration_for_parking_ticket(2):";
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
qCritical() << " payment option index:" << paymentOptionIndex;
qCritical() << " prepaid:" << prepaid;
qCritical() << " price:" << price;
qCritical() << " permit type:" << permitType.toString() << endl;
// }
if (start_parking_time.isValid()) {
QString cs = start_parking_time.toString(Qt::ISODate);
@ -1009,9 +1012,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
}
// DEBUG
qCritical() << "compute_duration_for_parking_ticket(): ";
qCritical() << " endTime: " << endTime;
qCritical() << " ticketEndTime: " << ticketEndTime;
qCritical() << "\ncompute_duration_for_parking_ticket():";
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
qCritical() << " endTime:" << endTime;
qCritical() << " ticketEndTime:" << ticketEndTime.toString(Qt::ISODate) << endl;
}
} else {
return calcState.set(CalcState::State::INVALID_START_DATE);

View File

@ -10,9 +10,12 @@
#include <sstream>
#include <algorithm>
#include <optional>
#include <iterator>
#include <QDateTime>
#include <QScopedArrayPointer>
#include <QDebug>
#include <QTimeZone>
double total_duration_min = 0.0f;
double total_cost = 0.0f;
@ -175,6 +178,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const pra_price = itr->second.pra_price;
// qCritical() << DBG_HEADER << "pra_price" << pra_price;
int const durationId = itr->second.pra_payment_unit_id;
if (pop_accumulate_prices) {
price += pra_price;
@ -182,8 +188,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
price = pra_price;
}
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
//qCritical() << DBG_HEADER << " duration id" << durationId;
// qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
// qCritical() << DBG_HEADER << " duration id" << durationId;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
@ -2787,151 +2793,229 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
m_timeSteps[paymentOptionIndex].clear();
Configuration::TariffDurationType::iterator prev_it = cfg->Duration.end();
start = s;
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
QDateTime const start(s.date(),
QTime(s.time().hour(), s.time().minute(), 0),
s.timeZone());
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
}
QDateTime current(start);
bool casePrepay = false;
int const weekDay = start.date().dayOfWeek();
int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
// compute prepay settings
// assumption: prepay settings the same for all days
QDateTime prepayStart(start);
QDateTime prepayEnd(start);
prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
if (start <= prepayEnd) {
prepayStart = prepayStart.addDays(-1);
} else {
prepayEnd = prepayEnd.addDays(1);
}
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay end" << prepayEnd.toString(Qt::ISODate);
}
int const prepayDurationInMinutes = start.secsTo(prepayEnd) / 60;
// compute carryover settings
// assumption: carryover settings the same for all days
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
QDateTime carryOverStart(start);
QDateTime carryOverEnd(start);
carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
if (start <= carryOverEnd) {
carryOverStart = carryOverStart.addDays(-1);
} else {
carryOverEnd = carryOverEnd.addDays(1);
}
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);
}
// int cnt = 0;
for (Configuration::TariffDurationType::iterator it = cfg->Duration.begin();
it != cfg->Duration.end();
++it) {
it->second.pun_duration = it->second.pun_duration_saved;
if (it->second.pun_requires_change) {
if (it->second.pun_netto && !it->second.pun_brutto) {
int weekDay = start.date().dayOfWeek();
bool casePrepay = false;
if (m_timeSteps[paymentOptionIndex].isEmpty()) {
// handle possible prepay-condition, which applies only
// for the very first step
// if (++cnt > 2) continue;
int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
QDateTime prepayStart(start);
QDateTime prepayEnd(start);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
}
prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
if (it->second.pun_mutable) {
if (it->second.pun_netto) {
if (it->second.pun_round_to_next_24h_boundary == false) {
//int weekDay = start.date().dayOfWeek();
if (m_timeSteps[paymentOptionIndex].isEmpty()) {
// handle possible prepay-condition, which applies only
// for the very first step
if (start <= prepayEnd) {
prepayStart = prepayStart.addDays(-1);
} else {
prepayEnd = prepayEnd.addDays(1);
}
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay end" << prepayEnd.toString(Qt::ISODate);
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << start.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << prepayStart.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << prepayEnd.toString(Qt::ISODate);
if (prepayStart <= start && start <= prepayEnd) {
it->second.pun_duration = prepayDurationInMinutes;
it->second.pun_duration += it->second.pun_duration_saved ;
casePrepay = true;
}
if (prepayStart <= start && start <= prepayEnd) {
it->second.pun_duration = start.secsTo(prepayEnd) / 60;
it->second.pun_duration += it->second.pun_duration_saved ;
casePrepay = true;
}
//if (start >= prepayStart && ) {
// it->second.pun_duration = start.secsTo(prepayEnd) / 60;
// it->second.pun_duration += it->second.pun_duration_saved ;
// casePrepay = true;
//}
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
}
if (!casePrepay) {
// handle possible carryover-condition
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
QDateTime carryOverStart(start);
QDateTime carryOverEnd(start);
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << carryOverStart.toString(Qt::ISODate);
carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
//while (carryOverStart > carryOverEnd) {
// carryOverEnd = carryOverEnd.addDays(1);
//}
if (start <= carryOverEnd) {
carryOverStart = carryOverStart.addDays(-1);
} else {
carryOverEnd = carryOverEnd.addDays(1);
}
int durationInSecs = it->second.pun_duration_saved * 60;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << durationInSecs;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << start.addSecs(durationInSecs).toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << carryOverStart.toString(Qt::ISODate);
it->second.pun_duration = it->second.pun_duration_saved;
if (start >= carryOverStart) {
it->second.pun_duration += start.secsTo(carryOverEnd) / 60;
} else {
// start < carryOverStart
if (start.addSecs(durationInSecs) >= carryOverStart) {
// cross carry over section
it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
it->second.pun_duration += it->second.pun_next_step_correction;
prev_it = it;
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
}
}
if (!casePrepay) {
// handle possible carryover-condition
int const durationInSecs = it->second.pun_duration_saved * 60;
it->second.pun_duration = it->second.pun_duration_saved;
if (current >= carryOverStart && current < carryOverEnd) {
it->second.pun_duration += current.secsTo(carryOverEnd) / 60;
} else {
// start < carryOverStart
QDateTime const &newCurrent = current.addSecs(durationInSecs);
if (newCurrent > carryOverStart && newCurrent <= carryOverEnd) {
// cross carry over section
it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
it->second.pun_duration += it->second.pun_next_step_correction;
}
}
} else {
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
}
if (pop_accumulate_durations) {
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
} else {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
int d = m_timeSteps[paymentOptionIndex].last();
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
}
}
current = current.addSecs(m_timeSteps[paymentOptionIndex].last() * 60);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
}
} else { // if (it->pun_round_to_next_24h_boundary == false) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") round-to-next-24h-boundary";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
}
if (casePrepay) {
// the last time step contains the (dynamic) prepay duration
// so it is possible to compute the last duration
int lastDuration = m_timeSteps[paymentOptionIndex].last() - prepayDurationInMinutes;
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") last duration " << lastDuration;
int const minutesToAdd = 1440 - lastDuration;
current = current.addSecs(minutesToAdd * 60);
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
}
if (pop_accumulate_durations) {
m_timeSteps[paymentOptionIndex] << minutesToAdd;
} else {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
int d = m_timeSteps[paymentOptionIndex].last();
m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
}
}
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
casePrepay = false;
} else {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << it->second.pun_duration;
}
int secs = s.secsTo(current);
int const dayInSecs = 1440 * 60;
int const rest = secs % dayInSecs;
int const minutesToAdd = (dayInSecs - rest) / 60;
current = current.addSecs(minutesToAdd * 60);
it->second.pun_duration = minutesToAdd;
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
}
if (pop_accumulate_durations) {
m_timeSteps[paymentOptionIndex] << minutesToAdd;
} else {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
int d = m_timeSteps[paymentOptionIndex].last();
m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
}
}
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
}
}
} else { // if (it->second.pun_netto) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
}
} else { // mutable == false
if (it->second.pun_brutto) { // no handling for prepay and carry-over
if (pop_accumulate_durations) {
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
} else {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
int d = m_timeSteps[paymentOptionIndex].last();
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
} else {
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
}
}
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
<< "no change required, but set to brutto, which does not have to be changed";
}
} else {
if (it->second.pun_fixed) { // no change required: must be true
if (it->second.pun_brutto) { // no handling for prepay and carry-over
if (pop_accumulate_durations) {
int correction = 0;
if (prev_it != cfg->Duration.end()) {
correction = prev_it->second.pun_next_step_correction;
prev_it->second.pun_next_step_correction = 0;
}
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
int d = m_timeSteps[paymentOptionIndex].last();
it->second.pun_duration -= correction;
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
} else {
it->second.pun_duration -= correction;
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
}
}
} else
if (it->second.pun_netto) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "TODO";
}
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "fixed is false, but no change required";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
}
}
}
#if 0
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
QDateTime nextTime = start;
// 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
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
@ -2953,10 +3037,9 @@ 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;
QDateTime nextTime(s);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << 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);
@ -2983,7 +3066,7 @@ 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__ << ") paymentOptionIndex" << paymentOptionIndex;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;

View File

@ -144,7 +144,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
continue;
}
qCritical() << " -" << mb_name;
// qCritical() << " -" << mb_name;
// Get array for each JSON object member
auto mb_array = document[mb_name].GetArray();
@ -797,9 +797,25 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
Duration.pun_fixed = k->value.GetBool();
}
}
else if (strcmp(inner_obj_name, "pun_requires_change") == 0) {
else if (strcmp(inner_obj_name, "pun_mutable") == 0) {
if (k->value.IsBool()) {
Duration.pun_requires_change = k->value.GetBool();
Duration.pun_mutable = k->value.GetBool();
}
}
else if (strcmp(inner_obj_name, "pun_round_to_next_24h_boundary") == 0) {
if (k->value.IsBool()) {
Duration.pun_round_to_next_24h_boundary = k->value.GetBool();
}
}
else if (strcmp(inner_obj_name, "pun_round_to_prev_24h_boundary") == 0) {
if (k->value.IsBool()) {
Duration.pun_round_to_prev_24h_boundary = k->value.GetBool();
}
}
else if (strcmp(inner_obj_name, "pun_align_with_timepoint") == 0) {
if (k->value.IsString()) {
QDateTime const &dt = QDateTime::fromString(k->value.GetString(), Qt::ISODate);
Duration.pun_align_with_timepoint = dt;
}
}
break;
@ -866,7 +882,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
} break;
case MemberType::DurationType:
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
// qCritical() << Duration;
//qCritical() << Duration;
break;
case MemberType::SpecialDaysWorktimeType:
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
@ -922,7 +938,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
break;
case MemberType::PrepaidOptionType:
cfg->TariffPrepayOptions.insert(pair<int, ATBPrepay>(TariffPrepayOption.id, TariffPrepayOption));
qCritical() << TariffPrepayOption;
//qCritical() << TariffPrepayOption;
break;
default:
break;

View File

@ -742,7 +742,13 @@ int main() {
}
if (zone == 3) {
//input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
input.open("/home/linux/customer_502/etc/psa_tariff/tariff03.json");
//input.open("/home/linux/customer_502/etc/psa_tariff/tariff01.json");
// schnals
// input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
// muehlbach
input.open("/opt/ptu5/opt/customer_504/etc/psa_tariff/tariff01.json");
}
std::stringstream sstr;
@ -916,7 +922,9 @@ int main() {
QDateTime end;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(18, 0, 0));
s.setTime(QTime(10, 0, 0));
#if 0
pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
@ -938,16 +946,18 @@ int main() {
qCritical() << " pop_min_price " << pop_min_price;
qCritical() << " pop_max_price " << pop_max_price;
qCritical() << "pop_daily_card_price " << pop_daily_card_price;
#endif
CalcState calcState;
#if 0
for (int i = 1; i < 11; ++i) {
#if 1
qCritical() << "start" << s.toString(Qt::ISODate);
//for (int i = 1; i < 11; ++i) {
for (int i = 0; i < 21; ++i) {
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)i*200,
(double)i*10,
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
<< ": price" << i*200 << "->" << end.toString(Qt::ISODate) << calcState.toString();
<< ": price" << i*10 << "->" << end.toString(Qt::ISODate) << calcState.toString();
}
#else
struct price_t price;