Minor: small changes for tests of SCHOENAU

This commit is contained in:
Gerhard Hoffmann 2024-04-24 09:54:29 +02:00
parent 3b813e5eff
commit 76bb1eb56a

View File

@ -35,7 +35,7 @@ extern "C" char* strptime(const char* s,
#include "calculate_price.h" #include "calculate_price.h"
#define SZEGED (0) #define SZEGED (0)
#define SCHOENAU_KOENIGSEE (0) #define SCHOENAU_KOENIGSEE (1)
#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)
@ -43,7 +43,7 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_KIRCHDORF (0) #define NEUHAUSER_KIRCHDORF (0)
#define BAD_NEUENAHR_AHRWEILER (0) #define BAD_NEUENAHR_AHRWEILER (0)
#define NEUHAUSER_CHRISTOPH_REISEN (0) #define NEUHAUSER_CHRISTOPH_REISEN (0)
#define NEUHAUSER_PERNEGG_AN_DER_MUR (1) #define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
int main() { int main() {
#if NEUHAUSER_PERNEGG_AN_DER_MUR==1 #if NEUHAUSER_PERNEGG_AN_DER_MUR==1
@ -475,44 +475,54 @@ int main() {
#endif #endif
#if SCHOENAU_KOENIGSEE==1 #if SCHOENAU_KOENIGSEE==1
//QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff01.json"); for (int zone=1; zone < 3; ++zone) {
QString f("/opt/ptu5/opt/customer_332/etc/psa_tariff/tariff02.json"); std::ifstream input;
std::ifstream input(f.toUtf8().constData()); 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");
}
std::stringstream sstr; qCritical() << "--------------------";
while(input >> sstr.rdbuf()); qCritical() << " ZONE" << zone;
std::string json(sstr.str()); qCritical() << "--------------------";
Configuration cfg; std::stringstream sstr;
while(input >> sstr.rdbuf());
std::string json(sstr.str());
bool isParsed = cfg.ParseJson(&cfg, json.c_str()); Configuration cfg;
cout << endl;
if (isParsed) { bool isParsed = cfg.ParseJson(&cfg, json.c_str());
qCritical() << "parsed" << f; cout << endl;
int minParkingTime = get_minimal_parkingtime(&cfg); if (isParsed) {
qCritical() << "minimal_parking_time" << minParkingTime; // qCritical() << "parsed zone" << zone << "file";
QDateTime start = QDateTime::currentDateTime(); int minParkingTime = get_minimal_parkingtime(&cfg);
qCritical() << "minimal_parking_time" << minParkingTime;
// zone 1 QDateTime start = QDateTime::currentDateTime();
//int timeSteps[] = {60, 180, 1440, 2880, 4320, 5670, 7200, 8640, 10080, 11520, 12960, 14400};
static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg); // zone 1
qCritical() << "TimeSteps" << timeSteps; //int timeSteps[] = {60, 180, 1440, 2880, 4320, 5670, 7200, 8640, 10080, 11520, 12960, 14400};
for (int i = 0 ; i < timeSteps.size(); ++i) { static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
QDateTime end = start.addSecs(timeSteps.at(i)*60); qCritical() << "TimeSteps" << timeSteps;
double price = Calculator::GetInstance().GetCostFromDuration( for (int i = 0 ; i < timeSteps.size(); ++i) {
&cfg, QDateTime end = start.addSecs(timeSteps.at(i)*60);
start,
timeSteps.at(i)); double price = Calculator::GetInstance().GetCostFromDuration(
qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i) &cfg,
<< "(" << timeSteps.at(i)/60 << "h)" start,
<< "price=" << price; timeSteps.at(i));
qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i)
<< "(" << timeSteps.at(i)/60 << "h)"
<< "price=" << price;
}
} }
} }
#endif #endif