TestAlgo.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. package algo;
  2. import java.awt.*;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.LinkedList;
  6. import java.util.List;
  7. import javax.swing.*;
  8. import algo.StorageElement.Mode;
  9. import api.AddOn;
  10. import classes.*;
  11. import ui.controller.Control;
  12. public class TestAlgo implements AddOn {
  13. private boolean cancel = false;
  14. // Gui Part:
  15. private Control control;
  16. private JTextArea textArea;
  17. private JPanel content = new JPanel();
  18. // ProgressBar
  19. private JProgressBar progressBar = new JProgressBar();
  20. private long startTime;
  21. private Thread runThread;
  22. // Blackstart Resistance in Watt
  23. private HolonObject powerPlant;
  24. private TextField blackstartResistanceTextfield;
  25. private TextField blackstartSuccessTimeTextfield;
  26. private TextField powerplantMaxOutputTextfield;
  27. private TextField blackstartStartTimeTextfield;
  28. private TextField simulationDurationTextfield;
  29. private int blackstartSuccessTime;
  30. private int blackstartStartTime;
  31. private int blackstartRunningCounter;
  32. private float powerplantMaxOutput;
  33. private List<HolonObject> renewableProducers;
  34. private List<HolonObject> consumers;
  35. private StorageProductionController SPC;
  36. public static void main(String[] args) {
  37. JFrame newFrame = new JFrame("exampleWindow");
  38. TestAlgo instance = new TestAlgo();
  39. newFrame.setContentPane(instance.getPanel());
  40. newFrame.pack();
  41. newFrame.setVisible(true);
  42. newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  43. }
  44. public TestAlgo() {
  45. content.setLayout(new BorderLayout());
  46. textArea = new JTextArea();
  47. textArea.setEditable(false);
  48. JScrollPane scrollPane = new JScrollPane(textArea);
  49. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createOptionPanel(), scrollPane);
  50. splitPane.setResizeWeight(0.0);
  51. content.add(splitPane, BorderLayout.CENTER);
  52. content.setPreferredSize(new Dimension(800, 800));
  53. }
  54. public JPanel createOptionPanel() {
  55. JPanel optionPanel = new JPanel(new BorderLayout());
  56. JScrollPane scrollPane = new JScrollPane(createParameterPanel());
  57. scrollPane.setBorder(BorderFactory.createTitledBorder("Parameter"));
  58. optionPanel.add(scrollPane, BorderLayout.CENTER);
  59. optionPanel.add(createButtonPanel(), BorderLayout.PAGE_END);
  60. return optionPanel;
  61. }
  62. private Component createParameterPanel() {
  63. JPanel parameterPanel = new JPanel(null);
  64. parameterPanel.setPreferredSize(new Dimension(510, 300));
  65. blackstartResistanceTextfield = new TextField("5000000");
  66. blackstartResistanceTextfield.setBounds(10, 10, 170, 20);
  67. parameterPanel.add(blackstartResistanceTextfield);
  68. JLabel blackstartResistanceLabel = new JLabel("Blackstart resistance in Watt");
  69. blackstartResistanceLabel.setBounds(185, 10, 300, 20);
  70. parameterPanel.add(blackstartResistanceLabel);
  71. blackstartSuccessTimeTextfield = new TextField("30");
  72. blackstartSuccessTimeTextfield.setBounds(10, 35, 170, 20);
  73. parameterPanel.add(blackstartSuccessTimeTextfield);
  74. JLabel blackstartSuccessTimeLabel = new JLabel("Time for successfull blackstart in minutes(iterations)");
  75. blackstartSuccessTimeLabel.setBounds(185, 35, 300, 20);
  76. parameterPanel.add(blackstartSuccessTimeLabel);
  77. blackstartStartTimeTextfield = new TextField("15");
  78. blackstartStartTimeTextfield.setBounds(10, 60, 170, 20);
  79. parameterPanel.add(blackstartStartTimeTextfield);
  80. JLabel blackstartStartTimeLabel = new JLabel("Starttime for the blackstart");
  81. blackstartStartTimeLabel.setBounds(185, 60, 300, 20);
  82. parameterPanel.add(blackstartStartTimeLabel);
  83. simulationDurationTextfield = new TextField("500");// TODO:!
  84. simulationDurationTextfield.setBounds(10, 85, 170, 20);
  85. parameterPanel.add(simulationDurationTextfield);
  86. JLabel simulationDurationLabel = new JLabel("How long should the simulation run?");
  87. simulationDurationLabel.setBounds(185, 85, 300, 20);
  88. parameterPanel.add(simulationDurationLabel);
  89. powerplantMaxOutputTextfield = new TextField("40000000");
  90. powerplantMaxOutputTextfield.setBounds(10, 110, 170, 20);
  91. parameterPanel.add(powerplantMaxOutputTextfield);
  92. JLabel powerplantMaxOutputLabel = new JLabel("Powerplant Output afer Blackstart");
  93. powerplantMaxOutputLabel.setBounds(185, 110, 300, 20);
  94. parameterPanel.add(powerplantMaxOutputLabel);
  95. // JButton selectGroupNodeButton = new JButton("Select GroupNode");
  96. // selectGroupNodeButton.setEnabled(false);
  97. // selectGroupNodeButton.setBounds(10, 25, 165, 20);
  98. // selectGroupNodeButton.addActionListener(actionEvent -> selectGroupNode());
  99. // borderPanel.add(selectGroupNodeButton);
  100. // JCheckBox useGroupNodeCheckBox = new JCheckBox();
  101. // useGroupNodeCheckBox.setSelected(false);
  102. // useGroupNodeCheckBox.setBounds(155, 1, 25, 20);
  103. // useGroupNodeCheckBox.addActionListener(actionEvent -> {
  104. // useGroupNode = useGroupNodeCheckBox.isSelected();
  105. // selectGroupNodeButton.setEnabled(useGroupNode);
  106. // });
  107. // borderPanel.add(useGroupNodeCheckBox);
  108. return parameterPanel;
  109. }
  110. public JPanel createButtonPanel() {
  111. JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  112. JButton cancelButton = new JButton("Cancel Run");
  113. cancelButton.addActionListener(actionEvent -> cancel());
  114. buttonPanel.add(cancelButton);
  115. JButton clearButton = new JButton("Clear Console");
  116. clearButton.addActionListener(actionEvent -> clear());
  117. buttonPanel.add(clearButton);
  118. JButton resetButton = new JButton("Reset");
  119. resetButton.setToolTipText("Resets the State to before the Algorithm has runed.");
  120. resetButton.addActionListener(actionEvent -> reset());
  121. buttonPanel.add(resetButton);
  122. JButton runButton = new JButton("Run");
  123. runButton.addActionListener(actionEvent -> {
  124. Runnable task = () -> run();
  125. runThread = new Thread(task);
  126. runThread.start();
  127. });
  128. buttonPanel.add(runButton);
  129. return buttonPanel;
  130. }
  131. private void cancel() {
  132. if (runThread.isAlive()) {
  133. println("");
  134. println("Cancel run.");
  135. cancel = true;
  136. progressBar.setValue(0);
  137. } else {
  138. println("Nothing to cancel.");
  139. }
  140. }
  141. private void run() {
  142. cancel = false;
  143. disableGuiInput(true);
  144. startTimer();
  145. initAlgo();
  146. if (cancel) {
  147. reset();
  148. disableGuiInput(false);
  149. return;
  150. }
  151. printElapsedTime();
  152. disableGuiInput(false);
  153. }
  154. private void reset() {
  155. println("RESET DOES NOTHING platzhalter");
  156. }
  157. private void disableGuiInput(boolean bool) {
  158. control.guiDisable(bool);
  159. }
  160. @Override
  161. public JPanel getPanel() {
  162. return content;
  163. }
  164. @Override
  165. public void setController(Control control) {
  166. this.control = control;
  167. }
  168. private void clear() {
  169. textArea.setText("");
  170. }
  171. private void print(String message) {
  172. textArea.append(message);
  173. }
  174. private void println(String message) {
  175. textArea.append(message + "\n");
  176. }
  177. private void startTimer() {
  178. startTime = System.currentTimeMillis();
  179. }
  180. private void printElapsedTime() {
  181. long elapsedMilliSeconds = System.currentTimeMillis() - startTime;
  182. println("Execution Time of Algo in Milliseconds:" + elapsedMilliSeconds);
  183. }
  184. ///////////////////////////////////////////////////////////////////////////////////
  185. /**
  186. *
  187. */
  188. private void initAlgo() {
  189. try {
  190. // init
  191. SPC = new StorageProductionController(getStorageElements());// DANGER DONT GIVE NULL
  192. renewableProducers = getRenewableProducers();
  193. consumers = getConsumers();
  194. powerPlant = getPowerPlant();// DANGER DONT GIVE NULL
  195. if(powerPlant == null){
  196. println("No Power Plant in Model");
  197. return;
  198. }
  199. calcResistance();
  200. blackstartRunningCounter = 0;
  201. deactivateBlackstart();
  202. control.getModel().setCurIteration(0);
  203. // prepare model
  204. /////////
  205. setPowerplantProduction(0);
  206. enableAllConsumers();
  207. SPC.disableStorageProduction(-1); //disable all storage production
  208. for (StorageElement se :
  209. getStorageElements()) {
  210. se.setStateOfCharge(10000);
  211. }
  212. // StorageElement ele = new StorageElement("Storage", 1, 0, control.getModel());
  213. // ele.setStatusAndSetEnergy(Mode.EMIT, 5000);
  214. //
  215. // System.out.println(""+ele.getEnergyPerElement());
  216. // powerPlant.addElement(ele);
  217. // for (HolonElement elem : powerPlant.getElements()) {
  218. // if(elem instanceof StorageElement) {
  219. // println("boom");
  220. // }
  221. // }
  222. // TODO: prios?
  223. /////////
  224. // Get parameters from textfields
  225. setPowerPlantBlackstartResistance(-Float.parseFloat(blackstartResistanceTextfield.getText()));
  226. blackstartSuccessTime = Integer.parseInt(blackstartSuccessTimeTextfield.getText());
  227. powerplantMaxOutput = Float.parseFloat(powerplantMaxOutputTextfield.getText());
  228. blackstartStartTime = Integer.parseInt(blackstartStartTimeTextfield.getText());
  229. control.getModel().setIterations(Integer.parseInt(simulationDurationTextfield.getText()));
  230. updateVisual();
  231. if (blackstartStartTime + blackstartSuccessTime > control.getModel().getIterations() - 1) {
  232. println("No Time for the blackstart, use working numbers");
  233. } else {
  234. blackstartMain(control.getModel().getCurIteration());
  235. }
  236. } catch (NumberFormatException e) {
  237. println("Worng Input, only numbers please");
  238. }
  239. }
  240. /**
  241. *
  242. * @param curIteration
  243. */
  244. private void blackstartMain(int curIteration) {
  245. // try {
  246. // Thread.sleep(1000);
  247. // } catch (InterruptedException e) {
  248. // // TODO Auto-generated catch block
  249. // e.printStackTrace();
  250. // }
  251. control.getModel().setCurIteration(curIteration);
  252. if (blackstartRunning()) {
  253. if (!blackstartAlgo(curIteration)) {
  254. // blackstart for this iteration was not successfull
  255. deactivateBlackstart();
  256. updateVisual();
  257. println("Simulation of blackstart failed in Iteration: " + curIteration);
  258. } else {
  259. // blackstart for this iteration was successfull
  260. blackstartRunningCounter++;
  261. if (blackstartRunningCounter == blackstartSuccessTime) {
  262. // blackstart was successfull for the needed iterations
  263. deactivateBlackstart();
  264. enableAllConsumers();
  265. updateVisual();
  266. println("Simulation of blackstart Successfull in Iteration: " + curIteration);
  267. } else {
  268. // blackstart not finished yet
  269. updateVisual();
  270. blackstartMain(curIteration + 1);
  271. }
  272. }
  273. } else {
  274. // blackstart has not started yet
  275. if (curIteration == blackstartStartTime) {
  276. activateBlackstart();
  277. disableConsumers();
  278. blackstartMain(curIteration);
  279. } else {
  280. updateVisual();
  281. blackstartMain(curIteration + 1);
  282. }
  283. }
  284. }
  285. /**
  286. * TODO:HOLEG UNTERVERSORGUNG CHECKEN
  287. *
  288. * @param curIteration
  289. * @return true or false depending on whether the blackstart was successful for
  290. * this iteration
  291. */
  292. private boolean blackstartAlgo(int curIteration) {
  293. if (currentRenewableProduction() < getPowerPlantBlackstartResistance()) {
  294. // renewable energy production is not sufficient for the blackstart
  295. if (SPC.currentPossibleStorageProduction() >= getPowerPlantBlackstartResistance()
  296. - currentRenewableProduction()) {// is there currently enough power available from storage?
  297. SPC.enableStorageProduction(getPowerPlantBlackstartResistance() - currentRenewableProduction());
  298. rampUpPowerplant();
  299. enableConsumers(getPowerplantProduction());
  300. return true;
  301. } else {
  302. // blackstart has failed
  303. SPC.disableStorageProduction(-1);//TODO:disable all
  304. println("Not enough storage energy available");
  305. return false;
  306. }
  307. } else {
  308. //TODO: disable storage?
  309. // renewable energy production is sufficient for the blackstart
  310. rampUpPowerplant();
  311. enableConsumers(
  312. currentRenewableProduction() - getPowerPlantBlackstartResistance() + getPowerplantProduction());
  313. return true;
  314. }
  315. }
  316. private HolonObject getPowerPlant() {
  317. for (AbstractCpsObject cps : control.getModel().getObjectsOnCanvas()) {
  318. // geht nur wenn nur ein power plant vorhanden ist
  319. if (cps instanceof HolonObject) {
  320. if (cps.getObjName().equals("Power Plant")) {
  321. return (HolonObject) cps;
  322. }
  323. }
  324. }
  325. return null;
  326. }
  327. private ArrayList<StorageElement> getStorageElements() {
  328. ArrayList<StorageElement> storageElements = new ArrayList<StorageElement>();
  329. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  330. // if(holonObject.getName().contentEquals("House")) {
  331. // holonObject.addElement(new StorageElement("Storage", 1, 0, control.getModel()));
  332. // }
  333. for (HolonElement ele : holonObject.getElements()) {
  334. if(ele instanceof StorageElement){
  335. storageElements.add((StorageElement) ele);
  336. }
  337. // if (ele.getEleName().equals("Storage")) {
  338. // println(ele.getEleName() + "is : " + ele.getClass());
  339. // if (ele instanceof StorageElement) {
  340. // println("boomboomboomboom");
  341. // }
  342. // }
  343. }
  344. }
  345. return storageElements;
  346. }
  347. private void calcResistance() {
  348. if (powerPlant != null) {
  349. // println("Powerplant Energy @"+powerPlant.getEnergyAtTimeStep(1));
  350. // println("" + getPowerplantProduction());
  351. // travers
  352. if (powerPlant.getConnectedTo().size() > 0) {
  353. for (CpsEdge edge : powerPlant.getConnectedTo()) {
  354. // println(edge.toString());
  355. if (powerPlant.getId() == edge.getA().getId()) {
  356. traversEdges(edge.getB(), powerPlant, calcEdgeLength(edge));
  357. } else {
  358. traversEdges(edge.getA(), powerPlant, calcEdgeLength(edge));
  359. }
  360. }
  361. } else {
  362. println("Nothing connected to powerplant");
  363. }
  364. } else {
  365. println("No powerplant connected");
  366. }
  367. }
  368. private void traversEdges(AbstractCpsObject currentObject, AbstractCpsObject last, double distance) {
  369. if (currentObject.getConnectedTo().size() > 1) { // recursive call for all edges
  370. for (CpsEdge edge : currentObject.getConnectedTo()) {
  371. if (currentObject.getId() == edge.getA().getId()) { // look at which way the edge points
  372. if (last.getId() != edge.getB().getId()) {
  373. traversEdges(edge.getB(), currentObject, distance + calcEdgeLength(edge));
  374. }
  375. } else {
  376. if (last.getId() != edge.getA().getId()) {
  377. traversEdges(edge.getA(), currentObject, distance + calcEdgeLength(edge));
  378. }
  379. }
  380. }
  381. } else { // at leaf
  382. // println("Distance to " + currentObject.getId() + ": " + distance);
  383. // ((HolonObject) currentObject).addElement(new StorageElement("Storage", 1, 0, control.getModel()));
  384. for (HolonElement ele : ((HolonObject) currentObject).getElements()) {
  385. if (ele.getEleName() == "Solar Panels") {
  386. ele.setEnergyPerElement(5000);// TODO: das wollen wir ja so nicht
  387. // println("Energy: " + ele.getEnergyPerElement());
  388. // set how much energy is left after resistance22
  389. ele.setEnergyPerElement(calcEnergyAfterResistance(ele.getEnergyPerElement(), distance));// TODO: das
  390. // wollen
  391. // wir ja so
  392. // auch
  393. // nicht
  394. // println("Energy after resistance: " + ele.getEnergyPerElement());
  395. }
  396. }
  397. }
  398. }
  399. private float calcEnergyAfterResistance(float currentEnergy, double distance) {
  400. // 230v kupfer 30mm durchmesser
  401. int volatage = 230;
  402. int diameter = 30;
  403. // kupfer
  404. double specificMaterialResistance = 0.017;
  405. double blackstartResistance = Math.pow(volatage, 2) / getPowerPlantBlackstartResistance();
  406. double cableResistance = specificMaterialResistance * (distance / (0.25 * Math.PI * Math.pow(diameter, 2)));
  407. return (float) (1 - (cableResistance / (cableResistance + blackstartResistance))) * currentEnergy;
  408. }
  409. private double calcEdgeLength(CpsEdge edge) {
  410. Position aPos = edge.getA().getPosition();
  411. Position bPos = edge.getB().getPosition();
  412. double xDiff = Math.abs(aPos.x - bPos.x);
  413. double yDiff = Math.abs(aPos.y - bPos.y);
  414. return Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
  415. }
  416. private void disableConsumers() {
  417. // TODO: disableBatteryLoading? will ich das wirklich?
  418. // SPC.disableStorageProduction();
  419. for (HolonObject consumer : consumers) {
  420. for (HolonElement ele : consumer.getElements()) {
  421. if (ele.isActive() && ele.isConsumer()) {
  422. ele.setActive(false);
  423. }
  424. }
  425. }
  426. }
  427. private void enableConsumers(float energyAvailable) {
  428. println("currenctrenewable: " + currentRenewableProduction());
  429. println("currenctpossiblestorage: " + SPC.currentPossibleStorageProduction());
  430. println("blackstart resi: " + getPowerPlantBlackstartResistance());
  431. println("current pp production: " + getPowerplantProduction());
  432. println("energy available for consumers" + energyAvailable);
  433. // Damit wir immer die gleiche ausgangslage haben //TODO: wirklich?
  434. disableConsumers();
  435. // TODO: das ganze lieber mit prirotaeten
  436. for (HolonObject consumer : consumers) {
  437. for (HolonElement ele : consumer.getElements()) {
  438. if (energyAvailable > 0
  439. && energyAvailable - Math.abs(ele.getEnergyPerElement() * ele.getAmount()) >= 0) {
  440. if (!ele.isActive()) {
  441. ele.setActive(true);
  442. energyAvailable = energyAvailable - Math.abs(ele.getEnergyPerElement() * ele.getAmount());// +
  443. // since
  444. // its
  445. // negative
  446. // System.out.println("Element " + ele.getId() + " was enabled Energy left: "+ energyAvailable);
  447. }
  448. } else {
  449. return;
  450. }
  451. }
  452. }
  453. // if (!SPC.batteriesFull()) {
  454. // // TODO: load unused batteries
  455. // } else {
  456. //
  457. // }
  458. }
  459. private void enableAllConsumers() {
  460. for (HolonObject consumer : consumers) {
  461. for (HolonElement ele : consumer.getElements()) {
  462. if (!ele.isActive() && ele.isConsumer()) {
  463. ele.setActive(true);
  464. }
  465. }
  466. }
  467. }
  468. private float currentRenewableProduction() {
  469. float production = 0;
  470. for (HolonObject house : renewableProducers) {
  471. for (HolonElement ele : house.getElements()) {
  472. if (ele.getEleName().equals("Solar Panels")) {// TODO: hier muss noch mehr dazu
  473. production = production + ele.getEnergyAtTimeStep(control.getModel().getCurIteration());
  474. }
  475. }
  476. }
  477. return production;
  478. }
  479. private void rampUpPowerplant() {
  480. for (HolonElement ele : powerPlant.getElements()) {
  481. if (ele.getEleName().equals("Power")) {
  482. ele.setEnergyPerElement(ele.getEnergyPerElement() + powerplantMaxOutput / blackstartSuccessTime);
  483. }
  484. }
  485. }
  486. private float getPowerplantProduction() {
  487. float totalProduction = 0;
  488. for (HolonElement ele : powerPlant.getElements()) {
  489. if (ele.getEleName().equals("Power")) {
  490. totalProduction = ele.getEnergyPerElement();
  491. }
  492. }
  493. return totalProduction;
  494. }
  495. private float setPowerplantProduction(float power) {
  496. float totalProduction = 0;
  497. for (HolonElement ele : powerPlant.getElements()) {
  498. if (ele.getEleName().equals("Power")) {
  499. ele.setEnergyPerElement(power);
  500. }
  501. }
  502. return totalProduction;
  503. }
  504. private float getPowerPlantBlackstartResistance() {
  505. for (HolonElement ele : powerPlant.getElements()) {
  506. if (ele.getEleName().equals("Blackstart")) {
  507. return -ele.getEnergyPerElement();
  508. }
  509. }
  510. return 0;
  511. }
  512. private void setPowerPlantBlackstartResistance(float resistance) {
  513. for (HolonElement ele : powerPlant.getElements()) {
  514. if (ele.getEleName().equals("Blackstart")) {
  515. ele.setEnergyPerElement(resistance);
  516. }
  517. }
  518. }
  519. private boolean blackstartRunning() {
  520. for (HolonElement ele : powerPlant.getElements()) {
  521. if (ele.getEleName().equals("Blackstart")) {
  522. if (ele.isActive()) {
  523. return true;
  524. } else {
  525. return false;
  526. }
  527. }
  528. }
  529. return false;
  530. }
  531. private void activateBlackstart() {
  532. for (HolonElement ele : powerPlant.getElements()) {
  533. if (ele.getEleName().equals("Blackstart")) {
  534. ele.setActive(true);
  535. }
  536. }
  537. }
  538. private void deactivateBlackstart() {
  539. for (HolonElement ele : powerPlant.getElements()) {
  540. if (ele.getEleName().equals("Blackstart")) {
  541. ele.setActive(false);
  542. }
  543. }
  544. }
  545. private LinkedList<HolonObject> getRenewableProducers() {
  546. LinkedList<HolonObject> list = new LinkedList<HolonObject>();
  547. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  548. if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
  549. // werden ob es renewables gibt
  550. list.add(holonObject);
  551. }
  552. }
  553. return list;
  554. }
  555. private LinkedList<HolonObject> getConsumers() {
  556. LinkedList<HolonObject> list = new LinkedList<HolonObject>();
  557. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  558. if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
  559. // werden ob es consumer gibt
  560. list.add(holonObject);
  561. }
  562. }
  563. return list;
  564. }
  565. /**
  566. * To let the User See the current state without touching the Canvas.
  567. */
  568. private void updateVisual() {
  569. System.out.println("Start updateVisual in Iteration: " + control.getModel().getCurIteration());
  570. control.calculateStateAndVisualForCurrentTimeStep();
  571. control.updateCanvas();
  572. System.out.println("Finish updateVisual in Iteration: " + control.getModel().getCurIteration());
  573. }
  574. }