Compare commits
10 Commits
c153652b3d
...
977356040c
Author | SHA1 | Date | |
---|---|---|---|
977356040c | |||
2a89f90745 | |||
f2356bec55 | |||
2d6ef2d158 | |||
e5d23d8022 | |||
02927be9c9 | |||
c6d396f34b | |||
026c791c79 | |||
927164e23e | |||
507b5d1b9c |
@ -25,6 +25,9 @@
|
|||||||
#include "time_range_header.h"
|
#include "time_range_header.h"
|
||||||
#include "tariff_timestep_config.h"
|
#include "tariff_timestep_config.h"
|
||||||
#include "tariff_product.h"
|
#include "tariff_product.h"
|
||||||
|
#include "tariff_interpolation.h"
|
||||||
|
#include "tariff_prepaid.h"
|
||||||
|
#include "tariff_carryover.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -41,6 +44,9 @@ public:
|
|||||||
using TimeRangeType = std::multimap<int, ATBTimeRange>;
|
using TimeRangeType = std::multimap<int, ATBTimeRange>;
|
||||||
using TariffProductType = std::multimap<int, ATBTariffProduct>;
|
using TariffProductType = std::multimap<int, ATBTariffProduct>;
|
||||||
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
||||||
|
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
||||||
|
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
||||||
|
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||||
|
|
||||||
ATBProject project;
|
ATBProject project;
|
||||||
ATBCurrency Currency;
|
ATBCurrency Currency;
|
||||||
@ -61,6 +67,9 @@ public:
|
|||||||
multimap<int, ATBTimeBase> TimeBase;
|
multimap<int, ATBTimeBase> TimeBase;
|
||||||
multimap<int, ATBCustomer> Customer;
|
multimap<int, ATBCustomer> Customer;
|
||||||
TariffProductType TariffProduct;
|
TariffProductType TariffProduct;
|
||||||
|
TariffInterpolationType TariffInterpolations;
|
||||||
|
TariffPrepaidType TariffPrepaidOptions;
|
||||||
|
TariffCarryOverType TariffCarryOverOptions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse JSON string
|
/// Parse JSON string
|
||||||
@ -85,6 +94,8 @@ public:
|
|||||||
std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
|
std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
|
||||||
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
|
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
|
||||||
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
|
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
|
||||||
|
std::optional<ATBInterpolation> getInterpolationType(int type) const;
|
||||||
|
std::optional<ATBPrepaid> getPrepaidType(int type) const;
|
||||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
|
||||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
|
||||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
|
||||||
@ -92,6 +103,8 @@ public:
|
|||||||
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
|
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
|
||||||
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
||||||
|
|
||||||
|
std::optional<QDateTime> adaptStart(QDateTime const &start, int prepaid_option_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identify type of JSON member
|
/// Identify type of JSON member
|
||||||
|
@ -1,11 +1,37 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class ATBDuration
|
class ATBDuration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit ATBDuration()
|
||||||
|
: pun_id(0)
|
||||||
|
, pun_label("")
|
||||||
|
, pun_duration(0)
|
||||||
|
, pun_duration_min(0)
|
||||||
|
, pun_duration_max(0)
|
||||||
|
, pun_interpolation_id(-1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
|
||||||
|
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_min: " << td.pun_duration_min << "\n"
|
||||||
|
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
||||||
|
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
int pun_id;
|
int pun_id;
|
||||||
std::string pun_label;
|
std::string pun_label;
|
||||||
int pun_duration;
|
int pun_duration;
|
||||||
int pun_duration_min;
|
int pun_duration_min;
|
||||||
int pun_duration_max;
|
int pun_duration_max;
|
||||||
|
int pun_interpolation_id;
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,10 @@ enum MemberType
|
|||||||
TimeBaseType = 0x0C,
|
TimeBaseType = 0x0C,
|
||||||
TimeRangeType = 0x0D,
|
TimeRangeType = 0x0D,
|
||||||
TimeStepConfigType = 0x0E,
|
TimeStepConfigType = 0x0E,
|
||||||
ProductType = 0x0F
|
ProductType = 0x0F,
|
||||||
|
InterpolationType = 0x10,
|
||||||
|
PrepaidType = 0x11,
|
||||||
|
CarryOverType = 0x12
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MEMBER_TYPE_H_INCLUDED
|
#endif // MEMBER_TYPE_H_INCLUDED
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
pop_min_price = 0;
|
pop_min_price = 0;
|
||||||
pop_max_price = 0;
|
pop_max_price = 0;
|
||||||
pop_carry_over = -1;
|
pop_carry_over = -1;
|
||||||
|
pop_carry_over_option_id = -1;
|
||||||
|
pop_prepaid_option_id = -1;
|
||||||
pop_carry_over_target = false;
|
pop_carry_over_target = false;
|
||||||
pop_carry_over_time_range_id = -1;
|
pop_carry_over_time_range_id = -1;
|
||||||
pop_carry_over_start_time_range = -1;
|
pop_carry_over_start_time_range = -1;
|
||||||
@ -44,6 +46,8 @@ public:
|
|||||||
double pop_min_price;
|
double pop_min_price;
|
||||||
double pop_max_price;
|
double pop_max_price;
|
||||||
int pop_carry_over;
|
int pop_carry_over;
|
||||||
|
int pop_carry_over_option_id;
|
||||||
|
int pop_prepaid_option_id;
|
||||||
bool pop_carry_over_target;
|
bool pop_carry_over_target;
|
||||||
int pop_carry_over_time_range_id;
|
int pop_carry_over_time_range_id;
|
||||||
int pop_carry_over_start_time_range;
|
int pop_carry_over_start_time_range;
|
||||||
|
70
library/include/mobilisis/tariff_carryover.h
Normal file
70
library/include/mobilisis/tariff_carryover.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#ifndef TARIFF_CARRYOVER_H_INCLUDED
|
||||||
|
#define TARIFF_CARRYOVER_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
struct ATBCarryOver {
|
||||||
|
struct week {
|
||||||
|
int day;
|
||||||
|
bool seemless;
|
||||||
|
bool never;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
} carryover[8];
|
||||||
|
|
||||||
|
int id;
|
||||||
|
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBCarryOver const &co) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id:" << co.id << "\n"
|
||||||
|
<< " **** Monday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Monday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Monday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Monday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Monday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Monday].never << "\n"
|
||||||
|
<< " **** Tuesday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Tuesday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Tuesday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Tuesday].never << "\n"
|
||||||
|
<< " **** Wednesday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Wednesday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Wednesday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Wednesday].never << "\n"
|
||||||
|
<< " **** Thursday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Thursday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Thursday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Thursday].never << "\n"
|
||||||
|
<< " **** Friday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Friday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Friday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Friday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Friday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Friday].never << "\n"
|
||||||
|
<< " **** Saturday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Saturday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Saturday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Saturday].never << "\n"
|
||||||
|
<< " **** Sunday **** \n"
|
||||||
|
<< " day: " << co.carryover[(int)Qt::Sunday].day << "\n"
|
||||||
|
<< " static_start: " << co.carryover[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << co.carryover[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << co.carryover[(int)Qt::Sunday].seemless << "\n"
|
||||||
|
<< " never: " << co.carryover[(int)Qt::Sunday].never << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_CARRYOVER_H_INCLUDED
|
89
library/include/mobilisis/tariff_interpolation.h
Normal file
89
library/include/mobilisis/tariff_interpolation.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#ifndef TARIFF_INTERPOLATION_H_INCLUDED
|
||||||
|
#define TARIFF_INTERPOLATION_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct ATBInterpolation {
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
NO_INTERPOLATION = 1,
|
||||||
|
STATIC_WALLCLOCK_TIME_VALUES = 2,
|
||||||
|
STATIC_TIMEPOINT_AND_DURATION = 3,
|
||||||
|
DYNAMIC_TIMEPOINT_AND_STATIC_DURATION = 4,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION = 5,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE = 6,
|
||||||
|
DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
static QString name(int i) {
|
||||||
|
switch(i) {
|
||||||
|
case (int)(NO_INTERPOLATION):
|
||||||
|
return QString("%1: NO_INTERPOLATION").arg(i);
|
||||||
|
case (int)(STATIC_WALLCLOCK_TIME_VALUES):
|
||||||
|
return QString("%1: STATIC_WALLCLOCK_TIME_VALUES").arg(i);
|
||||||
|
case (int)(STATIC_TIMEPOINT_AND_DURATION):
|
||||||
|
return QString("%1: STATIC_TIMEPOINT_AND_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_TIMEPOINT_AND_STATIC_DURATION):
|
||||||
|
return QString("%1: DYNAMIC_TIMEPOINT_AND_STATIC_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_DURATION").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_PRICE").arg(i);
|
||||||
|
case (int)(DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME):
|
||||||
|
return QString("%1: DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME").arg(i);
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit ATBInterpolation()
|
||||||
|
: id(0)
|
||||||
|
, static_start(QTime())
|
||||||
|
, static_end(QTime())
|
||||||
|
, static_start_str(QString())
|
||||||
|
, static_end_str(QString())
|
||||||
|
, static_duration(0)
|
||||||
|
, dynamic_start(QTime())
|
||||||
|
, dynamic_end(QTime())
|
||||||
|
, dynamic_start_str(QString())
|
||||||
|
, dynamic_end_str(QString())
|
||||||
|
, dynamic_duration(0)
|
||||||
|
, dynamic_until_price(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int id;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
QString static_start_str;
|
||||||
|
QString static_end_str;
|
||||||
|
int static_duration;
|
||||||
|
QTime dynamic_start;
|
||||||
|
QTime dynamic_end;
|
||||||
|
QString dynamic_start_str;
|
||||||
|
QString dynamic_end_str;
|
||||||
|
int dynamic_duration;
|
||||||
|
int dynamic_until_price;
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBInterpolation const &i) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id: " << name(i.id) << "\n"
|
||||||
|
<< " static_start: " << i.static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << i.static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_start_str: " << i.static_start_str << "\n"
|
||||||
|
<< " static_end_str: " << i.static_end_str << "\n"
|
||||||
|
<< " static_duration: " << i.static_duration << "\n"
|
||||||
|
<< " dynamic_start: " << i.dynamic_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " dynamic_end: " << i.dynamic_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " dynamic_start_str: " << i.dynamic_start_str << "\n"
|
||||||
|
<< " dynamic_end_str: " << i.dynamic_end_str << "\n"
|
||||||
|
<< " dynamic_duration: " << i.dynamic_duration << "\n"
|
||||||
|
<< "dynamic_until_price: " << i.dynamic_until_price << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_INTERPOLATION_H_INCLUDED
|
@ -13,7 +13,13 @@ enum class PERMIT_TYPE : quint8 {
|
|||||||
DAY_TICKET_CHILD=6,
|
DAY_TICKET_CHILD=6,
|
||||||
INVALID=7,
|
INVALID=7,
|
||||||
FOOD_STAMP=8,
|
FOOD_STAMP=8,
|
||||||
TWENTY_FOUR_HOURS_TICKET=9
|
TWENTY_FOUR_HOURS_TICKET=9,
|
||||||
|
SHORT_TERM_PARKING_PKW=10,
|
||||||
|
SHORT_TERM_PARKING_BUS=11,
|
||||||
|
SHORT_TERM_PARKING_CAMPER=12,
|
||||||
|
DAY_TICKET_PKW=13,
|
||||||
|
DAY_TICKET_BUS=14,
|
||||||
|
DAY_TICKET_CAMPER=15
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PermitType {
|
struct PermitType {
|
||||||
@ -43,12 +49,30 @@ struct PermitType {
|
|||||||
case 6:
|
case 6:
|
||||||
m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
|
m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
m_permitType = PERMIT_TYPE::FOOD_STAMP;
|
m_permitType = PERMIT_TYPE::FOOD_STAMP;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 9:
|
||||||
m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
|
m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
|
||||||
break;
|
break;
|
||||||
|
case 10:
|
||||||
|
m_permitType = PERMIT_TYPE::SHORT_TERM_PARKING_PKW;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
m_permitType = PERMIT_TYPE::SHORT_TERM_PARKING_BUS;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
m_permitType = PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
m_permitType = PERMIT_TYPE::DAY_TICKET_PKW;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
m_permitType = PERMIT_TYPE::DAY_TICKET_BUS;
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
m_permitType = PERMIT_TYPE::DAY_TICKET_CAMPER;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_permitType = PERMIT_TYPE::INVALID;
|
m_permitType = PERMIT_TYPE::INVALID;
|
||||||
}
|
}
|
||||||
@ -77,14 +101,25 @@ struct PermitType {
|
|||||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||||
return 6;
|
return 6;
|
||||||
case PERMIT_TYPE::FOOD_STAMP:
|
case PERMIT_TYPE::FOOD_STAMP:
|
||||||
return 7;
|
|
||||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
|
||||||
return 8;
|
return 8;
|
||||||
|
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||||
|
return 9;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
|
||||||
|
return 10;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
|
||||||
|
return 11;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||||
|
return 12;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||||
|
return 13;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_BUS:
|
||||||
|
return 14;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_CAMPER:
|
||||||
|
return 15;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 7;
|
return 7;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toString() {
|
QString toString() {
|
||||||
@ -107,6 +142,18 @@ struct PermitType {
|
|||||||
return QString("FOOD_STAMP");
|
return QString("FOOD_STAMP");
|
||||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||||
return QString("TWENTY_FOUR_HOURS_TICKET");
|
return QString("TWENTY_FOUR_HOURS_TICKET");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
|
||||||
|
return QString("SHORT_TERM_PARKING_PKW");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
|
||||||
|
return QString("SHORT_TERM_PARKING_BUS");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||||
|
return QString("SHORT_TERM_PARKING_CAMPER");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||||
|
return QString("DAY_TICKET_PKW");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_BUS:
|
||||||
|
return QString("DAY_TICKET_BUS");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_CAMPER:
|
||||||
|
return QString("DAY_TICKET_CAMPER");
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -133,6 +180,18 @@ struct PermitType {
|
|||||||
return QString("FOOD_STAMP");
|
return QString("FOOD_STAMP");
|
||||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
|
||||||
return QString("TWENTY_FOUR_HOURS_TICKET");
|
return QString("TWENTY_FOUR_HOURS_TICKET");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
|
||||||
|
return QString("SHORT_TERM_PARKING_PKW");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
|
||||||
|
return QString("SHORT_TERM_PARKING_BUS");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||||
|
return QString("SHORT_TERM_PARKING_CAMPER");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||||
|
return QString("DAY_TICKET_PKW");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_BUS:
|
||||||
|
return QString("DAY_TICKET_BUS");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_CAMPER:
|
||||||
|
return QString("DAY_TICKET_CAMPER");
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
29
library/include/mobilisis/tariff_prepaid.h
Normal file
29
library/include/mobilisis/tariff_prepaid.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef TARIFF_PREPAID_H_INCLUDED
|
||||||
|
#define TARIFF_PREPAID_H_INCLUDED
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct ATBPrepaid {
|
||||||
|
explicit ATBPrepaid() = default;
|
||||||
|
int id;
|
||||||
|
bool anytime;
|
||||||
|
bool never;
|
||||||
|
QTime static_start;
|
||||||
|
QTime static_end;
|
||||||
|
|
||||||
|
friend QDebug operator<<(QDebug debug, ATBPrepaid const &pp) {
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
|
debug.nospace()
|
||||||
|
<< " id: " << pp.id << "\n"
|
||||||
|
<< " static_start: " << pp.static_start.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " static_end: " << pp.static_end.toString(Qt::ISODate) << "\n"
|
||||||
|
<< " anytime: " << pp.anytime << "\n"
|
||||||
|
<< " never: " << pp.never << "\n";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARIFF_PREPAID_H_INCLUDED
|
@ -84,7 +84,10 @@ HEADERS += \
|
|||||||
include/mobilisis/tariff_timestep_config.h \
|
include/mobilisis/tariff_timestep_config.h \
|
||||||
include/mobilisis/tariff_product.h \
|
include/mobilisis/tariff_product.h \
|
||||||
include/mobilisis/tariff_permit_type.h \
|
include/mobilisis/tariff_permit_type.h \
|
||||||
include/mobilisis/tariff_global_defines.h
|
include/mobilisis/tariff_global_defines.h \
|
||||||
|
include/mobilisis/tariff_interpolation.h \
|
||||||
|
include/mobilisis/tariff_prepaid.h \
|
||||||
|
include/mobilisis/tariff_carryover.h
|
||||||
|
|
||||||
OTHER_FILES += src/main.cpp \
|
OTHER_FILES += src/main.cpp \
|
||||||
../tariffs/tariff_korneuburg.json \
|
../tariffs/tariff_korneuburg.json \
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "tariff_time_range.h"
|
#include "tariff_time_range.h"
|
||||||
#include "ticket.h"
|
#include "ticket.h"
|
||||||
#include "tariff_global_defines.h"
|
#include "tariff_global_defines.h"
|
||||||
|
#include "tariff_prepaid.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -2090,6 +2091,9 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
|||||||
return QList<int>();
|
return QList<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define DEBUG_GET_TIME_STEPS (1)
|
||||||
|
|
||||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
|
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||||
|
|
||||||
@ -2107,12 +2111,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||||
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||||
|
int const pop_prepaid_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||||
|
|
||||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
||||||
|
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||||
@ -2126,11 +2132,15 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
} else {
|
} else {
|
||||||
uint16_t timeStepCompensation = 0;
|
uint16_t timeStepCompensation = 0;
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
||||||
|
|
||||||
if (pop_carry_over) {
|
if (pop_carry_over) {
|
||||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
||||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range id:" << pop_carry_over_time_range_id;
|
||||||
|
|
||||||
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
if (carryOverTimeRangeFrom.secsTo(carryOverTimeRangeTo) <= 60) { // carry over time point, usually 00:00:00
|
||||||
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||||
@ -2163,7 +2173,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
} else {
|
} else {
|
||||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->Duration.erase(search);
|
cfg->Duration.erase(search);
|
||||||
@ -2174,8 +2184,158 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
m_timeSteps[paymentOptionIndex].clear();
|
||||||
|
|
||||||
|
std::optional<QDateTime> adaptedStart = cfg->adaptStart(start, pop_prepaid_option_id);
|
||||||
|
if (adaptedStart) {
|
||||||
|
start = adaptedStart.value();
|
||||||
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
auto search = cfg->Duration.find(durationId);
|
||||||
|
if (search != cfg->Duration.end()) {
|
||||||
|
ATBDuration duration = search->second;
|
||||||
|
|
||||||
|
if (duration.pun_interpolation_id == -1) {
|
||||||
|
|
||||||
|
// should never happen -> misconfigured tariff-file
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") ERROR pun_interpolation not set!";
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") See for instance customer_505/6";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
|
||||||
|
if (ipolCheck) {
|
||||||
|
ATBInterpolation interpolation = ipolCheck.value();
|
||||||
|
|
||||||
|
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_END_TIME) {
|
||||||
|
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
|
int const end_time = interpolation.dynamic_end.hour() * 60 + interpolation.dynamic_end.minute();
|
||||||
|
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
||||||
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
||||||
|
|
||||||
|
QDateTime carryOver = start;
|
||||||
|
carryOver.setTime(interpolation.dynamic_end);
|
||||||
|
|
||||||
|
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
|
int nextTimeStep = start_time + duration.pun_duration;
|
||||||
|
int rest = end_time - nextTimeStep;
|
||||||
|
if (nextTimeStep <= end_time) {
|
||||||
|
|
||||||
|
if (durationId == 1) {
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_interpolation:" << duration.pun_interpolation_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end:" << interpolation.dynamic_end.toString(Qt::ISODate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int const timeStep = nextTimeStep;
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step:" << timeStep;
|
||||||
|
|
||||||
|
if (timeStep < duration.pun_duration_min || timeStep > duration.pun_duration_max) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||||
|
<< QString("ERROR timeStep (%1) < durationMin (%2) || timeStep (%3)) > durationMax (%4)")
|
||||||
|
.arg(timeStep).arg(duration.pun_duration_min)
|
||||||
|
.arg(timeStep).arg(duration.pun_duration_max);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
|
// set dynamic minimal parking time
|
||||||
|
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep;
|
||||||
|
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
|
duration.pun_duration = timeStep;
|
||||||
|
timeStepCompensation = end_time - start_time;
|
||||||
|
|
||||||
|
if (duration.pun_duration > 0) {
|
||||||
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
// timeStepComp: added to (otherwise static) time-steps
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration_max:" << duration.pun_duration_max;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration.pun_duration:" << duration.pun_duration;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
duration.pun_duration = nextTimeStep;
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
QTime nextTime(0, 0, 0);
|
||||||
|
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (duration.pun_duration > 0) {
|
||||||
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (rest > 0) {
|
||||||
|
// last time step before swicthing to dayticket (see Schnals 505/506)
|
||||||
|
duration.pun_duration = duration.pun_duration_max;
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
QTime nextTime(0, 0, 0);
|
||||||
|
nextTime = nextTime.addSecs(duration.pun_duration * 60);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTime.toString(Qt::ISODate);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun id:" << duration.pun_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (duration.pun_duration > 0) {
|
||||||
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg->Duration.erase(search);
|
||||||
|
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration_max:" << duration.pun_duration_max;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step compensation:" << timeStepCompensation;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
duration.pun_duration += start_time + timeStepCompensation;
|
||||||
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
|
|
||||||
|
cfg->Duration.erase(search);
|
||||||
|
cfg->Duration.insert(pair<int, ATBDuration>(duration.pun_id, duration));
|
||||||
|
} else {
|
||||||
|
cfg->Duration.erase(search);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
} else { // if (carryOverTimeRangeFrom == carryOverTimeRangeTo) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@ -2203,9 +2363,22 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
|
|||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||||
|
|
||||||
|
#if DEBUG_GET_TIME_STEPS==1
|
||||||
|
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||||
|
QDateTime nextTime = start;
|
||||||
|
nextTime.setTime(QTime(0, 0, 0));
|
||||||
|
nextTime = nextTime.addSecs(m_timeSteps[paymentOptionIndex][i] * 60);
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") step"
|
||||||
|
<< i << m_timeSteps[0][i] << "->" << nextTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return m_timeSteps[paymentOptionIndex];
|
return m_timeSteps[paymentOptionIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef DEBUG_GET_TIME_STEPS
|
||||||
|
|
||||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const {
|
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const {
|
||||||
|
|
||||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "tariff_permit_type.h"
|
#include "tariff_permit_type.h"
|
||||||
#include "tariff_business_hours.h"
|
#include "tariff_business_hours.h"
|
||||||
#include "tariff_global_defines.h"
|
#include "tariff_global_defines.h"
|
||||||
|
#include "tariff_carryover.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -30,6 +31,9 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
|||||||
if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType;
|
if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType;
|
||||||
if (strcmp(member_name, "TimeStepConfig") == 0) return MemberType::TimeStepConfigType;
|
if (strcmp(member_name, "TimeStepConfig") == 0) return MemberType::TimeStepConfigType;
|
||||||
if (strcmp(member_name, "Product") == 0) return MemberType::ProductType;
|
if (strcmp(member_name, "Product") == 0) return MemberType::ProductType;
|
||||||
|
if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
|
||||||
|
if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
|
||||||
|
if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
|
||||||
else return MemberType::UnknownType;
|
else return MemberType::UnknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +104,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
ATBTimeRange TimeRange;
|
ATBTimeRange TimeRange;
|
||||||
ATBTimeStepConfig TimeStepConfig;
|
ATBTimeStepConfig TimeStepConfig;
|
||||||
ATBTariffProduct TariffProduct;
|
ATBTariffProduct TariffProduct;
|
||||||
|
ATBInterpolation TariffInterpolation;
|
||||||
|
ATBPrepaid TariffPrepaidOption;
|
||||||
|
ATBCarryOver TariffCarryOver;
|
||||||
|
|
||||||
MemberType mb_type = MemberType::UnknownType;
|
MemberType mb_type = MemberType::UnknownType;
|
||||||
this->currentPaymentOptions.clear();
|
this->currentPaymentOptions.clear();
|
||||||
@ -164,6 +171,167 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
{
|
{
|
||||||
case MemberType::UnknownType:
|
case MemberType::UnknownType:
|
||||||
break;
|
break;
|
||||||
|
case MemberType::CarryOverType: {
|
||||||
|
if (QString(inner_obj_name) == QString("carry_over_id")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const &x = k->value.GetInt();
|
||||||
|
TariffCarryOver.id = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("carry_over_week")) {
|
||||||
|
if (k->value.IsArray()) {
|
||||||
|
auto days = k->value.GetArray();
|
||||||
|
for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
|
||||||
|
if (days[j].IsObject()) {
|
||||||
|
auto weekday = days[j].GetObject();
|
||||||
|
for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
|
||||||
|
int day = j+1; // 8 entries
|
||||||
|
QString member(QString::fromStdString(w->name.GetString()));
|
||||||
|
if (member == "carry_over_day") {
|
||||||
|
if (w->value.IsInt()) {
|
||||||
|
rapidjson::SizeType const d = w->value.GetInt();
|
||||||
|
if (d != (j+1)) {
|
||||||
|
qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
|
||||||
|
}
|
||||||
|
TariffCarryOver.carryover[day].day = day;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (member == "carry_over_seemless") {
|
||||||
|
if (w->value.IsBool()) {
|
||||||
|
bool b = w->value.GetBool();
|
||||||
|
TariffCarryOver.carryover[day].seemless = b;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (member == "carry_over_never") {
|
||||||
|
if (w->value.IsBool()) {
|
||||||
|
bool b = w->value.GetBool();
|
||||||
|
TariffCarryOver.carryover[day].never = b;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (member == "carry_over_static_start") {
|
||||||
|
if (w->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||||
|
TariffCarryOver.carryover[day].static_start = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (member == "carry_over_static_end") {
|
||||||
|
if (w->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
||||||
|
TariffCarryOver.carryover[day].static_end = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case MemberType::PrepaidType: {
|
||||||
|
if (QString(inner_obj_name) == QString("prepaid_id")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const &x = k->value.GetInt();
|
||||||
|
TariffPrepaidOption.id = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("prepaid_anytime")) {
|
||||||
|
if (k->value.IsBool()) {
|
||||||
|
bool const &x = k->value.GetBool();
|
||||||
|
TariffPrepaidOption.anytime = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("prepaid_never")) {
|
||||||
|
if (k->value.IsBool()) {
|
||||||
|
bool const &x = k->value.GetBool();
|
||||||
|
TariffPrepaidOption.never = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("prepaid_static_start")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffPrepaidOption.static_start = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("prepaid_static_end")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffPrepaidOption.static_end = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case MemberType::InterpolationType: {
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_id")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const &x = k->value.GetInt();
|
||||||
|
TariffInterpolation.id = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_static_start")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffInterpolation.static_start = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_static_end")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffInterpolation.static_end = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_static_start_str")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QString const &s = k->value.GetString();
|
||||||
|
TariffInterpolation.static_start_str = s;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_static_end_str")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QString const &s = k->value.GetString();
|
||||||
|
TariffInterpolation.static_end_str = s;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_static_duration")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const x = k->value.GetInt();
|
||||||
|
TariffInterpolation.static_duration = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_start")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffInterpolation.dynamic_start = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_end")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
|
||||||
|
TariffInterpolation.dynamic_end = t;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_start_str")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QString const &s = k->value.GetString();
|
||||||
|
TariffInterpolation.dynamic_start_str = s;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_end_str")) {
|
||||||
|
if (k->value.IsString()) {
|
||||||
|
QString const &s = k->value.GetString();
|
||||||
|
TariffInterpolation.dynamic_end_str = s;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_duration")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const x = k->value.GetInt();
|
||||||
|
TariffInterpolation.dynamic_duration = x;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (QString(inner_obj_name) == QString("interpol_dynamic_until_price")) {
|
||||||
|
if (k->value.IsInt()) {
|
||||||
|
int const x = k->value.GetInt();
|
||||||
|
TariffInterpolation.dynamic_until_price = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case MemberType::ProductType: {
|
case MemberType::ProductType: {
|
||||||
if (QString(inner_obj_name) == QString("tariff_product_id")) {
|
if (QString(inner_obj_name) == QString("tariff_product_id")) {
|
||||||
if (k->value.IsInt()) {
|
if (k->value.IsInt()) {
|
||||||
@ -413,6 +581,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
||||||
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
||||||
|
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) {
|
||||||
|
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
||||||
|
} else if (strcmp(inner_obj_name, "pop_carry_over_option_id") == 0) {
|
||||||
|
this->currentPaymentOptions.last().pop_carry_over_option_id = k->value.GetInt();
|
||||||
} else if (strcmp(inner_obj_name, "pop_carry_over") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_carry_over") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_carry_over = k->value.GetInt();
|
this->currentPaymentOptions.last().pop_carry_over = k->value.GetInt();
|
||||||
} else if (strcmp(inner_obj_name, "pop_carry_over_time_range_id") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_carry_over_time_range_id") == 0) {
|
||||||
@ -499,6 +671,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
else if (strcmp(inner_obj_name, "pun_duration") == 0) Duration.pun_duration = k->value.GetDouble();
|
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_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_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;
|
break;
|
||||||
case MemberType::SpecialDaysWorktimeType:
|
case MemberType::SpecialDaysWorktimeType:
|
||||||
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
||||||
@ -562,6 +735,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
} break;
|
} break;
|
||||||
case MemberType::DurationType:
|
case MemberType::DurationType:
|
||||||
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
|
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
|
||||||
|
// qCritical() << Duration;
|
||||||
break;
|
break;
|
||||||
case MemberType::SpecialDaysWorktimeType:
|
case MemberType::SpecialDaysWorktimeType:
|
||||||
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
|
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
|
||||||
@ -602,6 +776,19 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
case MemberType::ProductType:
|
case MemberType::ProductType:
|
||||||
cfg->TariffProduct.insert(pair<int, ATBTariffProduct>(TariffProduct.m_tariff_product_id, TariffProduct));
|
cfg->TariffProduct.insert(pair<int, ATBTariffProduct>(TariffProduct.m_tariff_product_id, TariffProduct));
|
||||||
qCritical() << TariffProduct;
|
qCritical() << TariffProduct;
|
||||||
|
break;
|
||||||
|
case MemberType::InterpolationType:
|
||||||
|
cfg->TariffInterpolations.insert(pair<int, ATBInterpolation>(TariffInterpolation.id, TariffInterpolation));
|
||||||
|
qCritical() << TariffInterpolation;
|
||||||
|
break;
|
||||||
|
case MemberType::PrepaidType:
|
||||||
|
cfg->TariffPrepaidOptions.insert(pair<int, ATBPrepaid>(TariffPrepaidOption.id, TariffPrepaidOption));
|
||||||
|
qCritical() << TariffPrepaidOption;
|
||||||
|
break;
|
||||||
|
case MemberType::CarryOverType:
|
||||||
|
cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
|
||||||
|
qCritical() << TariffCarryOver;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -840,6 +1027,47 @@ Configuration::getDailyTicketsForAllKeys() const {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<ATBInterpolation> Configuration::getInterpolationType(int key) const {
|
||||||
|
std::optional<ATBInterpolation> value;
|
||||||
|
for (auto[it, rangeEnd] = this->TariffInterpolations.equal_range(key); it != rangeEnd; ++it) {
|
||||||
|
value = value.value_or(it->second);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ATBPrepaid> Configuration::getPrepaidType(int key) const {
|
||||||
|
std::optional<ATBPrepaid> value;
|
||||||
|
for (auto[it, rangeEnd] = this->TariffPrepaidOptions.equal_range(key); it != rangeEnd; ++it) {
|
||||||
|
value = value.value_or(it->second);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<QDateTime> Configuration::adaptStart(QDateTime const &start, int prepaid_option_id) {
|
||||||
|
std::optional<QDateTime> value;
|
||||||
|
QDateTime s = start;
|
||||||
|
|
||||||
|
std::optional<ATBPrepaid> prepaid_option = getPrepaidType(prepaid_option_id);
|
||||||
|
if (prepaid_option.has_value()) {
|
||||||
|
ATBPrepaid prepaid = prepaid_option.value();
|
||||||
|
if (prepaid.anytime == true) {
|
||||||
|
int const weekdayId = s.date().dayOfWeek();
|
||||||
|
QTime worktime_from = QTime::fromString(WeekDaysWorktime.find(weekdayId)->second.pwd_time_from.c_str(), Qt::ISODate);
|
||||||
|
QTime worktime_to = QTime::fromString(WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str(), Qt::ISODate);
|
||||||
|
if (s.time() < worktime_from) {
|
||||||
|
s.setTime(worktime_from);
|
||||||
|
} else
|
||||||
|
if (worktime_to < s.time()) {
|
||||||
|
s = start.addDays(1);
|
||||||
|
s.setTime(worktime_from);
|
||||||
|
}
|
||||||
|
s.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||||
|
value = value.value_or(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<QVector<ATBDailyTicket>>
|
std::optional<QVector<ATBDailyTicket>>
|
||||||
Configuration::getDailyTicketsForKey(int key) const {
|
Configuration::getDailyTicketsForKey(int key) const {
|
||||||
QVector<ATBDailyTicket> tickets;
|
QVector<ATBDailyTicket> tickets;
|
||||||
|
186
main/main.cpp
186
main/main.cpp
@ -48,7 +48,9 @@ extern "C" char* strptime(const char* s,
|
|||||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||||
#define NEUHAUSER_STOCKERAU (0)
|
#define NEUHAUSER_STOCKERAU (0)
|
||||||
#define KLEIPEDA_LITAUEN (0)
|
#define KLEIPEDA_LITAUEN (0)
|
||||||
#define SEXTEN (1)
|
#define SEXTEN (0)
|
||||||
|
#define SCHNALS_LEITER_KIRCHL (1)
|
||||||
|
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||||
|
|
||||||
#if NEUHAUSER_KIRCHDORF==1
|
#if NEUHAUSER_KIRCHDORF==1
|
||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||||
@ -209,8 +211,20 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
|
|||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
#if 0
|
|
||||||
|
|
||||||
|
|
||||||
|
//487 {
|
||||||
|
// 488 "pra_payment_option_id": 1049,
|
||||||
|
// 489 "pra_payment_unit_id": 84,
|
||||||
|
// 490 "pra_price":"840"
|
||||||
|
//>>491 }
|
||||||
|
|
||||||
|
//for (int i = 1; i < 85; ++i) {
|
||||||
|
//printf("{\n \"\pra_payment_option_id\": 1049,\n \"\pra_payment_unit_id\": %d,\n \"pra_price\": %d\n},\n",
|
||||||
|
// i, i*10);
|
||||||
|
//}
|
||||||
|
//return 0;
|
||||||
|
#if 0
|
||||||
MessageHelper msgHelp;
|
MessageHelper msgHelp;
|
||||||
// msgHelp.createLoginMessageChunksToSend(0x02);
|
// msgHelp.createLoginMessageChunksToSend(0x02);
|
||||||
msgHelp.createAuthorizeMessageChunksToSend(0x02);
|
msgHelp.createAuthorizeMessageChunksToSend(0x02);
|
||||||
@ -537,10 +551,10 @@ int main() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||||
for (int minutes = 480; minutes < 481; minutes += 1) {
|
for (int minutes = 0; minutes < 1440; minutes += 1) {
|
||||||
QDateTime start = s.addSecs(minutes * 60);
|
QDateTime start = s.addSecs(minutes * 60);
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
QDateTime effectiveStart = start;
|
QDateTime effectiveStart = start;
|
||||||
|
|
||||||
@ -554,14 +568,15 @@ int main() {
|
|||||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 100; i <= 100; i += 10) {
|
for (int i = 10; i <= 400; i += 10) {
|
||||||
//for (int i = 2100; i <= 2100; i += 10) {
|
//for (int i = 2100; i <= 2100; i += 10) {
|
||||||
cost = i;
|
cost = i;
|
||||||
|
|
||||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||||
|
|
||||||
|
|
||||||
qCritical() << "end" << end.toString(Qt::ISODate);
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||||
|
<< "> end" << end.toString(Qt::ISODate);
|
||||||
|
|
||||||
durationInMinutes = pop_min_time;
|
durationInMinutes = pop_min_time;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -599,7 +614,7 @@ int main() {
|
|||||||
if (!cs) {
|
if (!cs) {
|
||||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << cs.toString();
|
// qCritical() << cs.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -620,6 +635,163 @@ int main() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (SCHNALS_LEITER_KIRCHL==1 || SCHNALS_STAUMAUER==1)
|
||||||
|
std::ifstream input;
|
||||||
|
int pop_min_time;
|
||||||
|
int pop_max_time;
|
||||||
|
int pop_min_price;
|
||||||
|
int pop_max_price;
|
||||||
|
int pop_daily_card_price;
|
||||||
|
|
||||||
|
input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
||||||
|
//input.open("/opt/ptu5/opt/customer_506/etc/psa_tariff/tariff01.json");
|
||||||
|
|
||||||
|
std::stringstream sstr;
|
||||||
|
while(input >> sstr.rdbuf());
|
||||||
|
std::string json(sstr.str());
|
||||||
|
|
||||||
|
Configuration cfg;
|
||||||
|
|
||||||
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
if (isParsed) {
|
||||||
|
pop_min_time = get_minimal_parkingtime(&cfg);
|
||||||
|
pop_max_time = get_maximal_parkingtime(&cfg);
|
||||||
|
pop_min_price = get_minimal_parkingprice(&cfg);
|
||||||
|
pop_max_price = get_maximal_parkingprice(&cfg);
|
||||||
|
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||||
|
|
||||||
|
qCritical() << " pop_min_time: " << pop_min_time;
|
||||||
|
qCritical() << " pop_max_time: " << pop_max_time;
|
||||||
|
qCritical() << " pop_min_price: " << pop_min_price;
|
||||||
|
qCritical() << " pop_max_price: " << pop_max_price;
|
||||||
|
|
||||||
|
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||||
|
qCritical() << "TimeSteps" << timeSteps;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
CalcState cs;
|
||||||
|
double cost;
|
||||||
|
int durationInMinutes = 0;
|
||||||
|
int offsetInMinutes = 0;
|
||||||
|
|
||||||
|
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
|
||||||
|
for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
|
||||||
|
QDateTime s(QDate(2024, 7, 14 + day), QTime());
|
||||||
|
QDateTime end;
|
||||||
|
|
||||||
|
switch (day) {
|
||||||
|
case (int)Qt::Monday:
|
||||||
|
qCritical() << "Monday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Tuesday:
|
||||||
|
qCritical() << "Tuesday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Wednesday:
|
||||||
|
qCritical() << "Wednesday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Thursday:
|
||||||
|
qCritical() << "Thursday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Friday:
|
||||||
|
qCritical() << "Friday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Saturday:
|
||||||
|
qCritical() << "Saturday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Sunday:
|
||||||
|
qCritical() << "Sunday";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||||
|
for (int minutes = 420; minutes < 420; minutes += 1) {
|
||||||
|
QDateTime start = s.addSecs(minutes * 60);
|
||||||
|
|
||||||
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
QDateTime effectiveStart = start;
|
||||||
|
|
||||||
|
// hier sollte man auch testen was passiert, falls man ausserhalb
|
||||||
|
// der verkaufsdaten steht
|
||||||
|
if (start.time() < QTime(8, 0, 0)) {
|
||||||
|
effectiveStart.setTime(QTime(8, 0, 0));
|
||||||
|
} else
|
||||||
|
if (start.time() <= QTime(19, 0, 0)) {
|
||||||
|
effectiveStart = start;
|
||||||
|
} else {
|
||||||
|
effectiveStart = start.addDays(1);
|
||||||
|
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 10; i <= 400; i += 10) {
|
||||||
|
//for (int i = 2100; i <= 2100; i += 10) {
|
||||||
|
cost = i;
|
||||||
|
|
||||||
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||||
|
|
||||||
|
|
||||||
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||||
|
<< "> end" << end.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
durationInMinutes = pop_min_time;
|
||||||
|
if (i > 0) {
|
||||||
|
durationInMinutes += (i/10) * 4;
|
||||||
|
}
|
||||||
|
offsetInMinutes = 0;
|
||||||
|
|
||||||
|
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
|
||||||
|
if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
|
||||||
|
offsetInMinutes = 780; // 19:00 -> 8:00
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
i += 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||||
|
|
||||||
|
if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
|
||||||
|
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
||||||
|
qCritical() << "| cost ............................." << cost;
|
||||||
|
qCritical() << "| durationInMinutes ................" << durationInMinutes
|
||||||
|
<< "(" << (durationInMinutes - 60) << "+ 60 )";
|
||||||
|
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
||||||
|
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cs) {
|
||||||
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||||
|
} else {
|
||||||
|
// qCritical() << cs.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
|
||||||
|
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||||
|
qCritical() << __LINE__ << "cost ............................." << cost;
|
||||||
|
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
|
||||||
|
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
|
||||||
|
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||||
|
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||||
|
exit(-1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if NEUHAUSER_STOCKERAU==1
|
#if NEUHAUSER_STOCKERAU==1
|
||||||
std::ifstream input;
|
std::ifstream input;
|
||||||
int pop_min_time;
|
int pop_min_time;
|
||||||
|
Loading…
Reference in New Issue
Block a user