|
@@ -18,7 +18,10 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
private float maxInRatio;
|
|
|
|
|
|
@Expose
|
|
|
- private float maxOutRatio;
|
|
|
+ private float nominalOutRatio;
|
|
|
+
|
|
|
+ @Expose
|
|
|
+ private float currentMaxOutRatio;
|
|
|
|
|
|
@Expose
|
|
|
private float chargingRatio;
|
|
@@ -26,11 +29,11 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
@Expose
|
|
|
private resistanceCalculator resistanceCalculator;
|
|
|
|
|
|
- public StorageElement(String eleName, int amount, float energy, Model model, float capacity, float maxInRatio, float maxOutRatio) {
|
|
|
+ public StorageElement(String eleName, int amount, float energy, Model model, float capacity, float maxInRatio, float nominalOutRatio) {
|
|
|
super(eleName, amount, energy, model);
|
|
|
this.stateOfCharge = 0;
|
|
|
this.maxInRatio = maxInRatio;
|
|
|
- this.maxOutRatio = maxOutRatio;
|
|
|
+ this.nominalOutRatio = nominalOutRatio;
|
|
|
this.capacity = capacity * 60;// we save in watts per minute for ease of use
|
|
|
this.status = Mode.STANDBY;
|
|
|
this.chargingRatio = 0;
|
|
@@ -46,8 +49,8 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
|
|
|
public float getPossibleProduction(float energyRequiredForPowerplantBlackstart) {
|
|
|
if (stateOfCharge > 0) {
|
|
|
- if (stateOfCharge >= maxOutRatio) {
|
|
|
- return energyAfterResistance(maxOutRatio, energyRequiredForPowerplantBlackstart);
|
|
|
+ if (stateOfCharge >= nominalOutRatio) {
|
|
|
+ return energyAfterResistance(nominalOutRatio, energyRequiredForPowerplantBlackstart);
|
|
|
} else {
|
|
|
return energyAfterResistance(stateOfCharge, energyRequiredForPowerplantBlackstart);
|
|
|
}
|
|
@@ -56,6 +59,18 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private float getPossiblePower(){
|
|
|
+ if (stateOfCharge > 0) {
|
|
|
+ if (stateOfCharge >= nominalOutRatio) {
|
|
|
+ return nominalOutRatio;
|
|
|
+ } else {
|
|
|
+ return stateOfCharge;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private float energyAfterResistance(float energy, float energyRequiredForPowerplantBlackstart){
|
|
|
return resistanceCalculator.calcEnergyAfterResistance(energy, getLowDistance(), getHighDistance(), energyRequiredForPowerplantBlackstart);
|
|
|
}
|
|
@@ -76,9 +91,9 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
chargingRatio = 0;
|
|
|
return 0;
|
|
|
case EMIT:
|
|
|
- if (energyNeed >= maxOutRatio) { // more energy wanted than can be giving
|
|
|
- if (stateOfCharge >= maxOutRatio) { // more energy wanted than can be given
|
|
|
- return emitWantedEnergy(maxOutRatio, energyRequiredForPowerplantBlackstart);
|
|
|
+ if (energyNeed >= currentMaxOutRatio) { // more energy wanted than can be giving
|
|
|
+ if (stateOfCharge >= currentMaxOutRatio) { // more energy wanted than can be given
|
|
|
+ return emitWantedEnergy(currentMaxOutRatio, energyRequiredForPowerplantBlackstart);
|
|
|
}
|
|
|
} else {// less wanted than what can be max be given
|
|
|
if(stateOfCharge >= energyNeed){
|
|
@@ -134,6 +149,7 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
case COLLECT:
|
|
|
case EMIT:
|
|
|
stateOfCharge = stateOfCharge - chargingRatio;
|
|
|
+ setCurrentMaxOutRatio();
|
|
|
break;
|
|
|
default:
|
|
|
}
|
|
@@ -148,6 +164,17 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
|
|
|
public void setStateOfCharge(float percentage){
|
|
|
this.stateOfCharge = capacity * (percentage / 100);
|
|
|
+ setCurrentMaxOutRatio();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCurrentMaxOutRatio(){
|
|
|
+ if(stateOfCharge > capacity * 0.8){
|
|
|
+ currentMaxOutRatio = (float) (nominalOutRatio * 1.1);
|
|
|
+ }else if(stateOfCharge < capacity * 0.2){
|
|
|
+ currentMaxOutRatio = (float) (nominalOutRatio * 0.8);
|
|
|
+ }else{
|
|
|
+ currentMaxOutRatio = nominalOutRatio;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private float notEnoughChargedToEmitWantedEnergy(float energyRequiredForPowerplantBlackstart){
|
|
@@ -171,8 +198,12 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
return stateOfCharge;
|
|
|
}
|
|
|
|
|
|
- public float getMaxOutRatio() {
|
|
|
- return maxOutRatio;
|
|
|
+ public float getNominalOutRatio() {
|
|
|
+ return nominalOutRatio;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getCurrentMaxOutRatio() {
|
|
|
+ return currentMaxOutRatio;
|
|
|
}
|
|
|
|
|
|
public boolean chargeDepleted(){
|
|
@@ -185,7 +216,11 @@ public class StorageElement extends HolonElement implements Comparable<StorageEl
|
|
|
|
|
|
@Override
|
|
|
public int compareTo(StorageElement storageElement) {
|
|
|
- if(this.stateOfCharge < storageElement.getStateOfCharge()){
|
|
|
+ if(this.getPossiblePower() < storageElement.getPossiblePower()){
|
|
|
+ return -1;
|
|
|
+ }else if(this.getPossiblePower() > storageElement.getPossiblePower()){
|
|
|
+ return 1;
|
|
|
+ }else if(this.stateOfCharge < storageElement.getStateOfCharge()){
|
|
|
return -1;
|
|
|
}else if(this.stateOfCharge > storageElement.getStateOfCharge()){
|
|
|
return 1;
|