Commit c66ad64d authored by Gerrit Erichsen's avatar Gerrit Erichsen
Browse files

Fixing some issues, while missing the most pressing one.

parent 3ed93d3e
......@@ -313,7 +313,7 @@ void CharLAlgorithm::addConventionalPlant(size_t network, size_t location, strin
}
void CharLAlgorithm::addStoragePlant(size_t network, size_t location, string name,
double nominalPower, double capacity,
double nominalPowerCharge, double nominalPowerDischarge, double capacity,
double gradientCharge, double gradientDischarge,
const EfficiencyField &efficiencyCharge, const EfficiencyField &efficiencyDischarge,
vector<pair<double, double> > selfDischarge,
......@@ -329,7 +329,8 @@ void CharLAlgorithm::addStoragePlant(size_t network, size_t location, string nam
{
if (network < m_nodes.size())
{
Storage dummy(name, nominalPower, capacity, gradientCharge, gradientDischarge,
Storage dummy(name, nominalPowerCharge, nominalPowerDischarge,
capacity, gradientCharge, gradientDischarge,
efficiencyCharge, efficiencyDischarge, selfDischarge,
startTimeHotCharge, startTimeWarmCharge, startTimeColdCharge,
startTimeHotDischarge, startTimeWarmDischarge, startTimeColdDischarge,
......
......@@ -105,7 +105,7 @@ public:
double hotStartEmissions, double warmStartEmissions, double coldStartEmissions,
double temperatureCoefficient, string fuelType, int lifeTime);
void addStoragePlant(size_t network, size_t location, string name,
double nominalPower, double capacity,
double nominalPowerCharge, double nominalPowerDischarge, double capacity,
double gradientCharge, double gradientDischarge,
const EfficiencyField &efficiencyCharge, const EfficiencyField &efficiencyDischarge,
vector<pair<double, double> > selfDischarge,
......
......@@ -73,7 +73,7 @@ void Node::addStoragePlant(Storage & plant)
//add storage plant to network
m_storage.push_back(new Storage(plant));
//integrate installed storage power
m_installedStoragePower += plant.getNominalPower();
m_installedStoragePower += plant.getNominalPowerCharge();
m_installedStorageCapacity += plant.getStorageCapacity();
//calculate invest cost of storage plant and add to result
m_result->addToInvestCostOfNetworkStorage(plant.getAnnuityCost());
......@@ -1245,7 +1245,7 @@ void Node::calculateStoragePowerOperationPlan(int timeStep)
// get Forecast for storage
//only if forecasted load is not close to zero
if (!isCloseEnoughToEqual(fabs(m_storage[j]->getForecastLoad(timeStep)), 0., m_storage[j]->getNominalPower() * 1e-5))
if (!isCloseEnoughToEqual(fabs(m_storage[j]->getForecastLoad(timeStep)), 0., m_storage[j]->getNominalPowerCharge() * 1e-5))
{
//get forecasted storage load
storageLoadForecast = m_storage[j]->getForecastLoad(timeStep);
......@@ -2041,22 +2041,22 @@ void Node::calculateForecastStatistics(int time, bool reset)
if (m_storage[i]->getForecastLoad(time) > 0.)
{
storageEmissionsForecast += m_storage[i]->getForecastLoad(time) * storageEmissionFactor * m_preferences->getStepTime()
* (1. / m_storage[i]->getEfficiencyDischargeParameterA() * m_storage[i]->getForecastLoad(time) + m_storage[i]->getEfficiencyDischargeParameterB() * m_storage[i]->getNominalPower());
* (1. / m_storage[i]->getEfficiencyDischargeParameterA() * m_storage[i]->getForecastLoad(time) + m_storage[i]->getEfficiencyDischargeParameterB() * m_storage[i]->getNominalPowerCharge());
}
else if (m_storage[i]->getForecastLoad(time) < 0.)
{
storageEmissionsForecast += m_storage[i]->getForecastLoad(time) * storageEmissionFactor * m_preferences->getStepTime()
* (m_storage[i]->getEfficiencyChargeParameterA() * fabs(m_storage[i]->getForecastLoad(time)) - m_storage[i]->getEfficiencyChargeParameterB() * m_storage[i]->getNominalPower());
* (m_storage[i]->getEfficiencyChargeParameterA() * fabs(m_storage[i]->getForecastLoad(time)) - m_storage[i]->getEfficiencyChargeParameterB() * m_storage[i]->getNominalPowerCharge());
}
if (m_storage[i]->getPowerAtTimeStep(time) > 0.)
{
storageEmissionsAlgorithm += m_storage[i]->getPowerAtTimeStep(time) * storageEmissionFactor * m_preferences->getStepTime()
* (1. / m_storage[i]->getEfficiencyDischargeParameterA() * m_storage[i]->getPowerAtTimeStep(time) + m_storage[i]->getEfficiencyDischargeParameterB() * m_storage[i]->getNominalPower());
* (1. / m_storage[i]->getEfficiencyDischargeParameterA() * m_storage[i]->getPowerAtTimeStep(time) + m_storage[i]->getEfficiencyDischargeParameterB() * m_storage[i]->getNominalPowerCharge());
}
else if (m_storage[i]->getPowerAtTimeStep(time) < 0.)
{
storageEmissionsAlgorithm += m_storage[i]->getPowerAtTimeStep(time) * storageEmissionFactor * m_preferences->getStepTime()
* (m_storage[i]->getEfficiencyChargeParameterA() * fabs(m_storage[i]->getPowerAtTimeStep(time)) - m_storage[i]->getEfficiencyChargeParameterB() * m_storage[i]->getNominalPower());
* (m_storage[i]->getEfficiencyChargeParameterA() * fabs(m_storage[i]->getPowerAtTimeStep(time)) - m_storage[i]->getEfficiencyChargeParameterB() * m_storage[i]->getNominalPowerCharge());
}
}
for (int i = 0; i < m_conventional.size(); i++)
......
......@@ -6,7 +6,8 @@
#include "OptimisationSchedule.h" //tz - needed for linearisation of efficiency curves
Storage::Storage(string name, double nominalPower, double capacity, double gradientCharge, double gradientDischarge,
Storage::Storage(string name, double nominalPower, double nominalPowerDischarge, double capacity,
double gradientCharge, double gradientDischarge,
EfficiencyField efficiencyCharge, EfficiencyField efficiencyDischarge,
vector<pair<double, double> > selfDischarge, double startTimeHotCharge, double startTimeWarmCharge,
double startTimeColdCharge, double startTimeHotDischarge, double startTimeWarmDischarge,
......@@ -19,7 +20,7 @@ Storage::Storage(string name, double nominalPower, double capacity, double gradi
int lifeTimeCharge, int lifeTimeDischarge, double typicalUnitSizeCharge, double typicalUnitSizeDischarge,
const SimulationPreferences * preferences): // bw: added from GUI
m_name(name),
m_nominalPower(nominalPower),
m_nominalPowerCharge(nominalPower),
m_gradientCharge(gradientCharge),
m_gradientDischarge(gradientDischarge),
m_storageCapacity(capacity),
......@@ -70,8 +71,8 @@ Storage::Storage(string name, double nominalPower, double capacity, double gradi
{
m_minPowerCharge = m_efficiencyCharge.getMinX() * nominalPower;
m_maxPowerCharge = m_efficiencyCharge.getMaxX() * nominalPower;
m_minPowerDischarge = m_efficiencyDischarge.getMinX() * nominalPower;
m_maxPowerDischarge = m_efficiencyDischarge.getMaxX() * nominalPower;
m_minPowerDischarge = m_efficiencyDischarge.getMinX() * nominalPowerDischarge;
m_maxPowerDischarge = m_efficiencyDischarge.getMaxX() * nominalPowerDischarge;
size_t nSteps = static_cast<size_t>(m_preferences->getNumberOfTimeSteps());
m_load.assign(nSteps, 0.);
......@@ -117,7 +118,7 @@ Storage::Storage(string name, double nominalPower, double capacity, double gradi
Storage::Storage(const Storage & rhs) :
m_name(rhs.m_name),
m_nominalPower(rhs.m_nominalPower),
m_nominalPowerCharge(rhs.m_nominalPowerCharge),
m_gradientCharge(rhs.m_gradientCharge),
m_gradientDischarge(rhs.m_gradientDischarge),
m_storageCapacity(rhs.m_storageCapacity),
......@@ -231,7 +232,7 @@ void Storage::charge(double power, size_t step)
}
//setting values accordingly to result
m_load[step] = -power;
m_fullLoadHoursCharge += power * m_preferences->getStepTime() / m_nominalPower;
m_fullLoadHoursCharge += power * m_preferences->getStepTime() / m_nominalPowerCharge;
}
void Storage::discharge(double power, size_t step)
......@@ -244,7 +245,9 @@ void Storage::discharge(double power, size_t step)
{
if (power * m_preferences->getStepTime() * getEfficiencyDischarge(step, power) < m_initialStorageLevel)
{
m_storageLevel[step] = m_initialStorageLevel - power * m_preferences->getStepTime() / getEfficiencyDischarge(step, power);
m_storageLevel[step] = m_initialStorageLevel
- power * m_preferences->getStepTime()
/ getEfficiencyDischarge(step, power);
m_lastStepOfPower = step;
}
else if (m_initialStorageLevel > 0.)
......@@ -253,8 +256,9 @@ void Storage::discharge(double power, size_t step)
do
{
power = powerNew;
powerNew = m_initialStorageLevel / m_preferences->getStepTime() * getEfficiencyDischarge(step, power);
}while(fabs(power - powerNew) > 0.01 * power);
powerNew = m_initialStorageLevel
/ m_preferences->getStepTime() * getEfficiencyDischarge(step, power);
} while(fabs(power - powerNew) > 0.01 * power);
power = powerNew;
m_storageLevel[step] = 0.;
m_lastStepOfPower = step;
......@@ -267,7 +271,9 @@ void Storage::discharge(double power, size_t step)
}
else if (power * m_preferences->getStepTime() * getEfficiencyDischarge(step, power) <= m_storageLevel[step - 1])
{
m_storageLevel[step] = m_storageLevel[step - 1] - power * m_preferences->getStepTime() / getEfficiencyDischarge(step, power);
m_storageLevel[step] = m_storageLevel[step - 1]
- power * m_preferences->getStepTime()
/ getEfficiencyDischarge(step, power);
m_lastStepOfPower = step;
}
else if (m_storageLevel[step - 1] > 0.)
......@@ -276,14 +282,15 @@ void Storage::discharge(double power, size_t step)
do
{
power = powerNew;
powerNew = m_storageLevel[step - 1] / m_preferences->getStepTime() * getEfficiencyDischarge(step, power); //"power" for efficiency not entirely correct, though
}while(fabs(power - powerNew) > 0.01 * power);
powerNew = m_storageLevel[step - 1]
/ m_preferences->getStepTime() * getEfficiencyDischarge(step, power); //"power" for efficiency not entirely correct, though
} while(fabs(power - powerNew) > 0.01 * power);
power = powerNew;
m_storageLevel[step] = 0.;
m_lastStepOfPower = step;
}
m_load[step] = power;
m_fullLoadHoursDischarge += power * m_preferences->getStepTime() / m_nominalPower;
m_fullLoadHoursDischarge += power * m_preferences->getStepTime() / m_nominalPowerDischarge;
}
void Storage::turnOff(int step, bool charging)
......@@ -291,11 +298,11 @@ void Storage::turnOff(int step, bool charging)
if (step < 0 || step >= (int)m_load.size()) return;
if (charging)
{
m_fullLoadHoursCharge -= fabs(m_load[step]) * m_preferences->getStepTime() / m_nominalPower;
m_fullLoadHoursCharge -= fabs(m_load[step]) * m_preferences->getStepTime() / m_nominalPowerCharge;
}
else
{
m_fullLoadHoursDischarge -= m_load[step] * m_preferences->getStepTime() / m_nominalPower;
m_fullLoadHoursDischarge -= m_load[step] * m_preferences->getStepTime() / m_nominalPowerCharge;
}
m_load[step] = 0.;
selfDischarge(step);
......@@ -471,7 +478,7 @@ double Storage::getMinPowerCharge(int step) const
{
lastStorageLevel = m_storageLevel[step - 1];
powerByGradient = m_load[step - 1]
- m_nominalPower * m_gradientCharge * 0.01 * 60. * m_preferences->getStepTime();
- m_nominalPowerCharge * m_gradientCharge * 0.01 * 60. * m_preferences->getStepTime();
if ((m_storageCapacity - lastStorageLevel) / m_preferences->getStepTime()
< std::max(m_minPowerCharge, powerByGradient)) return 0.;
}
......@@ -507,7 +514,7 @@ double Storage::getMinPowerDischarge(int step)
if (step > 0 && !isCloseEnoughToEqual(m_gradientDischarge, 0.))
{
double power = m_load[step - 1]
- m_gradientDischarge * 0.01 * m_nominalPower * m_preferences->getStepTime() * 60.;
- m_gradientDischarge * 0.01 * m_nominalPowerCharge * m_preferences->getStepTime() * 60.;
return std::max(m_minPowerDischarge, power);
}
......@@ -538,7 +545,7 @@ double Storage::getMaxPowerDischarge(int step) const
double powerLimitFromLoad = m_maxPowerDischarge;
if (step > 0 && !isCloseEnoughToEqual(m_gradientDischarge, 0.))
{
powerLimitFromLoad = m_load[step - 1] + m_gradientDischarge * 0.01 * m_nominalPower * m_preferences->getStepTime() * 60.;
powerLimitFromLoad = m_load[step - 1] + m_gradientDischarge * 0.01 * m_nominalPowerCharge * m_preferences->getStepTime() * 60.;
powerLimitFromLoad = std::min(powerLimitFromLoad, m_maxPowerDischarge);
}
return std::min(powerLimitFromLoad, powerLimitFromCapacity * getEfficiencyDischarge(step, powerLimitFromCapacity));
......@@ -558,7 +565,8 @@ double Storage::getEfficiencyCharge(size_t step, double power) const
if (m_preferences->getLevelOfInterpolation() == 1)
{
return m_efficiencyCharge.getEfficiency(power, lastStorageLevel / m_storageCapacity);
return m_efficiencyCharge.getEfficiency(power / m_nominalPowerCharge,
lastStorageLevel / m_storageCapacity);
}
else //level = 0 --> const value required
{
......@@ -584,7 +592,8 @@ double Storage::getEfficiencyDischarge(size_t step, double power) const
if (m_preferences->getLevelOfInterpolation() == 1)
{
return m_efficiencyDischarge.getEfficiency(power, lastStorageLevel / m_storageCapacity);
return m_efficiencyDischarge.getEfficiency(power / m_nominalPowerDischarge,
lastStorageLevel / m_storageCapacity);
}
else //level = 0 --> const value required
{
......@@ -618,7 +627,7 @@ double Storage::getInitialStorageLevelAsPercentage() const
double Storage::getInvestCost() const
{
//TODO: when splitting discharge and charge power, make better calculation
double investCostPower = m_nominalPower * m_specificInvestCostPowerCharge + m_nominalPower * m_specificInvestCostPowerDischarge;
double investCostPower = m_nominalPowerCharge * m_specificInvestCostPowerCharge + m_nominalPowerCharge * m_specificInvestCostPowerDischarge;
double investCostCapacity = m_storageCapacity * m_specificInvestCostCapacity;
return investCostPower + investCostCapacity;
}
......@@ -730,13 +739,13 @@ double Storage::getStorageLevelAtTimeStep(int step) const
double Storage::getTotalPowerFedByPlant() const
{
//calculated on demand; TODO: think about extra value, that saves this information
return m_nominalPower * m_fullLoadHoursDischarge;
return m_nominalPowerCharge * m_fullLoadHoursDischarge;
}
double Storage::getTotalPowerConsumption() const
{
//calculated on demand; TODO: think about extra value, that saves this information
return m_nominalPower * m_fullLoadHoursCharge;
return m_nominalPowerCharge * m_fullLoadHoursCharge;
}
double Storage::getTotalHeatFed() const
......
......@@ -30,7 +30,8 @@ using namespace std;
class CHARLALGORITHMSHARED_EXPORT Storage
{
public:
Storage(string name, double nominalPower, double capacity, double gradientCharge, double gradientDischarge,
Storage(string name, double nominalPower, double nominalPowerDischarge,
double capacity, double gradientCharge, double gradientDischarge,
EfficiencyField efficiencyCharge, EfficiencyField efficiencyDischarge,
vector<pair<double, double> > selfDischarge, double startTimeHotCharge, double startTimeWarmCharge,
double startTimeColdCharge, double startTimeHotDischarge, double startTimeWarmDischarge,
......@@ -60,7 +61,8 @@ public:
// void setOperationPlanPeriodIsValid(bool validation); //tz - setter for m_operationPlanPeriodIsValid
//get Funktionen
double getNominalPower() const {return m_nominalPower;}
double getNominalPowerCharge() const {return m_nominalPowerCharge;}
double getNominalPowerDischarge() const {return m_nominalPowerDischarge;}
double getLifeTimeCharge() const {return m_lifeTimeCharge;} // bw: added from GUI
double getLifeTimeDischarge() const {return m_lifeTimeDischarge;} // bw: added from GUI
int getTypicalUnitSizeCharge() const {return m_typicalUnitSizeCharge;} // bw: added from GUI
......@@ -161,7 +163,8 @@ public:
private:
// VALUES ENTERED BY USER ///////////////////////////////////////////////////////////////////////////////////////////////////////////
string m_name; //name (rather type) of storage
double m_nominalPower; //nominal power of plant, to which all values are scaled in MW
double m_nominalPowerCharge; //nominal power of plant, to which all values are scaled in MW
double m_nominalPowerDischarge; //!< nominal discharge power of plant; in MW
double m_gradientCharge; //power gradient charge part may achieve in %/min
double m_gradientDischarge; //power gradient discharge part may achieve in %/min
double m_storageCapacity; //overall capacity of storage in MWh
......
......@@ -1028,20 +1028,19 @@ void CharLGui::runAlgorithm()
node = m_modelNodes->getItemNonConst(i);
for (int j = 0; j < node->getPlantTablePtr()->rowCount(); j++)
{
nOptionsPerPlant.append(node->getPlantTablePtr()->getNumberOfVariationsForItem(j));
nOptionsPerPlant.append(node->getPlantTablePtr()->getNumberOfVariationsForItem(j, 0));
}
for (int j = 0; j < node->getStorageTablePtr()->rowCount(); j++)
{
nOptionsPerPlant.append(node->getStorageTablePtr()->getNumberOfVariationsForItem(j));
nOptionsPerPlant.append(node->getStorageTablePtr()->getNumberOfVariationsForItem(j, -1));
}
for (int j = 0; j < node->getSolarTablePtr()->rowCount(); j++)
{
nOptionsPerPlant.append(node->getSolarTablePtr()->getNumberOfVariationsForItem(j));
nOptionsPerPlant.append(node->getSolarTablePtr()->getNumberOfVariationsForItem(j, 0));
}
for (int j = 0; j < node->getWindTablePtr()->rowCount(); j++)
{
nOptionsPerPlant.append(1);
//nOptionsPerPlant.append(network->getWindTablePtr()->getNumberOfVariationsForItem(j));
nOptionsPerPlant.append(node->getWindTablePtr()->getNumberOfVariationsForItem(j, 0));
}
}
......@@ -1052,6 +1051,7 @@ void CharLGui::runAlgorithm()
{
nOptionsOfFollowingPlants[i] = nTotalOptions;
nTotalOptions *= nOptionsPerPlant[i];
qDebug() << "Options for plant " << i << ":" << nOptionsPerPlant[i] << ". Total now" << nTotalOptions;
}
nOptionsPerPlant.clear();
......@@ -1065,7 +1065,7 @@ void CharLGui::runAlgorithm()
//////////////////////////////////////
// CALCULATE ALL OPTIONS //
//////////////////////////////////////
int nMaxThreads = QThreadPool::globalInstance()->maxThreadCount();
int nMaxThreads = std::max(1, QThreadPool::globalInstance()->maxThreadCount() - 1);
int i = 0;
while (i < nTotalOptions)
{
......@@ -1098,7 +1098,7 @@ void CharLGui::runAlgorithm()
algorithmInstances.append(new RunnableAlgorithm(algorithm,
m_preferences->getAccptableBlackout()));
algorithmInstances.back()->setAutoDelete(false);
qDebug() << "Started Thread " << j << "of" << nThreads << "at a max of" << nMaxThreads;
qDebug() << "Started Thread " << j + 1 << "of" << nThreads << "at a max of" << nMaxThreads;
QThreadPool::globalInstance()->start(algorithmInstances.back());
}
else
......@@ -1174,6 +1174,7 @@ bool CharLGui::configureAlgorithm(CharLAlgorithm * algorithm,
size_t locationIndex = 0;
int counter = 0;
const NodesTableItem * node = nullptr;
qDebug() << "About to configure option " << targetOption;
for (int i = 0; i < m_modelNodes->rowCount(); i++)
{
node = static_cast<const NodesTableItem *>(m_modelNodes->getItem(i));
......@@ -1245,20 +1246,29 @@ bool CharLGui::configureAlgorithm(CharLAlgorithm * algorithm,
targetOption = targetOption % nOptionsOfFollowingPlants[counter];
const ConfigTableItem * config = static_cast<const ConfigTableItem *>(node->getConstStorageTablePtr()->getItem(j));
const StorageTableItem * storage = static_cast<const StorageTableItem *>(m_modelStorage->getItem(config->getSelectedItemProducer()));
int nVariationsCapacity = node->getConstStorageTablePtr()->getNumberOfVariationsForItem(j, 1);
int nVariationsPowerDis = node->getConstStorageTablePtr()->getNumberOfVariationsForItem(j, 2);
double configPower = std::min(config->getMinPower()
+ (targetOption
/ node->getConstStorageTablePtr()->getNumberOfVariationsForItem(j, true))
/ (nVariationsCapacity * nVariationsPowerDis))
* config->getStepSizePower(),
config->getMaxPower());
double configCapacity = std::min(config->getMinCapacity()
+ (targetOption
% node->getConstStorageTablePtr()->getNumberOfVariationsForItem(j, true))
+ ((targetOption
% (nVariationsCapacity * nVariationsPowerDis))
/ nVariationsPowerDis)
* config->getStepSizeCapacity(),
config->getMaxCapacity());
double configPowerDis = std::min(config->getMinPower2()
+ ((targetOption
% (nVariationsCapacity * nVariationsPowerDis))
% nVariationsPowerDis)
* config->getStepSizePower2(),
config->getMaxPower2());
if (configPower > 1. && configCapacity > 1.)
{
algorithm->addStoragePlant(nodeIndex, locationIndex, storage->getName().toStdString(),
configPower, configCapacity,
configPower, configPowerDis, configCapacity,
storage->getGradientCharge(),
storage->getGradientDischarge(),
storage->getEfficiencyCharge(),
......
......@@ -778,19 +778,22 @@ void ConfigTableModel::clearData()
/////////////////////////////////////////////////////////////////////////////////////
/// \brief ConfigTableModel::getNumberOfVariationsForItem
/// \param itemIndex
/// \param onlyCapacity
/// \param entryNo which entry in the order shall be called (-1 for all)
/// \return a fairly high integer representing a number of possible combinations
/// calculates number of variations as entered via minima, maxima and stepSize. if
/// onlyCapacity is false (defaulted) the combinations are a product of power and
/// capacity variations, otherwise it is only capacity variations
/////////////////////////////////////////////////////////////////////////////////////
int ConfigTableModel::getNumberOfVariationsForItem(int itemIndex, bool onlyCapacity) const
int ConfigTableModel::getNumberOfVariationsForItem(int itemIndex, int entryNo) const
{
int variations = 1;
int variations2 = 1;
int variations3 = 1;
if (m_displayOnlyDefault)
{
variations = (m_defaultItem.getMaxPower() - m_defaultItem.getMinPower()) / m_defaultItem.getStepSizePower();
variations = (m_defaultItem.getMaxPower()
- m_defaultItem.getMinPower())
/ m_defaultItem.getStepSizePower();
if (variations <= 0)
{
variations = 1;
......@@ -802,12 +805,25 @@ int ConfigTableModel::getNumberOfVariationsForItem(int itemIndex, bool onlyCapac
}
else if (itemIndex >= 0 && itemIndex < m_data.count())
{
variations = (m_data[itemIndex].getMaxPower() - m_data[itemIndex].getMinPower()) / m_data[itemIndex].getStepSizePower();
variations = (m_data[itemIndex].getMaxPower()
- m_data[itemIndex].getMinPower())
/ m_data[itemIndex].getStepSizePower();
if (variations <= 0)
{
variations = 1;
}
else
{
variations++;
}
if (entryNo == 0) return variations;
if (m_additionalInfo == AdditionalInfo::Capacity
|| m_additionalInfo == AdditionalInfo::Storage
|| m_additionalInfo == AdditionalInfo::Biomass) // item is a storage
{
variations2 *= (m_data[itemIndex].getMaxCapacity() - m_data[itemIndex].getMinCapacity()) / m_data[itemIndex].getStepSizeCapacity();
variations2 *= (m_data[itemIndex].getMaxCapacity()
- m_data[itemIndex].getMinCapacity())
/ m_data[itemIndex].getStepSizeCapacity();
if (variations2 <= 0) //
{
variations2 = 1;
......@@ -816,21 +832,27 @@ int ConfigTableModel::getNumberOfVariationsForItem(int itemIndex, bool onlyCapac
{
variations2++;
}
if (onlyCapacity)
if (entryNo == 1) return variations2;
if (m_additionalInfo == AdditionalInfo::Storage)
{
return variations2;
variations3 = (m_data[itemIndex].getMaxPower2()
- m_data[itemIndex].getMinPower2())
/ m_data[itemIndex].getStepSizePower2();
if (variations3 <= 0)
{
variations3 = 1;
}
else if (m_data[itemIndex].getMinPower() > 1.e-5
&& m_data[itemIndex].getMinCapacity() > 1.e-5)
{
variations3++;
}
}
}
if (variations <= 0)
{
variations = 1;
}
else
{
variations++;
}
}
return variations * variations2;
qDebug() << "var1 " << variations << "var2" << variations2 << "var3" << variations3;
return variations * variations2 * variations3;
}
//////////////////////////////////////////
......
......@@ -113,7 +113,7 @@ public:
void setSelectorModelLocations(SelectorListModel * model);
void setDefault(bool isDefault);
int getNumberOfVariationsForItem(int itemIndex,
bool onlyCapacity = false) const;
int entryNo = false) const;
private:
QVector<ConfigTableItem> m_data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment