Compare commits

..

No commits in common. "861a405ec07f0480a906869d80823d2a68dec79a" and "8367eb9fa828b1a20c7c72bb378f443ded559c2f" have entirely different histories.

4 changed files with 77 additions and 36 deletions

View File

@ -91,7 +91,7 @@ public:
// helper function to find time steps for a tariff with PaymentMethod::Steps // helper function to find time steps for a tariff with PaymentMethod::Steps
// (e.g. Schoenau/Koenigsee) // (e.g. Schoenau/Koenigsee)
// //
QList<int> &GetTimeSteps(Configuration *cfg, int paymentOptionIndex=0) const; QList<int> GetTimeSteps(Configuration *cfg, int paymentOptionIndex=0) const;
QList<int> GetSteps(Configuration *cfg, int paymentOptionIndex=0) const { return GetTimeSteps(cfg, paymentOptionIndex); } QList<int> GetSteps(Configuration *cfg, int paymentOptionIndex=0) const { return GetTimeSteps(cfg, paymentOptionIndex); }
QList<int> GetPriceSteps(Configuration *cfg) const; QList<int> GetPriceSteps(Configuration *cfg) const;

View File

@ -344,7 +344,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes; qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown; qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
Configuration const *cfg = tariff; Configuration *cfg = tariff;
// compute payment method id (e.g. Linear=3, Steps=4) // compute payment method id (e.g. Linear=3, Steps=4)
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg); PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
@ -372,39 +372,71 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
// progressive tariff: e.g. Neuhauser, Kirchdorf (743) // progressive tariff: e.g. Neuhauser, Kirchdorf (743)
(paymentMethodId == PaymentMethod::Progressive)) (paymentMethodId == PaymentMethod::Progressive))
{ {
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff); QVector<QList<int>> stepListVec;
int const size = stepList.size(); QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(tariff);
if (size == 0) {
qCritical() << "compute_next_timestep() *ERROR empty step-list*"; qCritical() << " compute_next_timestep() time-steps: " << timeSteps;
int paymentOptionIndex = 0;
int const pop_time_step_config = tariff->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
QList<int> lst;
for (int index = 0; index < 5; ++index) {
lst.clear();
QListIterator<int> i(timeSteps);
while (i.hasNext()) {
switch (index) {
case 0:
lst.append(i.next());
break;
case 1:
lst.append(i.next() - 2);
break;
case 2:
lst.append(i.next() - 1);
break;
case 3:
lst.append(i.next() + 1);
break;
case 4:
lst.append(i.next() + 2);
break;
default:;
}
}
qCritical() << " compute_next_timestep() " << index << "list of time-steps" << lst;
stepListVec.append(lst);
}
}
int stepListIndex = -1;
for (int index = 0; index < stepListVec.size(); ++index) {
if (stepListVec[index].indexOf(currentTimeMinutes) != -1) {
stepListIndex = index;
break;
}
}
if (stepListIndex == -1) {
qCritical() << "compute_next_timestep() *NO STEP INDEX* for currentTimeMinutes (" << currentTimeMinutes << ")";
return currentTimeMinutes; return currentTimeMinutes;
} }
qCritical() << " compute_next_timestep() first time step:" << stepList[0]; QList<int> const &stepList = stepListVec[stepListIndex];
qCritical() << " compute_next_timestep() index:" << stepListIndex;
qCritical() << " compute_next_timestep() timeSteps:" << stepList; qCritical() << " compute_next_timestep() timeSteps:" << stepList;
qCritical() << " compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
// consider time shift: the step-list might have been computed at a int const currentStepIndex = stepList.indexOf(currentTimeMinutes); // must be currentStepIndex != -1
// slightly different time point
int maxStep = -1;
if (size >= 2) {
maxStep = stepList[1] - stepList[0];
}
int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
if (std::abs(stepList[0] - currentTimeMinutes) <= tolerance) {
qCritical().noquote()
<< QString(" compute_next_timestep() correction stepList[0]=%1 -> %2:")
.arg(stepList[0]).arg(currentTimeMinutes);
stepList[0] = currentTimeMinutes;
qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList;
}
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
if (currentStepIndex == -1) { if (currentStepIndex == -1) {
qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")"; qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
return currentTimeMinutes; return currentTimeMinutes;
} }
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = stepList.first();
if (UpDown == 1) { // UP if (UpDown == 1) { // UP
if (stepList[currentStepIndex] == stepList.last()) { if (stepList[currentStepIndex] == stepList.last()) {
qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")"; qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";

View File

@ -2090,17 +2090,21 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
return QList<int>(); return QList<int>();
} }
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const { QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex; qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg << "paymentOptionIndex:" << paymentOptionIndex;
if (m_timeSteps.size() > paymentOptionIndex) { if (m_timeSteps.size() > paymentOptionIndex) {
if (!m_timeSteps[paymentOptionIndex].isEmpty()) { qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps[m_timeSteps.size() - 1];
return m_timeSteps[paymentOptionIndex]; qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps;
} qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps size:" << m_timeSteps.size();
return m_timeSteps[m_timeSteps.size() - 1];
} else { } else {
m_timeSteps.push_back(QList<int>()); m_timeSteps.push_back(QList<int>());
qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps;
} }
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "m_timeSteps:" << m_timeSteps;
QDateTime start = QDateTime::currentDateTime(); QDateTime start = QDateTime::currentDateTime();
start.setTime(QTime(start.time().hour(), start.time().minute(), 0)); start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
@ -2124,6 +2128,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
m_timeSteps[paymentOptionIndex].append(step); m_timeSteps[paymentOptionIndex].append(step);
} }
} else { } else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
uint16_t timeStepCompensation = 0; uint16_t timeStepCompensation = 0;
if (pop_carry_over) { if (pop_carry_over) {
@ -2201,7 +2207,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
} }
} }
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps; qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "NEW timeSteps:" << m_timeSteps;
return m_timeSteps[paymentOptionIndex]; return m_timeSteps[paymentOptionIndex];
} }

View File

@ -2755,7 +2755,7 @@ int main() {
#endif #endif
#if NEUHAUSER_BILEXA_GALTUER==1 #if NEUHAUSER_BILEXA_GALTUER==1
std::ifstream input("/home/linux/customer_745/etc/psa_tariff/tariff01.json"); std::ifstream input("/opt/ptu5/opt/customer_745/etc/psa_tariff/tariff01.json");
std::stringstream sstr; std::stringstream sstr;
while(input >> sstr.rdbuf()); while(input >> sstr.rdbuf());
@ -2781,6 +2781,9 @@ int main() {
int nextStep = compute_next_timestep(&cfg, minParkTime + 1, 1); int nextStep = compute_next_timestep(&cfg, minParkTime + 1, 1);
qCritical() << "nextStep" << nextStep; qCritical() << "nextStep" << nextStep;
return 0;
QDateTime const start = QDateTime::currentDateTime(); QDateTime const start = QDateTime::currentDateTime();
int paymentOptionIndex = cfg.getPaymentOptionIndex(start); int paymentOptionIndex = cfg.getPaymentOptionIndex(start);