Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
16ccb706da
|
|||
fcbc8dcdc3 | |||
ed99bae725 | |||
627d14204d | |||
d8a4c4eaa7
|
|||
4f45db4fde | |||
a744a1ebb3 | |||
df16bd7f9c | |||
b751ba339e |
@@ -11,6 +11,7 @@ enum class PERMIT_TYPE : quint8 {
|
||||
DAY_TICKET_ADULT,
|
||||
DAY_TICKET_TEEN,
|
||||
DAY_TICKET_CHILD,
|
||||
FOOD_STAMP,
|
||||
INVALID
|
||||
};
|
||||
|
||||
@@ -41,6 +42,9 @@ struct PermitType {
|
||||
case 6:
|
||||
m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
|
||||
break;
|
||||
case 7:
|
||||
m_permitType = PERMIT_TYPE::FOOD_STAMP;
|
||||
break;
|
||||
default:
|
||||
m_permitType = PERMIT_TYPE::INVALID;
|
||||
}
|
||||
@@ -52,7 +56,7 @@ struct PermitType {
|
||||
|
||||
operator PERMIT_TYPE() const { return m_permitType; }
|
||||
|
||||
operator int() const {
|
||||
operator int () const {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return 0;
|
||||
@@ -68,6 +72,8 @@ struct PermitType {
|
||||
return 5;
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return 6;
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return 7;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -75,7 +81,7 @@ struct PermitType {
|
||||
|
||||
}
|
||||
|
||||
operator QString() const {
|
||||
operator QString () {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
@@ -91,6 +97,32 @@ struct PermitType {
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QString("INVALID");
|
||||
}
|
||||
|
||||
operator QString () const {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
return QString("DAY_TICKET");
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||
return QString("DAY_TICKET_ADULT");
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
return QString("DAY_TICKET_CHILD");
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
return QString("DAY_TICKET_TEEN");
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||
return QString("SHORT_TERM_PARKING");
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
return QString("SZEGED_START");
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
return QString("SZEGED_STOP");
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
return QString("FOOD_STAMP");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -85,6 +85,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::FOOD_STAMP:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
|
||||
if (products) {
|
||||
@@ -132,7 +134,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
|
||||
if (pv) {
|
||||
QVector<ATBPaymentRate> const &paymentRate = pv.value();
|
||||
if (paymentRate.size() > 0) {
|
||||
int const price = paymentRate.at(0).pra_price; // price is given per hour
|
||||
int const price = paymentRate.last().pra_price; // price is given per hour
|
||||
maxPrice = qRound((maxTime * price) / 60.0f);
|
||||
}
|
||||
}
|
||||
|
@@ -1736,6 +1736,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
||||
if (dailyTickets) {
|
||||
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
||||
switch (permitType) {
|
||||
case PERMIT_TYPE::FOOD_STAMP: {
|
||||
// TODO
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
std::optional<ATBCustomer> c = cfg->getCustomerForType(ATBCustomer::CustomerType::ADULT);
|
||||
if (c) {
|
||||
|
@@ -569,15 +569,16 @@ int main() {
|
||||
int Up = 1;
|
||||
//compute_next_timestep(&cfg, )
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
for (int i=0; i<timeSteps.size(); ++i) {
|
||||
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
||||
qCritical() << "nextTimeStep" << nextTimeStep;
|
||||
|
||||
// uint32_t price = calculator.GetPriceForTimeStep(&cfg, timeSteps.at(i));
|
||||
// uint32_t duration = calculator.GetDurationForPrice(&cfg, price);
|
||||
// qCritical() << "nextTimeStep relative to start:"
|
||||
// << duration << start.addSecs(duration * 60)
|
||||
// << "(price so far:" << price << ")";
|
||||
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i));
|
||||
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
||||
qCritical() << "nextTimeStep relative to start:"
|
||||
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||
<< "(price so far:" << price << ")";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -639,50 +640,19 @@ int main() {
|
||||
cout << endl;
|
||||
|
||||
if (isParsed) {
|
||||
bool nextDay = false;
|
||||
bool prePaid = false;
|
||||
|
||||
// zone 1 (lila)
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
QDateTime end;
|
||||
int marken[] = { 3*60, 5*60, 10*60};
|
||||
for (int duration = 0; duration < 3; ++duration) {
|
||||
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);
|
||||
|
||||
// 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)
|
||||
// << "cost" << cost
|
||||
// << "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60;
|
||||
}
|
||||
}
|
||||
int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
|
||||
qCritical() << "price food stamp" << price;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_KORNEUBURG==1
|
||||
std::ifstream input("/tmp/tariff_korneuburg.json");
|
||||
std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
|
||||
int pop_max_time;
|
||||
|
||||
std::stringstream sstr;
|
||||
while(input >> sstr.rdbuf());
|
||||
std::string json(sstr.str());
|
||||
|
||||
Calculator calculator;
|
||||
Configuration cfg;
|
||||
|
||||
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||
@@ -704,19 +674,19 @@ int main() {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
//qCritical() << "";
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "end" << end.toString(Qt::ISODate)
|
||||
// << "duration" << duration
|
||||
// << "cost" << cost;
|
||||
|
||||
std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< "duration" << duration
|
||||
<< "cost" << cost;
|
||||
|
||||
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "cost" << cost
|
||||
// << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user