TestAlgo.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. println("Not enough storage energy available");
  304. return false;
  305. }
  306. } else {
  307. // renewable energy production is sufficient for the blackstart
  308. rampUpPowerplant();
  309. enableConsumers(
  310. currentRenewableProduction() - getPowerPlantBlackstartResistance() + getPowerplantProduction());
  311. return true;
  312. }
  313. }
  314. private HolonObject getPowerPlant() {
  315. for (AbstractCpsObject cps : control.getModel().getObjectsOnCanvas()) {
  316. // geht nur wenn nur ein power plant vorhanden ist
  317. if (cps instanceof HolonObject) {
  318. if (cps.getObjName().equals("Power Plant")) {
  319. return (HolonObject) cps;
  320. }
  321. }
  322. }
  323. return null;
  324. }
  325. private ArrayList<StorageElement> getStorageElements() {
  326. ArrayList<StorageElement> storageElements = new ArrayList<StorageElement>();
  327. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  328. // if(holonObject.getName().contentEquals("House")) {
  329. // holonObject.addElement(new StorageElement("Storage", 1, 0, control.getModel()));
  330. // }
  331. for (HolonElement ele : holonObject.getElements()) {
  332. if(ele instanceof StorageElement){
  333. storageElements.add((StorageElement) ele);
  334. }
  335. // if (ele.getEleName().equals("Storage")) {
  336. // println(ele.getEleName() + "is : " + ele.getClass());
  337. // if (ele instanceof StorageElement) {
  338. // println("boomboomboomboom");
  339. // }
  340. // }
  341. }
  342. }
  343. return storageElements;
  344. }
  345. private void calcResistance() {
  346. if (powerPlant != null) {
  347. // println("Powerplant Energy @"+powerPlant.getEnergyAtTimeStep(1));
  348. // println("" + getPowerplantProduction());
  349. // travers
  350. if (powerPlant.getConnectedTo().size() > 0) {
  351. for (CpsEdge edge : powerPlant.getConnectedTo()) {
  352. // println(edge.toString());
  353. if (powerPlant.getId() == edge.getA().getId()) {
  354. traversEdges(edge.getB(), powerPlant, calcEdgeLength(edge));
  355. } else {
  356. traversEdges(edge.getA(), powerPlant, calcEdgeLength(edge));
  357. }
  358. }
  359. } else {
  360. println("Nothing connected to powerplant");
  361. }
  362. } else {
  363. println("No powerplant connected");
  364. }
  365. }
  366. private void traversEdges(AbstractCpsObject currentObject, AbstractCpsObject last, double distance) {
  367. if (currentObject.getConnectedTo().size() > 1) { // recursive call for all edges
  368. for (CpsEdge edge : currentObject.getConnectedTo()) {
  369. if (currentObject.getId() == edge.getA().getId()) { // look at which way the edge points
  370. if (last.getId() != edge.getB().getId()) {
  371. traversEdges(edge.getB(), currentObject, distance + calcEdgeLength(edge));
  372. }
  373. } else {
  374. if (last.getId() != edge.getA().getId()) {
  375. traversEdges(edge.getA(), currentObject, distance + calcEdgeLength(edge));
  376. }
  377. }
  378. }
  379. } else { // at leaf
  380. // println("Distance to " + currentObject.getId() + ": " + distance);
  381. // ((HolonObject) currentObject).addElement(new StorageElement("Storage", 1, 0, control.getModel()));
  382. for (HolonElement ele : ((HolonObject) currentObject).getElements()) {
  383. if (ele.getEleName() == "Solar Panels") {
  384. ele.setEnergyPerElement(5000);// TODO: das wollen wir ja so nicht
  385. // println("Energy: " + ele.getEnergyPerElement());
  386. // set how much energy is left after resistance22
  387. ele.setEnergyPerElement(calcEnergyAfterResistance(ele.getEnergyPerElement(), distance));// TODO: das
  388. // wollen
  389. // wir ja so
  390. // auch
  391. // nicht
  392. // println("Energy after resistance: " + ele.getEnergyPerElement());
  393. }
  394. }
  395. }
  396. }
  397. private float calcEnergyAfterResistance(float currentEnergy, double distance) {
  398. // 230v kupfer 30mm durchmesser
  399. int volatage = 230;
  400. int diameter = 30;
  401. // kupfer
  402. double specificMaterialResistance = 0.017;
  403. double blackstartResistance = Math.pow(volatage, 2) / getPowerPlantBlackstartResistance();
  404. double cableResistance = specificMaterialResistance * (distance / (0.25 * Math.PI * Math.pow(diameter, 2)));
  405. return (float) (1 - (cableResistance / (cableResistance + blackstartResistance))) * currentEnergy;
  406. }
  407. private double calcEdgeLength(CpsEdge edge) {
  408. Position aPos = edge.getA().getPosition();
  409. Position bPos = edge.getB().getPosition();
  410. double xDiff = Math.abs(aPos.x - bPos.x);
  411. double yDiff = Math.abs(aPos.y - bPos.y);
  412. return Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
  413. }
  414. private void disableConsumers() {
  415. // TODO: disableBatteryLoading? will ich das wirklich?
  416. // SPC.disableStorageProduction();
  417. for (HolonObject consumer : consumers) {
  418. for (HolonElement ele : consumer.getElements()) {
  419. if (ele.isActive() && ele.isConsumer()) {
  420. ele.setActive(false);
  421. }
  422. }
  423. }
  424. }
  425. private void enableConsumers(float energyAvailable) {
  426. println("currenctrenewable: " + currentRenewableProduction());
  427. println("currenctpossiblestorage: " + SPC.currentPossibleStorageProduction());
  428. println("blackstart resi: " + getPowerPlantBlackstartResistance());
  429. println("current pp production: " + getPowerplantProduction());
  430. println("energy available for consumers" + energyAvailable);
  431. // Damit wir immer die gleiche ausgangslage haben //TODO: wirklich?
  432. disableConsumers();
  433. // TODO: das ganze lieber mit prirotaeten
  434. for (HolonObject consumer : consumers) {
  435. for (HolonElement ele : consumer.getElements()) {
  436. if (energyAvailable > 0
  437. && energyAvailable - Math.abs(ele.getEnergyPerElement() * ele.getAmount()) >= 0) {
  438. if (!ele.isActive()) {
  439. ele.setActive(true);
  440. energyAvailable = energyAvailable - Math.abs(ele.getEnergyPerElement() * ele.getAmount());// +
  441. // since
  442. // its
  443. // negative
  444. // System.out.println("Element " + ele.getId() + " was enabled Energy left: "+ energyAvailable);
  445. }
  446. } else {
  447. return;
  448. }
  449. }
  450. }
  451. // if (!SPC.batteriesFull()) {
  452. // // TODO: load unused batteries
  453. // } else {
  454. //
  455. // }
  456. }
  457. private void enableAllConsumers() {
  458. for (HolonObject consumer : consumers) {
  459. for (HolonElement ele : consumer.getElements()) {
  460. if (!ele.isActive() && ele.isConsumer()) {
  461. ele.setActive(true);
  462. }
  463. }
  464. }
  465. }
  466. private float currentRenewableProduction() {
  467. float production = 0;
  468. for (HolonObject house : renewableProducers) {
  469. for (HolonElement ele : house.getElements()) {
  470. if (ele.getEleName().equals("Solar Panels")) {// TODO: hier muss noch mehr dazu
  471. production = production + ele.getEnergyAtTimeStep(control.getModel().getCurIteration());
  472. }
  473. }
  474. }
  475. return production;
  476. }
  477. private void rampUpPowerplant() {
  478. for (HolonElement ele : powerPlant.getElements()) {
  479. if (ele.getEleName().equals("Power")) {
  480. ele.setEnergyPerElement(ele.getEnergyPerElement() + powerplantMaxOutput / blackstartSuccessTime);
  481. }
  482. }
  483. }
  484. private float getPowerplantProduction() {
  485. float totalProduction = 0;
  486. for (HolonElement ele : powerPlant.getElements()) {
  487. if (ele.getEleName().equals("Power")) {
  488. totalProduction = ele.getEnergyPerElement();
  489. }
  490. }
  491. return totalProduction;
  492. }
  493. private float setPowerplantProduction(float power) {
  494. float totalProduction = 0;
  495. for (HolonElement ele : powerPlant.getElements()) {
  496. if (ele.getEleName().equals("Power")) {
  497. ele.setEnergyPerElement(power);
  498. }
  499. }
  500. return totalProduction;
  501. }
  502. private float getPowerPlantBlackstartResistance() {
  503. for (HolonElement ele : powerPlant.getElements()) {
  504. if (ele.getEleName().equals("Blackstart")) {
  505. return -ele.getEnergyPerElement();
  506. }
  507. }
  508. return 0;
  509. }
  510. private void setPowerPlantBlackstartResistance(float resistance) {
  511. for (HolonElement ele : powerPlant.getElements()) {
  512. if (ele.getEleName().equals("Blackstart")) {
  513. ele.setEnergyPerElement(resistance);
  514. }
  515. }
  516. }
  517. private boolean blackstartRunning() {
  518. for (HolonElement ele : powerPlant.getElements()) {
  519. if (ele.getEleName().equals("Blackstart")) {
  520. if (ele.isActive()) {
  521. return true;
  522. } else {
  523. return false;
  524. }
  525. }
  526. }
  527. return false;
  528. }
  529. private void activateBlackstart() {
  530. for (HolonElement ele : powerPlant.getElements()) {
  531. if (ele.getEleName().equals("Blackstart")) {
  532. ele.setActive(true);
  533. }
  534. }
  535. }
  536. private void deactivateBlackstart() {
  537. for (HolonElement ele : powerPlant.getElements()) {
  538. if (ele.getEleName().equals("Blackstart")) {
  539. ele.setActive(false);
  540. }
  541. }
  542. }
  543. private LinkedList<HolonObject> getRenewableProducers() {
  544. LinkedList<HolonObject> list = new LinkedList<HolonObject>();
  545. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  546. if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
  547. // werden ob es renewables gibt
  548. list.add(holonObject);
  549. }
  550. }
  551. return list;
  552. }
  553. private LinkedList<HolonObject> getConsumers() {
  554. LinkedList<HolonObject> list = new LinkedList<HolonObject>();
  555. for (HolonObject holonObject : control.getModel().getAllHolonObjectsOnCanvas()) {
  556. if (holonObject.getObjName().contentEquals("House")) {// TODO: das reicht so nicht da muss noch gecheckt
  557. // werden ob es consumer gibt
  558. list.add(holonObject);
  559. }
  560. }
  561. return list;
  562. }
  563. /**
  564. * To let the User See the current state without touching the Canvas.
  565. */
  566. private void updateVisual() {
  567. System.out.println("Start updateVisual in Iteration: " + control.getModel().getCurIteration());
  568. control.calculateStateAndVisualForCurrentTimeStep();
  569. control.updateCanvas();
  570. System.out.println("Finish updateVisual in Iteration: " + control.getModel().getCurIteration());
  571. }
  572. }