added out-of-service handling
This commit is contained in:
parent
141d3281b7
commit
f547f563bf
@ -277,6 +277,12 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
|
|||||||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
|
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
|
||||||
int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
|
int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
|
||||||
|
|
||||||
|
|
||||||
|
int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
|
||||||
|
QDateTime const &dt);
|
||||||
|
|
||||||
|
int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt);
|
||||||
|
|
||||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||||
int UpDown, PermitType const &permitType);
|
int UpDown, PermitType const &permitType);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
QTime ValidFrom;
|
QTime ValidFrom;
|
||||||
int ValidForWeekDay{};
|
int ValidForWeekDay{};
|
||||||
QString tariffFileName{};
|
QStringList tariffFileName{};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse JSON string
|
/// Parse JSON string
|
||||||
|
@ -34,6 +34,95 @@ QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
|
|||||||
|
|
||||||
static std::map<PERMIT_TYPE, std::unique_ptr<parking_tariff_t>> tariffs;
|
static std::map<PERMIT_TYPE, std::unique_ptr<parking_tariff_t>> tariffs;
|
||||||
static QDateTime start_ = QDateTime::currentDateTime();
|
static QDateTime start_ = QDateTime::currentDateTime();
|
||||||
|
static Configuration const *current_tariff{nullptr};
|
||||||
|
|
||||||
|
int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt) {
|
||||||
|
// L201
|
||||||
|
if (current_tariff->tariffFileName.contains("tariff01")) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "NO";
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
// L264
|
||||||
|
if (current_tariff->tariffFileName.contains("tariff02") ||
|
||||||
|
current_tariff->tariffFileName.contains("tariff02_1700_2300") ||
|
||||||
|
current_tariff->tariffFileName.contains("tariff02_1900_2300")) {
|
||||||
|
// feiertage
|
||||||
|
QDate const &d = dt.date();
|
||||||
|
if (d.toString(Qt::ISODate) == "2025-06-09"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-06-19"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-08-15"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-10-03"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-11-01"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-12-25"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-12-26") {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int const day = d.dayOfWeek();
|
||||||
|
if (day == 7) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dt.time() >= QTime::fromString("23:00:00", Qt::ISODate)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
// H242
|
||||||
|
if (current_tariff->tariffFileName.contains("tariff03") ||
|
||||||
|
current_tariff->tariffFileName.contains("tariff03_H242_sat")) {
|
||||||
|
// feiertage
|
||||||
|
QDate const &d = dt.date();
|
||||||
|
if (d.toString(Qt::ISODate) == "2025-06-09"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-06-19"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-08-15"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-10-03"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-11-01"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-12-25"
|
||||||
|
|| d.toString(Qt::ISODate) == "2025-12-26") {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int const day = d.dayOfWeek();
|
||||||
|
if (day == 7) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime const &t = dt.time();
|
||||||
|
if (day <= 5) {
|
||||||
|
if (t < QTime::fromString("18:00:00", Qt::ISODate)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (day == 6) {
|
||||||
|
if (t < QTime::fromString("14:00:00", Qt::ISODate)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t >= QTime::fromString("23:00:00", Qt::ISODate)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "YES";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "NO";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
|
||||||
|
QDateTime const &dt) {
|
||||||
|
Q_UNUSED(cfg);
|
||||||
|
return isOutOfService(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||||
@ -102,6 +191,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = cfg;
|
||||||
|
|
||||||
int weekDay = start_.date().dayOfWeek();
|
int weekDay = start_.date().dayOfWeek();
|
||||||
qCritical() << __func__ << __LINE__ << cfg << "CCCCCC week" << (int)permitType << weekDay;
|
qCritical() << __func__ << __LINE__ << cfg << "CCCCCC week" << (int)permitType << weekDay;
|
||||||
|
|
||||||
@ -210,6 +301,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = cfg;
|
||||||
|
|
||||||
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
paymentOptionIndex = getPaymentOptionIndex(*cfg);
|
||||||
if (paymentOptionIndex == -1) {
|
if (paymentOptionIndex == -1) {
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
@ -299,6 +392,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = cfg;
|
||||||
|
|
||||||
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
|
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
}
|
}
|
||||||
@ -379,6 +474,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = cfg;
|
||||||
|
|
||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||||
} break;
|
} break;
|
||||||
@ -598,6 +695,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = cfg;
|
||||||
|
|
||||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
|
if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
|
||||||
@ -724,6 +823,8 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
|
|||||||
qCritical() << " ... error parsing tariff";
|
qCritical() << " ... error parsing tariff";
|
||||||
return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
|
return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
|
||||||
}
|
}
|
||||||
|
QFileInfo fi(confFile);
|
||||||
|
(*tariff)->tariffFileName << fi.baseName();
|
||||||
} else {
|
} else {
|
||||||
delete *tariff;
|
delete *tariff;
|
||||||
*tariff = nullptr;
|
*tariff = nullptr;
|
||||||
@ -750,7 +851,8 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
|
|||||||
qCritical() << " ... error parsing tariff in" << f.fileName();
|
qCritical() << " ... error parsing tariff in" << f.fileName();
|
||||||
qCritical() << " ... json" << json;
|
qCritical() << " ... json" << json;
|
||||||
} else {
|
} else {
|
||||||
t->tariffFileName = p.second.trimmed();
|
QFileInfo fi(p.second.trimmed());
|
||||||
|
t->tariffFileName << fi.baseName();
|
||||||
QTime validFrom(QTime::fromString(p.first, Qt::ISODate));
|
QTime validFrom(QTime::fromString(p.first, Qt::ISODate));
|
||||||
if (validFrom.isValid()) {
|
if (validFrom.isValid()) {
|
||||||
t->ValidFrom = validFrom;
|
t->ValidFrom = validFrom;
|
||||||
@ -841,6 +943,8 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
|
||||||
qCritical() << __LINE__ << "compute_next_timestep() start: " << start_.toString(Qt::ISODate);
|
qCritical() << __LINE__ << "compute_next_timestep() start: " << start_.toString(Qt::ISODate);
|
||||||
qCritical() << __LINE__ << "compute_next_timestep() valid from: " << tariff->ValidFrom.toString(Qt::ISODate);
|
qCritical() << __LINE__ << "compute_next_timestep() valid from: " << tariff->ValidFrom.toString(Qt::ISODate);
|
||||||
qCritical() << __LINE__ << "compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
qCritical() << __LINE__ << "compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||||
@ -992,7 +1096,10 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
|
qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
|
||||||
|
|
||||||
// L264
|
// L264
|
||||||
if (tariff->tariffFileName.contains("tariff02")) {
|
qCritical() << __LINE__ << "compute_next_timestep() TTTTTT tariff-files:" << tariff->tariffFileName;
|
||||||
|
if (tariff->tariffFileName.contains("tariff02") ||
|
||||||
|
tariff->tariffFileName.contains("tariff02_1700_2300") ||
|
||||||
|
tariff->tariffFileName.contains("tariff02_1900_2300")) {
|
||||||
QDateTime dt = start_.addSecs( stepList[nextStepIndex] * 60);
|
QDateTime dt = start_.addSecs( stepList[nextStepIndex] * 60);
|
||||||
qCritical() << __LINE__ << "compute_next_timestep() dt:" << dt.toString(Qt::ISODate);
|
qCritical() << __LINE__ << "compute_next_timestep() dt:" << dt.toString(Qt::ISODate);
|
||||||
|
|
||||||
@ -1085,6 +1192,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__;
|
qCritical() << __func__ << ":" << __LINE__;
|
||||||
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
|
||||||
@ -1214,6 +1323,10 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||||
|
<< isOutOfService(start_);
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
|
||||||
|
|
||||||
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
|
int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
|
||||||
@ -1540,6 +1653,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||||
|
<< isOutOfService(start_);
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
@ -1616,6 +1733,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||||
|
<< isOutOfService(start_);
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
@ -1968,6 +2089,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||||
|
<< isOutOfService(start_);
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
@ -2018,6 +2143,10 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tariff = tariff;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
|
||||||
|
<< isOutOfService(start_);
|
||||||
|
|
||||||
tariff->getPaymentOptions(0).pop_max_price
|
tariff->getPaymentOptions(0).pop_max_price
|
||||||
= tariff->getPaymentOptions(0).pop_max_price_save;
|
= tariff->getPaymentOptions(0).pop_max_price_save;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user