Use Calculator::getInstance()
This commit is contained in:
parent
627d14204d
commit
ed99bae725
@ -37,8 +37,8 @@ extern "C" char* strptime(const char* s,
|
||||
#define SZEGED (0)
|
||||
#define SCHOENAU_KOENIGSEE (0)
|
||||
#define NEUHAUSER_KORNEUBURG (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_KIRCHDORF (0)
|
||||
|
||||
@ -569,15 +569,16 @@ int main() {
|
||||
int Up = 1;
|
||||
//compute_next_timestep(&cfg, )
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
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.GetPriceForTimeStep(&cfg, timeSteps.at(i));
|
||||
// uint32_t duration = calculator.GetDurationForPrice(&cfg, price);
|
||||
// qCritical() << "nextTimeStep relative to start:"
|
||||
// << duration << start.addSecs(duration * 60)
|
||||
// << "(price so far:" << price << ")";
|
||||
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i));
|
||||
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
||||
qCritical() << "nextTimeStep relative to start:"
|
||||
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||
<< "(price so far:" << price << ")";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -645,14 +646,13 @@ int main() {
|
||||
#endif
|
||||
|
||||
#if NEUHAUSER_KORNEUBURG==1
|
||||
std::ifstream input("/tmp/tariff_korneuburg.json");
|
||||
std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
|
||||
int pop_max_time;
|
||||
|
||||
std::stringstream sstr;
|
||||
while(input >> sstr.rdbuf());
|
||||
std::string json(sstr.str());
|
||||
|
||||
Calculator calculator;
|
||||
Configuration cfg;
|
||||
|
||||
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||
@ -674,19 +674,19 @@ int main() {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
//qCritical() << "";
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "end" << end.toString(Qt::ISODate)
|
||||
// << "duration" << duration
|
||||
// << "cost" << cost;
|
||||
|
||||
std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< "duration" << duration
|
||||
<< "cost" << cost;
|
||||
|
||||
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "cost" << cost
|
||||
// << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user