SimulationManager.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. package ui.controller;
  2. import classes.*;
  3. import ui.model.Model;
  4. import ui.view.FlexiblePane;
  5. import ui.view.MyCanvas;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. /**
  9. * Controller for Simulation.
  10. *
  11. * @author Gruppe14
  12. */
  13. public class SimulationManager {
  14. int global = 0;
  15. private Model model;
  16. private ArrayList<AbstractCpsObject> objectsToHandle;
  17. // private ArrayList<CpsEdge> allConnections;
  18. private ArrayList<SubNet> subNets;
  19. private ArrayList<CpsEdge> brokenEdges;
  20. private MyCanvas canvas;
  21. private int timeStep;
  22. private HashMap<Integer, Float> tagTable = new HashMap<>();
  23. private FlexiblePane flexPane;
  24. private HashMap<HolonElement, Float> flexDevicesTurnedOnThisTurn = new HashMap<>();
  25. /**
  26. * Constructor.
  27. *
  28. * @param m Model
  29. */
  30. SimulationManager(Model m) {
  31. canvas = null;
  32. model = m;
  33. subNets = new ArrayList<>();
  34. brokenEdges = new ArrayList<>();
  35. }
  36. /**
  37. * calculates the flow of the edges and the supply for objects.
  38. *
  39. * @param x current Iteration
  40. */
  41. void calculateStateForTimeStep(int x) {
  42. reset();
  43. timeStep = x;
  44. searchForSubNets();
  45. for (SubNet singleSubNet : subNets) {
  46. resetConnections(singleSubNet.getObjects().get(0), new ArrayList<>(), new ArrayList<>());
  47. }
  48. for (SubNet singleSubNet : subNets) {
  49. float production = calculateEnergyWithoutFlexDevices("prod", singleSubNet, timeStep);
  50. float consumption = calculateEnergyWithoutFlexDevices("cons", singleSubNet, timeStep);
  51. // surplus of energy is computed by sum, since consumption is a negative value
  52. float energySurplus = production + consumption;
  53. float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
  54. // --------------- use flexible devices ---------------
  55. if (energySurplus != 0 && model.useFlexibleDevices()) {
  56. turnOnFlexibleDevices(singleSubNet, energySurplus, x);
  57. // if (!flexDevicesTurnedOnThisTurn.isEmpty()) {
  58. // System.out.println("The following devices were turned on in this turn: ");
  59. // System.out.println(flexDevicesTurnedOnThisTurn.toString());
  60. // }
  61. // recompute after having examined/turned on all flexible devices
  62. production = calculateEnergyWithFlexDevices("prod", singleSubNet, timeStep);
  63. consumption = calculateEnergyWithFlexDevices("cons", singleSubNet, timeStep);
  64. energySurplus = production + consumption;
  65. }
  66. // --------------- set flow simulation ---------------
  67. setFlowSimulation(singleSubNet);
  68. // --------------- visualise graph ---------------
  69. for (HolonObject hl : singleSubNet.getObjects()) {
  70. if (hl.getState() != HolonObject.NO_ENERGY
  71. && hl.getState() != HolonObject.PRODUCER) {
  72. for (int i = 0; i < hl.getConnections().size(); i++) {
  73. CpsEdge edge = hl.getConnectedTo().get(i);
  74. if (edge.isWorking() && edge.getFlow() > 0
  75. || edge.getCapacity() == CpsEdge.CAPACITY_INFINITE) {
  76. if ((production + consumption) >= 0) {
  77. if (energySurplus > 0) {
  78. hl.setState(HolonObject.OVER_SUPPLIED);
  79. } else {
  80. hl.setState(HolonObject.SUPPLIED);
  81. }
  82. } else {
  83. if ((production + minConsumption) >= 0) {
  84. hl.setState(HolonObject.PARTIALLY_SUPPLIED);
  85. } else if (hl.checkIfPartiallySupplied(timeStep)) {
  86. hl.setState(HolonObject.PARTIALLY_SUPPLIED);
  87. } else {
  88. hl.setState(HolonObject.NOT_SUPPLIED);
  89. }
  90. }
  91. break;
  92. }
  93. }
  94. if (hl.checkIfPartiallySupplied(timeStep)
  95. && hl.getState() != HolonObject.SUPPLIED
  96. && hl.getState() != HolonObject.OVER_SUPPLIED) {
  97. hl.setState(HolonObject.PARTIALLY_SUPPLIED);
  98. }
  99. }
  100. }
  101. }
  102. canvas.repaint();
  103. flexPane.recalculate();
  104. }
  105. /**
  106. * search for all flexible devices in the network and turn them on, until energy surplus = 0
  107. * or all devices have been examined.
  108. *
  109. * This code could be compressed (cases inside over- and underproduction are the same), but we decided that it
  110. * is better readable this way
  111. *
  112. * @param subNet the subnet
  113. * @param energySurplus the current surplus of energy
  114. */
  115. private void turnOnFlexibleDevices(SubNet subNet, float energySurplus, int timestep) {
  116. for (HolonObject holonOb : subNet.getObjects()) {
  117. for (HolonElement holonEl : holonOb.getElements()) {
  118. // if this element is flexible and active (can be considered for calculations)
  119. if (holonEl.isFlexible() && holonEl.isActive()) {
  120. float energyAvailableSingle = holonEl.getAvailableEnergyAt(timestep);
  121. float energyAvailableMultiple = energyAvailableSingle * holonEl.getAmount();
  122. // ------------- flexible consumer / OVERPRODUCTION -------------
  123. if (energyAvailableMultiple < 0 && energySurplus > 0) {
  124. // if there is more wasted energy than energy that this device can give, give all energy available
  125. if (Math.abs(energyAvailableMultiple) <= Math.abs(energySurplus)) {
  126. energySurplus += energyAvailableMultiple;
  127. // set the new energy consumption to the maximum
  128. holonEl.setEnergyPerElement(energyAvailableSingle);
  129. flexDevicesTurnedOnThisTurn.put(holonEl, energyAvailableMultiple);
  130. }
  131. // else: we just need to turn on part of the flexible energy available
  132. else {
  133. float energyNeeded = -energySurplus;
  134. energySurplus += energyNeeded; // should give 0, but was kept this was for consistency
  135. // the energy needed divided through the amount of elements
  136. holonEl.setEnergyPerElement(energyNeeded / holonEl.getAmount());
  137. flexDevicesTurnedOnThisTurn.put(holonEl, energyNeeded);
  138. }
  139. }
  140. // ------------- flexible producer / UNDERPRODUCTION -------------
  141. else if (energyAvailableMultiple > 0 && energySurplus < 0) {
  142. // if there is more energy needed than this device can give, give all the energy available
  143. if (Math.abs(energyAvailableMultiple) <= Math.abs(energySurplus)) {
  144. energySurplus += energyAvailableMultiple;
  145. // set the new energy consumption to the maximum
  146. holonEl.setEnergyPerElement(energyAvailableSingle);
  147. flexDevicesTurnedOnThisTurn.put(holonEl, energyAvailableMultiple);
  148. }
  149. // else: we just need to turn on part of the flexible energy available
  150. else {
  151. float energyNeeded = -energySurplus;
  152. int i = 0;
  153. energySurplus += energyNeeded; // should give 0, but was kept this was for consistency
  154. // the energy needed divided through the amount of elements
  155. holonEl.setEnergyPerElement(energyNeeded / holonEl.getAmount());
  156. flexDevicesTurnedOnThisTurn.put(holonEl, energyNeeded);
  157. }
  158. }
  159. }
  160. if (energySurplus == 0) {
  161. break;
  162. }
  163. }
  164. if (energySurplus == 0) {
  165. break;
  166. }
  167. }
  168. }
  169. /**
  170. * Set Flow Simulation.
  171. *
  172. * @param sN Subnet
  173. */
  174. private void setFlowSimulation(SubNet sN) {
  175. ArrayList<AbstractCpsObject> producers = new ArrayList<>();
  176. AbstractCpsObject tmp = null;
  177. tagTable = new HashMap<>();
  178. // traverse all objects in this subnet
  179. for (HolonObject hl : sN.getObjects()) {
  180. float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
  181. // if their production is higher than their consumption
  182. if (energy > 0) {
  183. tagTable.put(hl.getId(), energy);
  184. hl.addTag(hl.getId());
  185. for (CpsEdge edge : hl.getConnections()) {
  186. if (edge.isWorking()) {
  187. // set other end of edge as tmp-object
  188. // and add this end to the other end's tag-list
  189. AbstractCpsObject a = edge.getA();
  190. AbstractCpsObject b = edge.getB();
  191. if (a.getId() == hl.getId()) {
  192. b.addTag(hl.getId());
  193. tmp = b;
  194. }
  195. if (b.getId() == hl.getId()) {
  196. a.addTag(hl.getId());
  197. tmp = a;
  198. }
  199. edge.setFlow(edge.getFlow() + energy);
  200. edge.calculateState();
  201. edge.addTag(hl.getId());
  202. if (edge.isWorking() && !producers.contains(tmp)) {
  203. if (tmp instanceof HolonSwitch) {
  204. if (((HolonSwitch) tmp).getState(timeStep)) {
  205. producers.add(tmp);
  206. }
  207. } else if (!(tmp instanceof CpsUpperNode)) {
  208. producers.add(tmp);
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. setFlowSimRec(producers, 0);
  216. }
  217. /**
  218. * Set Flow Simulation Rec.
  219. *
  220. * @param nodes the nodes
  221. * @param iter the Iteration
  222. */
  223. private void setFlowSimRec(ArrayList<AbstractCpsObject> nodes, int iter) {
  224. ArrayList<AbstractCpsObject> newNodes = new ArrayList<>();
  225. ArrayList<CpsEdge> changedEdges = new ArrayList<>();
  226. AbstractCpsObject tmp;
  227. if (nodes.size() != 0) {
  228. for (AbstractCpsObject cps : nodes) {
  229. // check whether the cps is in a legit state if it is a switch
  230. if (legitState(cps)) {
  231. for (CpsEdge edge : cps.getConnections()) {
  232. // is edge working
  233. // and does the edge's tag-list not (yet) contain all tags of the cps
  234. if (edge.isWorking()
  235. && (!(edge.containsTags(edge.getTags(), cps.getTag())))) {
  236. if (edge.getA().getId() == cps.getId()) {
  237. tmp = edge.getB();
  238. } else {
  239. tmp = edge.getA();
  240. }
  241. for (Integer tag : cps.getTag()) {
  242. if (!(edge.getTags().contains(tag))
  243. && !(edge.getPseudoTags().contains(tag))) {
  244. edge.setFlow(edge.getFlow() + tagTable.get(tag));
  245. edge.addTag(tag);
  246. }
  247. }
  248. // uppernodes do not spread energy
  249. if (!(tmp instanceof CpsUpperNode)) {
  250. for (Integer tag : tmp.getTag()) {
  251. if (!(edge.getTags().contains(tag))
  252. && tagTable.get(tag) != null
  253. && !(edge.getPseudoTags().contains(tag))) {
  254. edge.setFlow(edge.getFlow() + tagTable.get(tag));
  255. edge.addPseudoTag(tag);
  256. changedEdges.add(edge);
  257. }
  258. }
  259. }
  260. edge.calculateState();
  261. if (edge.isWorking()
  262. && !(tmp instanceof CpsUpperNode)) {
  263. tmp.addAllPseudoTags(cps.getTag());
  264. if (!newNodes.contains(tmp)) {
  265. newNodes.add(tmp);
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. setPseudoTags(newNodes, changedEdges);
  273. setFlowSimRec(newNodes, iter + 1);
  274. }
  275. }
  276. /**
  277. * Set the Pseudo Tags.
  278. *
  279. * @param nodes Array of AbstractCpsObjects
  280. */
  281. private void setPseudoTags(ArrayList<AbstractCpsObject> nodes, ArrayList<CpsEdge> edges) {
  282. for (AbstractCpsObject node : nodes) {
  283. node.recalculateTags();
  284. node.setPseudoTags(new ArrayList<>());
  285. }
  286. for (CpsEdge edge : edges) {
  287. edge.recalculateTags();
  288. edge.setPseudoTag(new ArrayList<>());
  289. }
  290. }
  291. /**
  292. * Reset the Connection.
  293. *
  294. * @param cps CpsObject
  295. * @param visitedObj the visited Objects
  296. * @param visitedEdges the visited Edges
  297. */
  298. private void resetConnections(AbstractCpsObject cps, ArrayList<Integer> visitedObj,
  299. ArrayList<CpsEdge> visitedEdges) {
  300. visitedObj.add(cps.getId());
  301. cps.resetTags();
  302. for (CpsEdge e : cps.getConnections()) {
  303. if (!(visitedEdges.contains(e))) {
  304. e.setFlow(0);
  305. e.calculateState();
  306. e.setTags(new ArrayList<>());
  307. visitedEdges.add(e);
  308. if (!(visitedObj.contains(e.getA().getId()))) {
  309. resetConnections(e.getA(), visitedObj, visitedEdges);
  310. e.getA().resetTags();
  311. }
  312. if (!(visitedObj.contains(e.getB().getId()))) {
  313. resetConnections(e.getB(), visitedObj, visitedEdges);
  314. e.getB().resetTags();
  315. }
  316. }
  317. }
  318. }
  319. /**
  320. * calculates the energy of either all producers or consumers.
  321. * Flexible devices are filtered out
  322. *
  323. * @param type Type
  324. * @param sN Subnet
  325. * @param x Integer
  326. * @return The Energy
  327. */
  328. private float calculateEnergyWithoutFlexDevices(String type, SubNet sN, int x) {
  329. float energy = 0;
  330. for (HolonObject hl : sN.getObjects()) {
  331. float currentEnergyWithoutFlexibles = hl.getCurrentEnergyAtTimeStepWithoutFlexiblesAndResetFlexibles(x);
  332. if (type.equals("prod")) {
  333. if (currentEnergyWithoutFlexibles > 0) {
  334. energy += currentEnergyWithoutFlexibles;
  335. hl.setState(HolonObject.PRODUCER);
  336. }
  337. }
  338. if (type.equals("cons")) {
  339. if (currentEnergyWithoutFlexibles < 0) {
  340. energy = energy + currentEnergyWithoutFlexibles;
  341. hl.setState(HolonObject.NOT_SUPPLIED);
  342. }
  343. }
  344. if (currentEnergyWithoutFlexibles == 0) {
  345. hl.setState(HolonObject.NO_ENERGY);
  346. }
  347. }
  348. return energy;
  349. }
  350. /**
  351. * calculates the energy of either all producers or consumers.
  352. * Flexible devices are filtered out
  353. *
  354. * @param type Type
  355. * @param sN Subnet
  356. * @param x Integer
  357. * @return The Energy
  358. */
  359. private float calculateEnergyWithFlexDevices(String type, SubNet sN, int x) {
  360. float energy = 0;
  361. for (HolonObject hl : sN.getObjects()) {
  362. float currentEnergy = hl.getCurrentEnergyAtTimeStep(x);
  363. if (type.equals("prod")) {
  364. if (currentEnergy > 0) {
  365. energy += currentEnergy;
  366. hl.setState(HolonObject.PRODUCER);
  367. }
  368. }
  369. if (type.equals("cons")) {
  370. if (currentEnergy < 0) {
  371. energy = energy + currentEnergy;
  372. hl.setState(HolonObject.NOT_SUPPLIED);
  373. }
  374. }
  375. if (currentEnergy == 0) {
  376. hl.setState(HolonObject.NO_ENERGY);
  377. }
  378. }
  379. return energy;
  380. }
  381. /**
  382. * Calculate the Minimum Energy.
  383. *
  384. * @param sN Subnet
  385. * @param x Integer
  386. * @return the Calculated minimum Energy
  387. */
  388. private float calculateMinimumEnergy(SubNet sN, int x) {
  389. float min = 0;
  390. float minElement = 0;
  391. for (HolonObject hl : sN.getObjects()) {
  392. if (hl.getElements().size() > 0 && hl.getElements().get(0).getOverallEnergyAtTimeStep(x) < 0) {
  393. minElement = hl.getElements().get(0).getOverallEnergyAtTimeStep(x);
  394. }
  395. for (HolonElement he : hl.getElements()) {
  396. float overallEnergy = he.getOverallEnergyAtTimeStep(x);
  397. if (minElement < overallEnergy && overallEnergy < 0) {
  398. minElement = overallEnergy;
  399. }
  400. }
  401. min = min + minElement;
  402. }
  403. return min;
  404. }
  405. /**
  406. * generates all subNets from all objectsToHandle.
  407. */
  408. private void searchForSubNets() {
  409. subNets = new ArrayList<>();
  410. brokenEdges.clear();
  411. boolean end = false;
  412. int i = 0;
  413. AbstractCpsObject cps;
  414. if (objectsToHandle.size() > 0) {
  415. while (!end) {
  416. cps = objectsToHandle.get(i);
  417. SubNet singleSubNet = new SubNet(new ArrayList<>(), new ArrayList<>(),
  418. new ArrayList<>());
  419. singleSubNet = buildSubNet(cps, new ArrayList<>(), singleSubNet);
  420. if (singleSubNet.getObjects().size() != 0) {
  421. subNets.add(singleSubNet);
  422. }
  423. if (0 == objectsToHandle.size()) {
  424. end = true;
  425. }
  426. }
  427. }
  428. }
  429. /**
  430. * recursivly generates a subnet of all objects, that one specific object is
  431. * connected to.
  432. *
  433. * @param cps AbstractCpsObject
  434. * @param visited visited Array of Integer
  435. * @param sN Subnets
  436. * @return Subnet
  437. */
  438. private SubNet buildSubNet(AbstractCpsObject cps, ArrayList<Integer> visited, SubNet sN) {
  439. visited.add(cps.getId());
  440. if (cps instanceof HolonObject) {
  441. sN.getObjects().add((HolonObject) cps);
  442. }
  443. if (cps instanceof HolonSwitch) {
  444. sN.getSwitches().add((HolonSwitch) cps);
  445. }
  446. removeFromToHandle(cps.getId());
  447. AbstractCpsObject a;
  448. AbstractCpsObject b;
  449. for (CpsEdge edge : cps.getConnections()) {
  450. if (edge.isWorking()) {
  451. a = edge.getA();
  452. b = edge.getB();
  453. if (!(cps instanceof HolonSwitch)) {
  454. if (!(sN.getEdges().contains(edge))) {
  455. sN.getEdges().add(edge);
  456. }
  457. }
  458. if (cps instanceof HolonSwitch && ((HolonSwitch) cps).getState(timeStep)) {
  459. if (!(sN.getEdges().contains(edge))) {
  460. sN.getEdges().add(edge);
  461. }
  462. }
  463. if (!visited.contains(a.getId()) && legitState(cps) && !(a instanceof CpsUpperNode)) {
  464. sN = buildSubNet(a, visited, sN);
  465. }
  466. if (!visited.contains(b.getId()) && legitState(cps) && !(b instanceof CpsUpperNode)) {
  467. sN = buildSubNet(b, visited, sN);
  468. }
  469. if (a instanceof CpsUpperNode && a.getId() != cps.getId()) {
  470. edge.setConnected(CpsEdge.CON_UPPER_NODE_NOT_INSIDE);
  471. checkForConnectedStates(b, (CpsUpperNode) a, edge);
  472. }
  473. if (b instanceof CpsUpperNode && b.getId() != cps.getId()) {
  474. edge.setConnected(CpsEdge.CON_UPPER_NODE_NOT_INSIDE);
  475. checkForConnectedStates(a, (CpsUpperNode) b, edge);
  476. }
  477. } else {
  478. brokenEdges.add(edge);
  479. }
  480. }
  481. return sN;
  482. }
  483. /**
  484. * is the Switch in a legitimate State.
  485. *
  486. * @param current AbstractCpsObject
  487. * @return boolean
  488. */
  489. private boolean legitState(AbstractCpsObject current) {
  490. return !(current instanceof HolonSwitch)
  491. || ((HolonSwitch) current).getState(timeStep);
  492. }
  493. // /**
  494. // * ensures that objectsToHandle only contains HolonObjects.
  495. // */
  496. // public void cleanObjectsToHandle() {
  497. // for (int i = 0; i < objectsToHandle.size(); i++) {
  498. // if (!(objectsToHandle.get(i) instanceof HolonObject)) {
  499. // objectsToHandle.remove(i);
  500. // }
  501. // }
  502. // }
  503. /**
  504. * removes an Object that already has been handled.
  505. *
  506. * @param id the Object ID
  507. */
  508. private void removeFromToHandle(int id) {
  509. for (int i = 0; i < objectsToHandle.size(); i++) {
  510. if (objectsToHandle.get(i).getId() == id) {
  511. objectsToHandle.remove(i);
  512. }
  513. }
  514. }
  515. /**
  516. * copies the data of an array of Objects.
  517. *
  518. * @param toCopy the ArrayList of CpsObjects co Copy
  519. */
  520. private void copyObjects(ArrayList<AbstractCpsObject> toCopy) {
  521. for (AbstractCpsObject cps : toCopy) {
  522. if (cps instanceof CpsUpperNode) {
  523. copyObjects(((CpsUpperNode) cps).getNodes());
  524. } else {
  525. objectsToHandle.add(cps);
  526. }
  527. }
  528. }
  529. /**
  530. * Prints the Components auf all subnets.
  531. */
  532. private void printNetsToConsole() {
  533. for (int i = 0; i < subNets.size(); i++) {
  534. SubNet subNet = subNets.get(i);
  535. System.out.println("SUBNET NR:" + i);
  536. subNet.toString(timeStep);
  537. }
  538. }
  539. /**
  540. * Set the Canvas.
  541. *
  542. * @param can the Canvas
  543. */
  544. public void setCanvas(MyCanvas can) {
  545. canvas = can;
  546. }
  547. /**
  548. * Reset all Data to the current state of the Model.
  549. */
  550. public void reset() {
  551. objectsToHandle = new ArrayList<>();
  552. copyObjects(model.getObjectsOnCanvas());
  553. flexDevicesTurnedOnThisTurn = new HashMap<>();
  554. }
  555. /**
  556. * Resets the State of all Edges
  557. */
  558. private void resetEdges() {
  559. for (CpsEdge e : brokenEdges) {
  560. e.setWorkingState(true);
  561. }
  562. }
  563. /**
  564. * Resets the State for the whole Simulation Model
  565. */
  566. void resetSimulation() {
  567. reset();
  568. resetEdges();
  569. }
  570. /**
  571. * Get all Subnets.
  572. *
  573. * @return all Subnets
  574. */
  575. public ArrayList<SubNet> getSubNets() {
  576. return subNets;
  577. }
  578. /**
  579. * Get broken Edges
  580. */
  581. // public ArrayList<CpsEdge> getBrokenEdges() {
  582. // return brokenEdges;
  583. // }
  584. /**
  585. * checks whether a given object is connected to an object inside the upperNode.
  586. * if yes, the state for the edge is changed in "connected" or "not connected"
  587. */
  588. private void checkForConnectedStates(AbstractCpsObject cps, CpsUpperNode cUNode, CpsEdge theEdge) {
  589. AbstractCpsObject tmp;
  590. for (CpsEdge edge : cps.getConnections()) {
  591. if (edge.getA().getId() == cps.getId()) {
  592. tmp = edge.getB();
  593. } else {
  594. tmp = edge.getA();
  595. }
  596. if (cUNode.getNodes().contains(tmp)) {
  597. if (tmp instanceof CpsUpperNode) {
  598. checkForConnectedStates(cps, (CpsUpperNode) tmp, theEdge);
  599. } else {
  600. theEdge.setConnected(CpsEdge.CON_UPPER_NODE_AND_INSIDE);
  601. break;
  602. }
  603. }
  604. }
  605. }
  606. public FlexiblePane getFlexiblePane() {
  607. return flexPane;
  608. }
  609. void setFlexiblePane(FlexiblePane fp) {
  610. flexPane = fp;
  611. }
  612. }