minor: add some utility lines

This commit is contained in:
Gerhard Hoffmann 2024-10-21 13:06:22 +02:00
parent 1f6606f382
commit 5cfca87f3e

View File

@ -39,10 +39,10 @@ extern "C" char* strptime(const char* s,
#define SZEGED (0)
#define SCHOENAU_KOENIGSEE (0)
#define NEUHAUSER_KORNEUBURG (1)
#define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
#define NEUHAUSER_BILEXA_GALTUER (0)
#define NEUHAUSER_BILEXA_GALTUER (1)
#define BAD_NEUENAHR_AHRWEILER (0)
#define NEUHAUSER_CHRISTOPH_REISEN (0)
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
@ -53,6 +53,7 @@ extern "C" char* strptime(const char* s,
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
#define VALSER_ALM (0)
#define NEUHAUSER_FORCHACH (0)
#define STADT_WEIDEN (0)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -221,10 +222,17 @@ int main() {
// 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);
// {
// "pun_duration": 0,
// "pun_id": 0,
// "pun_label": "0 min"
// }
//for (int i = 0; i <= 140; ++i) {
//printf("{\n \"\pun_duration\": %d,\n \"\pun_id\": %d,\n \"pun_label\": \"%d min\"\n},\n",
// i*6, i, i*6);
//}
//return 0;
#if 0
MessageHelper msgHelp;
@ -2673,7 +2681,7 @@ int main() {
int Up = 1;
//compute_next_timestep(&cfg, )
QDateTime const start = QDateTime::currentDateTime();
QDateTime const start = QDateTime::fromString("2024-10-13T12:00:00");
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
if (paymentOptionIndex < 0) {
@ -2685,7 +2693,7 @@ int main() {
QSet<uint32_t> const prices{700, 1400, 2100, 2800, 3500, 4200, 4900};
for (int i=0; i<timeSteps.size(); ++i) {
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << "nextTimeStep" << nextTimeStep;
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
@ -2785,6 +2793,66 @@ int main() {
}
#endif
#if STADT_WEIDEN==1
std::ifstream input("/opt/ptu5/opt/customer_6/etc/psa_tariff/tariff01.json");
int pop_max_time;
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) {
qCritical() << __func__ << ":" << __LINE__ << "parsed";
QDateTime s(QDate(2024, 10, 14), QTime());
QDateTime end;
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
qCritical() << "TimeSteps" << timeSteps;
int offset = 1150;
QDateTime start = s.addSecs(offset * 60);
CalcState cs;
#if 0
struct price_t costs;
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
QDateTime end = start.addSecs(timeSteps.at(i)*60);
// if (i != 2) continue;
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
int price1 = costs.netto;
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
<< timeSteps.at(i) << "ZZZZZZZZZZZZZ PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
}
exit(0);
}
#else
double cost = 220;
qCritical() << "XXXXXXXX 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);
//}
exit(0);
}
#endif
#endif // STADT WEIDEN
#if NEUHAUSER_KORNEUBURG==1
std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
int pop_max_time;