|
@@ -1,7 +1,13 @@
|
|
package blackstart;
|
|
package blackstart;
|
|
|
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
+import java.nio.file.Paths;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -31,7 +37,7 @@ public class ControlAlgorithm implements AddOn {
|
|
private TextField storageStartCharge;
|
|
private TextField storageStartCharge;
|
|
private TextField carStartCharge;
|
|
private TextField carStartCharge;
|
|
private TextField waitBetweenIterations;
|
|
private TextField waitBetweenIterations;
|
|
- private TextField lowVolatageTextfield;
|
|
+ private TextField fileNameTextfield;
|
|
private TextField highVolatageTextfield;
|
|
private TextField highVolatageTextfield;
|
|
private TextField renewableTextfield;
|
|
private TextField renewableTextfield;
|
|
|
|
|
|
@@ -43,6 +49,9 @@ public class ControlAlgorithm implements AddOn {
|
|
private List<HolonObject> consumers;
|
|
private List<HolonObject> consumers;
|
|
private StorageProductionController SPC;
|
|
private StorageProductionController SPC;
|
|
|
|
|
|
|
|
+ private Path file;
|
|
|
|
+ private ArrayList<String> lines;
|
|
|
|
+
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
JFrame newFrame = new JFrame("exampleWindow");
|
|
JFrame newFrame = new JFrame("exampleWindow");
|
|
ControlAlgorithm instance = new ControlAlgorithm();
|
|
ControlAlgorithm instance = new ControlAlgorithm();
|
|
@@ -142,21 +151,21 @@ public class ControlAlgorithm implements AddOn {
|
|
parameterPanel.add(waitBetweenIterationsLabel);
|
|
parameterPanel.add(waitBetweenIterationsLabel);
|
|
|
|
|
|
|
|
|
|
- lowVolatageTextfield = new TextField("230");
|
|
+ fileNameTextfield = new TextField("Eval.txt");
|
|
- lowVolatageTextfield.setBounds(425, 10, 95, 20);
|
|
+ fileNameTextfield.setBounds(425, 10, 95, 20);
|
|
- parameterPanel.add(lowVolatageTextfield);
|
|
+ parameterPanel.add(fileNameTextfield);
|
|
-
|
|
+
|
|
- JLabel lowVolatageLabel = new JLabel("low voltage in volt");
|
|
+ JLabel fileNameLabel = new JLabel("Filename");
|
|
- lowVolatageLabel.setBounds(530, 10, 300, 20);
|
|
+ fileNameLabel.setBounds(530, 10, 300, 20);
|
|
- parameterPanel.add(lowVolatageLabel);
|
|
+ parameterPanel.add(fileNameLabel);
|
|
-
|
|
+
|
|
- highVolatageTextfield = new TextField("20000");
|
|
+
|
|
- highVolatageTextfield.setBounds(425, 35, 95, 20);
|
|
+
|
|
- parameterPanel.add(highVolatageTextfield);
|
|
+
|
|
-
|
|
+
|
|
- JLabel highVolatageLabel = new JLabel("high voltage in volt");
|
|
+
|
|
- highVolatageLabel.setBounds(530, 35, 300, 20);
|
|
+
|
|
- parameterPanel.add(highVolatageLabel);
|
|
+
|
|
|
|
|
|
renewableTextfield = new TextField("300");
|
|
renewableTextfield = new TextField("300");
|
|
renewableTextfield.setBounds(425, 60, 95, 20);
|
|
renewableTextfield.setBounds(425, 60, 95, 20);
|
|
@@ -209,6 +218,7 @@ public class ControlAlgorithm implements AddOn {
|
|
}
|
|
}
|
|
|
|
|
|
private void println(String message) {
|
|
private void println(String message) {
|
|
|
|
+ lines.add(message);
|
|
textArea.append(message + "\n");
|
|
textArea.append(message + "\n");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -238,9 +248,9 @@ public class ControlAlgorithm implements AddOn {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
control.getModel().setResistanceCalculator(new ResistanceCalculator(
|
|
control.getModel().setResistanceCalculator(new ResistanceCalculator(
|
|
- Integer.parseInt(lowVolatageTextfield.getText()),
|
|
+ 230,
|
|
- Integer.parseInt(highVolatageTextfield.getText()),
|
|
+ 10000,
|
|
- 10, 25,0.017, 0.017));
|
|
+ 35, 25,0.017, 0.017));
|
|
control.getModel().getResistanceCalculator().setDistancesToCalcResistance(powerplant);
|
|
control.getModel().getResistanceCalculator().setDistancesToCalcResistance(powerplant);
|
|
|
|
|
|
blackstartRunningCounter = 0;
|
|
blackstartRunningCounter = 0;
|
|
@@ -269,6 +279,9 @@ public class ControlAlgorithm implements AddOn {
|
|
se.setStateOfCharge(Float.parseFloat(storageStartCharge.getText()));
|
|
se.setStateOfCharge(Float.parseFloat(storageStartCharge.getText()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ lines = new ArrayList<String>();
|
|
|
|
+ lines.add(fileNameTextfield.getText());
|
|
|
|
+ file = Paths.get(fileNameTextfield.getText());
|
|
updateVisual();
|
|
updateVisual();
|
|
if (blackstartStartTime + blackstartSuccessTime > control.getModel().getIterations() - 1) {
|
|
if (blackstartStartTime + blackstartSuccessTime > control.getModel().getIterations() - 1) {
|
|
println("No Time for the blackstart, use working numbers");
|
|
println("No Time for the blackstart, use working numbers");
|
|
@@ -293,6 +306,7 @@ public class ControlAlgorithm implements AddOn {
|
|
deactivateBlackstart();
|
|
deactivateBlackstart();
|
|
updateVisual();
|
|
updateVisual();
|
|
println("Simulation of blackstart failed in Iteration: " + curIteration);
|
|
println("Simulation of blackstart failed in Iteration: " + curIteration);
|
|
|
|
+ writeOutputTxt();
|
|
} else {
|
|
} else {
|
|
|
|
|
|
blackstartRunningCounter++;
|
|
blackstartRunningCounter++;
|
|
@@ -303,6 +317,7 @@ public class ControlAlgorithm implements AddOn {
|
|
enableAllConsumers();
|
|
enableAllConsumers();
|
|
updateVisual();
|
|
updateVisual();
|
|
println("Simulation of blackstart Successfull in Iteration: " + curIteration);
|
|
println("Simulation of blackstart Successfull in Iteration: " + curIteration);
|
|
|
|
+ writeOutputTxt();
|
|
} else {
|
|
} else {
|
|
|
|
|
|
updateVisual();
|
|
updateVisual();
|
|
@@ -323,9 +338,7 @@ public class ControlAlgorithm implements AddOn {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- * TODO: HOLEG UNTERVERSORGUNG CHECKEN
|
|
|
|
* TODO: global resistance calculator?
|
|
* TODO: global resistance calculator?
|
|
- * TODO: entladen besser verteilen
|
|
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* maybes:
|
|
* maybes:
|
|
@@ -353,7 +366,11 @@ public class ControlAlgorithm implements AddOn {
|
|
println("Not enough storage energy available");
|
|
println("Not enough storage energy available");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- } else {
|
|
+ } else {try {
|
|
|
|
+ Files.write(file, lines, StandardCharsets.UTF_8);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
rampUpPowerplant();
|
|
rampUpPowerplant();
|
|
@@ -533,6 +550,14 @@ public class ControlAlgorithm implements AddOn {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void writeOutputTxt(){
|
|
|
|
+ try {
|
|
|
|
+ Files.write(file, lines, StandardCharsets.UTF_8);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void printCurrentEnergyState(){
|
|
private void printCurrentEnergyState(){
|
|
println("CURRENT ALGORITHM ITERATION: "+ control.getModel().getCurIteration());
|
|
println("CURRENT ALGORITHM ITERATION: "+ control.getModel().getCurIteration());
|
|
println("blackstart resi: " + getEnergyRequiredForPowerplantBlackstart());
|
|
println("blackstart resi: " + getEnergyRequiredForPowerplantBlackstart());
|