|
@@ -13,18 +13,14 @@ import ui.controller.Control;
|
|
|
import ui.controller.StorageProductionController;
|
|
|
|
|
|
public class controlAlgorithm implements AddOn {
|
|
|
- private boolean cancel = false;
|
|
|
-
|
|
|
// Gui Part:
|
|
|
private Control control;
|
|
|
private JTextArea textArea;
|
|
|
private JPanel content = new JPanel();
|
|
|
// ProgressBar
|
|
|
- private JProgressBar progressBar = new JProgressBar();
|
|
|
private long startTime;
|
|
|
private Thread runThread;
|
|
|
|
|
|
- // Blackstart Resistance in Watt
|
|
|
private HolonObject powerplant;
|
|
|
|
|
|
private TextField blackstartEnergyrequierementTextfield;
|
|
@@ -117,11 +113,11 @@ public class controlAlgorithm implements AddOn {
|
|
|
powerplantMaxOutputLabel.setBounds(185, 110, 300, 20);
|
|
|
parameterPanel.add(powerplantMaxOutputLabel);
|
|
|
|
|
|
- storageStartCharge = new TextField("10000");
|
|
|
+ storageStartCharge = new TextField("0.16666666");
|
|
|
storageStartCharge.setBounds(10, 135, 170, 20);
|
|
|
parameterPanel.add(storageStartCharge);
|
|
|
|
|
|
- JLabel storageStartChargeLabel = new JLabel("Storage charge at start");
|
|
|
+ JLabel storageStartChargeLabel = new JLabel("Storage charge at start in kWh");
|
|
|
storageStartChargeLabel.setBounds(185, 135, 300, 20);
|
|
|
parameterPanel.add(storageStartChargeLabel);
|
|
|
|
|
@@ -133,36 +129,11 @@ public class controlAlgorithm implements AddOn {
|
|
|
waitBetweenIterationsLabel.setBounds(185, 205, 300, 20);
|
|
|
parameterPanel.add(waitBetweenIterationsLabel);
|
|
|
|
|
|
-// JButton selectGroupNodeButton = new JButton("Select GroupNode");
|
|
|
-// selectGroupNodeButton.setEnabled(false);
|
|
|
-// selectGroupNodeButton.setBounds(10, 25, 165, 20);
|
|
|
-// selectGroupNodeButton.addActionListener(actionEvent -> selectGroupNode());
|
|
|
-// borderPanel.add(selectGroupNodeButton);
|
|
|
-
|
|
|
-// JCheckBox useGroupNodeCheckBox = new JCheckBox();
|
|
|
-// useGroupNodeCheckBox.setSelected(false);
|
|
|
-// useGroupNodeCheckBox.setBounds(155, 1, 25, 20);
|
|
|
-// useGroupNodeCheckBox.addActionListener(actionEvent -> {
|
|
|
-// useGroupNode = useGroupNodeCheckBox.isSelected();
|
|
|
-// selectGroupNodeButton.setEnabled(useGroupNode);
|
|
|
-// });
|
|
|
-// borderPanel.add(useGroupNodeCheckBox);
|
|
|
-
|
|
|
return parameterPanel;
|
|
|
}
|
|
|
|
|
|
public JPanel createButtonPanel() {
|
|
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
|
|
- JButton cancelButton = new JButton("Cancel Run");
|
|
|
- cancelButton.addActionListener(actionEvent -> cancel());
|
|
|
- buttonPanel.add(cancelButton);
|
|
|
- JButton clearButton = new JButton("Clear Console");
|
|
|
- clearButton.addActionListener(actionEvent -> clear());
|
|
|
- buttonPanel.add(clearButton);
|
|
|
- JButton resetButton = new JButton("Reset");
|
|
|
- resetButton.setToolTipText("Resets the State to before the Algorithm has runed.");
|
|
|
- resetButton.addActionListener(actionEvent -> reset());
|
|
|
- buttonPanel.add(resetButton);
|
|
|
JButton runButton = new JButton("Run");
|
|
|
runButton.addActionListener(actionEvent -> {
|
|
|
Runnable task = this::run;
|
|
@@ -173,36 +144,15 @@ public class controlAlgorithm implements AddOn {
|
|
|
return buttonPanel;
|
|
|
}
|
|
|
|
|
|
- private void cancel() {
|
|
|
- if (runThread.isAlive()) {
|
|
|
- println("");
|
|
|
- println("Cancel run.");
|
|
|
- cancel = true;
|
|
|
- progressBar.setValue(0);
|
|
|
- } else {
|
|
|
- println("Nothing to cancel.");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void run() {
|
|
|
clear();
|
|
|
- cancel = false;
|
|
|
disableGuiInput(true);
|
|
|
startTimer();
|
|
|
initAlgo();
|
|
|
- if (cancel) {
|
|
|
- reset();
|
|
|
- disableGuiInput(false);
|
|
|
- return;
|
|
|
- }
|
|
|
printElapsedTime();
|
|
|
disableGuiInput(false);
|
|
|
}
|
|
|
|
|
|
- private void reset() {
|
|
|
- println("RESET DOES NOTHING platzhalter");
|
|
|
- }
|
|
|
-
|
|
|
private void disableGuiInput(boolean bool) {
|
|
|
control.guiDisable(bool);
|
|
|
}
|
|
@@ -250,9 +200,8 @@ public class controlAlgorithm implements AddOn {
|
|
|
println("No Power Plant in Model");
|
|
|
return;
|
|
|
}
|
|
|
- resistanceCalculator resistanceCalculator = new resistanceCalculator(230, 30, 0.017);//TODO
|
|
|
+ resistanceCalculator resistanceCalculator = new resistanceCalculator(230, 20000, 30, 0.017);//TODO
|
|
|
resistanceCalculator.setDistancesToCalcResistance(powerplant);
|
|
|
-// println("bla" + resistanceCalculator.calcEnergyNeededForCertainEnergyAfterResistance(1750, 1000, 4000000));
|
|
|
blackstartRunningCounter = 0;
|
|
|
deactivateBlackstart();
|
|
|
control.getModel().setCurIteration(0);
|
|
@@ -273,7 +222,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
control.getModel().setIterations(Integer.parseInt(simulationDurationTextfield.getText()));
|
|
|
for (StorageElement se :
|
|
|
getStorageElements()) {
|
|
|
- se.setStateOfCharge(Integer.parseInt(storageStartCharge.getText()));
|
|
|
+ se.setStateOfCharge(Float.parseFloat(storageStartCharge.getText())*1000*60);
|
|
|
}
|
|
|
|
|
|
updateVisual();
|
|
@@ -336,7 +285,8 @@ public class controlAlgorithm implements AddOn {
|
|
|
* TODO: batterie status wechesel fuehrt zu unterversorgung in GUI FIX?: in storage if bei charge auskommentieren
|
|
|
* TODO: batterie laden prios? entfernung? doppelt sortieren
|
|
|
* TODO: renewables mit verlust
|
|
|
- * TODO: transformer + voltage unterscheidung
|
|
|
+ * TODO: cable diameter/specificresistance
|
|
|
+ * TODO: stelle fuer ergebnissausgabe ueberdenken
|
|
|
*
|
|
|
* @return true or false depending on whether the blackstart was successful for
|
|
|
* this iteration
|
|
@@ -397,7 +347,7 @@ public class controlAlgorithm implements AddOn {
|
|
|
println("currenctrenewable: " + currentRenewableProduction());
|
|
|
for (StorageElement ele :
|
|
|
getStorageElements()) {
|
|
|
- println("Storage ID: " + ele.getId() + " now at " + ele.getStateOfCharge() + " charge " + "(" + (ele.getStateOfCharge()/60)/1000 + "kWh)");
|
|
|
+ println("Storage ID: " + ele.getId() + " at distance " + ele.getLowDistance() + " at charge " + (ele.getStateOfCharge()/60)/1000 + "kWh");
|
|
|
}
|
|
|
println("currenctpossiblestorage: " + SPC.currentPossibleStorageProduction());
|
|
|
println("blackstart resi: " + getEnergyRequiredForPowerplantBlackstart());
|