2023-04-28 11:00:01 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <time.h>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
2023-05-15 14:05:55 +02:00
|
|
|
#include <calculate_price.h>
|
|
|
|
|
2023-04-28 11:00:01 +02:00
|
|
|
|
|
|
|
extern "C" char* strptime(const char* s,
|
|
|
|
const char* f,
|
|
|
|
struct tm* tm) {
|
|
|
|
// Isn't the C++ standard lib nice? std::get_time is defined such that its
|
|
|
|
// format parameters are the exact same as strptime. Of course, we have to
|
|
|
|
// create a string stream first, and imbue it with the current C locale, and
|
|
|
|
// we also have to make sure we return the right things if it fails, or
|
|
|
|
// if it succeeds, but this is still far simpler an implementation than any
|
|
|
|
// of the versions in any of the C standard libraries.
|
|
|
|
std::istringstream input(s);
|
|
|
|
input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
|
|
|
|
input >> std::get_time(tm, f);
|
|
|
|
if (input.fail()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return (char*)(s + input.tellg());
|
|
|
|
}
|
|
|
|
#endif
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDateTime>
|
2023-05-12 12:43:07 +02:00
|
|
|
#include <QDir>
|
2024-02-22 08:02:55 +01:00
|
|
|
#include <QFileInfo>
|
2024-06-04 11:27:57 +02:00
|
|
|
#include <QSet>
|
|
|
|
#include <initializer_list>
|
2023-05-12 12:43:07 +02:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include "calculator_functions.h"
|
2024-01-30 14:00:55 +01:00
|
|
|
#include "calculate_price.h"
|
2024-06-26 16:25:23 +02:00
|
|
|
#include <stdlib.h>
|
2023-04-24 15:31:46 +02:00
|
|
|
|
2024-06-05 17:05:19 +02:00
|
|
|
#define SZEGED (0)
|
2024-04-24 10:52:18 +02:00
|
|
|
#define SCHOENAU_KOENIGSEE (0)
|
2024-04-24 11:56:50 +02:00
|
|
|
#define NEUHAUSER_KORNEUBURG (0)
|
2024-04-30 14:09:48 +02:00
|
|
|
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
2024-04-24 13:11:28 +02:00
|
|
|
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
2024-02-15 16:12:10 +01:00
|
|
|
#define NEUHAUSER_BILEXA_GALTUER (0)
|
2024-09-02 16:40:38 +02:00
|
|
|
#define BAD_NEUENAHR_AHRWEILER (1)
|
2024-05-07 16:21:36 +02:00
|
|
|
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
2024-06-04 11:27:57 +02:00
|
|
|
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
2024-06-26 16:25:23 +02:00
|
|
|
#define NEUHAUSER_STOCKERAU (0)
|
2024-08-02 11:13:50 +02:00
|
|
|
#define KLEIPEDA_LITAUEN (0)
|
2024-07-19 14:03:06 +02:00
|
|
|
#define SEXTEN (0)
|
2024-07-29 11:30:36 +02:00
|
|
|
#define SCHNALS_LEITER_KIRCHL (0)
|
2024-07-19 14:03:06 +02:00
|
|
|
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
2024-09-02 16:40:38 +02:00
|
|
|
#define VALSER_ALM (0)
|
2023-12-06 10:52:35 +01:00
|
|
|
|
2024-04-24 11:56:50 +02:00
|
|
|
#if NEUHAUSER_KIRCHDORF==1
|
|
|
|
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
switch (step) {
|
|
|
|
case 30:
|
|
|
|
if (cost != 30) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 30;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 35:
|
|
|
|
if (cost != 40) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 40;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
if (cost != 50) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 50;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 45:
|
|
|
|
if (cost != 60) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 60;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
if (cost != 70) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 70;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 55:
|
|
|
|
if (cost != 80) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 80;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 60:
|
|
|
|
if (cost != 90) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 90;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 65:
|
|
|
|
if (cost != 100) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 100;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 70:
|
|
|
|
if (cost != 110) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 110;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 75:
|
|
|
|
if (cost != 120) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 120;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 80:
|
|
|
|
if (cost != 130) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 130;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 85:
|
|
|
|
if (cost != 140) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 140;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
if (cost != 150) {
|
|
|
|
qCritical() << "ERROR COMPUTING COST"
|
|
|
|
<< "HAVE" << cost
|
|
|
|
<< "SHOULD" << 150;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-06-05 17:05:19 +02:00
|
|
|
#include <cmath>
|
2024-06-07 13:33:04 +02:00
|
|
|
#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;
|
|
|
|
*/
|
2024-04-24 11:56:50 +02:00
|
|
|
|
2024-06-13 17:23:47 +02:00
|
|
|
|
2024-06-26 16:25:23 +02:00
|
|
|
int main() {
|
|
|
|
|
2024-07-19 14:03:06 +02:00
|
|
|
|
|
|
|
//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
|
2024-06-26 16:25:23 +02:00
|
|
|
MessageHelper msgHelp;
|
|
|
|
// msgHelp.createLoginMessageChunksToSend(0x02);
|
|
|
|
msgHelp.createAuthorizeMessageChunksToSend(0x02);
|
2024-06-13 17:23:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
qCritical() << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
|
|
|
|
|
|
|
|
// unsigned static char terminalID[IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE];
|
|
|
|
// unsigned static char terminalAPAK[IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE];
|
|
|
|
strncpy((char *)&terminalID[0], "T-TPS-SELF2002in", IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE);
|
|
|
|
strncpy((char *)&terminalAPAK[0], "8AC304380E0E476BA2558B75DB9E2516", IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE);
|
|
|
|
|
2024-06-26 16:25:23 +02:00
|
|
|
//iuc_asynchpos_command_Login();
|
|
|
|
iuc_asynchpos_command_authorize(1000);
|
|
|
|
|
|
|
|
qCritical() << "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
|
2024-06-13 17:23:47 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
// test aes
|
|
|
|
aes_init();
|
|
|
|
|
|
|
|
uint32_t crc = 0;
|
|
|
|
|
|
|
|
QByteArray a("T-TPS-SELF2002");
|
|
|
|
qCritical() << a.toHex(' ');
|
|
|
|
|
|
|
|
//QByteArray xx("\x0D\x54\x2D\x54\x50\x53\x2D\x53\x45\x4C\x46\x32\x30\x30\x32\x85\x4C\x6F\x67\x69\x6E\x04\x54\x69\x6D\x65\x00\x13\x32\x30\x32\x34\x2d\x30\x36\x2d\x31\x31\x20\x31\x33\x3a\x34\x34\x3a\x33\x35\x00\x02",
|
|
|
|
// 48);
|
|
|
|
|
|
|
|
//QByteArray xx("123456789", 9);
|
|
|
|
|
|
|
|
QByteArray xx("2E5450532D53454C4632303032854C6F67696E0454696D650013323032342d30362d31312031333a34343a333505466C616773000341505300",
|
|
|
|
114);
|
|
|
|
unsigned char bb = 0;
|
|
|
|
//32:4b:e7:4e:1d:d7:b5:ae
|
|
|
|
QByteArray b("\x00\x46\x00\x32\x4b\xe7\x4e\x1d\xd7\xb5\xae\x0E\x54\x2D\x54\x50\x53\x2D\x53\x45\x4C\x46\x32\x30\x30\x32\x85\x4C\x6F\x67\x69\x6E\x04\x54\x69\x6D\x65\x00\x13\x32\x30\x32\x34\x2d\x30\x36\x2d\x31\x31\x20\x31\x33\x3a\x34\x34\x3a\x33\x35\x05\x46\x6C\x61\x67\x73\x00\x03\x41\x50\x53\x00\x02",
|
|
|
|
71);
|
|
|
|
qCritical() << "B" << b.toHex(':');
|
|
|
|
|
|
|
|
for (int i=0; i < b.size(); ++i) {
|
|
|
|
//printf("%d %02x\n", i, (unsigned char)b.at(i));
|
|
|
|
bb = bb ^ b.at(i);
|
|
|
|
}
|
|
|
|
printf("bb=%02x\n", bb);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qCritical() << xx.size() << "xx" << xx.toHex(' ');
|
|
|
|
|
|
|
|
crc = iuc_asynchpos_sub_updateCRC(crc, xx.data(), xx.size());
|
|
|
|
|
|
|
|
printf("111 crc=%04x\n", crc);
|
|
|
|
|
|
|
|
crc = crc32(xx.data(), xx.size());
|
|
|
|
printf("222 crc=%04x\n", crc);
|
|
|
|
|
|
|
|
QByteArray ba("TEST\x0E\x0E\x47\x6B\xA2\x55\x8B\x75\xDB\x9E\x25\x16");
|
|
|
|
|
|
|
|
ba[0] = (crc >> 24);
|
|
|
|
ba[1] = (crc >> 16);
|
|
|
|
ba[2] = (crc >> 8);
|
|
|
|
ba[3] = (crc);
|
|
|
|
|
|
|
|
qCritical() << ba.toHex(' ');
|
|
|
|
|
|
|
|
QDateTime current = QDateTime::currentDateTime();
|
|
|
|
QString const &s = current.toString(Qt::ISODate);
|
|
|
|
QByteArray time(s.toStdString().c_str());
|
|
|
|
time[10] = ' ';
|
|
|
|
|
|
|
|
qCritical() << time.toHex(' ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//unsigned char in[] = "TESTTESTTESTTEST";
|
|
|
|
//unsigned char in[] = ba.data();
|
|
|
|
unsigned char key[] = "8AC304380E0E476BA2558B75DB9E2516";
|
|
|
|
//unsigned char key[] = "\x8A\xC3\x04\x38\x0E\x0E\x47\x6B\xA2\x55\x8B\x75\xDB\x9E\x25\x16";
|
|
|
|
unsigned char output[256];
|
|
|
|
|
|
|
|
memset(output, 0, sizeof(output));
|
|
|
|
|
|
|
|
aes_encrypt((unsigned char*)ba.data(), output, key);
|
|
|
|
|
|
|
|
qCritical() << ba.toHex(':') << endl;
|
|
|
|
qCritical() << QByteArray((char*)key).toHex(':') << endl;
|
|
|
|
qCritical() << QByteArray((char*)output).toHex(':') << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//char aes_encrypt(unsigned char *input,unsigned char *output,unsigned char *key);
|
|
|
|
|
2024-06-07 13:33:04 +02:00
|
|
|
#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) {
|
2024-09-02 16:40:38 +02:00
|
|
|
//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;
|
2024-06-07 13:33:04 +02:00
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
//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;
|
2024-06-07 13:33:04 +02:00
|
|
|
|
2024-06-13 17:23:47 +02:00
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
//qCritical() << "TimeSteps" << timeSteps;
|
2024-06-13 17:23:47 +02:00
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
// return 0;
|
2024-06-13 17:23:47 +02:00
|
|
|
|
2024-06-07 13:33:04 +02:00
|
|
|
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) {
|
2024-09-02 16:40:38 +02:00
|
|
|
QDateTime s(QDate(2024, 8, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
|
2024-06-07 13:33:04 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
QDateTime start(s);
|
|
|
|
start.setTime(QTime(21, 30, 0));
|
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
int netto_parking_time = 14 * 60;
|
|
|
|
struct price_t costs;
|
|
|
|
PermitType pt(PERMIT_TYPE::SHORT_TERM_PARKING);
|
|
|
|
|
|
|
|
double cost = 150;
|
|
|
|
|
|
|
|
//cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
|
|
|
|
// end, &costs, pt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << costs.netto
|
|
|
|
// << "> end" << end.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
|
|
|
//}
|
|
|
|
|
|
|
|
exit(0);
|
2024-06-07 13:33:04 +02:00
|
|
|
|
2024-06-26 16:25:23 +02:00
|
|
|
/*
|
|
|
|
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|
|
|
parking_tariff_t *tariff,
|
|
|
|
QDateTime &start_parking_time,
|
|
|
|
int netto_parking_time,
|
|
|
|
QDateTime &end_parking_time, // return value
|
|
|
|
struct price_t *price, // return value
|
|
|
|
bool prepaid = true);
|
|
|
|
*/
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
|
|
|
for (int minutes = 540; minutes <= 540; ++minutes) {
|
|
|
|
// QDateTime start = s.addSecs(minutes * 60);
|
|
|
|
QDateTime start(QDateTime::currentDateTime());
|
|
|
|
QDateTime effectiveStart(QDateTime::currentDateTime());
|
2024-06-07 13:33:04 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
for (int i = 30; i <= 30; i += 10) {
|
2024-06-07 13:33:04 +02:00
|
|
|
//for (int i = 2100; i <= 2100; i += 10) {
|
|
|
|
cost = i;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
|
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
2024-06-07 13:33:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-07-16 16:42:39 +02:00
|
|
|
#if SEXTEN==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_501/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()); // 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|
|
|
parking_tariff_t *tariff,
|
|
|
|
QDateTime &start_parking_time,
|
|
|
|
int netto_parking_time,
|
|
|
|
QDateTime &end_parking_time, // return value
|
|
|
|
struct price_t *price, // return value
|
|
|
|
bool prepaid = true);
|
|
|
|
*/
|
|
|
|
|
|
|
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
2024-08-01 16:46:09 +02:00
|
|
|
for (int minutes = 480; minutes <= 480; minutes += 1) {
|
2024-07-16 16:42:39 +02:00
|
|
|
QDateTime start = s.addSecs(minutes * 60);
|
|
|
|
|
2024-07-19 14:03:06 +02:00
|
|
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
2024-07-16 16:42:39 +02:00
|
|
|
|
|
|
|
QDateTime effectiveStart = start;
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
/*
|
2024-07-19 14:03:06 +02:00
|
|
|
for (int i = 10; i <= 400; i += 10) {
|
2024-07-16 16:42:39 +02:00
|
|
|
cost = i;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
|
2024-07-19 14:03:06 +02:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
2024-07-16 16:42:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
|
|
}
|
2024-08-01 16:46:09 +02:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
int netto_parking_time = 60;
|
|
|
|
struct price_t price;
|
2024-07-16 16:42:39 +02:00
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
QDateTime const s = start;
|
2024-07-16 16:42:39 +02:00
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
|
|
|
qCritical() << "start" << s.toString(Qt::ISODate)
|
|
|
|
<< "netto_parking_time" << netto_parking_time
|
|
|
|
<< "< price" << price.netto
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
2024-07-16 16:42:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2024-07-19 14:03:06 +02:00
|
|
|
#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;
|
|
|
|
|
2024-07-22 15:46:13 +02:00
|
|
|
//input.open("/home/linux/customer_505/etc/psa_tariff/tariff01.json");
|
|
|
|
input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
2024-07-19 14:03:06 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-07-21 20:58:12 +02:00
|
|
|
//QDateTime s = QDateTime::currentDateTime();
|
|
|
|
//s.setTime(QTime(13, 30, 0));
|
|
|
|
//std::optional<QDateTime> e = cfg.getInterpolationEnd(s, 0);
|
|
|
|
//if (e) {
|
|
|
|
// qCritical() << " endtime: " << e.value().toString(Qt::ISODate);
|
|
|
|
//}
|
|
|
|
//return 0;
|
|
|
|
|
2024-07-22 15:46:13 +02:00
|
|
|
//QDateTime start = QDateTime::currentDateTime();
|
|
|
|
//start.setTime(QTime(18, 0, 0));
|
|
|
|
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
|
|
|
//qCritical() << "TimeSteps" << timeSteps;
|
2024-07-19 14:03:06 +02:00
|
|
|
|
2024-07-22 15:46:13 +02:00
|
|
|
//return 0;
|
2024-07-19 14:03:06 +02:00
|
|
|
|
|
|
|
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) {
|
2024-07-22 15:46:13 +02:00
|
|
|
QDateTime s(QDate(2024, 7, 21 + day), QTime(0, 0, 0));
|
2024-07-19 14:03:06 +02:00
|
|
|
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) {
|
2024-07-24 12:34:28 +02:00
|
|
|
for (int minutes = 1020; minutes <= 1020; minutes += 1) {
|
2024-07-19 14:03:06 +02:00
|
|
|
QDateTime start = s.addSecs(minutes * 60);
|
|
|
|
|
2024-07-22 15:46:13 +02:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate);
|
2024-07-19 14:03:06 +02:00
|
|
|
|
|
|
|
QDateTime effectiveStart = start;
|
|
|
|
|
|
|
|
// hier sollte man auch testen was passiert, falls man ausserhalb
|
|
|
|
// der verkaufsdaten steht
|
2024-07-22 15:46:13 +02:00
|
|
|
if (start.time() < QTime(7, 0, 0)) {
|
|
|
|
effectiveStart.setTime(QTime(7, 0, 0));
|
2024-07-19 14:03:06 +02:00
|
|
|
} else
|
2024-07-22 15:46:13 +02:00
|
|
|
if (start.time() <= QTime(20, 0, 0)) {
|
2024-07-19 14:03:06 +02:00
|
|
|
effectiveStart = start;
|
|
|
|
} else {
|
|
|
|
effectiveStart = start.addDays(1);
|
2024-07-22 15:46:13 +02:00
|
|
|
effectiveStart.setTime(QTime(7, 0, 0)); // next day
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
#if 0
|
2024-07-24 17:35:46 +02:00
|
|
|
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
2024-07-24 12:34:28 +02:00
|
|
|
for (int i = 200; i <= 200; i += 10) {
|
|
|
|
cost = i;
|
|
|
|
|
2024-07-24 17:35:46 +02:00
|
|
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
2024-07-24 12:34:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
|
|
} else {
|
|
|
|
// qCritical() << cs.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
}
|
|
|
|
#else
|
2024-07-22 15:46:13 +02:00
|
|
|
for (int i = 700; i <= 1400; i += 700) {
|
2024-07-19 14:03:06 +02:00
|
|
|
//for (int i = 2100; i <= 2100; i += 10) {
|
|
|
|
cost = i;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) { // return value
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
|
|
} else {
|
|
|
|
// qCritical() << cs.toString();
|
|
|
|
}
|
|
|
|
|
2024-07-22 15:46:13 +02:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
|
|
|
}
|
2024-07-24 12:34:28 +02:00
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
start = QDateTime::currentDateTime();
|
|
|
|
start.setTime(QTime(9, 57, 0));
|
|
|
|
|
|
|
|
for (int i = 66; i <= 66; i += 6) {
|
2024-07-22 15:46:13 +02:00
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
2024-07-24 12:34:28 +02:00
|
|
|
cs = compute_price_for_parking_ticket(&cfg, start, i, end, &price);
|
|
|
|
|
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
|
|
|
|
<< "price" << price.netto;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VALSER_ALM==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;
|
|
|
|
|
2024-07-30 15:24:52 +02:00
|
|
|
int zone = 3;
|
2024-07-24 12:34:28 +02:00
|
|
|
|
|
|
|
if (zone == 1) {
|
|
|
|
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
|
|
|
|
}
|
|
|
|
if (zone == 3) {
|
|
|
|
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.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;
|
2024-07-19 14:03:06 +02:00
|
|
|
|
2024-07-24 12:34:28 +02:00
|
|
|
if (isParsed) {
|
|
|
|
|
2024-07-30 15:24:52 +02:00
|
|
|
if (zone == 1 || zone == 3) {
|
2024-07-29 11:30:36 +02:00
|
|
|
/*
|
|
|
|
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
|
|
|
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
|
|
|
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
|
|
|
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
|
|
|
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
|
|
|
|
|
|
|
qCritical() << " pop_min_time_pkw: " << pop_min_time;
|
|
|
|
qCritical() << " pop_max_time_pkw: " << pop_max_time;
|
|
|
|
qCritical() << " pop_min_price_pkw: " << pop_min_price;
|
|
|
|
qCritical() << " pop_max_price_pkw: " << pop_max_price;
|
|
|
|
|
|
|
|
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
|
|
|
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
|
|
|
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
|
|
|
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
|
|
|
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
|
|
|
|
|
|
|
qCritical() << " pop_min_time_bus: " << pop_min_time;
|
|
|
|
qCritical() << " pop_max_time_bus: " << pop_max_time;
|
|
|
|
qCritical() << " pop_min_price_bus: " << pop_min_price;
|
|
|
|
qCritical() << " pop_max_price_bus: " << pop_max_price;
|
|
|
|
*/
|
2024-07-30 15:24:52 +02:00
|
|
|
}
|
|
|
|
if (zone == 2) {
|
2024-07-29 11:30:36 +02:00
|
|
|
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;
|
|
|
|
}
|
2024-07-24 12:34:28 +02:00
|
|
|
|
|
|
|
//QDateTime start = QDateTime::currentDateTime();
|
|
|
|
//start.setTime(QTime(12, 0, 0));
|
|
|
|
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
|
|
|
//qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
//return 0;
|
2024-07-29 11:30:36 +02:00
|
|
|
if (zone == 1) {
|
|
|
|
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
|
|
|
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << timeSteps;
|
|
|
|
int Down = 0;
|
|
|
|
int Up = 1;
|
|
|
|
|
|
|
|
QDateTime const start = QDateTime::currentDateTime();
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
|
|
|
|
if (paymentOptionIndex < 0) {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
|
|
|
<< "< 0 for start" << start.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<uint32_t> const prices_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
|
|
|
QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
|
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
CalcState calcState;
|
|
|
|
QDateTime s(QDateTime::currentDateTime());
|
|
|
|
|
|
|
|
s.setTime(QTime(12, 0, 0));
|
|
|
|
|
|
|
|
//calcState = compute_duration_for_parking_ticket(&cfg, s,
|
|
|
|
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
|
|
|
//qCritical() << end.toString(Qt::ISODate);
|
|
|
|
//qCritical() << calcState.toString();
|
|
|
|
|
|
|
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
2024-08-01 16:46:09 +02:00
|
|
|
(double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
2024-07-29 11:30:36 +02:00
|
|
|
qCritical() << end.toString(Qt::ISODate);
|
|
|
|
qCritical() << calcState.toString();
|
|
|
|
}
|
2024-07-24 12:34:28 +02:00
|
|
|
|
|
|
|
if (zone == 2) {
|
|
|
|
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
|
|
|
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << timeSteps;
|
|
|
|
int Down = 0;
|
|
|
|
int Up = 1;
|
|
|
|
|
|
|
|
QDateTime const start = QDateTime::currentDateTime();
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
|
|
|
|
if (paymentOptionIndex < 0) {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
|
|
|
<< "< 0 for start" << start.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
|
|
|
|
2024-07-29 11:30:36 +02:00
|
|
|
QDateTime end;
|
|
|
|
CalcState calcState;
|
|
|
|
QDateTime s(QDateTime::currentDateTime());
|
|
|
|
|
|
|
|
s.setTime(QTime(18, 0, 0));
|
|
|
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
|
|
|
(double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
|
|
|
qCritical() << end.toString(Qt::ISODate);
|
|
|
|
qCritical() << calcState.toString();
|
|
|
|
#if 0
|
2024-07-24 12:34:28 +02:00
|
|
|
|
|
|
|
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::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
|
|
|
|
|
|
|
|
qCritical() << "price for" << timeSteps.at(i) << ": " << price;
|
|
|
|
|
|
|
|
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
|
|
|
|
|
|
|
qCritical() << "duration for price" << price << "duration: " << duration;
|
|
|
|
|
|
|
|
if (!prices.contains(price)) {
|
|
|
|
qCritical() << "ERROR nextTimeStep relative to start:"
|
|
|
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
|
|
|
<< "(price so far:" << price << ")";
|
|
|
|
exit(-1);
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
2024-07-24 12:34:28 +02:00
|
|
|
qCritical() << "nextTimeStep relative to start:"
|
|
|
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
|
|
|
<< "(price so far:" << price << ")";
|
|
|
|
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
2024-07-29 11:30:36 +02:00
|
|
|
#endif
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
2024-07-24 12:34:28 +02:00
|
|
|
if (zone == 3) {
|
2024-07-30 15:24:52 +02:00
|
|
|
//QDateTime xx(QDateTime::fromString("2024-07-31T00:00:00", Qt::ISODate));
|
|
|
|
//xx = xx.addSecs(-60); // --> "2024-07-30T23:59:00"
|
|
|
|
//qCritical() << xx.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
//QDateTime s(QDateTime::currentDateTime());
|
|
|
|
//s.setTime(QTime(12, 0, 0));
|
|
|
|
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, s);
|
|
|
|
//qCritical() << timeSteps;
|
|
|
|
int Down = 0;
|
|
|
|
int Up = 1;
|
2024-07-24 12:34:28 +02:00
|
|
|
|
2024-07-30 15:24:52 +02:00
|
|
|
QDateTime const start = QDateTime::currentDateTime();
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
2024-07-24 12:34:28 +02:00
|
|
|
|
2024-07-30 15:24:52 +02:00
|
|
|
if (paymentOptionIndex != 0) {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
|
|
|
<< "< 0 for start" << start.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//QSet<uint32_t> const prices1{800, 1600, 2400, 3200, 4000, 4800, 5600};
|
|
|
|
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
CalcState calcState;
|
|
|
|
|
|
|
|
QDateTime s(QDateTime::currentDateTime());
|
|
|
|
s.setTime(QTime(12, 0, 0));
|
|
|
|
|
|
|
|
int minimal_parking_price = get_minimal_parkingprice(&cfg,
|
2024-08-02 11:13:50 +02:00
|
|
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
2024-07-30 15:24:52 +02:00
|
|
|
paymentOptionIndex, s);
|
|
|
|
|
2024-08-02 11:13:50 +02:00
|
|
|
#if 0
|
2024-07-30 15:24:52 +02:00
|
|
|
qCritical() << "minimal parking price" << minimal_parking_price;
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
|
|
|
(double)minimal_parking_price + i*800,
|
2024-08-02 11:13:50 +02:00
|
|
|
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
2024-07-30 15:24:52 +02:00
|
|
|
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
|
|
|
}
|
|
|
|
|
2024-08-02 11:13:50 +02:00
|
|
|
#else
|
2024-07-30 15:24:52 +02:00
|
|
|
s.setTime(QTime(15, 0, 0));
|
|
|
|
|
|
|
|
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
2024-08-02 11:13:50 +02:00
|
|
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
2024-07-30 15:24:52 +02:00
|
|
|
paymentOptionIndex, s);
|
|
|
|
|
|
|
|
qCritical() << "minimal parking price" << minimal_parking_price;
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
|
|
|
(double)minimal_parking_price + i*800,
|
2024-08-02 11:13:50 +02:00
|
|
|
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
2024-07-30 15:24:52 +02:00
|
|
|
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
2024-07-24 12:34:28 +02:00
|
|
|
}
|
2024-08-02 11:13:50 +02:00
|
|
|
#endif
|
2024-07-24 12:34:28 +02:00
|
|
|
}
|
2024-07-19 14:03:06 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-06-05 17:05:19 +02:00
|
|
|
#if NEUHAUSER_STOCKERAU==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_748/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;
|
2024-06-06 14:01:01 +02:00
|
|
|
double const x = 30.0/7.0;
|
|
|
|
double cost;
|
|
|
|
int durationInMinutes;
|
|
|
|
int offsetInMinutes = 0;
|
|
|
|
|
2024-06-13 17:23:47 +02:00
|
|
|
//for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
|
|
|
|
for (int day = Qt::Tuesday; day <= Qt::Tuesday; ++day) {
|
|
|
|
QDateTime s(QDate(2024, 6, 9 + day), QTime()); // 20: (whit) monday,..., 26: sunday
|
2024-06-06 14:01:01 +02:00
|
|
|
QDateTime end;
|
|
|
|
|
2024-06-13 17:23:47 +02:00
|
|
|
for (int minutes = 660; minutes <= 660; ++minutes) {
|
2024-06-06 14:01:01 +02:00
|
|
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
|
|
|
QDateTime start = s.addSecs(minutes * 60);
|
|
|
|
QDateTime effectiveStart = start;
|
|
|
|
|
|
|
|
if (day >= Qt::Monday && day <= Qt::Friday) {
|
|
|
|
if (start.time() < QTime(8,0,0)) {
|
|
|
|
effectiveStart.setTime(QTime(8,0,0));
|
|
|
|
} else
|
|
|
|
if (start.time() <= QTime(12,0,0)) {
|
|
|
|
effectiveStart = start;
|
|
|
|
} else
|
|
|
|
if (start.time() < QTime(13,30,0)) {
|
|
|
|
effectiveStart.setTime(QTime(13,30,0));
|
|
|
|
} else
|
|
|
|
if (start.time() <= QTime(18,0,0)) {
|
|
|
|
effectiveStart = start;
|
|
|
|
} else {
|
|
|
|
effectiveStart = start.addDays(1);
|
|
|
|
effectiveStart.setTime(QTime(8,0,0)); // saturday
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (day == Qt::Saturday) {
|
|
|
|
if (start.time() < QTime(8,0,0)) {
|
|
|
|
effectiveStart.setTime(QTime(8,0,0));
|
|
|
|
} else
|
|
|
|
if (start.time() <= QTime(12,0,0)) {
|
|
|
|
effectiveStart = start;
|
|
|
|
} else {
|
|
|
|
effectiveStart = start.addDays(2);
|
|
|
|
effectiveStart.setTime(QTime(8,0,0)); // monday
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (day == Qt::Sunday) {
|
|
|
|
effectiveStart = start.addDays(1);
|
|
|
|
effectiveStart.setTime(QTime(8,0,0)); // monday
|
|
|
|
}
|
|
|
|
|
2024-06-13 17:23:47 +02:00
|
|
|
for (int i = 700; i <= 700; i += 10) {
|
2024-06-06 14:01:01 +02:00
|
|
|
cost = i;
|
|
|
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
|
|
|
durationInMinutes = truncf(x * (i/10));
|
|
|
|
offsetInMinutes = 0;
|
|
|
|
if (day >= Qt::Monday && day <= Qt::Friday) {
|
|
|
|
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(12, 0, 0)) {
|
|
|
|
if (effectiveStart.date().dayOfWeek() == start.date().dayOfWeek()) {
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) > QTime(12, 0, 0)) {
|
|
|
|
offsetInMinutes = 90; // 12:00 - 13:30
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
offsetInMinutes = 14 * 60; // 18:00 -> next day, 8:00
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) <= QTime(12, 0, 0)) {
|
|
|
|
offsetInMinutes = 0;
|
|
|
|
} else {
|
|
|
|
if (effectiveStart.date().dayOfWeek() == Qt::Saturday) {
|
|
|
|
offsetInMinutes = (12 + 24 + 8) * 60;
|
|
|
|
} else {
|
|
|
|
offsetInMinutes = 90;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (effectiveStart.time() >= QTime(13, 30, 0)) {
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) > QTime(18, 0, 0)) {
|
|
|
|
offsetInMinutes = 14 * 60; // 18:00 -> next day, 8:00
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (day == Qt::Saturday) {
|
|
|
|
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(12, 0, 0)) {
|
|
|
|
if (effectiveStart.date().dayOfWeek() == start.date().dayOfWeek()) {
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) > QTime(12, 0, 0)) {
|
|
|
|
offsetInMinutes = (12 + 24 + 8) * 60; // monday, 8:00
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
offsetInMinutes = (12 + 24 + 8) * 60; // monday, 8:00
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) <= QTime(12, 0, 0)) {
|
|
|
|
offsetInMinutes = 0;
|
|
|
|
} else {
|
|
|
|
offsetInMinutes = 90;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (day == Qt::Sunday) {
|
|
|
|
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(12, 0, 0)) {
|
|
|
|
if (effectiveStart.time().addSecs(durationInMinutes * 60) > QTime(12, 0, 0)) {
|
|
|
|
offsetInMinutes = 90;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
|
2024-06-13 17:23:47 +02:00
|
|
|
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
|
|
|
|
qCritical() << "| effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
|
|
|
qCritical() << "| cost ............................." << cost;
|
|
|
|
qCritical() << "| durationMinutes .................." << durationInMinutes;
|
|
|
|
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
|
|
|
|
qCritical() << "| effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
|
|
|
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
|
2024-06-06 14:01:01 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cs) {
|
|
|
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
|
|
} else {
|
|
|
|
qCritical() << "SUCCESS";
|
|
|
|
}
|
2024-06-13 17:23:47 +02:00
|
|
|
qCritical() << "start ............................" << cs.toString();
|
2024-06-06 14:01:01 +02:00
|
|
|
qCritical() << "start ............................" << start.toString(Qt::ISODate);
|
|
|
|
qCritical() << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
|
|
|
|
qCritical() << "cost ............................." << cost;
|
|
|
|
qCritical() << "durationMinutes .................." << durationInMinutes;
|
|
|
|
qCritical() << "offsetInMinutes .................." << offsetInMinutes;
|
|
|
|
qCritical() << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
|
|
|
|
qCritical() << "end .............................." << end.toString(Qt::ISODate) << endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-06-05 17:05:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2024-04-16 12:01:36 +02:00
|
|
|
#if NEUHAUSER_PERNEGG_AN_DER_MUR==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_747/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;
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
int price;
|
|
|
|
QDateTime productStart;
|
|
|
|
QDateTime productEnd;
|
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
|
|
|
start.setTime(QTime(0, 0, 0));
|
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
2024-04-24 09:33:57 +02:00
|
|
|
qCritical() << QString("line=%1 price (%2) :")
|
|
|
|
.arg(__LINE__)
|
|
|
|
.arg(start.time().toString(Qt::ISODate)) << price;
|
2024-04-16 12:01:36 +02:00
|
|
|
|
2024-05-15 15:19:13 +02:00
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
|
|
|
|
2024-04-16 12:01:36 +02:00
|
|
|
start.setTime(QTime(6, 0, 0));
|
|
|
|
productStart = productEnd = QDateTime();
|
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
2024-04-24 09:33:57 +02:00
|
|
|
qCritical() << QString("line=%1 price (%2-%3) :")
|
|
|
|
.arg(__LINE__)
|
2024-04-16 12:01:36 +02:00
|
|
|
.arg(productStart.time().toString(Qt::ISODate))
|
|
|
|
.arg(productEnd.time().toString(Qt::ISODate))
|
|
|
|
<< price;
|
|
|
|
|
2024-05-15 15:19:13 +02:00
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__)
|
|
|
|
<< price;
|
|
|
|
|
2024-05-06 11:38:37 +02:00
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
|
|
|
qCritical() << QString("line=%1 price:").arg(__LINE__) << price;
|
|
|
|
|
2024-04-16 12:01:36 +02:00
|
|
|
start.setTime(QTime(15, 0, 0));
|
|
|
|
productStart = productEnd = QDateTime();
|
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
2024-04-24 09:33:57 +02:00
|
|
|
qCritical() << QString("line=%1 price (%2-%3) :")
|
|
|
|
.arg(__LINE__)
|
2024-04-16 12:01:36 +02:00
|
|
|
.arg(productStart.time().toString(Qt::ISODate))
|
|
|
|
.arg(productEnd.time().toString(Qt::ISODate))
|
|
|
|
<< price;
|
|
|
|
|
2024-05-15 15:19:13 +02:00
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
|
|
|
|
2024-04-16 12:01:36 +02:00
|
|
|
start.setTime(QTime(16, 0, 0));
|
|
|
|
productStart = productEnd = QDateTime();
|
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
2024-04-24 09:33:57 +02:00
|
|
|
qCritical() << QString("line=%1 price (%2-%3) :")
|
|
|
|
.arg(__LINE__)
|
2024-04-16 12:01:36 +02:00
|
|
|
.arg(productStart.time().toString(Qt::ISODate))
|
|
|
|
.arg(productEnd.time().toString(Qt::ISODate))
|
|
|
|
<< price;
|
|
|
|
|
2024-05-15 15:19:13 +02:00
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
|
|
|
|
2024-04-16 12:01:36 +02:00
|
|
|
start.setTime(QTime(17, 0, 0));
|
|
|
|
productStart = productEnd = QDateTime();
|
2024-05-15 15:19:13 +02:00
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
2024-04-24 09:33:57 +02:00
|
|
|
qCritical() << QString("line=%1 price (%2-%3) :")
|
|
|
|
.arg(__LINE__)
|
2024-04-16 12:01:36 +02:00
|
|
|
.arg(productStart.time().toString(Qt::ISODate))
|
|
|
|
.arg(productEnd.time().toString(Qt::ISODate))
|
|
|
|
<< price;
|
2024-05-15 15:19:13 +02:00
|
|
|
|
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
|
|
|
|
|
|
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
|
|
|
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
2024-06-04 11:27:57 +02:00
|
|
|
|
|
|
|
for (int h = 0; h < 24; ++h) {
|
|
|
|
start.setTime(QTime(h, 0, 0));
|
|
|
|
productStart = productEnd = QDateTime();
|
|
|
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
|
|
|
qCritical() << QString("line=%1 %2 price (%3-%4) :")
|
|
|
|
.arg(__LINE__)
|
|
|
|
.arg(start.time().toString(Qt::ISODate))
|
|
|
|
.arg(productStart.time().toString(Qt::ISODate))
|
|
|
|
.arg(productEnd.time().toString(Qt::ISODate))
|
|
|
|
<< price;
|
|
|
|
}
|
2024-04-16 12:01:36 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NEUHAUSER_CHRISTOPH_REISEN==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_746/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;
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{
|
|
|
|
360, 420, 1440, 2880, 4320, 5400, 7440});
|
|
|
|
|
|
|
|
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
|
|
|
if (stepsConfigured != timeSteps) {
|
|
|
|
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
stepsConfigured.push_front(360); // for test run
|
|
|
|
stepsConfigured.push_back(7440);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static const int Down = 0;
|
|
|
|
static const int Up = 1;
|
|
|
|
|
|
|
|
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
|
|
|
if (nextTimeStep != stepsConfigured.at(i+2)) {
|
|
|
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") ERROR"
|
|
|
|
<< nextTimeStep << stepsConfigured.at(i+2);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "curTimeStep" << timeSteps.at(i) << ", nextTimeStep" << nextTimeStep;
|
|
|
|
|
|
|
|
|
|
|
|
int prevTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Down);
|
|
|
|
if (prevTimeStep != stepsConfigured.at(i)) {
|
|
|
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") ERROR"
|
|
|
|
<< prevTimeStep << stepsConfigured.at(i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "curTimeStep" << timeSteps.at(i) << ", prevTimeStep" << prevTimeStep;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
2024-05-06 11:38:37 +02:00
|
|
|
start.setTime(QTime(10, 2, 30));
|
|
|
|
start.setDate(QDate(2024, 5, 5));
|
|
|
|
|
|
|
|
// 2024-05-05 10:02:30
|
2024-04-16 12:01:36 +02:00
|
|
|
|
|
|
|
struct price_t costs;
|
2024-06-04 11:27:57 +02:00
|
|
|
double const cost[] = {600, 700, 800, 1600, 2400, 3200, 4000};
|
2024-04-16 12:01:36 +02:00
|
|
|
double price1 = 0;
|
|
|
|
double price2 = 0;
|
|
|
|
|
|
|
|
CalcState cs;
|
|
|
|
|
|
|
|
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
|
|
|
|
|
|
|
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
|
|
|
|
if (cs.getStatus() != CalcState::State::SUCCESS) {
|
|
|
|
qCritical() << "ERROR STATUS" << costs.netto;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
price1 = costs.netto;
|
|
|
|
price2 = Calculator::GetInstance().GetCostFromDuration(&cfg, start, timeSteps.at(i));
|
|
|
|
|
|
|
|
if (price1 != price2) {
|
|
|
|
qCritical() << "ERROR DIFFERENT PRICES" << price1 << price2;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
|
2024-04-24 09:17:26 +02:00
|
|
|
<< timeSteps.at(i) << "(" << timeSteps.at(i)/60 << "h)" << "PRICE=" << price1;
|
2024-04-16 12:01:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
|
|
|
|
start.toString(Qt::ISODate).toStdString().c_str(),
|
|
|
|
cost[i], false, true);
|
|
|
|
QDateTime d(QDateTime::fromString(QString(duration.c_str()), Qt::ISODate));
|
|
|
|
|
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate)
|
|
|
|
<< "cost[" << i << "]" << cost[i] << "duration" << d.toString(Qt::ISODate) << (start.secsTo(d) + 59) / 60;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2024-04-08 13:53:29 +02:00
|
|
|
#if BAD_NEUENAHR_AHRWEILER==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;
|
2024-04-12 14:14:40 +02:00
|
|
|
int pop_carry_over;
|
|
|
|
int pop_carry_over_time_range_id;
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
for (int zone=2; zone < 3; ++zone) {
|
2024-04-08 13:53:29 +02:00
|
|
|
//for (int t=6; t < 7; t+=20) {
|
|
|
|
switch (zone) {
|
|
|
|
case 1: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// standard-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json");
|
|
|
|
//pop_max_time = 6*60;
|
|
|
|
} break;
|
|
|
|
case 2: {
|
2024-09-02 16:40:38 +02:00
|
|
|
qCritical() << " ZONE 2: KURZZEIT 1";
|
2024-05-07 16:21:36 +02:00
|
|
|
// kuzzeit-1-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
|
|
|
|
//pop_max_time = 5*60;
|
|
|
|
} break;
|
|
|
|
case 3: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// kuzzeit-2-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json");
|
|
|
|
//pop_max_time = 6*60;
|
|
|
|
} break;
|
|
|
|
case 4: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// kuzzeit-3-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff04.json");
|
|
|
|
//pop_max_time = 4*60;
|
|
|
|
} break;
|
|
|
|
case 5: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// langzeit-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff05.json");
|
|
|
|
//pop_max_time = 6*60;
|
|
|
|
} break;
|
|
|
|
case 6: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// sondertarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff06.json");
|
|
|
|
//pop_max_time = 4*60;
|
|
|
|
} break;
|
|
|
|
case 7: {
|
2024-05-07 16:21:36 +02:00
|
|
|
// wochenend-tarif
|
2024-04-08 13:53:29 +02:00
|
|
|
input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff07.json");
|
|
|
|
//pop_max_time = 4*60;
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
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) {
|
2024-09-02 16:40:38 +02:00
|
|
|
|
|
|
|
qCritical() << "Parsed";
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
2024-04-08 13:53:29 +02:00
|
|
|
// test library functions
|
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
if (zone == 1) {
|
|
|
|
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;
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{
|
|
|
|
20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440});
|
|
|
|
|
|
|
|
//static QList<double> const cost
|
|
|
|
// = QList(std::initializer_list<double>{
|
|
|
|
// 0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 500});
|
|
|
|
|
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
//if (stepsConfigured != timeSteps) {
|
|
|
|
// qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
// return -1;
|
|
|
|
//}
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
|
|
|
|
|
|
|
struct price_t costs;
|
|
|
|
double price1 = 0;
|
|
|
|
double price2 = 0;
|
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
//for (int m=0; m < 1440; ++m) {
|
|
|
|
for (int m=480; m < 481; ++m) {
|
2024-04-12 14:14:40 +02:00
|
|
|
start.setTime(QTime(0, 0, 0));
|
|
|
|
start = start.addSecs(m*60);
|
|
|
|
|
|
|
|
qCritical() << "START" << start.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
//int Down = 0;
|
|
|
|
//int Up = 1;
|
|
|
|
// for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
// int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
|
|
|
// qCritical() << "nextTimeStep" << nextTimeStep;
|
|
|
|
//
|
|
|
|
// int prevTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Down);
|
|
|
|
// qCritical() << "prevTimeStep" << prevTimeStep;
|
|
|
|
//}
|
|
|
|
|
|
|
|
CalcState cs;
|
2024-09-02 16:40:38 +02:00
|
|
|
#if 1
|
2024-04-12 14:14:40 +02:00
|
|
|
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
2024-04-12 14:14:40 +02:00
|
|
|
if (cs.getStatus() != CalcState::State::SUCCESS) {
|
|
|
|
if (start.time().hour() >= 8 && start.time().hour() < 18) {
|
|
|
|
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
|
|
|
|
exit(-1);
|
|
|
|
} else {
|
|
|
|
if (cs.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
|
|
|
qCritical() << "CALC-STATE=" << QString(cs);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
qCritical() << "ERROR CALC-STATE-2=" << QString(cs);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
price1 = costs.netto;
|
|
|
|
price2 = Calculator::GetInstance().GetCostFromDuration(&cfg, start, timeSteps.at(i));
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
if (price1 != price2) {
|
|
|
|
qCritical() << "ERROR DIFFERENT PRICES" << price1 << price2;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
|
2024-08-01 16:46:09 +02:00
|
|
|
<< timeSteps.at(i) << "PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
|
2024-04-08 13:53:29 +02:00
|
|
|
|
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
|
|
|
|
// start.toString(Qt::ISODate).toStdString().c_str(),
|
|
|
|
// cost[i], false, true);
|
|
|
|
//qCritical() << "duration" << duration.c_str();
|
|
|
|
}
|
2024-09-02 16:40:38 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
double cost = 80;
|
|
|
|
qCritical() << "START" << start.toString(Qt::ISODate) << "cost" << cost;
|
|
|
|
QDateTime end;
|
|
|
|
|
|
|
|
cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
|
|
|
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
|
|
|
qCritical() << __LINE__ << cs.toString()
|
|
|
|
<< "START" << start.toString(Qt::ISODate)
|
|
|
|
<< "<duration" << start.secsTo(end) / 60
|
|
|
|
<< "cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
|
|
|
//}
|
|
|
|
#endif
|
2024-04-12 14:14:40 +02:00
|
|
|
}
|
|
|
|
} // zone == 1
|
|
|
|
if (zone == 2) {
|
|
|
|
int const numOptions = cfg.getAllPaymentOptions().size();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
for (int payOpt=0; payOpt < numOptions; ++payOpt) {
|
|
|
|
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING, payOpt);
|
|
|
|
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING, payOpt);
|
|
|
|
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING, payOpt);
|
|
|
|
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING, payOpt);
|
|
|
|
pop_daily_card_price = cfg.getPaymentOptions(payOpt).pop_daily_card_price;
|
|
|
|
|
|
|
|
pop_carry_over = cfg.getPaymentOptions(payOpt).pop_carry_over;
|
|
|
|
pop_carry_over_time_range_id = cfg.getPaymentOptions(payOpt).pop_carry_over_time_range_id;
|
|
|
|
|
|
|
|
qCritical() << QString(" pop_min_time[%1]: %2").arg(payOpt).arg(pop_min_time);
|
|
|
|
qCritical() << QString(" pop_max_time[%1]: %2").arg(payOpt).arg(pop_max_time);
|
|
|
|
qCritical() << QString(" pop_min_price[%1]: %2").arg(payOpt).arg(pop_min_price);
|
|
|
|
qCritical() << QString(" pop_max_price[%1]: %2").arg(payOpt).arg(pop_max_price);
|
|
|
|
qCritical() << QString(" pop_daily_card_price[%1]: %2").arg(payOpt).arg(pop_daily_card_price);
|
|
|
|
qCritical() << QString(" pop_carry_over[%1]: %2").arg(payOpt).arg(pop_carry_over);
|
|
|
|
qCritical() << QString("pop_carry_over_time_range_id[%1]: %2").arg(payOpt).arg(pop_carry_over_time_range_id);
|
|
|
|
|
|
|
|
if (pop_carry_over_time_range_id != -1) {
|
|
|
|
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;
|
|
|
|
qCritical() << QString(" timeRangeFrom[%1]: %2").arg(payOpt).arg(carryOverTimeRangeFrom.toString(Qt::ISODate));
|
|
|
|
qCritical() << QString(" timeRangeTo[%1]: %2").arg(payOpt).arg(carryOverTimeRangeTo.toString(Qt::ISODate));
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
}
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-12 14:14:40 +02:00
|
|
|
}
|
|
|
|
#endif
|
2024-04-19 13:24:10 +02:00
|
|
|
bool fail;
|
|
|
|
QDateTime start;
|
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
for (int i=1; i < 2; ++i) {
|
2024-04-19 13:24:10 +02:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 1:
|
2024-09-02 16:40:38 +02:00
|
|
|
start = QDateTime(QDate(2024, 10, 3), QTime(17, 0, 0)); // sunday
|
2024-04-19 13:24:10 +02:00
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 2:
|
2024-09-02 16:40:38 +02:00
|
|
|
start = QDateTime(QDate(2024, 4, 22), QTime(17, 30, 0)); // monday
|
2024-04-19 13:24:10 +02:00
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
start = QDateTime(QDate(2024, 4, 22), QTime(17, 30, 0)); // monday
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
default:;
|
|
|
|
}
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
//start = QDateTime::currentDateTime();
|
|
|
|
QList<int> timeSteps;
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
if (paymentOptionIndex != -1) {
|
|
|
|
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
|
|
|
timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, paymentOptionIndex);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
QList<int>::const_iterator step;
|
|
|
|
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
2024-09-02 16:40:38 +02:00
|
|
|
//qCritical() << __LINE__
|
|
|
|
// << "START" << start.toString(Qt::ISODate)
|
|
|
|
// << "<duration" << *step;
|
|
|
|
|
|
|
|
// if (*step != 180)
|
|
|
|
// continue;
|
|
|
|
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
double cost = 0;
|
|
|
|
CalcState cs;
|
2024-04-08 13:53:29 +02:00
|
|
|
|
2024-09-02 16:40:38 +02:00
|
|
|
QDateTime s(start);
|
|
|
|
|
|
|
|
qCritical() << __LINE__
|
|
|
|
<< "START" << start.toString(Qt::ISODate)
|
|
|
|
<< "<duration" << *step;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if ((cs = compute_price_for_parking_ticket(&cfg, s, *step, end, &price,
|
|
|
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
2024-04-19 13:24:10 +02:00
|
|
|
cost = price.netto;
|
2024-09-02 16:40:38 +02:00
|
|
|
qCritical() << __LINE__
|
|
|
|
<< "START" << start.toString(Qt::ISODate)
|
|
|
|
<< "<duration" << *step
|
|
|
|
<< "cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
2024-04-19 13:24:10 +02:00
|
|
|
} else {
|
|
|
|
if (fail == false) {
|
|
|
|
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
|
|
|
}
|
|
|
|
}
|
2024-09-02 16:40:38 +02:00
|
|
|
#else
|
|
|
|
cost = 210;
|
|
|
|
qCritical() << "START" << start.toString(Qt::ISODate) << "cost" << cost;
|
|
|
|
|
|
|
|
cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
|
|
|
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
|
|
|
qCritical() << __LINE__ << cs.toString()
|
|
|
|
<< "START" << start.toString(Qt::ISODate)
|
|
|
|
<< "<duration" << start.secsTo(end) / 60
|
|
|
|
<< "cost" << cost
|
|
|
|
<< "> end" << end.toString(Qt::ISODate);
|
|
|
|
break;
|
|
|
|
//}
|
|
|
|
#endif
|
|
|
|
|
2024-04-19 13:24:10 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
2024-04-08 13:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-30 14:09:48 +02:00
|
|
|
if (zone == 3) {
|
|
|
|
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;
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{20, 40, 60, 80, 100, 120});
|
|
|
|
|
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
|
|
|
if (stepsConfigured != timeSteps) {
|
|
|
|
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool fail;
|
|
|
|
QDateTime start;
|
|
|
|
|
|
|
|
for (int i=0; i < 5; ++i) {
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
start = QDateTime(QDate(2024, 4, 21), QTime(16, 0, 0)); // sunday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
start = QDateTime(QDate(2024, 4, 22), QTime(8, 0, 0)); // monday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
start = QDateTime(QDate(2024, 4, 23), QTime(17, 30, 0)); // tuesday
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
start = QDateTime(QDate(2024, 4, 24), QTime(7, 30, 0)); // wednesday
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
|
|
|
|
|
|
|
//start = QDateTime::currentDateTime();
|
|
|
|
QList<int> timeSteps;
|
|
|
|
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
if (paymentOptionIndex != -1) {
|
|
|
|
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
|
|
|
timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, paymentOptionIndex);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
|
|
|
QList<int>::const_iterator step;
|
|
|
|
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
|
|
|
|
|
|
|
double cost = 0;
|
|
|
|
CalcState cs;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
2024-04-30 14:09:48 +02:00
|
|
|
cost = price.netto;
|
|
|
|
qCritical() << "step" << *step << ": cost" << cost;
|
|
|
|
} else {
|
|
|
|
if (fail == false) {
|
|
|
|
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (zone == 4) {
|
|
|
|
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;
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{20, 40, 60, 80, 100, 120});
|
|
|
|
|
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
|
|
|
if (stepsConfigured != timeSteps) {
|
|
|
|
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool fail;
|
|
|
|
QDateTime start;
|
|
|
|
|
|
|
|
for (int i=4; i < 5; ++i) {
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
start = QDateTime(QDate(2024, 4, 21), QTime(16, 0, 0)); // sunday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
start = QDateTime(QDate(2024, 4, 22), QTime(8, 0, 0)); // monday
|
|
|
|
fail = false;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
start = QDateTime(QDate(2024, 4, 23), QTime(17, 30, 0)); // tuesday
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
start = QDateTime(QDate(2024, 4, 24), QTime(7, 30, 0)); // wednesday
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
|
|
|
|
|
|
|
//start = QDateTime::currentDateTime();
|
|
|
|
QList<int> timeSteps;
|
|
|
|
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
if (paymentOptionIndex != -1) {
|
|
|
|
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
|
|
|
timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, paymentOptionIndex);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
|
|
|
|
|
|
|
QList<int>::const_iterator step;
|
|
|
|
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
|
|
|
|
|
|
|
double cost = 0;
|
|
|
|
CalcState cs;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
2024-04-30 14:09:48 +02:00
|
|
|
cost = price.netto;
|
|
|
|
qCritical() << "step" << *step << ": cost" << cost;
|
|
|
|
} else {
|
|
|
|
if (fail == false) {
|
|
|
|
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-05-07 16:21:36 +02:00
|
|
|
if (zone == 5) { // langzeit-tarif
|
|
|
|
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() << zone << " pop_min_time: " << pop_min_time;
|
|
|
|
qCritical() << zone << " pop_max_time: " << pop_max_time;
|
|
|
|
qCritical() << zone << " pop_min_price: " << pop_min_price;
|
|
|
|
qCritical() << zone << " pop_max_price: " << pop_max_price;
|
|
|
|
qCritical() << zone << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{
|
|
|
|
20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440, 4320, 10080
|
|
|
|
});
|
|
|
|
|
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "( TimeSteps :" << __LINE__ << ")" << timeSteps;
|
|
|
|
|
|
|
|
if (stepsConfigured != timeSteps) {
|
|
|
|
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool fail;
|
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
|
|
|
|
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
if (paymentOptionIndex != -1) {
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
|
|
|
|
|
|
|
qCritical() << "paymentOptionIndex" << paymentOptionIndex;
|
|
|
|
|
|
|
|
QList<int>::const_iterator step;
|
|
|
|
int i = 0;
|
|
|
|
for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
|
|
|
|
if (++i < 16) continue;
|
|
|
|
|
|
|
|
double cost = 0;
|
|
|
|
CalcState cs;
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
|
2024-05-07 16:21:36 +02:00
|
|
|
cost = price.netto;
|
|
|
|
qCritical() << "step" << *step << ": cost" << cost;
|
|
|
|
} else {
|
|
|
|
if (fail == false) {
|
|
|
|
qCritical() << "<<<ERROR>>> cs =" << QString(cs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
|
|
|
|
}
|
2024-04-30 14:09:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
if (zone == 6) { // sondertarif: 24h ticket wohnmobile
|
2024-05-15 15:19:13 +02:00
|
|
|
// 8 euro; hoechstparkdauer 24h
|
2024-04-30 14:09:48 +02:00
|
|
|
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() << zone << " pop_min_time: " << pop_min_time;
|
|
|
|
qCritical() << zone << " pop_max_time: " << pop_max_time;
|
|
|
|
qCritical() << zone << " pop_min_price: " << pop_min_price;
|
|
|
|
qCritical() << zone << " pop_max_price: " << pop_max_price;
|
|
|
|
qCritical() << zone << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
|
|
|
start.setTime(QTime(0, 0, 0));
|
|
|
|
|
|
|
|
for (int i=0; i<1440; ++i) {
|
|
|
|
|
|
|
|
QDateTime productStart;
|
|
|
|
QDateTime productEnd;
|
|
|
|
|
|
|
|
int v = compute_product_price(&cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET, start, &productStart, &productEnd);
|
|
|
|
if (v != 800) {
|
|
|
|
qCritical() << "ERROR [" << i << "]" << "price 24h-ticket"
|
|
|
|
<< v << productStart.toString(Qt::ISODate)
|
|
|
|
<< productEnd.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
} else {
|
2024-05-15 15:19:13 +02:00
|
|
|
|
|
|
|
int const secs = productStart.secsTo(productEnd);
|
|
|
|
if (secs != 86400) {
|
|
|
|
qCritical() << "ERROR" << i << secs << v
|
|
|
|
<< productStart.toString(Qt::ISODate)
|
|
|
|
<< productEnd.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
} else {
|
|
|
|
qCritical() << i << secs << v
|
|
|
|
<< productStart.toString(Qt::ISODate)
|
2024-04-30 14:09:48 +02:00
|
|
|
<< productEnd.toString(Qt::ISODate);
|
2024-05-15 15:19:13 +02:00
|
|
|
}
|
2024-04-30 14:09:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
start = start.addSecs(60);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 7) {
|
2024-05-06 11:38:37 +02:00
|
|
|
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() << zone << " pop_min_time: " << pop_min_time;
|
|
|
|
qCritical() << zone << " pop_max_time: " << pop_max_time;
|
|
|
|
qCritical() << zone << " pop_min_price: " << pop_min_price;
|
|
|
|
qCritical() << zone << " pop_max_price: " << pop_max_price;
|
|
|
|
qCritical() << zone << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
|
|
|
static QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{
|
|
|
|
20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 1440});
|
|
|
|
|
|
|
|
//static QList<double> const cost
|
|
|
|
// = QList(std::initializer_list<double>{
|
|
|
|
// 0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 500});
|
2024-04-30 14:09:48 +02:00
|
|
|
|
2024-05-06 11:38:37 +02:00
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "( TimeSteps :" << __LINE__ << ")" << timeSteps;
|
|
|
|
|
|
|
|
if (stepsConfigured != timeSteps) {
|
|
|
|
qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
|
|
|
|
2024-05-07 16:21:36 +02:00
|
|
|
// testing
|
|
|
|
start.setDate(QDate(2024, 5, 5));
|
|
|
|
start.setTime(QTime(16, 0, 0));
|
|
|
|
|
2024-05-06 11:38:37 +02:00
|
|
|
struct price_t costs;
|
|
|
|
double price1 = 0;
|
|
|
|
double price2 = 0;
|
|
|
|
|
2024-05-07 16:21:36 +02:00
|
|
|
CalcState cs;
|
|
|
|
for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
2024-08-01 16:46:09 +02:00
|
|
|
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
2024-05-07 16:21:36 +02:00
|
|
|
qCritical() << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
2024-05-06 11:38:37 +02:00
|
|
|
for (int m=0; m < 1440; ++m) {
|
|
|
|
start.setTime(QTime(0, 0, 0));
|
|
|
|
start = start.addSecs(m*60);
|
|
|
|
|
|
|
|
qCritical() << "START" << start.toString(Qt::ISODate);
|
|
|
|
|
|
|
|
//int Down = 0;
|
|
|
|
//int Up = 1;
|
|
|
|
// for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
// int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
|
|
|
// qCritical() << "nextTimeStep" << nextTimeStep;
|
|
|
|
//
|
|
|
|
// int prevTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Down);
|
|
|
|
// qCritical() << "prevTimeStep" << prevTimeStep;
|
|
|
|
//}
|
|
|
|
|
|
|
|
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
|
|
|
|
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
|
|
|
|
2024-08-01 16:46:09 +02:00
|
|
|
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
2024-05-06 11:38:37 +02:00
|
|
|
if (cs.getStatus() != CalcState::State::SUCCESS) {
|
|
|
|
if (start.time().hour() >= 8 && start.time().hour() < 18) {
|
|
|
|
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
|
|
|
|
exit(-1);
|
|
|
|
} else {
|
|
|
|
if (cs.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
|
|
|
qCritical() << "CALC-STATE=" << QString(cs);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
qCritical() << "ERROR CALC-STATE-2=" << QString(cs);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
price1 = costs.netto;
|
|
|
|
price2 = Calculator::GetInstance().GetCostFromDuration(&cfg, start, timeSteps.at(i));
|
|
|
|
|
|
|
|
if (price1 != price2) {
|
|
|
|
qCritical() << "ERROR DIFFERENT PRICES" << price1 << price2;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
|
|
|
|
<< timeSteps.at(i) << "PRICE=" << price1;
|
|
|
|
|
|
|
|
|
|
|
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
|
|
|
|
// start.toString(Qt::ISODate).toStdString().c_str(),
|
|
|
|
// cost[i], false, true);
|
|
|
|
//qCritical() << "duration" << duration.c_str();
|
|
|
|
}
|
|
|
|
}
|
2024-04-30 14:09:48 +02:00
|
|
|
}
|
2024-04-08 13:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-01-24 16:36:29 +01:00
|
|
|
#if SCHOENAU_KOENIGSEE==1
|
2024-04-24 09:54:29 +02:00
|
|
|
for (int zone=1; zone < 3; ++zone) {
|
|
|
|
std::ifstream input;
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
if (zone == 1) {
|
|
|
|
input.open("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json");
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
input.open("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json");
|
|
|
|
}
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
qCritical() << "--------------------";
|
|
|
|
qCritical() << " ZONE" << zone;
|
|
|
|
qCritical() << "--------------------";
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
std::stringstream sstr;
|
|
|
|
while(input >> sstr.rdbuf());
|
|
|
|
std::string json(sstr.str());
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
Configuration cfg;
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
if (isParsed) {
|
|
|
|
// qCritical() << "parsed zone" << zone << "file";
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
int minParkingTime = get_minimal_parkingtime(&cfg);
|
|
|
|
qCritical() << "minimal_parking_time" << minParkingTime;
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
QDateTime start = QDateTime::currentDateTime();
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
// zone 1
|
|
|
|
//int timeSteps[] = {60, 180, 1440, 2880, 4320, 5670, 7200, 8640, 10080, 11520, 12960, 14400};
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
qCritical() << "TimeSteps" << timeSteps;
|
2024-01-24 16:36:29 +01:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
for (int i = 0 ; i < timeSteps.size(); ++i) {
|
|
|
|
QDateTime end = start.addSecs(timeSteps.at(i)*60);
|
2024-04-12 14:14:40 +02:00
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
double price = Calculator::GetInstance().GetCostFromDuration(
|
|
|
|
&cfg,
|
|
|
|
start,
|
|
|
|
timeSteps.at(i));
|
2024-06-04 11:27:57 +02:00
|
|
|
qCritical() << "zone" << zone
|
|
|
|
<< "GetCostFromDuration() time: " << timeSteps.at(i)
|
|
|
|
<< "(" << timeSteps.at(i)/60 << "h)"
|
|
|
|
<< "price=" << price;
|
|
|
|
|
|
|
|
switch(timeSteps.at(i)) {
|
|
|
|
case 60:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 300.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 300.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 3) {
|
|
|
|
if (price == 200.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 700.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 500.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 3) {
|
|
|
|
if (price == 400.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1440:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 900.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 600.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 3) {
|
|
|
|
if (price == 500.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2880:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 1800.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 1200.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4320:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 2700.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 1800.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5760:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 3600.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 2400.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7200:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 4500.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 3000.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8640:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 5400.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 3600.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10080:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 6300.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 4200.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11520:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 7200.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 4800.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12960:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 8100.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 5400.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 14400:
|
|
|
|
if (zone == 1) {
|
|
|
|
if (price == 9000.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zone == 2) {
|
|
|
|
if (price == 6000.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qCritical() << "ERROR zone" << zone
|
|
|
|
<< "GetCostFromDuration() time: " << timeSteps.at(i)
|
|
|
|
<< "(" << timeSteps.at(i)/60 << "h)"
|
|
|
|
<< "price=" << price;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2024-04-24 09:54:29 +02:00
|
|
|
}
|
2024-04-12 14:14:40 +02:00
|
|
|
}
|
2024-01-24 16:36:29 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-04-24 11:56:50 +02:00
|
|
|
|
2024-02-15 16:12:10 +01:00
|
|
|
#if NEUHAUSER_KIRCHDORF==1
|
2024-02-26 16:57:37 +01:00
|
|
|
//if (QDir("/opt/app/tools/atbupdate/customer_743").exists()) {
|
|
|
|
// if(QFileInfo::exists("/etc/psa_tariff/tariff01.json")) {
|
|
|
|
if (true) {
|
|
|
|
if(true) {
|
|
|
|
// const char *f = "/etc/psa_tariff/tariff01.json";
|
|
|
|
const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
2024-02-22 08:02:55 +01:00
|
|
|
std::ifstream input(f);
|
|
|
|
|
|
|
|
std::stringstream sstr;
|
|
|
|
while(input >> sstr.rdbuf());
|
|
|
|
std::string json(sstr.str());
|
|
|
|
|
|
|
|
Configuration cfg;
|
|
|
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
|
|
|
|
|
|
|
if (!isParsed) {
|
|
|
|
qCritical() << "ERROR: CANNOT PARSE" << f;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "Successfully parsed" << f;
|
|
|
|
|
|
|
|
int const minParkingTime = get_minimal_parkingtime(&cfg);
|
|
|
|
int const maxParkingTime = get_maximal_parkingtime(&cfg);
|
|
|
|
int const minParkingPrice = get_minimal_parkingprice(&cfg);
|
|
|
|
|
|
|
|
if (minParkingTime != 30) {
|
|
|
|
qCritical() << "ERROR: WRONG MIN_PARKING_TIME" << minParkingTime;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "min_parking_time " << minParkingTime;
|
|
|
|
|
|
|
|
if (maxParkingTime != 90) {
|
|
|
|
qCritical() << "ERROR: WRONG MAX_PARKING_TIME" << maxParkingTime;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "max_parking_time " << maxParkingTime;
|
|
|
|
|
|
|
|
|
|
|
|
if (minParkingPrice != 30) {
|
|
|
|
qCritical() << "ERROR: WRONG MIN_PARKING_PRICE" << minParkingPrice;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "min_parking_price" << minParkingPrice;
|
|
|
|
|
|
|
|
QList<int> const stepsConfigured
|
|
|
|
= QList(std::initializer_list<int>{
|
|
|
|
30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90});
|
|
|
|
|
|
|
|
QList<int> const steps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
|
|
|
|
|
|
|
if (stepsConfigured != steps) {
|
|
|
|
qCritical() << "ERROR: WRONG TIME-STEP-LIST" << steps;
|
|
|
|
qCritical() << "SHOULD BE" << stepsConfigured;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
qCritical() << "time steps" << steps;
|
|
|
|
|
|
|
|
QDateTime s(QDate(2024, 2, 21), QTime());
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
|
|
|
|
|
|
|
QList<int>::const_iterator step;
|
|
|
|
for (step = steps.cbegin(); step != steps.cend(); ++step) {
|
|
|
|
qCritical() << QString("*** NEXT STEP: %1 ***").arg(*step);
|
2024-02-27 17:11:00 +01:00
|
|
|
//for (int offset = 691; offset < 692; ++offset) {
|
|
|
|
for (int offset = 480; offset < 1080; ++offset) {
|
2024-02-27 12:23:52 +01:00
|
|
|
//for (int offset = 7*60; offset < (18*60)-90; ++offset) {
|
|
|
|
//for (int offset = (18*60)-90; offset < 18*60; ++offset) {
|
|
|
|
//for (int offset = 1046; offset < 1047; ++offset) {
|
2024-02-22 08:02:55 +01:00
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
|
|
|
QDateTime const firstStart = start;
|
|
|
|
|
2024-02-27 17:30:15 +01:00
|
|
|
//if (*step != 30) continue;
|
2024-02-27 17:11:00 +01:00
|
|
|
|
|
|
|
double cost = 0;
|
2024-02-27 12:23:52 +01:00
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
if (compute_price_for_parking_ticket(&cfg, start, *step, end, &price)) {
|
2024-02-27 17:11:00 +01:00
|
|
|
cost = price.netto;
|
2024-02-22 08:02:55 +01:00
|
|
|
|
2024-02-26 16:57:37 +01:00
|
|
|
qCritical() << "****" << offset << *step << "****";
|
|
|
|
qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
|
|
|
qCritical() << " start :" << start.toString(Qt::ISODate);
|
|
|
|
qCritical() << " end :" << end.toString(Qt::ISODate);
|
|
|
|
qCritical() << " cost :" << cost;
|
2024-02-22 08:02:55 +01:00
|
|
|
|
|
|
|
if (offset < 8*60) { // [7:00 - 8:00[
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 9*60) { // [8:00 - 9:00[
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 10*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 11*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 12*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 13*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 14*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 15*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 16*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
new_cost += ((*step-30)/5)*10;
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
//return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 17*60) {
|
2024-02-27 12:23:52 +01:00
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
double const f = ((*step-30)/5)*10;
|
|
|
|
new_cost += f;
|
|
|
|
new_cost = std::min(new_cost, f+30);
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
|
|
|
//return -1;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (offset < 18*60) {
|
|
|
|
double new_cost = cost;
|
|
|
|
if (offset > (18*60)-(*step)) {
|
|
|
|
double const f = ((*step-30)/5)*10;
|
|
|
|
new_cost += f;
|
|
|
|
new_cost = std::min(new_cost, f+30);
|
|
|
|
qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
|
|
|
|
}
|
|
|
|
if (!test_neuhauser_kirchdorf(*step, new_cost)) {
|
2024-02-22 08:02:55 +01:00
|
|
|
qCritical() << "ERROR AT OFFSET" << offset;
|
2024-02-27 12:23:52 +01:00
|
|
|
// return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2024-02-27 12:23:52 +01:00
|
|
|
qCritical() << "ERROR OFFSET TOO HIGH" << offset;
|
|
|
|
return -1;
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR COMPUTING PRICE FOR"
|
|
|
|
<< "start" << start.toString(Qt::ISODate)
|
|
|
|
<< "step" << *step
|
|
|
|
<< "end" << end.toString(Qt::ISODate);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-02-27 17:30:15 +01:00
|
|
|
QDateTime end2 = QDateTime();
|
|
|
|
if (compute_duration_for_parking_ticket(&cfg, start, cost, end2)) { // return value
|
2024-02-28 09:26:05 +01:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate)
|
2024-02-27 17:11:00 +01:00
|
|
|
<< "offset" << offset
|
|
|
|
<< "cost" << cost
|
2024-02-27 17:30:15 +01:00
|
|
|
<< "end" << end2.toString(Qt::ISODate);
|
|
|
|
if (end != end2) {
|
2024-02-28 09:26:05 +01:00
|
|
|
qCritical() << end.toString(Qt::ISODate)
|
2024-02-27 17:30:15 +01:00
|
|
|
<< end2.toString(Qt::ISODate);
|
|
|
|
}
|
2024-02-27 17:11:00 +01:00
|
|
|
}
|
2024-02-22 08:02:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2024-02-15 16:12:10 +01:00
|
|
|
const char *f = "/opt/ptu5/opt/customer_743/etc/psa_tariff/tariff01.json";
|
|
|
|
std::ifstream input(f);
|
|
|
|
|
|
|
|
std::stringstream sstr;
|
|
|
|
while(input >> sstr.rdbuf());
|
|
|
|
std::string json(sstr.str());
|
|
|
|
|
|
|
|
Configuration cfg;
|
|
|
|
|
|
|
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
|
|
|
if (isParsed) {
|
|
|
|
qCritical() << "Parsed" << f;
|
|
|
|
|
|
|
|
int minParkingTime = get_minimal_parkingtime(&cfg);
|
|
|
|
int maxParkingTime = get_maximal_parkingtime(&cfg);
|
|
|
|
int minParkingPrice = get_minimal_parkingprice(&cfg);
|
|
|
|
|
|
|
|
qCritical() << "min_parking_time " << minParkingTime;
|
|
|
|
qCritical() << "max_parking_time " << maxParkingTime;
|
|
|
|
qCritical() << "min_parking_price" << minParkingPrice;
|
|
|
|
|
|
|
|
bool nextDay = false;
|
|
|
|
bool prePaid = true;
|
|
|
|
// bool carryOver = false;
|
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
//QDateTime s = QDateTime::currentDateTime();
|
2024-02-21 11:08:49 +01:00
|
|
|
QDateTime s(QDate(2024, 2, 21), QTime());
|
2024-02-15 16:12:10 +01:00
|
|
|
QDateTime end;
|
2024-02-19 12:01:36 +01:00
|
|
|
for (int duration = 30; duration <= 90; duration += 5) {
|
2024-02-15 16:12:10 +01:00
|
|
|
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
|
|
|
|
qCritical() << "";
|
2024-02-19 12:01:36 +01:00
|
|
|
for (int offset = 420; offset <= 1080; ++offset) {
|
2024-02-22 08:02:55 +01:00
|
|
|
//for (int offset = 0; offset <= 0; ++offset) {
|
2024-02-15 16:12:10 +01:00
|
|
|
//for (int offset = 420; offset <= 1080; ++offset) {
|
|
|
|
//if (offset > 720 && offset < 840) {
|
|
|
|
// continue;
|
|
|
|
//}
|
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
|
|
|
QDateTime const firstStart = start;
|
|
|
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
|
|
|
|
|
|
|
struct price_t price;
|
|
|
|
compute_price_for_parking_ticket(&cfg, start, duration, end, &price);
|
|
|
|
|
|
|
|
double cost = price.netto;
|
2024-02-15 16:12:10 +01:00
|
|
|
|
2024-02-19 12:01:36 +01:00
|
|
|
//#if COST_FROM_DURATION==0
|
2024-02-15 16:12:10 +01:00
|
|
|
double cost_soll = 30 + ((duration-30)/5 * 10);
|
|
|
|
uint32_t duration_ist = start.secsTo(end) / 60;
|
|
|
|
|
|
|
|
if (duration_ist >= 120) {
|
|
|
|
duration_ist = duration_ist - 120;
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical() << "****" << offset << duration << "****";
|
|
|
|
qCritical() << " firstStart :" << firstStart.toString(Qt::ISODate);
|
|
|
|
qCritical() << " start :" << start.toString(Qt::ISODate);
|
|
|
|
qCritical() << " end :" << end.toString(Qt::ISODate);
|
2024-02-22 08:02:55 +01:00
|
|
|
//qCritical() << "duration (soll):" << duration;
|
|
|
|
//qCritical() << "duration (ist) :" << duration_ist;
|
|
|
|
//qCritical() << " cost (soll):" << cost_soll;
|
|
|
|
//qCritical() << " cost (ist) :" << cost;
|
2024-02-15 16:12:10 +01:00
|
|
|
|
2024-02-21 11:08:49 +01:00
|
|
|
// if (cost_soll != cost) {
|
2024-02-19 12:01:36 +01:00
|
|
|
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
|
|
|
// << "cost_soll" << cost_soll << "cost_ist" << cost;
|
|
|
|
//break;
|
2024-02-21 11:08:49 +01:00
|
|
|
// }
|
|
|
|
// if (duration != duration_ist) {
|
2024-02-15 16:12:10 +01:00
|
|
|
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
|
|
|
|
// << "duration_soll" << duration << "duration_ist" << duration_ist;
|
|
|
|
//break;
|
2024-02-21 11:08:49 +01:00
|
|
|
// }
|
2024-02-15 16:12:10 +01:00
|
|
|
|
2024-02-19 12:01:36 +01:00
|
|
|
//#else
|
2024-02-22 08:02:55 +01:00
|
|
|
//start = s.addSecs(offset * 60);
|
|
|
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
|
|
|
// start.toString(Qt::ISODate).toStdString().c_str(),
|
|
|
|
// cost, false, true);
|
2024-02-19 12:01:36 +01:00
|
|
|
|
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
//if (end.toString(Qt::ISODate) != QString(duration.c_str())) {
|
2024-02-19 12:01:36 +01:00
|
|
|
//qCritical() << "ERROR" << end.toString(Qt::ISODate)
|
|
|
|
// << QString(duration.c_str());
|
|
|
|
//break;
|
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
//}
|
2024-02-19 12:01:36 +01:00
|
|
|
|
2024-02-22 08:02:55 +01:00
|
|
|
//qCritical() << "start" << start.toString(Qt::ISODate)
|
|
|
|
// << "cost" << cost
|
|
|
|
// << "until" << duration.c_str()
|
|
|
|
// << "end" << end.toString(Qt::ISODate)
|
|
|
|
// << ":" << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60
|
|
|
|
// << (end.toString(Qt::ISODate) == QString(duration.c_str()));
|
2024-02-15 16:12:10 +01:00
|
|
|
|
2024-02-19 12:01:36 +01:00
|
|
|
//#endif // COST_FROM_DURATION
|
2024-02-15 16:12:10 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // 0
|
|
|
|
#endif
|
|
|
|
|
2024-01-18 14:34:57 +01:00
|
|
|
#if NEUHAUSER_BILEXA_GALTUER==1
|
|
|
|
std::ifstream input("/opt/ptu5/opt/customer_745/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) {
|
2024-04-24 13:11:28 +02:00
|
|
|
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
2024-01-23 10:50:42 +01:00
|
|
|
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
2024-01-18 14:34:57 +01:00
|
|
|
qCritical() << timeSteps;
|
2024-01-23 10:50:42 +01:00
|
|
|
int Down = 0;
|
|
|
|
int Up = 1;
|
|
|
|
//compute_next_timestep(&cfg, )
|
2024-01-18 14:34:57 +01:00
|
|
|
|
2024-03-07 08:18:40 +01:00
|
|
|
QDateTime const start = QDateTime::currentDateTime();
|
2024-04-24 13:11:28 +02:00
|
|
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
|
|
|
|
|
|
|
if (paymentOptionIndex < 0) {
|
|
|
|
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
|
|
|
<< "< 0 for start" << start.toString(Qt::ISODate);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
QSet<uint32_t> const prices{700, 1400, 2100, 2800, 3500, 4200, 4900};
|
|
|
|
|
2024-01-18 14:34:57 +01:00
|
|
|
for (int i=0; i<timeSteps.size(); ++i) {
|
2024-01-23 10:50:42 +01:00
|
|
|
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
|
|
|
qCritical() << "nextTimeStep" << nextTimeStep;
|
|
|
|
|
2024-04-24 13:11:28 +02:00
|
|
|
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
|
2024-03-07 08:18:40 +01:00
|
|
|
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
2024-06-04 11:27:57 +02:00
|
|
|
|
|
|
|
if (!prices.contains(price)) {
|
|
|
|
qCritical() << "ERROR nextTimeStep relative to start:"
|
|
|
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
|
|
|
<< "(price so far:" << price << ")";
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-03-07 08:18:40 +01:00
|
|
|
qCritical() << "nextTimeStep relative to start:"
|
|
|
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
|
|
|
<< "(price so far:" << price << ")";
|
2024-06-04 11:27:57 +02:00
|
|
|
|
2024-01-18 14:34:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-15 13:28:58 +01:00
|
|
|
#if NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM==1
|
2024-01-30 10:53:43 +01:00
|
|
|
std::ifstream input("/opt/ptu5/opt/customer_744/etc/psa_tariff/tariff01.json");
|
2023-12-15 13:28:58 +01:00
|
|
|
|
|
|
|
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) {
|
2024-02-22 16:25:30 +01:00
|
|
|
|
|
|
|
int v = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_ADULT);
|
|
|
|
qCritical() << "price adult" << v;
|
|
|
|
|
|
|
|
int w = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_TEEN);
|
|
|
|
qCritical() << "price teen" << w;
|
|
|
|
|
|
|
|
|
2024-01-31 11:37:11 +01:00
|
|
|
QDateTime s(QDate(2023, 11, 30), QTime());
|
|
|
|
QDateTime end;
|
|
|
|
struct price_t price;
|
2024-02-01 13:28:08 +01:00
|
|
|
|
2024-02-28 09:26:05 +01:00
|
|
|
for (int offset = 480; offset < 1200; ++offset) {
|
2024-01-31 11:37:11 +01:00
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
|
|
|
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
2024-02-28 09:26:05 +01:00
|
|
|
PERMIT_TYPE::DAY_TICKET_ADULT,
|
2024-04-24 12:01:24 +02:00
|
|
|
&price);
|
2024-06-04 11:27:57 +02:00
|
|
|
if (price.netto != 800) {
|
|
|
|
qCritical() << "ERROR(ADULT) start=" << start.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate) << "price (ADULT)" << price.netto;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-04-24 12:01:24 +02:00
|
|
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate) << "price (ADULT)" << price.netto;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int offset = 480; offset < 1200; ++offset) {
|
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
|
|
|
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
2024-02-28 09:26:05 +01:00
|
|
|
PERMIT_TYPE::DAY_TICKET_TEEN,
|
|
|
|
&price);
|
2024-06-04 11:27:57 +02:00
|
|
|
if (price.netto != 400) {
|
|
|
|
qCritical() << "ERROR(TEEN) start=" << start.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate) << "price (TEEN)" << price.netto;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-01-31 11:37:11 +01:00
|
|
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
2024-04-24 12:01:24 +02:00
|
|
|
<< "end" << end.toString(Qt::ISODate) << "price (TEEN)" << price.netto;
|
2024-01-31 11:37:11 +01:00
|
|
|
}
|
2023-12-15 13:28:58 +01:00
|
|
|
}
|
2024-02-28 09:26:05 +01:00
|
|
|
#undef ADULT
|
|
|
|
#undef TEEN
|
2023-12-15 13:28:58 +01:00
|
|
|
#endif
|
|
|
|
|
2023-12-12 10:59:49 +01:00
|
|
|
#if NEUHAUSER_LINSINGER_MASCHINENBAU==1
|
2024-01-31 15:08:16 +01:00
|
|
|
std::ifstream input("/opt/ptu5/opt/customer_741/etc/psa_tariff/tariff01.json");
|
2023-12-12 10:59:49 +01:00
|
|
|
|
|
|
|
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) {
|
2024-02-28 12:06:43 +01:00
|
|
|
int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
|
2024-06-04 11:27:57 +02:00
|
|
|
if (price != 300) {
|
|
|
|
qCritical() << "ERROR price food stamp" << price;
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
2024-02-28 12:06:43 +01:00
|
|
|
qCritical() << "price food stamp" << price;
|
2023-12-12 10:59:49 +01:00
|
|
|
}
|
|
|
|
#endif
|
2023-04-24 15:31:46 +02:00
|
|
|
|
2023-12-06 10:52:35 +01:00
|
|
|
#if NEUHAUSER_KORNEUBURG==1
|
2024-03-07 08:18:40 +01:00
|
|
|
std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
|
2023-12-05 17:30:12 +01:00
|
|
|
int pop_max_time;
|
2023-12-06 10:52:35 +01:00
|
|
|
|
|
|
|
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_max_time = 3*60;
|
|
|
|
bool nextDay = false;
|
|
|
|
bool prePaid = true;
|
|
|
|
// zone 1 (lila)
|
|
|
|
QDateTime s(QDate(2023, 11, 30), QTime());
|
|
|
|
QDateTime end;
|
|
|
|
for (int duration = 30; duration <= pop_max_time; duration += 5) {
|
|
|
|
for (int offset = 420; offset < 1140; ++offset) {
|
|
|
|
if (offset > 720 && offset < 840) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
|
|
|
//qCritical() << "start" << start.toString(Qt::ISODate);
|
|
|
|
|
2024-03-07 08:18:40 +01:00
|
|
|
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
2023-12-06 10:52:35 +01:00
|
|
|
//Q_ASSERT(cost == duration*2.5);
|
|
|
|
//qCritical() << "";
|
2024-03-07 08:18:40 +01:00
|
|
|
qCritical() << "start" << start.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate)
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "cost" << cost;
|
2023-12-06 10:52:35 +01:00
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
switch(duration) {
|
|
|
|
case 30:
|
|
|
|
if (cost == 60.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 35:
|
|
|
|
if (cost == 70.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
if (cost == 80.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 45:
|
|
|
|
if (cost == 90.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
if (cost == 100.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 55:
|
|
|
|
if (cost == 110.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 60:
|
|
|
|
if (cost == 120.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 65:
|
|
|
|
if (cost == 130.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 70:
|
|
|
|
if (cost == 140.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 75:
|
|
|
|
if (cost == 150.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 80:
|
|
|
|
if (cost == 160.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 85:
|
|
|
|
if (cost == 170.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
if (cost == 180.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 95:
|
|
|
|
if (cost == 190.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 100:
|
|
|
|
if (cost == 200.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 105:
|
|
|
|
if (cost == 210.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 110:
|
|
|
|
if (cost == 220.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 115:
|
|
|
|
if (cost == 230.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
if (cost == 240.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 125:
|
|
|
|
if (cost == 250.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 130:
|
|
|
|
if (cost == 260.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 135:
|
|
|
|
if (cost == 270.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 140:
|
|
|
|
if (cost == 280.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 145:
|
|
|
|
if (cost == 290.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 150:
|
|
|
|
if (cost == 300.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 155:
|
|
|
|
if (cost == 310.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 160:
|
|
|
|
if (cost == 320.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 165:
|
|
|
|
if (cost == 330.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 170:
|
|
|
|
if (cost == 340.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 175:
|
|
|
|
if (cost == 350.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
if (cost == 360.0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qCritical() << "ERROR(1) start" << start.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate)
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "cost" << cost;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2024-03-07 08:18:40 +01:00
|
|
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
2023-12-06 10:52:35 +01:00
|
|
|
//Q_ASSERT(cost == duration*2.5);
|
2024-03-07 08:18:40 +01:00
|
|
|
//qCritical() << "start" << start.toString(Qt::ISODate)
|
|
|
|
// << "cost" << cost
|
|
|
|
// << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
2023-12-06 10:52:35 +01:00
|
|
|
}
|
|
|
|
}
|
2024-04-24 10:52:18 +02:00
|
|
|
|
|
|
|
Configuration::SpecialDaysType specialDays = cfg.SpecialDays;
|
|
|
|
for (Configuration::SpecialDaysType::const_iterator it = specialDays.cbegin();
|
|
|
|
it != specialDays.cend(); ++it) {
|
|
|
|
QDate d = QDate::fromString(QString::fromStdString(it->second.ped_date_start), Qt::ISODate);
|
|
|
|
s.setDate(d);
|
|
|
|
s.setTime(QTime(12, 0, 0));
|
|
|
|
int duration = 30;
|
|
|
|
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, s, end, duration, nextDay, prePaid);
|
2024-06-04 11:27:57 +02:00
|
|
|
if (cost != 60.0) {
|
|
|
|
qCritical() << "ERROR(2) start" << s.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate)
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "cost" << cost;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2024-04-24 10:52:18 +02:00
|
|
|
qCritical() << "start" << s.toString(Qt::ISODate)
|
|
|
|
<< "end" << end.toString(Qt::ISODate)
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "cost" << cost;
|
|
|
|
}
|
|
|
|
|
2023-12-06 10:52:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
2024-02-26 16:57:37 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SZEGED==1
|
2023-12-05 17:30:12 +01:00
|
|
|
std::ifstream input;
|
2024-01-30 14:00:55 +01:00
|
|
|
int pop_min_time;
|
2023-12-06 10:52:35 +01:00
|
|
|
int pop_max_time;
|
2024-01-30 14:00:55 +01:00
|
|
|
int pop_min_price;
|
|
|
|
int pop_max_price;
|
2024-02-22 16:25:30 +01:00
|
|
|
int pop_daily_card_price;
|
2023-12-06 10:52:35 +01:00
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
for (int zone = 1; zone < 2; ++zone) {
|
2024-01-30 14:00:55 +01:00
|
|
|
//for (int t=6; t < 7; t+=20) {
|
2024-02-22 16:25:30 +01:00
|
|
|
switch (zone) {
|
2023-12-05 17:30:12 +01:00
|
|
|
case 1: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff01.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 6*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
case 2: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff02.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 5*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
case 3: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff03.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 6*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
case 4: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff04.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 4*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
case 5: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff05.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 6*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
case 6: {
|
2024-02-26 16:57:37 +01:00
|
|
|
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff06.json");
|
2024-01-30 14:00:55 +01:00
|
|
|
//pop_max_time = 4*60;
|
2023-12-05 17:30:12 +01:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
continue;
|
2023-04-24 15:31:46 +02:00
|
|
|
}
|
2023-12-05 17:30:12 +01:00
|
|
|
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) {
|
2024-01-30 14:00:55 +01:00
|
|
|
// test library functions
|
|
|
|
|
|
|
|
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);
|
2024-02-22 16:25:30 +01:00
|
|
|
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
2024-01-30 14:00:55 +01:00
|
|
|
|
2024-02-01 13:28:08 +01:00
|
|
|
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;
|
2024-02-22 16:25:30 +01:00
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
|
|
|
|
pop_daily_card_price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET);
|
|
|
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
|
|
|
|
2024-02-22 16:25:30 +01:00
|
|
|
if (pop_min_time > pop_max_time) {
|
|
|
|
qCritical() << "ERROR pop_min_time > pop_max_time"
|
|
|
|
<< pop_min_time << pop_max_time;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pop_min_price > pop_max_price) {
|
|
|
|
qCritical() << "ERROR pop_min_price > pop_max_price"
|
|
|
|
<< pop_min_price << pop_max_price;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pop_daily_card_price < pop_max_price) {
|
|
|
|
qCritical() << "ERROR pop_daily_card_price < pop_max_price"
|
|
|
|
<< pop_daily_card_price << pop_max_price;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMap<int, int> m;
|
2024-01-30 14:00:55 +01:00
|
|
|
|
2023-12-05 17:30:12 +01:00
|
|
|
{
|
|
|
|
// zone 1 (lila)
|
2024-04-08 13:53:29 +02:00
|
|
|
QDateTime s(QDate(2024, 3, 26), QTime());
|
2023-12-05 17:30:12 +01:00
|
|
|
QDateTime end;
|
2024-02-01 13:28:08 +01:00
|
|
|
int cnt = 1;
|
2024-02-22 16:25:30 +01:00
|
|
|
if (zone == 1) {
|
|
|
|
m.insert(5, pop_min_price);
|
2024-02-23 13:54:31 +01:00
|
|
|
m.insert(10, pop_min_price); // 42
|
2024-02-22 16:25:30 +01:00
|
|
|
|
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 55);
|
|
|
|
m.insert(25, 69);
|
|
|
|
m.insert(30, 83);
|
|
|
|
m.insert(35, 97);
|
|
|
|
m.insert(40, 110);
|
|
|
|
m.insert(45, 124);
|
|
|
|
m.insert(50, 138);
|
|
|
|
m.insert(55, 152);
|
|
|
|
m.insert(60, 165);
|
|
|
|
|
|
|
|
m.insert(65, 179);
|
|
|
|
m.insert(70, 193);
|
|
|
|
m.insert(75, 207);
|
|
|
|
m.insert(80, 220);
|
|
|
|
m.insert(85, 234);
|
|
|
|
m.insert(90, 248);
|
|
|
|
m.insert(95, 262);
|
|
|
|
m.insert(100, 275);
|
|
|
|
m.insert(105, 289);
|
|
|
|
m.insert(110, 303);
|
|
|
|
m.insert(115, 317);
|
|
|
|
m.insert(120, 330);
|
|
|
|
|
|
|
|
m.insert(125, 344);
|
|
|
|
m.insert(130, 358);
|
|
|
|
m.insert(135, 372);
|
|
|
|
m.insert(140, 385);
|
|
|
|
m.insert(145, 399);
|
|
|
|
m.insert(150, 413);
|
|
|
|
m.insert(155, 427);
|
|
|
|
m.insert(160, 440);
|
|
|
|
m.insert(165, 454);
|
|
|
|
m.insert(170, 468);
|
|
|
|
m.insert(175, 482);
|
|
|
|
m.insert(180, 495);
|
|
|
|
|
|
|
|
m.insert(185, 509);
|
|
|
|
m.insert(190, 523);
|
|
|
|
m.insert(195, 537);
|
|
|
|
m.insert(200, 550);
|
|
|
|
m.insert(205, 564);
|
|
|
|
m.insert(210, 578);
|
|
|
|
m.insert(215, 592);
|
|
|
|
m.insert(220, 605);
|
|
|
|
m.insert(225, 619);
|
|
|
|
m.insert(230, 633);
|
|
|
|
m.insert(235, 647);
|
|
|
|
m.insert(240, 660);
|
|
|
|
|
|
|
|
m.insert(245, 674);
|
|
|
|
m.insert(250, 688);
|
|
|
|
m.insert(255, 702);
|
|
|
|
m.insert(260, 715);
|
|
|
|
m.insert(265, 729);
|
|
|
|
m.insert(270, 743);
|
|
|
|
m.insert(275, 757);
|
|
|
|
m.insert(280, 770);
|
|
|
|
m.insert(285, 784);
|
|
|
|
m.insert(290, 798);
|
|
|
|
m.insert(295, 812);
|
|
|
|
m.insert(300, 825);
|
|
|
|
|
|
|
|
m.insert(305, 839);
|
|
|
|
m.insert(310, 853);
|
|
|
|
m.insert(315, 867);
|
|
|
|
m.insert(320, 880);
|
|
|
|
m.insert(325, 894);
|
|
|
|
m.insert(330, 908);
|
|
|
|
m.insert(335, 922);
|
|
|
|
m.insert(340, 935);
|
|
|
|
m.insert(345, 949);
|
|
|
|
m.insert(350, 963);
|
|
|
|
m.insert(355, 977);
|
2024-02-23 13:54:31 +01:00
|
|
|
m.insert(360, pop_max_price); // 990
|
2024-02-22 16:25:30 +01:00
|
|
|
|
|
|
|
m.insert(365, pop_max_price);
|
|
|
|
m.insert(370, pop_max_price);
|
|
|
|
m.insert(375, pop_max_price);
|
|
|
|
m.insert(380, pop_max_price);
|
|
|
|
m.insert(385, pop_max_price);
|
|
|
|
m.insert(390, pop_max_price);
|
|
|
|
m.insert(395, pop_max_price);
|
|
|
|
m.insert(400, pop_max_price);
|
|
|
|
m.insert(405, pop_max_price);
|
|
|
|
m.insert(410, pop_max_price);
|
|
|
|
m.insert(415, pop_max_price);
|
|
|
|
m.insert(420, pop_max_price);
|
|
|
|
} else
|
|
|
|
if (zone == 2) {
|
2024-02-23 13:54:31 +01:00
|
|
|
m.insert(5, pop_min_price);
|
|
|
|
m.insert(10, pop_min_price); // 65
|
|
|
|
|
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 87);
|
|
|
|
m.insert(25, 109);
|
|
|
|
m.insert(30, 130);
|
|
|
|
m.insert(35, 152);
|
|
|
|
m.insert(40, 174);
|
|
|
|
m.insert(45, 195);
|
|
|
|
m.insert(50, 217);
|
|
|
|
m.insert(55, 239);
|
|
|
|
m.insert(60, 260);
|
|
|
|
|
|
|
|
m.insert(65, 282);
|
|
|
|
m.insert(70, 304);
|
|
|
|
m.insert(75, 325);
|
|
|
|
m.insert(80, 347);
|
|
|
|
m.insert(85, 369);
|
|
|
|
m.insert(90, 390);
|
|
|
|
m.insert(95, 412);
|
|
|
|
m.insert(100, 434);
|
|
|
|
m.insert(105, 455);
|
|
|
|
m.insert(110, 477);
|
|
|
|
m.insert(115, 499);
|
|
|
|
m.insert(120, 520);
|
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
m.insert(125, 542);
|
2024-02-23 13:54:31 +01:00
|
|
|
m.insert(130, 564);
|
|
|
|
m.insert(135, 585);
|
|
|
|
m.insert(140, 607);
|
|
|
|
m.insert(145, 629);
|
|
|
|
m.insert(150, 650);
|
|
|
|
m.insert(155, 672);
|
|
|
|
m.insert(160, 694);
|
|
|
|
m.insert(165, 715);
|
|
|
|
m.insert(170, 737);
|
|
|
|
m.insert(175, 759);
|
|
|
|
m.insert(180, 780);
|
|
|
|
|
|
|
|
m.insert(185, 802);
|
|
|
|
m.insert(190, 824);
|
|
|
|
m.insert(195, 845);
|
|
|
|
m.insert(200, 867);
|
|
|
|
m.insert(205, 889);
|
|
|
|
m.insert(210, 910);
|
|
|
|
m.insert(215, 932);
|
|
|
|
m.insert(220, 954);
|
|
|
|
m.insert(225, 975);
|
|
|
|
m.insert(230, 997);
|
|
|
|
m.insert(235, 1019);
|
|
|
|
m.insert(240, 1040);
|
|
|
|
|
|
|
|
m.insert(245, 1062);
|
|
|
|
m.insert(250, 1084);
|
|
|
|
m.insert(255, 1105);
|
|
|
|
m.insert(260, 1127);
|
|
|
|
m.insert(265, 1149);
|
|
|
|
m.insert(270, 1170);
|
|
|
|
m.insert(275, 1192);
|
|
|
|
m.insert(280, 1214);
|
|
|
|
m.insert(285, 1235);
|
|
|
|
m.insert(290, 1257);
|
|
|
|
m.insert(295, 1279);
|
|
|
|
m.insert(300, 1300);
|
|
|
|
|
|
|
|
m.insert(305, 1322);
|
|
|
|
m.insert(310, 1344);
|
|
|
|
m.insert(315, 1365);
|
|
|
|
m.insert(320, 1387);
|
|
|
|
m.insert(325, 1409);
|
|
|
|
m.insert(330, 1430);
|
|
|
|
m.insert(335, 1452);
|
|
|
|
m.insert(340, 1474);
|
|
|
|
m.insert(345, 1495);
|
|
|
|
m.insert(350, 1517);
|
|
|
|
m.insert(355, 1539);
|
|
|
|
m.insert(360, pop_max_price); // 1560
|
2024-02-22 16:25:30 +01:00
|
|
|
|
2024-02-23 13:54:31 +01:00
|
|
|
m.insert(365, pop_max_price);
|
|
|
|
m.insert(370, pop_max_price);
|
|
|
|
m.insert(375, pop_max_price);
|
|
|
|
m.insert(380, pop_max_price);
|
|
|
|
m.insert(385, pop_max_price);
|
|
|
|
m.insert(390, pop_max_price);
|
|
|
|
m.insert(395, pop_max_price);
|
|
|
|
m.insert(400, pop_max_price);
|
|
|
|
m.insert(405, pop_max_price);
|
|
|
|
m.insert(410, pop_max_price);
|
|
|
|
m.insert(415, pop_max_price);
|
|
|
|
m.insert(420, pop_max_price);
|
2024-02-23 14:20:16 +01:00
|
|
|
} else
|
|
|
|
if (zone == 3) {
|
|
|
|
m.insert(5, pop_min_price);
|
|
|
|
m.insert(10, pop_min_price); // 90
|
|
|
|
|
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 120);
|
|
|
|
m.insert(25, 150);
|
|
|
|
m.insert(30, 180);
|
|
|
|
m.insert(35, 210);
|
|
|
|
m.insert(40, 240);
|
|
|
|
m.insert(45, 270);
|
|
|
|
m.insert(50, 300);
|
|
|
|
m.insert(55, 330);
|
|
|
|
m.insert(60, 360);
|
|
|
|
m.insert(65, 390);
|
|
|
|
m.insert(70, 420);
|
|
|
|
m.insert(75, 450);
|
|
|
|
m.insert(80, 480);
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(85, 510);
|
|
|
|
m.insert(90, 540);
|
|
|
|
m.insert(95, 570);
|
|
|
|
m.insert(100, 600);
|
|
|
|
m.insert(105, 630);
|
|
|
|
m.insert(110, 660);
|
|
|
|
m.insert(115, 690);
|
|
|
|
m.insert(120, 720);
|
|
|
|
|
|
|
|
m.insert(125, 750);
|
|
|
|
m.insert(130, 780);
|
|
|
|
m.insert(135, 810);
|
|
|
|
m.insert(140, 840);
|
|
|
|
m.insert(145, 870);
|
|
|
|
m.insert(150, 900);
|
|
|
|
m.insert(155, 930);
|
|
|
|
m.insert(160, 960);
|
|
|
|
m.insert(165, 990);
|
|
|
|
m.insert(170, 1020);
|
|
|
|
m.insert(175, 1050);
|
|
|
|
m.insert(180, 1080);
|
|
|
|
|
|
|
|
m.insert(185, 1110);
|
|
|
|
m.insert(190, 1140);
|
|
|
|
m.insert(195, 1170);
|
|
|
|
m.insert(200, 1200);
|
|
|
|
m.insert(205, 1230);
|
|
|
|
m.insert(210, 1260);
|
|
|
|
m.insert(215, 1290);
|
|
|
|
m.insert(220, 1320);
|
|
|
|
m.insert(225, 1350);
|
|
|
|
m.insert(230, 1380);
|
|
|
|
m.insert(235, 1410);
|
|
|
|
m.insert(240, 1440);
|
|
|
|
|
|
|
|
m.insert(245, 1470);
|
|
|
|
m.insert(250, 1500);
|
|
|
|
m.insert(255, 1530);
|
|
|
|
m.insert(260, 1560);
|
|
|
|
m.insert(265, 1590);
|
|
|
|
m.insert(270, 1620);
|
|
|
|
m.insert(275, 1650);
|
|
|
|
m.insert(280, 1680);
|
|
|
|
m.insert(285, 1710);
|
|
|
|
m.insert(290, 1740);
|
|
|
|
m.insert(295, 1770);
|
|
|
|
m.insert(300, 1800);
|
|
|
|
|
|
|
|
m.insert(305, 1830);
|
|
|
|
m.insert(310, 1860);
|
|
|
|
m.insert(315, 1890);
|
|
|
|
m.insert(320, 1920);
|
|
|
|
m.insert(325, 1950);
|
|
|
|
m.insert(330, 1980);
|
|
|
|
m.insert(335, 2010);
|
|
|
|
m.insert(340, 2040);
|
|
|
|
m.insert(345, 2070);
|
|
|
|
m.insert(350, 2100);
|
|
|
|
m.insert(355, 2130);
|
|
|
|
m.insert(360, pop_max_price); // 2160
|
2024-02-23 14:20:16 +01:00
|
|
|
|
|
|
|
m.insert(365, pop_max_price);
|
|
|
|
m.insert(370, pop_max_price);
|
|
|
|
m.insert(375, pop_max_price);
|
|
|
|
m.insert(380, pop_max_price);
|
|
|
|
m.insert(385, pop_max_price);
|
|
|
|
m.insert(390, pop_max_price);
|
|
|
|
m.insert(395, pop_max_price);
|
|
|
|
m.insert(400, pop_max_price);
|
|
|
|
m.insert(405, pop_max_price);
|
|
|
|
m.insert(410, pop_max_price);
|
|
|
|
m.insert(415, pop_max_price);
|
|
|
|
m.insert(420, pop_max_price);
|
|
|
|
} else
|
|
|
|
if (zone == 4) {
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(5, pop_min_price);
|
|
|
|
m.insert(10, pop_min_price); // 163
|
2024-02-23 14:20:16 +01:00
|
|
|
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 217);
|
|
|
|
m.insert(25, 271);
|
|
|
|
m.insert(30, 325);
|
|
|
|
m.insert(35, 380);
|
|
|
|
m.insert(40, 434);
|
|
|
|
m.insert(45, 488);
|
|
|
|
m.insert(50, 542);
|
|
|
|
m.insert(55, 596);
|
|
|
|
m.insert(60, 650);
|
|
|
|
|
|
|
|
m.insert(65, 705);
|
|
|
|
m.insert(70, 759);
|
|
|
|
m.insert(75, 813);
|
|
|
|
m.insert(80, 867);
|
|
|
|
m.insert(85, 921);
|
|
|
|
m.insert(90, 975);
|
|
|
|
m.insert(95, 1030);
|
|
|
|
m.insert(100, 1084);
|
|
|
|
m.insert(105, 1138);
|
|
|
|
m.insert(110, 1192);
|
|
|
|
m.insert(115, 1246);
|
|
|
|
m.insert(120, 1300);
|
|
|
|
|
|
|
|
m.insert(125, 1355);
|
|
|
|
m.insert(130, 1409);
|
|
|
|
m.insert(135, 1463);
|
|
|
|
m.insert(140, 1517);
|
|
|
|
m.insert(145, 1571);
|
|
|
|
m.insert(150, 1625);
|
|
|
|
m.insert(155, 1680);
|
|
|
|
m.insert(160, 1734);
|
|
|
|
m.insert(165, 1788);
|
|
|
|
m.insert(170, 1842);
|
|
|
|
m.insert(175, 1896);
|
|
|
|
m.insert(180, 1950);
|
|
|
|
|
|
|
|
m.insert(185, 2005);
|
|
|
|
m.insert(190, 2059);
|
|
|
|
m.insert(195, 2113);
|
|
|
|
m.insert(200, 2167);
|
|
|
|
m.insert(205, 2221);
|
|
|
|
m.insert(210, 2275);
|
|
|
|
m.insert(215, 2330);
|
|
|
|
m.insert(220, 2384);
|
|
|
|
m.insert(225, 2438);
|
|
|
|
m.insert(230, 2492);
|
|
|
|
m.insert(235, 2546);
|
|
|
|
m.insert(240, pop_max_price); // 2600
|
|
|
|
|
|
|
|
m.insert(245, pop_max_price);
|
|
|
|
m.insert(250, pop_max_price);
|
|
|
|
m.insert(255, pop_max_price);
|
|
|
|
m.insert(260, pop_max_price);
|
|
|
|
m.insert(270, pop_max_price);
|
|
|
|
m.insert(280, pop_max_price);
|
|
|
|
m.insert(290, pop_max_price);
|
|
|
|
m.insert(300, pop_max_price);
|
2024-02-23 14:20:16 +01:00
|
|
|
} else
|
|
|
|
if (zone == 5) {
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(5, pop_min_price);
|
|
|
|
m.insert(10, pop_min_price); // 90
|
2024-02-23 14:20:16 +01:00
|
|
|
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 120);
|
|
|
|
m.insert(25, 150);
|
|
|
|
m.insert(30, 180);
|
|
|
|
m.insert(35, 210);
|
|
|
|
m.insert(40, 240);
|
|
|
|
m.insert(45, 270);
|
|
|
|
m.insert(50, 300);
|
|
|
|
m.insert(55, 330);
|
|
|
|
m.insert(60, 360);
|
|
|
|
m.insert(65, 390);
|
|
|
|
m.insert(70, 420);
|
|
|
|
m.insert(75, 450);
|
|
|
|
m.insert(80, 480);
|
|
|
|
m.insert(85, 510);
|
|
|
|
m.insert(90, 540);
|
|
|
|
m.insert(95, 570);
|
|
|
|
m.insert(100, 600);
|
|
|
|
m.insert(105, 630);
|
|
|
|
m.insert(110, 660);
|
|
|
|
m.insert(115, 690);
|
|
|
|
m.insert(120, 720);
|
|
|
|
|
|
|
|
m.insert(125, 750);
|
|
|
|
m.insert(130, 780);
|
|
|
|
m.insert(135, 810);
|
|
|
|
m.insert(140, 840);
|
|
|
|
m.insert(145, 870);
|
|
|
|
m.insert(150, 900);
|
|
|
|
m.insert(155, 930);
|
|
|
|
m.insert(160, 960);
|
|
|
|
m.insert(165, 990);
|
|
|
|
m.insert(170, 1020);
|
|
|
|
m.insert(175, 1050);
|
|
|
|
m.insert(180, 1080);
|
|
|
|
|
|
|
|
m.insert(185, 1110);
|
|
|
|
m.insert(190, 1140);
|
|
|
|
m.insert(195, 1170);
|
|
|
|
m.insert(200, 1200);
|
|
|
|
m.insert(205, 1230);
|
|
|
|
m.insert(210, 1260);
|
|
|
|
m.insert(215, 1290);
|
|
|
|
m.insert(220, 1320);
|
|
|
|
m.insert(225, 1350);
|
|
|
|
m.insert(230, 1380);
|
|
|
|
m.insert(235, 1410);
|
|
|
|
m.insert(240, 1440);
|
|
|
|
|
|
|
|
m.insert(245, 1470);
|
|
|
|
m.insert(250, 1500);
|
|
|
|
m.insert(255, 1530);
|
|
|
|
m.insert(260, 1560);
|
|
|
|
m.insert(265, 1590);
|
|
|
|
m.insert(270, 1620);
|
|
|
|
m.insert(275, 1650);
|
|
|
|
m.insert(280, 1680);
|
|
|
|
m.insert(285, 1710);
|
|
|
|
m.insert(290, 1740);
|
|
|
|
m.insert(295, 1770);
|
|
|
|
m.insert(300, 1800);
|
|
|
|
|
|
|
|
m.insert(305, 1830);
|
|
|
|
m.insert(310, 1860);
|
|
|
|
m.insert(315, 1890);
|
|
|
|
m.insert(320, 1920);
|
|
|
|
m.insert(325, 1950);
|
|
|
|
m.insert(330, 1980);
|
|
|
|
m.insert(335, 2010);
|
|
|
|
m.insert(340, 2040);
|
|
|
|
m.insert(345, 2070);
|
|
|
|
m.insert(350, 2100);
|
|
|
|
m.insert(355, 2130);
|
|
|
|
m.insert(360, pop_max_price); // 2160
|
|
|
|
|
|
|
|
m.insert(365, pop_max_price);
|
|
|
|
m.insert(370, pop_max_price);
|
|
|
|
m.insert(375, pop_max_price);
|
|
|
|
m.insert(380, pop_max_price);
|
|
|
|
m.insert(385, pop_max_price);
|
|
|
|
m.insert(390, pop_max_price);
|
|
|
|
m.insert(395, pop_max_price);
|
|
|
|
m.insert(400, pop_max_price);
|
|
|
|
m.insert(405, pop_max_price);
|
|
|
|
m.insert(410, pop_max_price);
|
|
|
|
m.insert(415, pop_max_price);
|
|
|
|
m.insert(420, pop_max_price);
|
2024-02-23 14:20:16 +01:00
|
|
|
} else
|
|
|
|
if (zone == 6) {
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(5, pop_min_price);
|
|
|
|
m.insert(10, pop_min_price); // 163
|
2024-02-23 14:20:16 +01:00
|
|
|
|
2024-02-24 11:07:04 +01:00
|
|
|
m.insert(pop_min_time, pop_min_price);
|
|
|
|
m.insert(20, 217);
|
|
|
|
m.insert(25, 271);
|
|
|
|
m.insert(30, 325);
|
|
|
|
m.insert(35, 380);
|
|
|
|
m.insert(40, 434);
|
|
|
|
m.insert(45, 488);
|
|
|
|
m.insert(50, 542);
|
|
|
|
m.insert(55, 596);
|
|
|
|
m.insert(60, 650);
|
|
|
|
|
|
|
|
m.insert(65, 705);
|
|
|
|
m.insert(70, 759);
|
|
|
|
m.insert(75, 813);
|
|
|
|
m.insert(80, 867);
|
|
|
|
m.insert(85, 921);
|
|
|
|
m.insert(90, 975);
|
|
|
|
m.insert(95, 1030);
|
|
|
|
m.insert(100, 1084);
|
|
|
|
m.insert(105, 1138);
|
|
|
|
m.insert(110, 1192);
|
|
|
|
m.insert(115, 1246);
|
|
|
|
m.insert(120, 1300);
|
|
|
|
|
|
|
|
m.insert(125, 1355);
|
|
|
|
m.insert(130, 1409);
|
|
|
|
m.insert(135, 1463);
|
|
|
|
m.insert(140, 1517);
|
|
|
|
m.insert(145, 1571);
|
|
|
|
m.insert(150, 1625);
|
|
|
|
m.insert(155, 1680);
|
|
|
|
m.insert(160, 1734);
|
|
|
|
m.insert(165, 1788);
|
|
|
|
m.insert(170, 1842);
|
|
|
|
m.insert(175, 1896);
|
|
|
|
m.insert(180, 1950);
|
|
|
|
|
|
|
|
m.insert(185, 2005);
|
|
|
|
m.insert(190, 2059);
|
|
|
|
m.insert(195, 2113);
|
|
|
|
m.insert(200, 2167);
|
|
|
|
m.insert(205, 2221);
|
|
|
|
m.insert(210, 2275);
|
|
|
|
m.insert(215, 2330);
|
|
|
|
m.insert(220, 2384);
|
|
|
|
m.insert(225, 2438);
|
|
|
|
m.insert(230, 2492);
|
|
|
|
m.insert(235, 2546);
|
|
|
|
m.insert(240, pop_max_price); // 2600
|
|
|
|
|
|
|
|
m.insert(245, pop_max_price);
|
|
|
|
m.insert(250, pop_max_price);
|
|
|
|
m.insert(255, pop_max_price);
|
|
|
|
m.insert(260, pop_max_price);
|
|
|
|
m.insert(270, pop_max_price);
|
|
|
|
m.insert(280, pop_max_price);
|
|
|
|
m.insert(290, pop_max_price);
|
|
|
|
m.insert(300, pop_max_price);
|
2024-02-22 16:25:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct price_t price;
|
|
|
|
for (int duration = pop_min_time; duration <= pop_max_time; duration += 5) {
|
2023-12-05 17:30:12 +01:00
|
|
|
for (int offset = 480; offset < 1080; ++offset) {
|
|
|
|
QDateTime start = s.addSecs(offset * 60);
|
2024-02-22 16:25:30 +01:00
|
|
|
end = QDateTime();
|
|
|
|
price.netto = 0;
|
|
|
|
if (compute_price_for_parking_ticket(&cfg, start, duration, end, &price)) {
|
2024-02-23 14:20:16 +01:00
|
|
|
double cost = price.netto;
|
2024-02-22 16:25:30 +01:00
|
|
|
|
2024-02-24 11:07:04 +01:00
|
|
|
//qCritical() << start.toString(Qt::ISODate) << end.toString(Qt::ISODate)
|
|
|
|
// << duration << cost;
|
2024-02-22 16:25:30 +01:00
|
|
|
|
2024-02-26 16:57:37 +01:00
|
|
|
if (cost != m[duration]) {
|
|
|
|
qCritical() << "ERROR computing_price_for_parking_ticket"
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "HAVE cost" << cost
|
|
|
|
<< "SHOULD HAVE cost" << m[duration];
|
|
|
|
return -1;
|
|
|
|
}
|
2024-02-22 16:25:30 +01:00
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR computing_price_for_parking_ticket AT"
|
|
|
|
<< cnt << "duration" << duration
|
|
|
|
<< "start" << start.toString(Qt::ISODate);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
start = s.addSecs(offset * 60);
|
|
|
|
end = QDateTime();
|
|
|
|
price.netto = 0;
|
|
|
|
|
2024-02-26 16:57:37 +01:00
|
|
|
if (compute_price_for_daily_ticket(&cfg, start, end, PERMIT_TYPE::DAY_TICKET, &price)) {
|
|
|
|
if (price.netto != pop_daily_card_price) {
|
|
|
|
qCritical() << "ERROR computing_price_for_daily_ticket"
|
|
|
|
<< "duration" << duration
|
|
|
|
<< "HAVE cost" << price.netto
|
|
|
|
<< "SHOULD HAVE cost" << pop_daily_card_price;
|
2024-02-22 16:25:30 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2024-02-26 16:57:37 +01:00
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR computing_price_for_daily_ticket AT"
|
|
|
|
<< "start" << start.toString(Qt::ISODate);
|
|
|
|
return -1;
|
2024-02-22 16:25:30 +01:00
|
|
|
}
|
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
// this->getDayTicketPrice(PERMIT_TYPE::DAY_TICKET)
|
|
|
|
|
|
|
|
// start = s.addSecs(offset * 60);
|
|
|
|
// end = QDateTime();
|
|
|
|
// if (compute_duration_for_daily_ticket(&cfg, start, end)) {
|
|
|
|
//
|
|
|
|
// } else {
|
|
|
|
// qCritical() << "ERROR computing_duration_for_daily_ticket AT"
|
|
|
|
// << "start" << start.toString(Qt::ISODate);
|
|
|
|
// return -1;
|
|
|
|
// }
|
2024-02-26 16:57:37 +01:00
|
|
|
|
2024-06-04 11:27:57 +02:00
|
|
|
// ++cnt;
|
2023-12-05 17:30:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-24 15:31:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2023-12-05 17:30:12 +01:00
|
|
|
|
2023-12-06 10:52:35 +01:00
|
|
|
#endif
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
//std::string json = "{\"Currency\":[{\"pcu_id\":2,\"pcu_sign\":\"Ft\",\"pcu_major\":\"HUF\",\"pcu_minor\":\"\",\"pcu_active\":true}],\"PaymentMethod\":[{\"pme_id\":1,\"pme_label\":\"progressive\"},{\"pme_id\":2,\"pme_label\":\"degressive\"},{\"pme_id\":3,\"pme_label\":\"linear\"},{\"pme_id\":4,\"pme_label\":\"steps\"}],\"PaymentOption\":[{\"pop_id\":17,\"pop_label\":\"Zone 1\",\"pop_payment_method_id\":3,\"pop_day_end_time\":\"00:00:00\",\"pop_day_night_end_time\":\"00:00:00\",\"pop_price_night\":0,\"pop_min_time\":15,\"pop_max_time\":240,\"pop_min_price\":120,\"pop_carry_over\":1}],\"PaymentRate\":[{\"pra_payment_option_id\":17,\"pra_payment_unit_id\":3,\"pra_price\":480}],\"Duration\":[{\"pun_id\":1,\"pun_label\":\"1h\",\"pun_duration\":60},{\"pun_id\":2,\"pun_label\":\"1 min\",\"pun_duration\":1},{\"pun_id\":3,\"pun_label\":\"15 min\",\"pun_duration\":15},{\"pun_id\":4,\"pun_label\":\"1d\",\"pun_duration\":1440},{\"pun_id\":6,\"pun_label\":\"2h\",\"pun_duration\":120},{\"pun_id\":7,\"pun_label\":\"3h\",\"pun_duration\":180},{\"pun_id\":11,\"pun_label\":\"4h\",\"pun_duration\":240},{\"pun_id\":17,\"pun_label\":\"30 min\",\"pun_duration\":30},{\"pun_id\":18,\"pun_label\":\"1.5h\",\"pun_duration\":90},{\"pun_id\":20,\"pun_label\":\"10min\",\"pun_duration\":10}],\"WeekDaysWorktime\":[{\"pwd_id\":540,\"pwd_period_week_day_id\":32,\"pwd_period_day_in_week_id\":1,\"pwd_time_from\":\"08:00:00\",\"pwd_time_to\":\"18:00:00\"},{\"pwd_id\":541,\"pwd_period_week_day_id\":32,\"pwd_period_day_in_week_id\":2,\"pwd_time_from\":\"08:00:00\",\"pwd_time_to\":\"18:00:00\"},{\"pwd_id\":542,\"pwd_period_week_day_id\":32,\"pwd_period_day_in_week_id\":3,\"pwd_time_from\":\"08:00:00\",\"pwd_time_to\":\"18:00:00\"},{\"pwd_id\":543,\"pwd_period_week_day_id\":32,\"pwd_period_day_in_week_id\":4,\"pwd_time_from\":\"08:00:00\",\"pwd_time_to\":\"18:00:00\"},{\"pwd_id\":544,\"pwd_period_week_day_id\":32,\"pwd_period_day_in_week_id\":5,\"pwd_time_from\":\"08:00:00\",\"pwd_time_to\":\"18:00:00\"}],\"PeriodYear\":[{\"pye_id\":1,\"pye_label\":\"Summer\",\"pye_start_month\":6,\"pye_start_day\":1,\"pye_end_month\":9,\"pye_end_day\":30},{\"pye_id\":2,\"pye_label\":\"Winter\",\"pye_start_month\":10,\"pye_start_day\":1,\"pye_end_month\":5,\"pye_end_day\":31},{\"pye_id\":8,\"pye_label\":\"Whole year\",\"pye_start_month\":1,\"pye_start_day\":1,\"pye_end_month\":12,\"pye_end_day\":31}],\"SpecialDaysWorktime\":[{\"pedwt_id\":2156,\"pedwt_period_exc_day_id\":2024,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2158,\"pedwt_period_exc_day_id\":2025,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2160,\"pedwt_period_exc_day_id\":2026,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2162,\"pedwt_period_exc_day_id\":2027,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2164,\"pedwt_period_exc_day_id\":2028,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2170,\"pedwt_period_exc_day_id\":2030,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2172,\"pedwt_period_exc_day_id\":2032,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2174,\"pedwt_period_exc_day_id\":11,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2175,\"pedwt_period_exc_day_id\":13,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2178,\"pedwt_period_exc_day_id\":2022,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2179,\"pedwt_period_exc_day_id\":14,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2180,\"pedwt_period_exc_day_id\":2017,\"pedwt_time_from\":\"00:00:00\",\"pedwt_time_to\":\"00:00:00\",\"pedwt_price\":0},{\"pedwt_id\":2181,\"pedwt_period_exc_day_id\":2018,\"pedwt_time_
|
|
|
|
|
|
|
|
for (int zone = 3; zone < 4; ++zone) {
|
|
|
|
// std::string fname("/opt/ptu5/opt/customer_281/szeged/tariff/szeged_winter_sale_zone");
|
|
|
|
std::string fname("/opt/ptu5/opt/ATB-CalculatorLinux_21.12.2022/tariff/szeged_winter_sale_zone");
|
|
|
|
|
|
|
|
fname += std::to_string(zone) + ".json";
|
|
|
|
|
|
|
|
std::cout << fname << std::endl;
|
|
|
|
|
|
|
|
std::ifstream input(fname);
|
|
|
|
std::stringstream sstr;
|
|
|
|
while(input >> sstr.rdbuf());
|
|
|
|
std::string json(sstr.str());
|
|
|
|
|
|
|
|
Calculator calculator;
|
|
|
|
Configuration cfg;
|
|
|
|
|
|
|
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
char const *startDate = "";
|
|
|
|
|
|
|
|
if (isParsed)
|
|
|
|
{
|
|
|
|
struct tm now; // = Utilities::DateTimeToStructTm("2023-03-01T16:00:00");
|
|
|
|
memset(&now, 0, sizeof(now));
|
|
|
|
char buffer[64];
|
2023-05-14 17:19:24 +02:00
|
|
|
//#if 0
|
2023-04-24 15:31:46 +02:00
|
|
|
// 3.Jan 2023 -> Tuesday
|
|
|
|
strptime("2023-01-03T14:00:00", "%Y-%m-%dT%H:%M:%S", &now);
|
|
|
|
for (int i = 0; i < 600; ++i) {
|
|
|
|
|
|
|
|
time_t now_t = mktime(&now);
|
|
|
|
now_t += 60;
|
|
|
|
now = *localtime(&now_t);
|
|
|
|
|
|
|
|
sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02d", now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
|
|
|
|
double cost = calculator.GetCostFromDuration(&cfg, PaymentOption::Option1, buffer, 240, false, true);
|
|
|
|
memset(buffer, 0, 64);
|
|
|
|
|
|
|
|
// cout << "======================================================" << endl;
|
|
|
|
// cout << "zone " << zone << " ===> " << i << " " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
switch (zone) {
|
|
|
|
case 1:
|
|
|
|
assert(cost == 879); // expected value: 880
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
assert(cost == 1920);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// cout << "======================================================" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zone 3 has problems
|
|
|
|
for (int i = 112; i <= 128; ++i)
|
|
|
|
{
|
|
|
|
startDate = "2022-12-23T17:00:00";
|
|
|
|
std::string validity = calculator.GetDurationFromCost(&cfg, PaymentOption::Option1, (char *)startDate, i, false, true);
|
|
|
|
cout << "zone " << zone << ", startDate " << startDate << " _price_ "
|
|
|
|
<< i << " Total duration is: " << validity << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 112; i <= 128; ++i)
|
|
|
|
{
|
|
|
|
startDate = "2022-12-09T18:00:00";
|
|
|
|
std::string validity = calculator.GetDurationFromCost(&cfg, PaymentOption::Option1, (char *)startDate, i, false, true);
|
|
|
|
cout << "zone " << zone << ", startDate " << startDate << " _price_ "
|
|
|
|
<< i << " Total duration is: " << validity << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 112; i <= 128; ++i) {
|
|
|
|
startDate = "2022-12-26T17:00:00";
|
|
|
|
std::string validity = calculator.GetDurationFromCost(&cfg, PaymentOption::Option1, (char *)startDate, i, false, true);
|
|
|
|
cout << "zone " << zone << ", startDate " << startDate << " _price_ "
|
|
|
|
<< i << " Total duration is: " << validity << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//std::string validity = calculator.GetDurationFromCost(&cfg, PaymentOption::Option1, (char*)"2022-12-22T05:00:00", 75, false, true);
|
|
|
|
//cout << "_price_ " << " Total duration is: " << validity << " min" << endl;
|
|
|
|
|
|
|
|
startDate = "2022-12-22T05:00:00";
|
|
|
|
std::string validity = calculator.GetDurationFromCost(&cfg, PaymentOption::Option1, (char*)startDate, 120, false, true);
|
|
|
|
cout << "zone " << zone << ", startDate " << startDate << " _price_ "
|
|
|
|
<< " Total duration is: " << validity << " min" << endl;
|
|
|
|
// working for all zones
|
|
|
|
//
|
|
|
|
// test Easter 2023
|
|
|
|
//
|
|
|
|
memset(&now, 0, sizeof(now));
|
|
|
|
strptime("2023-04-07T06:00:00", "%Y-%m-%dT%H:%M:%S", &now);
|
|
|
|
for (int i=0; i<6*24; ++i) {
|
|
|
|
time_t now_t = mktime(&now);
|
|
|
|
now_t += 60*60;
|
|
|
|
now = *localtime(&now_t);
|
|
|
|
|
|
|
|
sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02d", now.tm_year + 1900,
|
|
|
|
now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
|
|
|
|
|
|
|
|
int const duration = 120;
|
|
|
|
double cost = calculator.GetCostFromDuration(&cfg,
|
2023-05-14 17:19:24 +02:00
|
|
|
PaymentOption::Option1, buffer, duration,
|
|
|
|
false, true);
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
switch (zone) {
|
|
|
|
case 1:
|
|
|
|
cout << "===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
assert(cost == 440);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
assert(cost == 960);
|
|
|
|
cout << "===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (cost == 960) {
|
|
|
|
// cout << "===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
//} else {
|
|
|
|
// cout << "ERROR ===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
// assert(cost == 960);
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
// working for all zones
|
|
|
|
//
|
|
|
|
// test May 1st 2023
|
|
|
|
//
|
|
|
|
memset(&now, 0, sizeof(now));
|
|
|
|
strptime("2023-04-30T06:00:00", "%Y-%m-%dT%H:%M:%S", &now);
|
|
|
|
for (int i=0; i<6*24; ++i) {
|
|
|
|
time_t now_t = mktime(&now);
|
|
|
|
now_t += 60*60;
|
|
|
|
now = *localtime(&now_t);
|
|
|
|
|
|
|
|
sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02d", now.tm_year + 1900,
|
|
|
|
now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
|
|
|
|
|
|
|
|
int const duration = 120;
|
|
|
|
double cost = calculator.GetCostFromDuration(&cfg,
|
2023-05-14 17:19:24 +02:00
|
|
|
PaymentOption::Option1, buffer, duration,
|
|
|
|
false, true);
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
switch (zone) {
|
|
|
|
case 1:
|
|
|
|
cout << "===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
assert(cost == 440);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
assert(cost == 960);
|
|
|
|
cout << "===> [" << i << "] " << asctime(&now) << " - Total cost is: " << cost << " FT" << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// only zone 1 has some minor problems
|
|
|
|
//
|
|
|
|
// test 17/04/2023 - 27/04/2023
|
|
|
|
//
|
|
|
|
memset(&now, 0, sizeof(now));
|
|
|
|
strptime("2023-04-17T06:00:00", "%Y-%m-%dT%H:%M:%S", &now);
|
|
|
|
int duration = 0;
|
|
|
|
//for (int i=0; i<1440; ++i) {
|
|
|
|
for (int i=0; i<1440; ++i) {
|
|
|
|
time_t now_t = mktime(&now);
|
|
|
|
now_t += 600; // 10 minutes
|
|
|
|
now = *localtime(&now_t);
|
|
|
|
|
|
|
|
sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02d", now.tm_year + 1900,
|
|
|
|
now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
|
|
|
|
|
|
|
|
double const compCost = (duration < 15) ? 0 : duration * ((zone == 1) ? 3.6666 : 8.0);
|
|
|
|
double cost = calculator.GetCostFromDuration(&cfg,
|
2023-05-14 17:19:24 +02:00
|
|
|
PaymentOption::Option1, buffer, duration,
|
|
|
|
false, true);
|
2023-04-24 15:31:46 +02:00
|
|
|
if (fabs(cost - compCost) > 1.0) { // zone 1 has rounding errors
|
|
|
|
cout << "ERROR ===> [" << i << "] " << asctime(&now)
|
|
|
|
<< " - Total cost is: " << cost << " FT (computed="
|
|
|
|
<< compCost << ")" << endl;
|
|
|
|
// assert (cost == compCost);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++duration > 240) {
|
|
|
|
duration = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-26 16:57:37 +01:00
|
|
|
|
2023-04-24 15:31:46 +02:00
|
|
|
#endif
|
|
|
|
}
|