Added test-cases for Neuhauser-Christoph-Reisen (746) and Neuhauser-Pernegg-an-der-Mur (747)
This commit is contained in:
parent
b0c4ad0e2e
commit
8ff5b8e2b5
189
main/main.cpp
189
main/main.cpp
@ -41,9 +41,196 @@ extern "C" char* strptime(const char* s,
|
|||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||||
#define NEUHAUSER_KIRCHDORF (0)
|
#define NEUHAUSER_KIRCHDORF (0)
|
||||||
#define BAD_NEUENAHR_AHRWEILER (1)
|
#define BAD_NEUENAHR_AHRWEILER (0)
|
||||||
|
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
||||||
|
#define NEUHAUSER_PERNEGG_AN_DER_MUR (1)
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#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);
|
||||||
|
qCritical() << QString("price (%1) :").arg(start.time().toString(Qt::ISODate)) << price;
|
||||||
|
|
||||||
|
start.setTime(QTime(6, 0, 0));
|
||||||
|
productStart = productEnd = QDateTime();
|
||||||
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||||
|
qCritical() << QString("price (%1-%2) :")
|
||||||
|
.arg(productStart.time().toString(Qt::ISODate))
|
||||||
|
.arg(productEnd.time().toString(Qt::ISODate))
|
||||||
|
<< price;
|
||||||
|
|
||||||
|
start.setTime(QTime(15, 0, 0));
|
||||||
|
productStart = productEnd = QDateTime();
|
||||||
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||||
|
qCritical() << QString("price (%1-%2) :")
|
||||||
|
.arg(productStart.time().toString(Qt::ISODate))
|
||||||
|
.arg(productEnd.time().toString(Qt::ISODate))
|
||||||
|
<< price;
|
||||||
|
|
||||||
|
start.setTime(QTime(16, 0, 0));
|
||||||
|
productStart = productEnd = QDateTime();
|
||||||
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||||
|
qCritical() << QString("price (%1-%2) :")
|
||||||
|
.arg(productStart.time().toString(Qt::ISODate))
|
||||||
|
.arg(productEnd.time().toString(Qt::ISODate))
|
||||||
|
<< price;
|
||||||
|
|
||||||
|
start.setTime(QTime(17, 0, 0));
|
||||||
|
productStart = productEnd = QDateTime();
|
||||||
|
price = compute_product_price(&cfg, PERMIT_TYPE::INVALID, start, &productStart, &productEnd);
|
||||||
|
qCritical() << QString("price (%1-%2) :")
|
||||||
|
.arg(productStart.time().toString(Qt::ISODate))
|
||||||
|
.arg(productEnd.time().toString(Qt::ISODate))
|
||||||
|
<< price;
|
||||||
|
}
|
||||||
|
#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();
|
||||||
|
//start.setTime(QTime(0, 0, 0));
|
||||||
|
|
||||||
|
struct price_t costs;
|
||||||
|
double const cost[] = {600, 700, 800, 1600, 2400, 3000, 3600};
|
||||||
|
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: "
|
||||||
|
<< timeSteps.at(i) << "PRICE=" << price1;
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
#if BAD_NEUENAHR_AHRWEILER==1
|
#if BAD_NEUENAHR_AHRWEILER==1
|
||||||
std::ifstream input;
|
std::ifstream input;
|
||||||
int pop_min_time;
|
int pop_min_time;
|
||||||
|
Loading…
Reference in New Issue
Block a user