Add testcase for Kirchdorf

This commit is contained in:
Gerhard Hoffmann 2024-02-15 16:12:10 +01:00
parent 92c3b7c97c
commit 2ec94121f7

View File

@ -38,7 +38,8 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0) #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
#define NEUHAUSER_BILEXA_GALTUER (1) #define NEUHAUSER_BILEXA_GALTUER (0)
#define NEUHAUSER_KIRCHDORF (1)
int main() { int main() {
@ -87,6 +88,91 @@ int main() {
} }
#endif #endif
#if NEUHAUSER_KIRCHDORF==1
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;
#if 1
bool nextDay = false;
bool prePaid = true;
// bool carryOver = false;
QDateTime s(QDate(2023, 11, 30), QTime());
// QDateTime s(QDate(2023, 11, 26), QTime());
QDateTime end;
for (int duration = 30; duration <= 30; duration += 5) {
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
qCritical() << "";
for (int offset = 721; offset <= 721; ++offset) {
//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);
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
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);
qCritical() << "duration (soll):" << duration;
qCritical() << "duration (ist) :" << duration_ist;
qCritical() << " cost (soll):" << cost_soll;
qCritical() << " cost (ist) :" << cost;
if (cost_soll != cost) {
qCritical() << "ERROR" << __func__ << ":" << __LINE__
<< "cost_soll" << cost_soll << "cost_ist" << cost;
break;
}
if (duration != duration_ist) {
//qCritical() << "ERROR" << __func__ << ":" << __LINE__
// << "duration_soll" << duration << "duration_ist" << duration_ist;
//break;
}
//std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
//qCritical() << "start" << start.toString(Qt::ISODate)
// << "cost" << cost
// << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
}
}
#endif // 0
}
#endif
#if NEUHAUSER_BILEXA_GALTUER==1 #if NEUHAUSER_BILEXA_GALTUER==1
std::ifstream input("/opt/ptu5/opt/customer_745/etc/psa_tariff/tariff01.json"); std::ifstream input("/opt/ptu5/opt/customer_745/etc/psa_tariff/tariff01.json");