save for the weekend
This commit is contained in:
parent
48fccafe76
commit
34fbefc138
@ -146,8 +146,11 @@ struct CALCULATE_LIBRARY_API CalcState {
|
||||
s = CalcState::ABOVE_MAX_PARKING_TIME;
|
||||
break;
|
||||
}
|
||||
if (m_desc.size() > 0) {
|
||||
return s + ":" + m_desc;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
explicit operator QString () const noexcept {
|
||||
QString s;
|
||||
|
197
main/main.cpp
197
main/main.cpp
@ -45,7 +45,8 @@ extern "C" char* strptime(const char* s,
|
||||
#define BAD_NEUENAHR_AHRWEILER (0)
|
||||
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||
#define NEUHAUSER_STOCKERAU (1)
|
||||
#define NEUHAUSER_STOCKERAU (0)
|
||||
#define KLEIPEDA_LITAUEN (1)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@ -166,8 +167,182 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonValue>
|
||||
|
||||
/*
|
||||
QJsonObject root;
|
||||
QJsonArray PaymentRate;
|
||||
QJsonArray Duration;
|
||||
|
||||
for (int i = 1; i <= 15*15; ++i) {
|
||||
QJsonObject o;
|
||||
o["pra_payment_option_id"] = 1049;
|
||||
o["pra_payment_unit_id"] = i;
|
||||
if (i <= 15) {
|
||||
o["pra_price"] = 0;
|
||||
} else {
|
||||
o["pra_price"] = (i-15)*10;
|
||||
}
|
||||
|
||||
PaymentRate.push_back(o);
|
||||
}
|
||||
for (int i = 1; i <= 15*15; ++i) {
|
||||
QJsonObject o;
|
||||
o["pun_duration"] = i*4;
|
||||
o["pun_id"] = i;
|
||||
o["pun_label"] = QString("%1 min").arg(i*4);
|
||||
Duration.push_back(o);
|
||||
}
|
||||
|
||||
root["PaymentRate"] = PaymentRate;
|
||||
root["Duration"] = Duration;
|
||||
|
||||
qCritical().noquote() << QJsonDocument(root).toJson();
|
||||
|
||||
return 0;
|
||||
*/
|
||||
|
||||
int main() {
|
||||
#if KLEIPEDA_LITAUEN==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_335/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;
|
||||
|
||||
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, 5, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
|
||||
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 = 480; minutes <= 480; minutes += 60) {
|
||||
//for (int minutes = 0; minutes < 1440; minutes += 60) {
|
||||
QDateTime start = s.addSecs(minutes * 60);
|
||||
QDateTime effectiveStart = start;
|
||||
|
||||
if (start.time() < QTime(8, 0, 0)) {
|
||||
effectiveStart.setTime(QTime(8, 0, 0));
|
||||
} else
|
||||
if (start.time() <= QTime(22, 0, 0)) {
|
||||
effectiveStart = start;
|
||||
} else {
|
||||
effectiveStart = start.addDays(1);
|
||||
effectiveStart.setTime(QTime(8, 0, 0)); // next day
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 2100; 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
|
||||
durationInMinutes = pop_min_time;
|
||||
if (i > 0) {
|
||||
durationInMinutes += (i/10) * 4;
|
||||
}
|
||||
offsetInMinutes = 0;
|
||||
|
||||
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(22, 0, 0)) {
|
||||
if (effectiveStart.time().secsTo(QTime(22, 0, 0)) < (durationInMinutes * 60)) {
|
||||
offsetInMinutes = 600; // 22:00 -> 8:00
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
i += 20;
|
||||
}
|
||||
|
||||
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
||||
|
||||
if (day == Qt::Monday && minutes >= 480 && minutes <= 1320) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||
} else {
|
||||
qCritical() << cs.toString();
|
||||
}
|
||||
qCritical() << "start ............................" << start.toString(Qt::ISODate);
|
||||
qCritical() << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
||||
qCritical() << "cost ............................." << cost;
|
||||
qCritical() << "durationInMinutes ................" << durationInMinutes;
|
||||
qCritical() << "offsetInMinutes .................." << offsetInMinutes;
|
||||
qCritical() << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
||||
qCritical() << "end .............................." << end.toString(Qt::ISODate) << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_STOCKERAU==1
|
||||
std::ifstream input;
|
||||
int pop_min_time;
|
||||
@ -199,25 +374,6 @@ int main() {
|
||||
qCritical() << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << " pop_max_price: " << pop_max_price;
|
||||
|
||||
// tests:
|
||||
// 1: Mon-Freitag: jeweils
|
||||
// start 0-8.00
|
||||
// start 8.00-12.00
|
||||
// start 12.00-13.30
|
||||
// start 13.30-18.00
|
||||
// start 18.00-24.00
|
||||
// alle kosten durchspielen
|
||||
// 2. samstag
|
||||
// start 0-8.00
|
||||
// start 8.00-12.00
|
||||
// start nach 12.00
|
||||
// 2. sonntag
|
||||
|
||||
//QDateTime s(QDate(2024, 5, 27), QTime()); // monday
|
||||
//QDateTime s(QDate(2024, 5, 28), QTime()); // tuesday
|
||||
//QDateTime s(QDate(2024, 5, 29), QTime()); // wednesday
|
||||
//QDateTime s(QDate(2024, 5, 30), QTime()); // thursday
|
||||
|
||||
CalcState cs;
|
||||
double const x = 30.0/7.0;
|
||||
double cost;
|
||||
@ -267,7 +423,6 @@ int main() {
|
||||
}
|
||||
|
||||
for (int i = 70; i <= 600; i += 10) {
|
||||
// for (int i = 70; i <= 70; i += 10) {
|
||||
cost = i;
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
durationInMinutes = truncf(x * (i/10));
|
||||
|
Loading…
Reference in New Issue
Block a user