Quellcode durchsuchen

charge storages in normal operation

David Heck vor 5 Jahren
Ursprung
Commit
4977426a37

+ 6 - 5
src/blackstart/controlAlgorithm.java

@@ -10,6 +10,7 @@ import javax.swing.*;
 import api.AddOn;
 import classes.*;
 import ui.controller.Control;
+import ui.controller.StorageProductionController;
 
 public class controlAlgorithm implements AddOn {
 	private boolean cancel = false;
@@ -100,7 +101,7 @@ public class controlAlgorithm implements AddOn {
 		blackstartStartTimeLabel.setBounds(185, 60, 300, 20);
 		parameterPanel.add(blackstartStartTimeLabel);
 
-		simulationDurationTextfield = new TextField("500");// TODO:!
+		simulationDurationTextfield = new TextField("500");
 		simulationDurationTextfield.setBounds(10, 85, 170, 20);
 		parameterPanel.add(simulationDurationTextfield);
 
@@ -308,7 +309,6 @@ public class controlAlgorithm implements AddOn {
 		try {
 			Thread.sleep(Integer.parseInt(waitBetweenIterations.getText()));
 		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 		control.getModel().setCurIteration(curIteration);
@@ -348,11 +348,12 @@ public class controlAlgorithm implements AddOn {
 	}
 
 	/**
-	 * TODO:HOLEG UNTERVERSORGUNG CHECKEN
-	 * TODO: storage laden
-	 * TODO: storage im GUI hinzufuegen
+	 * TODO: HOLEG UNTERVERSORGUNG CHECKEN
+	 * TODO: storage im GUI hinzufuegen koennen
 	 * TODO: prios fuer elemente anschalten
 	 * TODO: elements und amount nachschauen
+	 * TODO: batterie status wechesel fuehrt zu unterversorgung in GUI
+	 * TODO: wie soll ich unter / ueberversorgung handeln vorm blackstart
 	 *
 	 * @param curIteration
 	 * @return true or false depending on whether the blackstart was successful for

+ 9 - 1
src/classes/StorageElement.java

@@ -165,7 +165,7 @@ public class StorageElement extends HolonElement {
 		return maxOutRatio;
 	}
 
-	public boolean storageChargeDepleted(){
+	public boolean chargeDepleted(){
 		if(stateOfCharge <= 0){
 			return true;
 		}else{
@@ -173,6 +173,14 @@ public class StorageElement extends HolonElement {
 		}
 	}
 
+	public boolean fullyCharged(){
+		if(stateOfCharge >= capacity){
+			return true;
+		}else{
+			return false;
+		}
+	}
+
 	public enum Mode {
 		COLLECT, EMIT, STANDBY
 	}

+ 3 - 16
src/ui/controller/SimulationManager.java

@@ -1,6 +1,5 @@
 package ui.controller;
 
-import blackstart.StorageProductionController;
 import classes.StorageElement;
 import classes.*;
 import ui.model.*;
@@ -105,12 +104,10 @@ public class SimulationManager {
                     //calc consuption and production
                     float consumption = calculateConsumption(net);
                     float production = calculateProduction(net);
-
-
                     float difference = production - consumption;
-                    System.out.println("Consumption " + consumption);
-                    System.out.println("production " + production);
-                    System.out.println("Difference " + difference);
+//                    System.out.println("Consumption " + consumption);
+//                    System.out.println("production " + production);
+//                    System.out.println("Difference " + difference);
 
                     if(difference > 0){
                         SPC.enableStorageCharging(difference);
@@ -147,16 +144,6 @@ public class SimulationManager {
 					cable.setState(CableState.Burned);
 					doAnotherLoop = true;
 				}
-
-
-                float consumption = calculateConsumption(net);
-                float production = calculateProduction(net);
-
-
-                float difference = production - consumption;
-                System.out.println("Consumption " + consumption);
-                System.out.println("production " + production);
-                System.out.println("Difference " + difference);
 			}
 		}
 		ArrayList<DecoratedNetwork> decorNetworks = new ArrayList<DecoratedNetwork>();

+ 15 - 3
src/blackstart/StorageProductionController.java → src/ui/controller/StorageProductionController.java

@@ -1,4 +1,4 @@
-package blackstart;
+package ui.controller;
 
 import classes.StorageElement;
 
@@ -54,7 +54,7 @@ public class StorageProductionController {
 //						&& se.getEnergyPerElement() < se.getMaxOutRatio()
 //						&& se.getEnergyPerElement() < se.getStateOfCharge())) {
                     // TODO: eventuell nach entfernung sortieren
-				if(!se.storageChargeDepleted()){
+				if(!se.chargeDepleted()){
 					energyLeftToEnabled = energyLeftToEnabled - se.setStatusAndSetEnergy(StorageElement.Mode.EMIT, energyLeftToEnabled);
 				}
 //                }
@@ -94,7 +94,19 @@ public class StorageProductionController {
 //			}
 //		}
 	}
-	public void enableStorageCharging(float energyAvailable){
 
+	//TODO: selbe probleme wie discharging
+	public void enableStorageCharging(float energyAvailable){
+		System.out.println("energy available to storage" + energyAvailable);
+		float availableEnergyLeft = energyAvailable;
+		for (StorageElement se: storages) {
+			if(!se.fullyCharged()){
+				availableEnergyLeft = availableEnergyLeft - se.setStatusAndSetEnergy(StorageElement.Mode.COLLECT, availableEnergyLeft);
+			}
+			if(availableEnergyLeft <= 0){
+				System.out.println("storage charging");
+				return;
+			}
+		}
 	}
 }

+ 0 - 1
src/ui/model/Model.java

@@ -4,7 +4,6 @@ import TypeAdapter.AbstractCpsObjectAdapter;
 import TypeAdapter.ColorAdapter;
 import TypeAdapter.PairAdapter;
 import TypeAdapter.PositionAdapter;
-import blackstart.StorageProductionController;
 import classes.*;
 
 import com.google.gson.Gson;