Compare commits
17 Commits
Neuhauser-
...
1c801f1053
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c801f1053 | |||
| 56fc95e33c | |||
| c0f81f174a | |||
| 6ba3963f25 | |||
| 1a350c0aeb | |||
| 15801be88e | |||
| 20e146d3c9 | |||
| 30768c6931 | |||
| 7933c826e6 | |||
| 9d5ddfc328 | |||
| 102607b71f | |||
| 81d515eb7f | |||
| ce61e5d3b2 | |||
| b6a0f5e8af | |||
| e0223b50f9 | |||
| 690267c388 | |||
| 9c19414e5a |
@@ -174,7 +174,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
QDateTime &start_parking_time,
|
||||
int netto_parking_time,
|
||||
QDateTime &end_parking_time, // return value
|
||||
struct price_t *price); // return value
|
||||
struct price_t *price, // return value
|
||||
bool prepaid = true);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket( // deprecated
|
||||
parking_tariff_t *tariff,
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace Utilities {
|
||||
uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||
uint32_t getMaximalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||
uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
|
||||
uint32_t getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId);
|
||||
BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
|
||||
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
||||
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
||||
|
||||
@@ -78,9 +78,13 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TY
|
||||
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
|
||||
int maxPrice = -1;
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
if (paymentMethodId == PaymentMethod::Progressive) {
|
||||
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||
int const key = cfg->getPaymentOptions().pop_id;
|
||||
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
|
||||
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
|
||||
@@ -91,6 +95,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
|
||||
maxPrice = qRound((maxTime * price) / 60.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
break;
|
||||
@@ -217,7 +222,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
|
||||
// use tariff with structure as for instance Schnau, Koenigsee:
|
||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||
if (paymentMethodId == PaymentMethod::Steps)
|
||||
if ((paymentMethodId == PaymentMethod::Steps) ||
|
||||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||
(paymentMethodId == PaymentMethod::Progressive))
|
||||
{
|
||||
const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
|
||||
@@ -345,7 +352,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
QDateTime &start_parking_time,
|
||||
int netto_parking_time,
|
||||
QDateTime &end_parking_time,
|
||||
struct price_t *price)
|
||||
struct price_t *price,
|
||||
bool prepaid)
|
||||
{
|
||||
CalcState calcState;
|
||||
double minMin = tariff->getPaymentOptions().pop_min_time;
|
||||
@@ -384,7 +392,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
start_parking_time, // starting time
|
||||
end_parking_time, // return value: end time
|
||||
netto_parking_time, // minutes, netto
|
||||
false, true);
|
||||
false, prepaid);
|
||||
double minCost = tariff->getPaymentOptions().pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
|
||||
|
||||
@@ -157,6 +157,17 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
static const bool carryOverNotSet = Utilities::isCarryOverNotSet(cfg, paymentMethodId);
|
||||
static const uint minParkingPrice = Utilities::getMinimalParkingPrice(cfg, paymentMethodId);
|
||||
static const uint maxParkingPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||
|
||||
if (cost < minParkingPrice) {
|
||||
qCritical() << QString("ERROR: COST < MIN_PARKING_PRICE (%1 < %2)").arg(cost).arg(minParkingPrice);
|
||||
return QDateTime().toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
|
||||
if (cost > maxParkingPrice) {
|
||||
qCritical() << QString("WARN: COST > MAX_PARKING_PRICE (%1 > %2)").arg(cost).arg(maxParkingPrice);
|
||||
cost = maxParkingPrice;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(carryOverNotSet, __func__, "CARRYOVER SET (FOR KIRCHDORF)");
|
||||
Q_ASSERT_X(prepaid, __func__, "PREPAID NOT SET (FOR KIRCHDORF)");
|
||||
@@ -220,6 +231,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
if (carryOverNotSet) {
|
||||
int range = 0;
|
||||
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
||||
int minsUsed = 0;
|
||||
QDateTime lastCurrent = QDateTime();
|
||||
|
||||
auto timeRangeIt = cfg->TimeRange.cbegin();
|
||||
@@ -235,7 +247,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
||||
|
||||
|
||||
if (current.time() >= to) {
|
||||
continue; // try to use next available work-time
|
||||
} else
|
||||
@@ -261,24 +272,29 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
int duration = timeRange.time_range_to_in_minutes_from_start -
|
||||
timeRange.time_range_from_in_minutes_from_start;
|
||||
|
||||
if (minsUsed > 0) {
|
||||
duration -= minsUsed;
|
||||
minsUsed = 0;
|
||||
}
|
||||
|
||||
if (current.addSecs(duration * 60).time() <= to) {
|
||||
if (minsToCarryOver > 0) { // the price for this time range
|
||||
// has been is paid already
|
||||
durationMinutes -= duration;
|
||||
durationMinutesNetto += duration;
|
||||
durationMinutesBrutto += duration;
|
||||
current = current.addSecs(duration*60);
|
||||
minsToCarryOver = 0;
|
||||
} else {
|
||||
for(const auto &x: cfg->PaymentRate) {
|
||||
ATBPaymentRate const rate = x.second;
|
||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||
if (minsToCarryOver > 0) {
|
||||
durationMinutes -= minsToCarryOver;
|
||||
durationMinutesNetto += minsToCarryOver;
|
||||
durationMinutesBrutto += minsToCarryOver;
|
||||
current = current.addSecs(minsToCarryOver*60);
|
||||
minsToCarryOver = 0;
|
||||
} else {
|
||||
if (price >= cost) {
|
||||
end_datetime = current;
|
||||
return end_datetime.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
|
||||
price += (uint)rate.pra_price;
|
||||
|
||||
if (price >= maxParkingPrice) {
|
||||
price = maxParkingPrice;
|
||||
}
|
||||
|
||||
durationMinutes -= duration;
|
||||
durationMinutesNetto += duration;
|
||||
durationMinutesBrutto += duration;
|
||||
@@ -289,10 +305,11 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
end_datetime = current;
|
||||
return end_datetime.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (durationMinutes <= 0) {
|
||||
end_datetime = current;
|
||||
@@ -305,21 +322,28 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
lastCurrent = current;
|
||||
current.setTime(to);
|
||||
int const minsLeft = lastCurrent.secsTo(current) / 60;
|
||||
minsUsed = lastCurrent.secsTo(current) / 60;
|
||||
|
||||
// mod duration: possibly discard some minutes in
|
||||
// the next time-range
|
||||
minsToCarryOver = (durationMinutes - minsLeft) % duration;
|
||||
if (durationMinutes >= minsUsed) {
|
||||
minsToCarryOver = durationMinutes - minsUsed;
|
||||
}
|
||||
|
||||
durationMinutes -= minsLeft;
|
||||
durationMinutesNetto += minsLeft;
|
||||
durationMinutesBrutto += minsLeft;
|
||||
durationMinutes -= minsUsed;
|
||||
durationMinutesNetto += minsUsed;
|
||||
durationMinutesBrutto += minsUsed;
|
||||
|
||||
if (minsLeft > 0) {
|
||||
if (minsUsed > 0) {
|
||||
for(const auto &x: cfg->PaymentRate) {
|
||||
ATBPaymentRate const rate = x.second;
|
||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||
price += (uint)rate.pra_price;
|
||||
|
||||
if (price >= maxParkingPrice) {
|
||||
price = maxParkingPrice;
|
||||
}
|
||||
|
||||
if (price >= cost) {
|
||||
end_datetime = current;
|
||||
// return end_datetime.toString(Qt::ISODate).toStdString();
|
||||
@@ -328,7 +352,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -473,9 +496,11 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
end_datetime.setTime(cs.getAllowedTimeRange().getTimeUntil());
|
||||
return cost;
|
||||
}
|
||||
} else {
|
||||
// it might be that in such a case even prepaid ("vorkauf")
|
||||
// is not allowed at any moment
|
||||
}
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << "NOT YET IMPLEMENTED";
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "NOT YET IMPLEMENTED";
|
||||
end_datetime = QDateTime();
|
||||
return 0;
|
||||
}
|
||||
@@ -527,6 +552,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
|
||||
if (current.time() >= to) {
|
||||
if (carryOverNotSet) {
|
||||
end_datetime = start;
|
||||
return 0;
|
||||
} else {
|
||||
QDateTime const dt = start;
|
||||
@@ -547,6 +573,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
if (carryOverNotSet) {
|
||||
int range = 0;
|
||||
int minsToCarryOver = 0; // from one work-time to the other on the same day
|
||||
int minsUsed = 0;
|
||||
QDateTime lastCurrent = QDateTime();
|
||||
|
||||
auto timeRangeIt = cfg->TimeRange.cbegin();
|
||||
@@ -562,7 +589,6 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
|
||||
Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
|
||||
|
||||
|
||||
if (current.time() >= to) {
|
||||
continue; // try to use next available work-time
|
||||
} else
|
||||
@@ -588,18 +614,23 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
int duration = timeRange.time_range_to_in_minutes_from_start -
|
||||
timeRange.time_range_from_in_minutes_from_start;
|
||||
|
||||
if (current.addSecs(duration * 60).time() <= to) {
|
||||
if (minsUsed > 0) {
|
||||
duration -= minsUsed;
|
||||
minsUsed = 0;
|
||||
}
|
||||
|
||||
if (current.addSecs(duration * 60).time() <= to) {
|
||||
if (minsToCarryOver > 0) { // the price for this time range
|
||||
// has been is paid already
|
||||
durationMinutes -= duration;
|
||||
durationMinutesNetto += duration;
|
||||
durationMinutesBrutto += duration;
|
||||
current = current.addSecs(duration*60);
|
||||
minsToCarryOver = 0;
|
||||
} else {
|
||||
for(const auto &x: cfg->PaymentRate) {
|
||||
ATBPaymentRate const rate = x.second;
|
||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||
if (minsToCarryOver > 0) {
|
||||
durationMinutes -= minsToCarryOver;
|
||||
durationMinutesNetto += minsToCarryOver;
|
||||
durationMinutesBrutto += minsToCarryOver;
|
||||
current = current.addSecs(minsToCarryOver*60);
|
||||
minsToCarryOver = 0;
|
||||
} else {
|
||||
price += (uint)rate.pra_price;
|
||||
|
||||
durationMinutes -= duration;
|
||||
@@ -607,10 +638,10 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
durationMinutesBrutto += duration;
|
||||
|
||||
current = current.addSecs(duration * 60);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (durationMinutes <= 0) {
|
||||
end_datetime = current;
|
||||
@@ -623,17 +654,19 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
|
||||
lastCurrent = current;
|
||||
current.setTime(to);
|
||||
int const minsLeft = lastCurrent.secsTo(current) / 60;
|
||||
minsUsed = lastCurrent.secsTo(current) / 60;
|
||||
|
||||
// mod duration: possibly discard some minutes in
|
||||
// the next time-range
|
||||
minsToCarryOver = (durationMinutes - minsLeft) % duration;
|
||||
if (durationMinutes >= minsUsed) {
|
||||
minsToCarryOver = durationMinutes - minsUsed;
|
||||
}
|
||||
|
||||
durationMinutes -= minsLeft;
|
||||
durationMinutesNetto += minsLeft;
|
||||
durationMinutesBrutto += minsLeft;
|
||||
durationMinutes -= minsUsed;
|
||||
durationMinutesNetto += minsUsed;
|
||||
durationMinutesBrutto += minsUsed;
|
||||
|
||||
if (minsLeft > 0) {
|
||||
if (minsUsed > 0) {
|
||||
for(const auto &x: cfg->PaymentRate) {
|
||||
ATBPaymentRate const rate = x.second;
|
||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||
@@ -642,7 +675,6 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1145,6 +1177,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
||||
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
||||
|
||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " start parking time:" << start.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " payment option id:" << pop_id;
|
||||
qCritical() << __func__ << ":" << __LINE__ << "payment option carry over:" << pop_carry_over;
|
||||
@@ -1152,6 +1186,13 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||
|
||||
if (paymentMethodId == PaymentMethod::Progressive) { // e.g. neuhauser kirchdorf (743)
|
||||
std::size_t const s = cfg->TimeRange.size();
|
||||
for (std::size_t id = 1; id <= s; ++id) {
|
||||
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
||||
m_timeSteps.append(step);
|
||||
}
|
||||
} else {
|
||||
uint16_t timeStepCompensation = 0;
|
||||
|
||||
if (pop_carry_over) {
|
||||
@@ -1210,6 +1251,7 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
} else { // if (pop_carry_over) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::STATIC";
|
||||
|
||||
|
||||
@@ -397,6 +397,14 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
|
||||
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
|
||||
}
|
||||
|
||||
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
|
||||
if (methodId == PaymentMethod::Progressive) {
|
||||
return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
|
||||
|
||||
int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
|
||||
|
||||
348
main/main.cpp
348
main/main.cpp
@@ -27,6 +27,7 @@ extern "C" char* strptime(const char* s,
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -36,11 +37,126 @@ extern "C" char* strptime(const char* s,
|
||||
#define SZEGED (0)
|
||||
#define SCHOENAU_KOENIGSEE (0)
|
||||
#define NEUHAUSER_KORNEUBURG (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_KIRCHDORF (1)
|
||||
#define NEUHAUSER_KIRCHDORF (0)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
switch (step) {
|
||||
case 30:
|
||||
if (cost != 30) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 30;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 35:
|
||||
if (cost != 40) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 40;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
if (cost != 50) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 50;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 45:
|
||||
if (cost != 60) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 60;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 50:
|
||||
if (cost != 70) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 70;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 55:
|
||||
if (cost != 80) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 80;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 60:
|
||||
if (cost != 90) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 90;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 65:
|
||||
if (cost != 100) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 100;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 70:
|
||||
if (cost != 110) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 110;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 75:
|
||||
if (cost != 120) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 120;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 80:
|
||||
if (cost != 130) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 130;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 85:
|
||||
if (cost != 140) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 140;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 90:
|
||||
if (cost != 150) {
|
||||
qCritical() << "ERROR COMPUTING COST"
|
||||
<< "HAVE" << cost
|
||||
<< "SHOULD" << 150;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
#if SCHOENAU_KOENIGSEE==1
|
||||
@@ -89,6 +205,160 @@ int main() {
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
if (QDir("/opt/app/tools/atbupdate/customer_743").exists()) {
|
||||
if(QFileInfo::exists("/etc/psa_tariff/tariff01.json")) {
|
||||
// if (true) {
|
||||
// if(true) {
|
||||
const char *f = "/etc/psa_tariff/tariff01.json";
|
||||
// const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
||||
std::ifstream input(f);
|
||||
|
||||
std::stringstream sstr;
|
||||
while(input >> sstr.rdbuf());
|
||||
std::string json(sstr.str());
|
||||
|
||||
Configuration cfg;
|
||||
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||
|
||||
if (!isParsed) {
|
||||
qCritical() << "ERROR: CANNOT PARSE" << f;
|
||||
return -1;
|
||||
}
|
||||
qCritical() << "Successfully parsed" << f;
|
||||
|
||||
int const minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
int const maxParkingTime = get_maximal_parkingtime(&cfg);
|
||||
int const minParkingPrice = get_minimal_parkingprice(&cfg);
|
||||
|
||||
if (minParkingTime != 30) {
|
||||
qCritical() << "ERROR: WRONG MIN_PARKING_TIME" << minParkingTime;
|
||||
return -1;
|
||||
}
|
||||
qCritical() << "min_parking_time " << minParkingTime;
|
||||
|
||||
if (maxParkingTime != 90) {
|
||||
qCritical() << "ERROR: WRONG MAX_PARKING_TIME" << maxParkingTime;
|
||||
return -1;
|
||||
}
|
||||
qCritical() << "max_parking_time " << maxParkingTime;
|
||||
|
||||
|
||||
if (minParkingPrice != 30) {
|
||||
qCritical() << "ERROR: WRONG MIN_PARKING_PRICE" << minParkingPrice;
|
||||
return -1;
|
||||
}
|
||||
qCritical() << "min_parking_price" << minParkingPrice;
|
||||
|
||||
QList<int> const stepsConfigured
|
||||
= QList(std::initializer_list<int>{
|
||||
30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90});
|
||||
|
||||
QList<int> const steps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
|
||||
if (stepsConfigured != steps) {
|
||||
qCritical() << "ERROR: WRONG TIME-STEP-LIST" << steps;
|
||||
qCritical() << "SHOULD BE" << stepsConfigured;
|
||||
return -1;
|
||||
}
|
||||
qCritical() << "time steps" << steps;
|
||||
|
||||
QDateTime s(QDate(2024, 2, 21), QTime());
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
|
||||
QList<int>::const_iterator step;
|
||||
for (step = steps.cbegin(); step != steps.cend(); ++step) {
|
||||
qCritical() << QString("*** NEXT STEP: %1 ***").arg(*step);
|
||||
for (int offset = 7*60; offset < 18*60; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
QDateTime const firstStart = start;
|
||||
|
||||
if (compute_price_for_parking_ticket(&cfg, start, *step, end, &price)) {
|
||||
double cost = price.netto;
|
||||
|
||||
//qCritical() << "****" << offset << *step << "****";
|
||||
//qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
||||
//qCritical() << " start :" << start.toString(Qt::ISODate);
|
||||
//qCritical() << " end :" << end.toString(Qt::ISODate);
|
||||
|
||||
if (offset < 8*60) { // [7:00 - 8:00[
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 9*60) { // [8:00 - 9:00[
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 10*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 11*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 12*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 13*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 14*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 15*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 16*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
if (offset < 17*60) {
|
||||
if (!test_neuhauser_kirchdorf(*step, cost)) {
|
||||
qCritical() << "ERROR AT OFFSET" << offset;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "WARN OFFSET TOO HIGH" << offset;
|
||||
}
|
||||
|
||||
} else {
|
||||
qCritical() << "ERROR COMPUTING PRICE FOR"
|
||||
<< "start" << start.toString(Qt::ISODate)
|
||||
<< "step" << *step
|
||||
<< "end" << end.toString(Qt::ISODate);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
||||
std::ifstream input(f);
|
||||
|
||||
@@ -110,18 +380,18 @@ int main() {
|
||||
qCritical() << "max_parking_time " << maxParkingTime;
|
||||
qCritical() << "min_parking_price" << minParkingPrice;
|
||||
|
||||
#if 1
|
||||
bool nextDay = false;
|
||||
bool prePaid = true;
|
||||
// bool carryOver = false;
|
||||
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
// QDateTime s(QDate(2023, 11, 26), QTime());
|
||||
//QDateTime s = QDateTime::currentDateTime();
|
||||
QDateTime s(QDate(2024, 2, 21), QTime());
|
||||
QDateTime end;
|
||||
for (int duration = 30; duration <= 90; duration += 5) {
|
||||
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
|
||||
qCritical() << "";
|
||||
for (int offset = 420; offset <= 1080; ++offset) {
|
||||
//for (int offset = 0; offset <= 0; ++offset) {
|
||||
//for (int offset = 420; offset <= 1080; ++offset) {
|
||||
//if (offset > 720 && offset < 840) {
|
||||
// continue;
|
||||
@@ -130,7 +400,12 @@ int main() {
|
||||
QDateTime const firstStart = start;
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
||||
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
||||
|
||||
struct price_t price;
|
||||
compute_price_for_parking_ticket(&cfg, start, duration, end, &price);
|
||||
|
||||
double cost = price.netto;
|
||||
|
||||
//#if COST_FROM_DURATION==0
|
||||
double cost_soll = 30 + ((duration-30)/5 * 10);
|
||||
@@ -140,54 +415,52 @@ int main() {
|
||||
duration_ist = duration_ist - 120;
|
||||
}
|
||||
|
||||
|
||||
qCritical() << "****" << offset << duration << "****";
|
||||
qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
||||
qCritical() << " start :" << start.toString(Qt::ISODate);
|
||||
qCritical() << " end :" << end.toString(Qt::ISODate);
|
||||
qCritical() << "duration (soll):" << duration;
|
||||
qCritical() << "duration (ist) :" << duration_ist;
|
||||
qCritical() << " cost (soll):" << cost_soll;
|
||||
qCritical() << " cost (ist) :" << cost;
|
||||
//qCritical() << "duration (soll):" << duration;
|
||||
//qCritical() << "duration (ist) :" << duration_ist;
|
||||
//qCritical() << " cost (soll):" << cost_soll;
|
||||
//qCritical() << " cost (ist) :" << cost;
|
||||
|
||||
if (cost_soll != cost) {
|
||||
// if (cost_soll != cost) {
|
||||
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
||||
// << "cost_soll" << cost_soll << "cost_ist" << cost;
|
||||
//break;
|
||||
}
|
||||
if (duration != duration_ist) {
|
||||
// }
|
||||
// if (duration != duration_ist) {
|
||||
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
||||
// << "duration_soll" << duration << "duration_ist" << duration_ist;
|
||||
//break;
|
||||
}
|
||||
// }
|
||||
|
||||
//#else
|
||||
start = s.addSecs(offset * 60);
|
||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
||||
start.toString(Qt::ISODate).toStdString().c_str(),
|
||||
cost, false, true);
|
||||
//start = s.addSecs(offset * 60);
|
||||
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
||||
// start.toString(Qt::ISODate).toStdString().c_str(),
|
||||
// cost, false, true);
|
||||
|
||||
|
||||
if (end.toString(Qt::ISODate) != QString(duration.c_str())) {
|
||||
//if (end.toString(Qt::ISODate) != QString(duration.c_str())) {
|
||||
//qCritical() << "ERROR" << end.toString(Qt::ISODate)
|
||||
// << QString(duration.c_str());
|
||||
//break;
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str()
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< ":" << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60
|
||||
<< (end.toString(Qt::ISODate) == QString(duration.c_str()));
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "cost" << cost
|
||||
// << "until" << duration.c_str()
|
||||
// << "end" << end.toString(Qt::ISODate)
|
||||
// << ":" << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60
|
||||
// << (end.toString(Qt::ISODate) == QString(duration.c_str()));
|
||||
|
||||
//#endif // COST_FROM_DURATION
|
||||
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_BILEXA_GALTUER==1
|
||||
@@ -239,6 +512,9 @@ int main() {
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
QDateTime end;
|
||||
struct price_t price;
|
||||
#define ADULT 0
|
||||
#define TEEN 1
|
||||
#if ADULT==1
|
||||
for (int offset = 480; offset < 1080; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
|
||||
@@ -249,7 +525,9 @@ int main() {
|
||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEEN==1
|
||||
for (int offset = 480; offset < 1080; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
||||
@@ -257,6 +535,7 @@ int main() {
|
||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -282,16 +561,23 @@ int main() {
|
||||
QDateTime end;
|
||||
int marken[] = { 3*60, 5*60, 10*60};
|
||||
for (int duration = 0; duration < 3; ++duration) {
|
||||
for (int offset = 360; offset <= 1080; ++offset) {
|
||||
for (int offset = 360; offset <= 360; ++offset) {
|
||||
// for (int offset = 360; offset < 1080; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
||||
//qCritical() << "";
|
||||
// note: prepaid == false (!)
|
||||
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
||||
|
||||
struct price_t price;
|
||||
if (compute_price_for_parking_ticket(&cfg, start, marken[duration], end, &price, prePaid)) {
|
||||
double cost = price.netto;
|
||||
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< "duration" << marken[duration]
|
||||
<< "cost" << cost;
|
||||
}
|
||||
|
||||
//std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
|
||||
Reference in New Issue
Block a user