Selaa lähdekoodia

initial rough disable storage impl

David Heck 4 vuotta sitten
vanhempi
commit
299a969559
2 muutettua tiedostoa jossa 24 lisäystä ja 29 poistoa
  1. 17 23
      src/algo/StorageProductionController.java
  2. 7 6
      src/algo/TestAlgo.java

+ 17 - 23
src/algo/StorageProductionController.java

@@ -1,6 +1,7 @@
 package algo;
 
 import java.util.ArrayList;
+import java.util.EmptyStackException;
 
 public class StorageProductionController {
 	private ArrayList<StorageElement> storages;
@@ -35,7 +36,7 @@ public class StorageProductionController {
 		System.out.println("energy needed from storage" + energyNeeded);
         float energyLeftToEnabled = energyNeeded;
 
-        if(currentStorageProduction() < energyNeeded){//TODO: das if muss ich nochmal ueberdenken
+//        if(currentStorageProduction() < energyNeeded){//TODO: das if muss ich nochmal ueberdenken
 //        	energyLeftToEnabled = energyNeeded - currentStorageProduction();
             //DONE?: Problem: es wird abgezogen weil ja schon emitter aber wir wolle das ja erhoehen...
         	for (StorageElement se: storages) {
@@ -55,9 +56,9 @@ public class StorageProductionController {
                     return;
                 }
             }
-        }else{//TODO:!!!!!! das ist nich fertig
-            disableStorageProduction(energyNeeded - currentStorageProduction());
-        }
+//        }else{
+//            disableStorageProduction(energyNeeded - currentStorageProduction());
+//        }
 	}
 
 	public void disableStorageProduction(float energyNotNeeded) {
@@ -67,28 +68,21 @@ public class StorageProductionController {
 			}
 		}
 //		float disabledEnergy = 0;
-//		StorageElement.Mode lastMode = null;
-//		float lastEnergy = 0;
 //
-//		for (StorageElement so : storages) {
-//			if (so.getStatus().equals(StorageElement.Mode.EMIT)) {
-//				// TODO: den groesten zuerst deaktivieren? > ein bissen verschwendung
-//				lastEnergy = so.getEnergyAtTimeStep(0);
-//				disabledEnergy += so.getEnergyAtTimeStep(0); // TODO:timestep
-//				lastMode = so.getStatus();
-//				so.setStatus(StorageElement.Mode.STANDBY, 0);
+//		//TODO: disable furthest first?
+//		for (StorageElement se : storages) {
+//			if (se.getStatus().equals(StorageElement.Mode.EMIT)) {
+//				if(se.getEnergyPerElement() > energyNotNeeded){
+//					disabledEnergy = disabledEnergy + energyNotNeeded;
+//					se.setStatusAndSetEnergy(StorageElement.Mode.EMIT, se.getEnergyPerElement() - energyNotNeeded);
+//				}else{
+//					disabledEnergy = disabledEnergy + se.getEnergyPerElement();
+//					se.setStatusAndSetEnergy(StorageElement.Mode.STANDBY, 0);
+//				}
 //			}
-//			// das vermutet der groeste wurde zuerste deaktiviert damit moeglichst
-//			// wenig engery verschwendet wird
-//			if (disabledEnergy > energyNotNeeded) {
-//				so.setStatus(lastMode, 0);
-//				disabledEnergy -= lastEnergy;
+//			if (disabledEnergy >= energyNotNeeded) {
+//				return;
 //			}
 //		}
 	}
-
-	public boolean batteriesFull() {
-
-		return false;
-	}
 }

+ 7 - 6
src/algo/TestAlgo.java

@@ -287,12 +287,12 @@ public class TestAlgo implements AddOn {
 	 * @param curIteration
 	 */
 	private void blackstartMain(int curIteration) {
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+//		try {
+//			Thread.sleep(1000);
+//		} catch (InterruptedException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
 		control.getModel().setCurIteration(curIteration);
 		if (blackstartRunning()) {
 			if (!blackstartAlgo(curIteration)) {
@@ -340,6 +340,7 @@ public class TestAlgo implements AddOn {
 			// renewable energy production is not sufficient for the blackstart
 			if (SPC.currentPossibleStorageProduction() >= getPowerPlantBlackstartResistance()
 					- currentRenewableProduction()) {// is there currently enough power available from storage?
+				SPC.disableStorageProduction(-1);// emergency fix
 				SPC.enableStorageProduction(getPowerPlantBlackstartResistance() - currentRenewableProduction());
 				rampUpPowerplant();
 				enableConsumers(getPowerplantProduction());