Ver Fonte

fix warinings

David Heck há 4 anos atrás
pai
commit
67716864d9

+ 11 - 28
src/blackstart/controlAlgorithm.java

@@ -165,7 +165,7 @@ public class controlAlgorithm implements AddOn {
 		buttonPanel.add(resetButton);
 		JButton runButton = new JButton("Run");
 		runButton.addActionListener(actionEvent -> {
-			Runnable task = () -> run();
+			Runnable task = this::run;
 			runThread = new Thread(task);
 			runThread.start();
 		});
@@ -220,10 +220,6 @@ public class controlAlgorithm implements AddOn {
 		textArea.setText("");
 	}
 
-	private void print(String message) {
-		textArea.append(message);
-	}
-
 	private void println(String message) {
 		textArea.append(message + "\n");
 	}
@@ -349,10 +345,9 @@ public class controlAlgorithm implements AddOn {
 
 	/**
 	 * 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: batterie status wechesel fuehrt zu unterversorgung in GUI FIX?: in storage if bei charge auskommentieren
 	 * TODO: wie soll ich unter / ueberversorgung handeln vorm blackstart
 	 * TODO: batterie modes wo nicht passiert? obwohl laden / entladen moeglich waere?
 	 * TODO: batterie laden prios? entfernung?
@@ -388,8 +383,8 @@ public class controlAlgorithm implements AddOn {
 	}
 
 	//TODO: das ist ja eigentlich doppelt
-	public ArrayList<StorageElement> getStorageElements() {
-		ArrayList<StorageElement> storageElements = new ArrayList<StorageElement>();
+	private ArrayList<StorageElement> getStorageElements() {
+		ArrayList<StorageElement> storageElements = new ArrayList<>();
 		for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
 			for (HolonElement ele : holonObject.getElements()) {
 				if(ele instanceof StorageElement){
@@ -438,22 +433,12 @@ public class controlAlgorithm implements AddOn {
 				}
 			}
 		} else { // at leaf
-//			println("Distance to " + currentObject.getId() + ": " + distance);
-//			((HolonObject) currentObject).addElement(new StorageElement("Storage", 1, 0, control.getModel(), 10000, 5000 ,5000));
 			for (HolonElement ele : ((HolonObject) currentObject).getElements()) {
 				ele.setDistance(distance);
-				if (ele.getEleName() == "Solar Panels") {// TODO: das wollen wir ja so nicht
-					ele.setEnergyPerElement(5000);
-//					println("Energy: " + ele.getEnergyPerElement());
-					// set how much energy is left after resistance22
-					ele.setEnergyPerElement(calcEnergyAfterResistance(ele.getEnergyPerElement(), distance));// TODO: das
-																											// wollen
-																											// wir ja so
-																											// auch
-																											// nicht
-//					println("Energy after resistance: " + ele.getEnergyPerElement());
-				}
-//				println(ele.getId() + " distance to pp " + ele.getDistance());
+//				if (ele.getEleName().equals("Solar Panels")) {// TODO: das wollen wir ja so nicht
+//					ele.setEnergyPerElement(5000);
+//					ele.setEnergyPerElement(calcEnergyAfterResistance(ele.getEnergyPerElement(), distance));
+//				}
 			}
 
 		}
@@ -568,14 +553,12 @@ public class controlAlgorithm implements AddOn {
 		return totalProduction;
 	}
 
-	private float setPowerplantProduction(float power) {
-		float totalProduction = 0;
+	private void setPowerplantProduction(float power) {
 		for (HolonElement ele : powerPlant.getElements()) {
 			if (ele.getEleName().equals("Power")) {
 				ele.setEnergyPerElement(power);
 			}
 		}
-		return totalProduction;
 	}
 
 	private float getPowerPlantBlackstartResistance() {
@@ -612,7 +595,7 @@ public class controlAlgorithm implements AddOn {
 	}
 
 	private LinkedList<HolonObject> getRenewableProducers() {
-		LinkedList<HolonObject> list = new LinkedList<HolonObject>();
+		LinkedList<HolonObject> list = new LinkedList<>();
 		for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
 			if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
 																	// werden ob es renewables gibt
@@ -623,7 +606,7 @@ public class controlAlgorithm implements AddOn {
 	}
 
 	private LinkedList<HolonObject> getConsumers() {
-		LinkedList<HolonObject> list = new LinkedList<HolonObject>();
+		LinkedList<HolonObject> list = new LinkedList<>();
 		for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
 			if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
 																	// werden ob es consumer gibt

+ 3 - 10
src/classes/StorageElement.java

@@ -1,8 +1,6 @@
 package classes;
 
 import com.google.gson.annotations.Expose;
-
-import classes.HolonElement;
 import ui.model.Model;
 
 public class StorageElement extends HolonElement {
@@ -33,12 +31,10 @@ public class StorageElement extends HolonElement {
 	}
 
 	public float getEnergyPerElement() {
-		switch (status) {
-			case STANDBY://TODO: switch wirklich notwendig?
+		if (status == Mode.STANDBY) {
 			return 0;
-		default:
-			return this.energyPerElement;
 		}
+		return this.energyPerElement;
 	}
 
 	public float getPossibleProduction() {
@@ -89,11 +85,9 @@ public class StorageElement extends HolonElement {
 			if (energyWanted >= maxInRatio) { // more engery given than can be collected
 				if (stateOfCharge + maxInRatio > capacity) { // Storage nearly full only load rest to get full
 					this.setEnergyPerElement(-(capacity - stateOfCharge));
-//					stateOfCharge = capacity;
 					return capacity - stateOfCharge;
 				} else { // load with maximal of what can be collected
 					this.setEnergyPerElement(-maxInRatio);
-//					stateOfCharge = stateOfCharge + maxInRatio;
 					return maxInRatio;
 				}
 			} else { // less engery given than can be taken in
@@ -103,11 +97,9 @@ public class StorageElement extends HolonElement {
 				} else {
 					if (stateOfCharge + energyWanted > capacity) { // Storage nearly full only load rest to get full
 						this.setEnergyPerElement(-(capacity - stateOfCharge));
-//						stateOfCharge = capacity;
 						return capacity - stateOfCharge;
 					} else { // take all engery that is available
 						this.setEnergyPerElement(-energyWanted);
-//						stateOfCharge = stateOfCharge + energy;
 						return energyWanted;
 					}
 				}
@@ -131,6 +123,7 @@ public class StorageElement extends HolonElement {
 				break;
 			default:
 		}
+		//TODO: fix for gui error comment out bottom if (not sure if side effects should work since storage gets disabled every iteration)
 		if(stateOfCharge <= 0 || stateOfCharge >= capacity){
 			status = Mode.STANDBY;
 			setEnergyPerElement(0);

+ 1 - 1
src/ui/controller/StorageProductionController.java

@@ -89,7 +89,7 @@ public class StorageProductionController {
 	}
 
 	//TODO: selbe probleme wie discharging
-	public void enableStorageCharging(float energyAvailable){
+	void enableStorageCharging(float energyAvailable){
 		System.out.println("energy available to storage" + energyAvailable);
 		float availableEnergyLeft = energyAvailable;
 		for (StorageElement se: storages) {