Ver código fonte

fix some typos and fix copy to support copying storage elements

David Heck 4 anos atrás
pai
commit
54724cf3f2

+ 1 - 1
src/algo/StorageElement.java

@@ -85,7 +85,7 @@ public class StorageElement extends HolonElement {
 					return notEnoughChargedToEmitWantedEnergy();
 				}
 			}
-		case COLLECT:
+			case COLLECT://TODO: testing
 			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));

+ 16 - 6
src/algo/TestAlgo.java

@@ -32,6 +32,7 @@ public class TestAlgo implements AddOn {
 	private TextField blackstartStartTimeTextfield;
 	private TextField simulationDurationTextfield;
 	private TextField storageStartCharge;
+	private TextField waitBetweenIterations;
 
 	private int blackstartSuccessTime;
 	private int blackstartStartTime;
@@ -123,6 +124,14 @@ public class TestAlgo implements AddOn {
 		storageStartChargeLabel.setBounds(185, 135, 300, 20);
 		parameterPanel.add(storageStartChargeLabel);
 
+		waitBetweenIterations = new TextField("0");
+		waitBetweenIterations.setBounds(10, 205, 170, 20);
+		parameterPanel.add(waitBetweenIterations);
+
+		JLabel waitBetweenIterationsLabel = new JLabel("Wait time between iterations");
+		waitBetweenIterationsLabel.setBounds(185, 205, 300, 20);
+		parameterPanel.add(waitBetweenIterationsLabel);
+
 //		JButton selectGroupNodeButton = new JButton("Select GroupNode");
 //		selectGroupNodeButton.setEnabled(false);
 //		selectGroupNodeButton.setBounds(10, 25, 165, 20);
@@ -295,12 +304,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(Integer.parseInt(waitBetweenIterations.getText()));
+		} catch (InterruptedException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 		control.getModel().setCurIteration(curIteration);
 		if (blackstartRunning()) {
 			if (!blackstartAlgo(curIteration)) {
@@ -340,6 +349,7 @@ public class TestAlgo implements AddOn {
 	/**
 	 * TODO:HOLEG UNTERVERSORGUNG CHECKEN
 	 * TODO: storage laden
+	 * TODO: run houses / elements from storage
 	 *
 	 * @param curIteration
 	 * @return true or false depending on whether the blackstart was successful for

+ 3 - 1
src/ui/controller/ClipboardController.java

@@ -236,7 +236,9 @@ public class ClipboardController {
                                     HashMap<Integer, HolonElement> eleDispatch) {
         JsonObject object = jsonElement.getAsJsonObject();
 
-        HolonElement temp = model.getGson().fromJson(object.get("properties"), HolonElement.class);
+        HolonElement temp = load.deserializeHolonElement(jsonElement);
+
+//        HolonElement temp = model.getGson().fromJson(object.get("properties"), HolonElement.class);
         load.initElements(temp);
         eleIDMapper(temp);
         // id which Object it was stored before

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

@@ -297,7 +297,7 @@ public class LoadController {
 
 	}
 
-	private HolonElement deserializeHolonElement(JsonElement jsonElement) {
+	public HolonElement deserializeHolonElement(JsonElement jsonElement) {
 		final HolonElement temp;
 		final JsonObject jsonObject = jsonElement.getAsJsonObject();
 		if (jsonObject.get("properties") != null) {

+ 5 - 0
src/ui/controller/SimulationManager.java

@@ -103,6 +103,11 @@ public class SimulationManager {
 			doAnotherLoop = false;
 			list = calculateNetworks(minimumModel, timestep, leftOver);
 			for(MinimumNetwork net : list) {
+				//if there is storage and it is needed turn it on//TODO:!!!
+//				if(!blackstartrunning() && storageexists()){
+//					turnOnStorage(energy needed())
+//				}
+
 				float energyOnCables = net.getHolonObjectList()
 						.stream()
 						.filter(object -> object.getEnergyAtTimeStepWithFlex(timestep, newFlexManager) > 0.0f)