From 1023f6ede166f39ba82da1c208be058a53be3383 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 2 Aug 2024 11:12:07 +0200 Subject: [PATCH] GetPriceForTimeStep(): Use "pop_accumulate_durations" setting to sum up the durations. Otherwise time-step will not be found in time-step-list. --- library/src/calculator_functions.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp index 0273e63..9c908de 100644 --- a/library/src/calculator_functions.cpp +++ b/library/src/calculator_functions.cpp @@ -2810,11 +2810,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p // paymentOptionIndex = 1; int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id; + int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations; int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices; uint32_t price = 0; + int pun_duration = 0; - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex; //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep; //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id; @@ -2828,19 +2830,25 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id; //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id; - int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration; - //int const pun_duration = cfg->Duration.find(2)->second.pun_duration; + if (pop_accumulate_durations) { + pun_duration += cfg->Duration.find(payment_unit_id)->second.pun_duration; + } else { + pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration; + } + if (pop_accumulate_prices) { price += itr->second.pra_price; } else { price = (uint32_t)(itr->second.pra_price); } - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price; - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id; - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id; - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration; - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep; + if (DBG_LEVEL >= DBG_DEBUG) { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep; + } if (timeStep == pun_duration) { qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;