Merge lp:~danilovesky/workcraft/trunk-refactor-stg-generator into lp:workcraft
- trunk-refactor-stg-generator
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 647 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-refactor-stg-generator |
Merge into: | lp:workcraft |
Diff against target: |
6002 lines (+2598/-1271) 55 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java (+31/-38) CircuitPlugin/src/org/workcraft/plugins/circuit/stg/NodeStg.java (+0/-29) CircuitPlugin/src/org/workcraft/plugins/circuit/stg/SignalStg.java (+0/-42) CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java (+7/-7) DfsPlugin/src/org/workcraft/plugins/dfs/stg/BinaryRegisterStg.java (+1/-0) DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowLogicStg.java (+1/-0) DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowRegisterStg.java (+1/-0) DfsPlugin/src/org/workcraft/plugins/dfs/stg/LogicStg.java (+1/-0) DfsPlugin/src/org/workcraft/plugins/dfs/stg/NodeStg.java (+0/-30) DfsPlugin/src/org/workcraft/plugins/dfs/stg/RegisterStg.java (+1/-0) DfsPlugin/src/org/workcraft/plugins/dfs/stg/StgGenerator.java (+262/-244) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java (+1/-1) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java (+1/-1) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java (+1/-1) DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java (+1/-1) DfsPlugin/src/org/workcraft/plugins/dfs/tools/StgGeneratorTool.java (+1/-1) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java (+1/-1) PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java (+52/-6) SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java (+4/-2) STGPlugin/src/org/workcraft/plugins/stg/generator/NodeStg.java (+38/-0) STGPlugin/src/org/workcraft/plugins/stg/generator/SignalStg.java (+52/-0) STGPlugin/src/org/workcraft/plugins/stg/generator/StgGenerator.java (+294/-0) WorkcraftCore/src/org/workcraft/plugins/shared/CommonVisualSettings.java (+1/-1) WorkcraftRunner/.fatjar (+0/-14) XmasPlugin/src/org/workcraft/plugins/xmas/XmasSettings.java (+14/-14) XmasPlugin/src/org/workcraft/plugins/xmas/components/StateDecoration.java (+7/-0) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualQueueComponent.java (+27/-20) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSinkComponent.java (+28/-0) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSourceComponent.java (+29/-2) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSwitchComponent.java (+47/-0) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasComponent.java (+4/-4) XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasConnection.java (+3/-3) XmasPlugin/src/org/workcraft/plugins/xmas/stg/ContactStg.java (+36/-0) XmasPlugin/src/org/workcraft/plugins/xmas/stg/ForkStg.java (+5/-4) XmasPlugin/src/org/workcraft/plugins/xmas/stg/FunctionStg.java (+4/-3) XmasPlugin/src/org/workcraft/plugins/xmas/stg/JoinStg.java (+5/-4) XmasPlugin/src/org/workcraft/plugins/xmas/stg/MergeStg.java (+39/-0) XmasPlugin/src/org/workcraft/plugins/xmas/stg/NodeStg.java (+0/-38) XmasPlugin/src/org/workcraft/plugins/xmas/stg/QueueStg.java (+50/-65) XmasPlugin/src/org/workcraft/plugins/xmas/stg/SignalStg.java (+0/-47) XmasPlugin/src/org/workcraft/plugins/xmas/stg/SinkStg.java (+4/-2) XmasPlugin/src/org/workcraft/plugins/xmas/stg/SlotStg.java (+40/-0) XmasPlugin/src/org/workcraft/plugins/xmas/stg/SourceStg.java (+4/-2) XmasPlugin/src/org/workcraft/plugins/xmas/stg/StgGenerator.java (+1118/-511) XmasPlugin/src/org/workcraft/plugins/xmas/stg/SwitchStg.java (+44/-0) XmasPlugin/src/org/workcraft/plugins/xmas/tools/JsonExport.java (+1/-1) XmasPlugin/src/org/workcraft/plugins/xmas/tools/PNetExt.java (+5/-6) XmasPlugin/src/org/workcraft/plugins/xmas/tools/PNetGen.java (+7/-9) XmasPlugin/src/org/workcraft/plugins/xmas/tools/StgGeneratorTool.java (+1/-1) XmasPlugin/src/org/workcraft/plugins/xmas/tools/SyncTool.java (+2/-2) XmasPlugin/src/org/workcraft/plugins/xmas/tools/VerAnalysis.java (+28/-12) XmasPlugin/src/org/workcraft/plugins/xmas/tools/VerConfTool.java (+11/-17) XmasPlugin/src/org/workcraft/plugins/xmas/tools/VerQuery.java (+32/-18) XmasPlugin/src/org/workcraft/plugins/xmas/tools/VerTool.java (+26/-10) XmasPlugin/src/org/workcraft/plugins/xmas/tools/XmasSimulationTool.java (+225/-57) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-refactor-stg-generator |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Approve | ||
Review via email: mp+272416@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Danil Sokolov (danilovesky) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java' | |||
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-07-26 21:27:56 +0000 | |||
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-09-25 14:54:20 +0000 | |||
4 | @@ -16,6 +16,7 @@ | |||
5 | 16 | import org.workcraft.dom.Node; | 16 | import org.workcraft.dom.Node; |
6 | 17 | import org.workcraft.dom.hierarchy.NamespaceHelper; | 17 | import org.workcraft.dom.hierarchy.NamespaceHelper; |
7 | 18 | import org.workcraft.dom.visual.Movable; | 18 | import org.workcraft.dom.visual.Movable; |
8 | 19 | import org.workcraft.dom.visual.Positioning; | ||
9 | 19 | import org.workcraft.dom.visual.TransformHelper; | 20 | import org.workcraft.dom.visual.TransformHelper; |
10 | 20 | import org.workcraft.dom.visual.VisualNode; | 21 | import org.workcraft.dom.visual.VisualNode; |
11 | 21 | import org.workcraft.exceptions.InvalidConnectionException; | 22 | import org.workcraft.exceptions.InvalidConnectionException; |
12 | @@ -41,6 +42,7 @@ | |||
13 | 41 | import org.workcraft.plugins.stg.VisualImplicitPlaceArc; | 42 | import org.workcraft.plugins.stg.VisualImplicitPlaceArc; |
14 | 42 | import org.workcraft.plugins.stg.VisualSTG; | 43 | import org.workcraft.plugins.stg.VisualSTG; |
15 | 43 | import org.workcraft.plugins.stg.VisualSignalTransition; | 44 | import org.workcraft.plugins.stg.VisualSignalTransition; |
16 | 45 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
17 | 44 | import org.workcraft.util.Geometry; | 46 | import org.workcraft.util.Geometry; |
18 | 45 | import org.workcraft.util.Hierarchy; | 47 | import org.workcraft.util.Hierarchy; |
19 | 46 | import org.workcraft.util.TwoWayMap; | 48 | import org.workcraft.util.TwoWayMap; |
20 | @@ -53,12 +55,12 @@ | |||
21 | 53 | 55 | ||
22 | 54 | private static final double SCALE_X = 4.0; | 56 | private static final double SCALE_X = 4.0; |
23 | 55 | private static final double SCALE_Y = 4.0; | 57 | private static final double SCALE_Y = 4.0; |
30 | 56 | private static final Point2D OFFSET_P1 = new Point2D.Double(0.0, -1.0); | 58 | private static final Point2D OFFSET_P1 = new Point2D.Double(0.0, -2.0); |
31 | 57 | private static final Point2D OFFSET_P0 = new Point2D.Double(0.0, 1.0); | 59 | private static final Point2D OFFSET_P0 = new Point2D.Double(0.0, +2.0); |
32 | 58 | private static final Point2D OFFSET_INIT_PLUS = new Point2D.Double(0.0, -1.0); | 60 | private static final Point2D OFFSET_INIT_PLUS = new Point2D.Double(0.0, -2.0); |
33 | 59 | private static final Point2D OFFSET_INIT_MINUS = new Point2D.Double(0.0, 1.0); | 61 | private static final Point2D OFFSET_INIT_MINUS = new Point2D.Double(0.0, +2.0); |
34 | 60 | private static final Point2D OFFSET_INC_PLUS = new Point2D.Double(0.0, -2.0); | 62 | private static final Point2D OFFSET_INC_PLUS = new Point2D.Double(0.0, -1.0); |
35 | 61 | private static final Point2D OFFSET_INC_MINUS = new Point2D.Double(0.0, 2.0); | 63 | private static final Point2D OFFSET_INC_MINUS = new Point2D.Double(0.0, +1.0); |
36 | 62 | 64 | ||
37 | 63 | private final VisualCircuit circuit; | 65 | private final VisualCircuit circuit; |
38 | 64 | private final VisualSTG stg; | 66 | private final VisualSTG stg; |
39 | @@ -176,13 +178,15 @@ | |||
40 | 176 | String signalName = CircuitUtils.getSignalName(circuit, signal); | 178 | String signalName = CircuitUtils.getSignalName(circuit, signal); |
41 | 177 | 179 | ||
42 | 178 | VisualPlace zeroPlace = stg.createPlace(signalName + NAME_SUFFIX_0, container); | 180 | VisualPlace zeroPlace = stg.createPlace(signalName + NAME_SUFFIX_0, container); |
44 | 179 | zeroPlace.setLabel(signalName + LABEL_SUFFIX_0); | 181 | zeroPlace.setNamePositioning(Positioning.TOP); |
45 | 182 | zeroPlace.setLabelPositioning(Positioning.BOTTOM); | ||
46 | 180 | if (!signal.getReferencedContact().getInitToOne()) { | 183 | if (!signal.getReferencedContact().getInitToOne()) { |
47 | 181 | zeroPlace.getReferencedPlace().setTokens(1); | 184 | zeroPlace.getReferencedPlace().setTokens(1); |
48 | 182 | } | 185 | } |
49 | 183 | 186 | ||
50 | 184 | VisualPlace onePlace = stg.createPlace(signalName + NAME_SUFFIX_1, container); | 187 | VisualPlace onePlace = stg.createPlace(signalName + NAME_SUFFIX_1, container); |
52 | 185 | onePlace.setLabel(signalName + LABEL_SUFFIX_1); | 188 | onePlace.setNamePositioning(Positioning.BOTTOM); |
53 | 189 | onePlace.setLabelPositioning(Positioning.TOP); | ||
54 | 186 | if (signal.getReferencedContact().getInitToOne()) { | 190 | if (signal.getReferencedContact().getInitToOne()) { |
55 | 187 | onePlace.getReferencedPlace().setTokens(1); | 191 | onePlace.getReferencedPlace().setTokens(1); |
56 | 188 | } | 192 | } |
57 | @@ -217,9 +221,9 @@ | |||
58 | 217 | 221 | ||
59 | 218 | private void createSignalStgTransitions(VisualContact driver, Dnf dnf, Direction direction) { | 222 | private void createSignalStgTransitions(VisualContact driver, Dnf dnf, Direction direction) { |
60 | 219 | SignalStg driverStg = driverToStgMap.getValue(driver); | 223 | SignalStg driverStg = driverToStgMap.getValue(driver); |
64 | 220 | VisualPlace predPlace = (direction == Direction.PLUS ? driverStg.P0 : driverStg.P1); | 224 | VisualPlace predPlace = (direction == Direction.PLUS ? driverStg.zero : driverStg.one); |
65 | 221 | VisualPlace succPlace = (direction == Direction.PLUS ? driverStg.P1 : driverStg.P0); | 225 | VisualPlace succPlace = (direction == Direction.PLUS ? driverStg.one : driverStg.zero); |
66 | 222 | HashSet<VisualSignalTransition> transitions = (direction == Direction.PLUS ? driverStg.Rs : driverStg.Fs); | 226 | Collection<VisualSignalTransition> transitions = (direction == Direction.PLUS ? driverStg.riseList : driverStg.fallList); |
67 | 223 | 227 | ||
68 | 224 | TreeSet<DnfClause> clauses = new TreeSet<DnfClause>( | 228 | TreeSet<DnfClause> clauses = new TreeSet<DnfClause>( |
69 | 225 | new Comparator<DnfClause>() { | 229 | new Comparator<DnfClause>() { |
70 | @@ -258,7 +262,7 @@ | |||
71 | 258 | if (sourceDriverStg == null) { | 262 | if (sourceDriverStg == null) { |
72 | 259 | throw new RuntimeException("No source for '" + circuit.getMathName(sourceContact) + "' while generating '" + signalName + "'."); | 263 | throw new RuntimeException("No source for '" + circuit.getMathName(sourceContact) + "' while generating '" + signalName + "'."); |
73 | 260 | } | 264 | } |
75 | 261 | VisualPlace place = literal.getNegation() ? sourceDriverStg.P0 : sourceDriverStg.P1; | 265 | VisualPlace place = literal.getNegation() ? sourceDriverStg.zero : sourceDriverStg.one; |
76 | 262 | placesToRead.add(place); | 266 | placesToRead.add(place); |
77 | 263 | } | 267 | } |
78 | 264 | 268 | ||
79 | @@ -267,14 +271,8 @@ | |||
80 | 267 | } | 271 | } |
81 | 268 | 272 | ||
82 | 269 | for (VisualPlace place : placesToRead) { | 273 | for (VisualPlace place : placesToRead) { |
83 | 270 | // FIXME: Why duplicate arcs would be created in the first place? | ||
84 | 271 | try { | 274 | try { |
91 | 272 | if(stg.getConnection(place, transition) == null) { | 275 | stg.connectUndirected(place, transition); |
86 | 273 | stg.connect(place, transition); | ||
87 | 274 | } | ||
88 | 275 | if(stg.getConnection(transition, place) == null) { | ||
89 | 276 | stg.connect(transition, place); | ||
90 | 277 | } | ||
92 | 278 | } catch (InvalidConnectionException e) { | 276 | } catch (InvalidConnectionException e) { |
93 | 279 | throw new RuntimeException(e); | 277 | throw new RuntimeException(e); |
94 | 280 | } | 278 | } |
95 | @@ -333,17 +331,15 @@ | |||
96 | 333 | } | 331 | } |
97 | 334 | 332 | ||
98 | 335 | if ((zeroPlace != null) && (onePlace != null)) { | 333 | if ((zeroPlace != null) && (onePlace != null)) { |
99 | 336 | zeroPlace.setLabel(signalName + LABEL_SUFFIX_0); | ||
100 | 337 | onePlace.setLabel(signalName + LABEL_SUFFIX_1); | ||
101 | 338 | SignalStg signalStg = new SignalStg(zeroPlace, onePlace); | 334 | SignalStg signalStg = new SignalStg(zeroPlace, onePlace); |
102 | 339 | result.put(driver, signalStg); | 335 | result.put(driver, signalStg); |
103 | 340 | for (VisualSignalTransition transition: stg.getVisualSignalTransitions()) { | 336 | for (VisualSignalTransition transition: stg.getVisualSignalTransitions()) { |
104 | 341 | if (signalName.equals(transition.getSignalName())) { | 337 | if (signalName.equals(transition.getSignalName())) { |
105 | 342 | if (transition.getDirection() == Direction.PLUS) { | 338 | if (transition.getDirection() == Direction.PLUS) { |
107 | 343 | signalStg.Rs.add(transition); | 339 | signalStg.riseList.add(transition); |
108 | 344 | } | 340 | } |
109 | 345 | if (transition.getDirection() == Direction.MINUS) { | 341 | if (transition.getDirection() == Direction.MINUS) { |
111 | 346 | signalStg.Fs.add(transition); | 342 | signalStg.fallList.add(transition); |
112 | 347 | } | 343 | } |
113 | 348 | } | 344 | } |
114 | 349 | } | 345 | } |
115 | @@ -358,8 +354,8 @@ | |||
116 | 358 | for (VisualContact driver: drivers) { | 354 | for (VisualContact driver: drivers) { |
117 | 359 | SignalStg signalStg = driverToStgMap.getValue(driver); | 355 | SignalStg signalStg = driverToStgMap.getValue(driver); |
118 | 360 | if (signalStg != null) { | 356 | if (signalStg != null) { |
121 | 361 | signalStg.Rs.removeAll(redundantTransitions); | 357 | signalStg.riseList.removeAll(redundantTransitions); |
122 | 362 | signalStg.Fs.removeAll(redundantTransitions); | 358 | signalStg.fallList.removeAll(redundantTransitions); |
123 | 363 | } | 359 | } |
124 | 364 | } | 360 | } |
125 | 365 | stg.remove(redundantTransitions); | 361 | stg.remove(redundantTransitions); |
126 | @@ -370,8 +366,8 @@ | |||
127 | 370 | for (VisualContact driver: drivers) { | 366 | for (VisualContact driver: drivers) { |
128 | 371 | SignalStg signalStg = driverToStgMap.getValue(driver); | 367 | SignalStg signalStg = driverToStgMap.getValue(driver); |
129 | 372 | if (signalStg != null) { | 368 | if (signalStg != null) { |
132 | 373 | HashSet<Node> deadPostset = new HashSet<Node>(stg.getPostset(signalStg.P0)); | 369 | HashSet<Node> deadPostset = new HashSet<Node>(stg.getPostset(signalStg.zero)); |
133 | 374 | deadPostset.retainAll(stg.getPostset(signalStg.P1)); | 370 | deadPostset.retainAll(stg.getPostset(signalStg.one)); |
134 | 375 | result.addAll(deadPostset); | 371 | result.addAll(deadPostset); |
135 | 376 | } | 372 | } |
136 | 377 | } | 373 | } |
137 | @@ -383,14 +379,14 @@ | |||
138 | 383 | for (VisualContact driver: drivers) { | 379 | for (VisualContact driver: drivers) { |
139 | 384 | SignalStg signalStg = driverToStgMap.getValue(driver); | 380 | SignalStg signalStg = driverToStgMap.getValue(driver); |
140 | 385 | if (signalStg != null) { | 381 | if (signalStg != null) { |
143 | 386 | result.addAll(getDuplicates(signalStg.Rs)); | 382 | result.addAll(getDuplicates(signalStg.riseList)); |
144 | 387 | result.addAll(getDuplicates(signalStg.Fs)); | 383 | result.addAll(getDuplicates(signalStg.fallList)); |
145 | 388 | } | 384 | } |
146 | 389 | } | 385 | } |
147 | 390 | return result; | 386 | return result; |
148 | 391 | } | 387 | } |
149 | 392 | 388 | ||
151 | 393 | private HashSet<Node> getDuplicates(HashSet<VisualSignalTransition> transitions) { | 389 | private HashSet<Node> getDuplicates(Collection<VisualSignalTransition> transitions) { |
152 | 394 | HashSet<Node> result = new HashSet<>(); | 390 | HashSet<Node> result = new HashSet<>(); |
153 | 395 | for (VisualSignalTransition t1: transitions) { | 391 | for (VisualSignalTransition t1: transitions) { |
154 | 396 | if (result.contains(t1)) continue; | 392 | if (result.contains(t1)) continue; |
155 | @@ -414,18 +410,18 @@ | |||
156 | 414 | if (signalStg != null) { | 410 | if (signalStg != null) { |
157 | 415 | VisualContact signal = CircuitUtils.findSignal(circuit, driver); | 411 | VisualContact signal = CircuitUtils.findSignal(circuit, driver); |
158 | 416 | Point2D centerPosition = getPosition(signal); | 412 | Point2D centerPosition = getPosition(signal); |
161 | 417 | setPosition(signalStg.P0, Geometry.add(centerPosition, OFFSET_P0)); | 413 | setPosition(signalStg.zero, Geometry.add(centerPosition, OFFSET_P0)); |
162 | 418 | setPosition(signalStg.P1, Geometry.add(centerPosition, OFFSET_P1)); | 414 | setPosition(signalStg.one, Geometry.add(centerPosition, OFFSET_P1)); |
163 | 419 | 415 | ||
164 | 420 | centerPosition = Geometry.add(centerPosition, getDirectionOffset(signal)); | 416 | centerPosition = Geometry.add(centerPosition, getDirectionOffset(signal)); |
165 | 421 | Point2D plusPosition = Geometry.add(centerPosition, OFFSET_INIT_PLUS); | 417 | Point2D plusPosition = Geometry.add(centerPosition, OFFSET_INIT_PLUS); |
167 | 422 | for (VisualSignalTransition transition: signalStg.Rs) { | 418 | for (VisualSignalTransition transition: signalStg.riseList) { |
168 | 423 | setPosition(transition, plusPosition); | 419 | setPosition(transition, plusPosition); |
169 | 424 | plusPosition = Geometry.add(plusPosition, OFFSET_INC_PLUS); | 420 | plusPosition = Geometry.add(plusPosition, OFFSET_INC_PLUS); |
170 | 425 | } | 421 | } |
171 | 426 | 422 | ||
172 | 427 | Point2D minusPosition = Geometry.add(centerPosition, OFFSET_INIT_MINUS); | 423 | Point2D minusPosition = Geometry.add(centerPosition, OFFSET_INIT_MINUS); |
174 | 428 | for (VisualSignalTransition transition: signalStg.Fs) { | 424 | for (VisualSignalTransition transition: signalStg.fallList) { |
175 | 429 | setPosition(transition, minusPosition); | 425 | setPosition(transition, minusPosition); |
176 | 430 | minusPosition = Geometry.add(minusPosition, OFFSET_INC_MINUS); | 426 | minusPosition = Geometry.add(minusPosition, OFFSET_INC_MINUS); |
177 | 431 | } | 427 | } |
178 | @@ -465,10 +461,7 @@ | |||
179 | 465 | SignalStg signalStg = driverToStgMap.getValue(driver); | 461 | SignalStg signalStg = driverToStgMap.getValue(driver); |
180 | 466 | if (signalStg != null) { | 462 | if (signalStg != null) { |
181 | 467 | Collection<Node> nodesToGroup = new LinkedList<Node>(); | 463 | Collection<Node> nodesToGroup = new LinkedList<Node>(); |
186 | 468 | nodesToGroup.add(signalStg.P1); | 464 | nodesToGroup.addAll(signalStg.getAllNodes()); |
183 | 469 | nodesToGroup.add(signalStg.P0); | ||
184 | 470 | nodesToGroup.addAll(signalStg.Rs); | ||
185 | 471 | nodesToGroup.addAll(signalStg.Fs); | ||
187 | 472 | 465 | ||
188 | 473 | Container currentLevel = null; | 466 | Container currentLevel = null; |
189 | 474 | Container oldLevel = stg.getCurrentLevel(); | 467 | Container oldLevel = stg.getCurrentLevel(); |
190 | 475 | 468 | ||
191 | === removed file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/NodeStg.java' | |||
192 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/NodeStg.java 2015-05-06 20:28:22 +0000 | |||
193 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/NodeStg.java 1970-01-01 00:00:00 +0000 | |||
194 | @@ -1,29 +0,0 @@ | |||
195 | 1 | package org.workcraft.plugins.circuit.stg; | ||
196 | 2 | |||
197 | 3 | import java.util.List; | ||
198 | 4 | |||
199 | 5 | import org.workcraft.dom.Node; | ||
200 | 6 | import org.workcraft.plugins.petri.VisualPlace; | ||
201 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
202 | 8 | |||
203 | 9 | public abstract class NodeStg { | ||
204 | 10 | public abstract List<VisualPlace> getAllVisualPlaces(); | ||
205 | 11 | public abstract List<VisualSignalTransition> getAllVisualTransitions(); | ||
206 | 12 | |||
207 | 13 | public boolean containsDirectlyOrByReference(Node n) { | ||
208 | 14 | if (n != null) { | ||
209 | 15 | for (VisualPlace p: getAllVisualPlaces()) { | ||
210 | 16 | if ((n == p) || ((p != null) && (n == p.getReferencedPlace()))) { | ||
211 | 17 | return true; | ||
212 | 18 | } | ||
213 | 19 | } | ||
214 | 20 | for (VisualSignalTransition t: getAllVisualTransitions()) { | ||
215 | 21 | if ((n == t) || ((t != null) && (n == t.getReferencedTransition()))) { | ||
216 | 22 | return true; | ||
217 | 23 | } | ||
218 | 24 | } | ||
219 | 25 | } | ||
220 | 26 | return false; | ||
221 | 27 | } | ||
222 | 28 | |||
223 | 29 | } | ||
224 | 30 | 0 | ||
225 | === removed file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/SignalStg.java' | |||
226 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/SignalStg.java 2015-05-06 20:28:22 +0000 | |||
227 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/SignalStg.java 1970-01-01 00:00:00 +0000 | |||
228 | @@ -1,42 +0,0 @@ | |||
229 | 1 | package org.workcraft.plugins.circuit.stg; | ||
230 | 2 | |||
231 | 3 | import java.util.ArrayList; | ||
232 | 4 | import java.util.Arrays; | ||
233 | 5 | import java.util.HashSet; | ||
234 | 6 | import java.util.List; | ||
235 | 7 | |||
236 | 8 | import org.workcraft.plugins.petri.VisualPlace; | ||
237 | 9 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
238 | 10 | |||
239 | 11 | |||
240 | 12 | public class SignalStg extends NodeStg { | ||
241 | 13 | public final VisualPlace P0; | ||
242 | 14 | public final VisualPlace P1; | ||
243 | 15 | public final HashSet<VisualSignalTransition> Rs; | ||
244 | 16 | public final HashSet<VisualSignalTransition> Fs; | ||
245 | 17 | |||
246 | 18 | public SignalStg(VisualPlace P0, VisualPlace P1) { | ||
247 | 19 | this(P0, P1, new HashSet<VisualSignalTransition>(), new HashSet<VisualSignalTransition>()); | ||
248 | 20 | } | ||
249 | 21 | |||
250 | 22 | public SignalStg(VisualPlace P0, VisualPlace P1, HashSet<VisualSignalTransition> Rs, HashSet<VisualSignalTransition> Fs) { | ||
251 | 23 | this.P0 = P0; | ||
252 | 24 | this.P1 = P1; | ||
253 | 25 | this.Rs = Rs; | ||
254 | 26 | this.Fs = Fs; | ||
255 | 27 | } | ||
256 | 28 | |||
257 | 29 | @Override | ||
258 | 30 | public List<VisualSignalTransition> getAllVisualTransitions() { | ||
259 | 31 | List<VisualSignalTransition> result = new ArrayList<VisualSignalTransition>(); | ||
260 | 32 | result.addAll(Rs); | ||
261 | 33 | result.addAll(Fs); | ||
262 | 34 | return result; | ||
263 | 35 | } | ||
264 | 36 | |||
265 | 37 | @Override | ||
266 | 38 | public List<VisualPlace> getAllVisualPlaces() { | ||
267 | 39 | return Arrays.asList(P0, P1); | ||
268 | 40 | } | ||
269 | 41 | |||
270 | 42 | } | ||
271 | 43 | 0 | ||
272 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java' | |||
273 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-06-30 13:42:58 +0000 | |||
274 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-09-25 14:54:20 +0000 | |||
275 | @@ -27,13 +27,13 @@ | |||
276 | 27 | import org.workcraft.plugins.circuit.VisualContact; | 27 | import org.workcraft.plugins.circuit.VisualContact; |
277 | 28 | import org.workcraft.plugins.circuit.VisualJoint; | 28 | import org.workcraft.plugins.circuit.VisualJoint; |
278 | 29 | import org.workcraft.plugins.circuit.stg.CircuitToStgConverter; | 29 | import org.workcraft.plugins.circuit.stg.CircuitToStgConverter; |
279 | 30 | import org.workcraft.plugins.circuit.stg.SignalStg; | ||
280 | 31 | import org.workcraft.plugins.petri.Place; | 30 | import org.workcraft.plugins.petri.Place; |
281 | 32 | import org.workcraft.plugins.petri.Transition; | 31 | import org.workcraft.plugins.petri.Transition; |
282 | 33 | import org.workcraft.plugins.shared.CommonSimulationSettings; | 32 | import org.workcraft.plugins.shared.CommonSimulationSettings; |
283 | 34 | import org.workcraft.plugins.stg.LabelParser; | 33 | import org.workcraft.plugins.stg.LabelParser; |
284 | 35 | import org.workcraft.plugins.stg.SignalTransition; | 34 | import org.workcraft.plugins.stg.SignalTransition; |
285 | 36 | import org.workcraft.plugins.stg.VisualSignalTransition; | 35 | import org.workcraft.plugins.stg.VisualSignalTransition; |
286 | 36 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
287 | 37 | import org.workcraft.plugins.stg.tools.StgSimulationTool; | 37 | import org.workcraft.plugins.stg.tools.StgSimulationTool; |
288 | 38 | import org.workcraft.util.Func; | 38 | import org.workcraft.util.Func; |
289 | 39 | 39 | ||
290 | @@ -149,7 +149,7 @@ | |||
291 | 149 | if ((converter != null) && contact.isDriver()) { | 149 | if ((converter != null) && contact.isDriver()) { |
292 | 150 | SignalStg signalStg = converter.getSignalStg(contact); | 150 | SignalStg signalStg = converter.getSignalStg(contact); |
293 | 151 | if (signalStg != null) { | 151 | if (signalStg != null) { |
295 | 152 | for (VisualSignalTransition transition : signalStg.getAllVisualTransitions()) { | 152 | for (VisualSignalTransition transition : signalStg.getAllTransitions()) { |
296 | 153 | if (net.isEnabled(transition.getReferencedTransition())) { | 153 | if (net.isEnabled(transition.getReferencedTransition())) { |
297 | 154 | result = transition.getReferencedTransition(); | 154 | result = transition.getReferencedTransition(); |
298 | 155 | break; | 155 | break; |
299 | @@ -209,10 +209,10 @@ | |||
300 | 209 | SignalStg signalStg = converter.getSignalStg(contact); | 209 | SignalStg signalStg = converter.getSignalStg(contact); |
301 | 210 | if (signalStg != null) { | 210 | if (signalStg != null) { |
302 | 211 | Node traceCurrentNode = getTraceCurrentNode(); | 211 | Node traceCurrentNode = getTraceCurrentNode(); |
305 | 212 | final boolean isOne = (signalStg.P1.getReferencedPlace().getTokens() == 1); | 212 | final boolean isOne = (signalStg.one.getReferencedPlace().getTokens() == 1); |
306 | 213 | final boolean isZero = (signalStg.P0.getReferencedPlace().getTokens() == 1); | 213 | final boolean isZero = (signalStg.zero.getReferencedPlace().getTokens() == 1); |
307 | 214 | final boolean isExcited = (getContactExcitedTransition(contact) != null); | 214 | final boolean isExcited = (getContactExcitedTransition(contact) != null); |
309 | 215 | final boolean isInTrace = (signalStg.containsDirectlyOrByReference(traceCurrentNode)); | 215 | final boolean isInTrace = (signalStg.contains(traceCurrentNode)); |
310 | 216 | return new Decoration() { | 216 | return new Decoration() { |
311 | 217 | @Override | 217 | @Override |
312 | 218 | public Color getColorisation() { | 218 | public Color getColorisation() { |
313 | @@ -248,8 +248,8 @@ | |||
314 | 248 | } else if ((node instanceof VisualJoint) || (node instanceof VisualCircuitConnection)) { | 248 | } else if ((node instanceof VisualJoint) || (node instanceof VisualCircuitConnection)) { |
315 | 249 | SignalStg signalStg = converter.getSignalStg((VisualNode)node); | 249 | SignalStg signalStg = converter.getSignalStg((VisualNode)node); |
316 | 250 | if (signalStg != null) { | 250 | if (signalStg != null) { |
319 | 251 | final boolean isOne = (signalStg.P1.getReferencedPlace().getTokens() == 1); | 251 | final boolean isOne = (signalStg.one.getReferencedPlace().getTokens() == 1); |
320 | 252 | final boolean isZero = (signalStg.P0.getReferencedPlace().getTokens() == 1); | 252 | final boolean isZero = (signalStg.zero.getReferencedPlace().getTokens() == 1); |
321 | 253 | return new Decoration() { | 253 | return new Decoration() { |
322 | 254 | @Override | 254 | @Override |
323 | 255 | public Color getColorisation() { | 255 | public Color getColorisation() { |
324 | 256 | 256 | ||
325 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/BinaryRegisterStg.java' | |||
326 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/BinaryRegisterStg.java 2013-09-10 15:21:42 +0000 | |||
327 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/BinaryRegisterStg.java 2015-09-25 14:54:20 +0000 | |||
328 | @@ -10,6 +10,7 @@ | |||
329 | 10 | import org.workcraft.dom.Node; | 10 | import org.workcraft.dom.Node; |
330 | 11 | import org.workcraft.plugins.petri.VisualPlace; | 11 | import org.workcraft.plugins.petri.VisualPlace; |
331 | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; |
332 | 13 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
333 | 13 | 14 | ||
334 | 14 | public class BinaryRegisterStg extends NodeStg { | 15 | public class BinaryRegisterStg extends NodeStg { |
335 | 15 | public final VisualPlace M0; // M=0 | 16 | public final VisualPlace M0; // M=0 |
336 | 16 | 17 | ||
337 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowLogicStg.java' | |||
338 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowLogicStg.java 2015-08-27 21:29:15 +0000 | |||
339 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowLogicStg.java 2015-09-25 14:54:20 +0000 | |||
340 | @@ -10,6 +10,7 @@ | |||
341 | 10 | import org.workcraft.dom.Node; | 10 | import org.workcraft.dom.Node; |
342 | 11 | import org.workcraft.plugins.petri.VisualPlace; | 11 | import org.workcraft.plugins.petri.VisualPlace; |
343 | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; |
344 | 13 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
345 | 13 | 14 | ||
346 | 14 | public class CounterflowLogicStg extends NodeStg { | 15 | public class CounterflowLogicStg extends NodeStg { |
347 | 15 | public final VisualPlace fwC0; // forwardC=0 | 16 | public final VisualPlace fwC0; // forwardC=0 |
348 | 16 | 17 | ||
349 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowRegisterStg.java' | |||
350 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowRegisterStg.java 2013-09-09 11:11:43 +0000 | |||
351 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/CounterflowRegisterStg.java 2015-09-25 14:54:20 +0000 | |||
352 | @@ -5,6 +5,7 @@ | |||
353 | 5 | 5 | ||
354 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 6 | import org.workcraft.plugins.petri.VisualPlace; |
355 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; |
356 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
357 | 8 | 9 | ||
358 | 9 | public class CounterflowRegisterStg extends NodeStg { | 10 | public class CounterflowRegisterStg extends NodeStg { |
359 | 10 | public final VisualPlace orM0; // orM=0 | 11 | public final VisualPlace orM0; // orM=0 |
360 | 11 | 12 | ||
361 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/LogicStg.java' | |||
362 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/LogicStg.java 2015-08-27 21:29:15 +0000 | |||
363 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/LogicStg.java 2015-09-25 14:54:20 +0000 | |||
364 | @@ -10,6 +10,7 @@ | |||
365 | 10 | import org.workcraft.dom.Node; | 10 | import org.workcraft.dom.Node; |
366 | 11 | import org.workcraft.plugins.petri.VisualPlace; | 11 | import org.workcraft.plugins.petri.VisualPlace; |
367 | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; | 12 | import org.workcraft.plugins.stg.VisualSignalTransition; |
368 | 13 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
369 | 13 | 14 | ||
370 | 14 | public class LogicStg extends NodeStg { | 15 | public class LogicStg extends NodeStg { |
371 | 15 | public final VisualPlace C0; // C=0 | 16 | public final VisualPlace C0; // C=0 |
372 | 16 | 17 | ||
373 | === removed file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/NodeStg.java' | |||
374 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/NodeStg.java 2015-08-27 21:29:15 +0000 | |||
375 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/NodeStg.java 1970-01-01 00:00:00 +0000 | |||
376 | @@ -1,30 +0,0 @@ | |||
377 | 1 | package org.workcraft.plugins.dfs.stg; | ||
378 | 2 | |||
379 | 3 | import java.util.List; | ||
380 | 4 | |||
381 | 5 | import org.workcraft.dom.Node; | ||
382 | 6 | import org.workcraft.plugins.petri.VisualPlace; | ||
383 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
384 | 8 | |||
385 | 9 | public abstract class NodeStg { | ||
386 | 10 | public abstract List<VisualSignalTransition> getAllTransitions(); | ||
387 | 11 | |||
388 | 12 | public abstract List<VisualPlace> getAllPlaces(); | ||
389 | 13 | |||
390 | 14 | public boolean contains(Node n) { | ||
391 | 15 | if (n != null) { | ||
392 | 16 | for (VisualPlace p: getAllPlaces()) { | ||
393 | 17 | if (n == p || (p != null && n == p.getReferencedPlace())) { | ||
394 | 18 | return true; | ||
395 | 19 | } | ||
396 | 20 | } | ||
397 | 21 | for (VisualSignalTransition t: getAllTransitions()) { | ||
398 | 22 | if (n == t || (t != null && n == t.getReferencedTransition())) { | ||
399 | 23 | return true; | ||
400 | 24 | } | ||
401 | 25 | } | ||
402 | 26 | } | ||
403 | 27 | return false; | ||
404 | 28 | } | ||
405 | 29 | |||
406 | 30 | } | ||
407 | 31 | 0 | ||
408 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/RegisterStg.java' | |||
409 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/RegisterStg.java 2015-08-27 21:29:15 +0000 | |||
410 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/RegisterStg.java 2015-09-25 14:54:20 +0000 | |||
411 | @@ -5,6 +5,7 @@ | |||
412 | 5 | 5 | ||
413 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 6 | import org.workcraft.plugins.petri.VisualPlace; |
414 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; |
415 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
416 | 8 | 9 | ||
417 | 9 | public class RegisterStg extends NodeStg { | 10 | public class RegisterStg extends NodeStg { |
418 | 10 | public final VisualPlace M0; // M=0 | 11 | public final VisualPlace M0; // M=0 |
419 | 11 | 12 | ||
420 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/stg/StgGenerator.java' | |||
421 | --- DfsPlugin/src/org/workcraft/plugins/dfs/stg/StgGenerator.java 2015-09-13 20:57:03 +0000 | |||
422 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/stg/StgGenerator.java 2015-09-25 14:54:20 +0000 | |||
423 | @@ -1,7 +1,7 @@ | |||
424 | 1 | package org.workcraft.plugins.dfs.stg; | 1 | package org.workcraft.plugins.dfs.stg; |
425 | 2 | 2 | ||
426 | 3 | import java.awt.Color; | 3 | import java.awt.Color; |
428 | 4 | import java.awt.geom.AffineTransform; | 4 | import java.awt.geom.Point2D; |
429 | 5 | import java.util.Collection; | 5 | import java.util.Collection; |
430 | 6 | import java.util.HashMap; | 6 | import java.util.HashMap; |
431 | 7 | import java.util.HashSet; | 7 | import java.util.HashSet; |
432 | @@ -12,10 +12,7 @@ | |||
433 | 12 | import org.workcraft.dom.Connection; | 12 | import org.workcraft.dom.Connection; |
434 | 13 | import org.workcraft.dom.Container; | 13 | import org.workcraft.dom.Container; |
435 | 14 | import org.workcraft.dom.Node; | 14 | import org.workcraft.dom.Node; |
436 | 15 | import org.workcraft.dom.visual.Movable; | ||
437 | 16 | import org.workcraft.dom.visual.Positioning; | 15 | import org.workcraft.dom.visual.Positioning; |
438 | 17 | import org.workcraft.dom.visual.TransformHelper; | ||
439 | 18 | import org.workcraft.dom.visual.connections.VisualConnection; | ||
440 | 19 | import org.workcraft.exceptions.InvalidConnectionException; | 16 | import org.workcraft.exceptions.InvalidConnectionException; |
441 | 20 | import org.workcraft.plugins.dfs.ControlRegister.SynchronisationType; | 17 | import org.workcraft.plugins.dfs.ControlRegister.SynchronisationType; |
442 | 21 | import org.workcraft.plugins.dfs.DfsSettings; | 18 | import org.workcraft.plugins.dfs.DfsSettings; |
443 | @@ -30,15 +27,14 @@ | |||
444 | 30 | import org.workcraft.plugins.dfs.VisualPushRegister; | 27 | import org.workcraft.plugins.dfs.VisualPushRegister; |
445 | 31 | import org.workcraft.plugins.dfs.VisualRegister; | 28 | import org.workcraft.plugins.dfs.VisualRegister; |
446 | 32 | import org.workcraft.plugins.petri.VisualPlace; | 29 | import org.workcraft.plugins.petri.VisualPlace; |
447 | 33 | import org.workcraft.plugins.stg.STG; | ||
448 | 34 | import org.workcraft.plugins.stg.SignalTransition; | 30 | import org.workcraft.plugins.stg.SignalTransition; |
449 | 35 | import org.workcraft.plugins.stg.VisualSTG; | ||
450 | 36 | import org.workcraft.plugins.stg.VisualSignalTransition; | 31 | import org.workcraft.plugins.stg.VisualSignalTransition; |
451 | 32 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
452 | 37 | import org.workcraft.util.CieColorUtils; | 33 | import org.workcraft.util.CieColorUtils; |
453 | 38 | import org.workcraft.util.ColorGenerator; | 34 | import org.workcraft.util.ColorGenerator; |
454 | 39 | import org.workcraft.util.Hierarchy; | 35 | import org.workcraft.util.Hierarchy; |
455 | 40 | 36 | ||
457 | 41 | public class StgGenerator { | 37 | public class StgGenerator extends org.workcraft.plugins.stg.generator.StgGenerator { |
458 | 42 | public static final String nameC = "C_"; | 38 | public static final String nameC = "C_"; |
459 | 43 | public static final String nameFwC = "fwC_"; | 39 | public static final String nameFwC = "fwC_"; |
460 | 44 | public static final String nameBwC = "bwC_"; | 40 | public static final String nameBwC = "bwC_"; |
461 | @@ -59,86 +55,97 @@ | |||
462 | 59 | public static final String labelFalseM = "falseM("; | 55 | public static final String labelFalseM = "falseM("; |
463 | 60 | public static final String label0 = ")=0"; | 56 | public static final String label0 = ")=0"; |
464 | 61 | public static final String label1 = ")=1"; | 57 | public static final String label1 = ")=1"; |
465 | 62 | private static final double xScaling = 6; | ||
466 | 63 | private static final double yScaling = 6; | ||
467 | 64 | 58 | ||
477 | 65 | private Map<VisualLogic, LogicStg> logicMap = new HashMap<>(); | 59 | private Map<VisualLogic, LogicStg> logicMap; |
478 | 66 | private Map<VisualRegister, RegisterStg> registerMap = new HashMap<>(); | 60 | private Map<VisualRegister, RegisterStg> registerMap; |
479 | 67 | private Map<VisualCounterflowLogic, CounterflowLogicStg> counterflowLogicMap = new HashMap<>(); | 61 | private Map<VisualCounterflowLogic, CounterflowLogicStg> counterflowLogicMap; |
480 | 68 | private Map<VisualCounterflowRegister, CounterflowRegisterStg> counterflowRegisterMap = new HashMap<>(); | 62 | private Map<VisualCounterflowRegister, CounterflowRegisterStg> counterflowRegisterMap; |
481 | 69 | private Map<VisualControlRegister, BinaryRegisterStg> controlRegisterMap = new HashMap<>(); | 63 | private Map<VisualControlRegister, BinaryRegisterStg> controlRegisterMap; |
482 | 70 | private Map<VisualPushRegister, BinaryRegisterStg> pushRegisterMap = new HashMap<>(); | 64 | private Map<VisualPushRegister, BinaryRegisterStg> pushRegisterMap; |
483 | 71 | private Map<VisualPopRegister, BinaryRegisterStg> popRegisterMap = new HashMap<>(); | 65 | private Map<VisualPopRegister, BinaryRegisterStg> popRegisterMap; |
475 | 72 | private final VisualDfs dfs; | ||
476 | 73 | private final VisualSTG stg; | ||
484 | 74 | 66 | ||
485 | 75 | public StgGenerator(VisualDfs dfs) { | 67 | public StgGenerator(VisualDfs dfs) { |
489 | 76 | this.dfs = dfs; | 68 | super(dfs); |
487 | 77 | this.stg = new VisualSTG(new STG()); | ||
488 | 78 | convert(); | ||
490 | 79 | } | 69 | } |
491 | 80 | 70 | ||
493 | 81 | private void convert() { | 71 | private VisualDfs getDfsModel() { |
494 | 72 | return (VisualDfs)getSrcModel(); | ||
495 | 73 | } | ||
496 | 74 | |||
497 | 75 | @Override | ||
498 | 76 | public Point2D getScale() { | ||
499 | 77 | return new Point2D.Double(6.0, 6.0); | ||
500 | 78 | } | ||
501 | 79 | |||
502 | 80 | @Override | ||
503 | 81 | public void convert() { | ||
504 | 82 | try { | 82 | try { |
506 | 83 | for(VisualLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualLogic.class)) { | 83 | for(VisualLogic l : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualLogic.class)) { |
507 | 84 | LogicStg lstg = generateLogicStg(l); | 84 | LogicStg lstg = generateLogicStg(l); |
509 | 85 | logicMap.put(l, lstg); | 85 | groupComponentStg(lstg); |
510 | 86 | putLogicStg(l, lstg); | ||
511 | 86 | } | 87 | } |
513 | 87 | for(VisualRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualRegister.class)) { | 88 | for(VisualRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualRegister.class)) { |
514 | 88 | RegisterStg rstg = generateRegisterSTG(r); | 89 | RegisterStg rstg = generateRegisterSTG(r); |
516 | 89 | registerMap.put(r, rstg); | 90 | groupComponentStg(rstg); |
517 | 91 | putRegisterStg(r, rstg); | ||
518 | 90 | } | 92 | } |
519 | 91 | 93 | ||
521 | 92 | for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowLogic.class)) { | 94 | for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualCounterflowLogic.class)) { |
522 | 93 | CounterflowLogicStg lstg = generateCounterflowLogicStg(l); | 95 | CounterflowLogicStg lstg = generateCounterflowLogicStg(l); |
524 | 94 | counterflowLogicMap.put(l, lstg); | 96 | groupComponentStg(lstg); |
525 | 97 | putCounterflowLogicStg(l, lstg); | ||
526 | 95 | } | 98 | } |
528 | 96 | for(VisualCounterflowRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowRegister.class)) { | 99 | for(VisualCounterflowRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualCounterflowRegister.class)) { |
529 | 97 | CounterflowRegisterStg rstg = generateCounterflowRegisterSTG(r); | 100 | CounterflowRegisterStg rstg = generateCounterflowRegisterSTG(r); |
531 | 98 | counterflowRegisterMap.put(r, rstg); | 101 | groupComponentStg(rstg); |
532 | 102 | putCounterflowRegisterStg(r, rstg); | ||
533 | 99 | } | 103 | } |
534 | 100 | 104 | ||
536 | 101 | for(VisualControlRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualControlRegister.class)) { | 105 | for(VisualControlRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualControlRegister.class)) { |
537 | 102 | BinaryRegisterStg rstg = generateControlRegisterStg(r); | 106 | BinaryRegisterStg rstg = generateControlRegisterStg(r); |
539 | 103 | controlRegisterMap.put(r, rstg); | 107 | groupComponentStg(rstg); |
540 | 108 | putControlRegisterStg(r, rstg); | ||
541 | 104 | } | 109 | } |
543 | 105 | for(VisualPushRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualPushRegister.class)) { | 110 | for(VisualPushRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualPushRegister.class)) { |
544 | 106 | BinaryRegisterStg rstg = generatePushRegisterStg(r); | 111 | BinaryRegisterStg rstg = generatePushRegisterStg(r); |
546 | 107 | pushRegisterMap.put(r, rstg); | 112 | groupComponentStg(rstg); |
547 | 113 | putPushRegisterStg(r, rstg); | ||
548 | 108 | } | 114 | } |
550 | 109 | for(VisualPopRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualPopRegister.class)) { | 115 | for(VisualPopRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualPopRegister.class)) { |
551 | 110 | BinaryRegisterStg rstg = generatePopRegisterStg(r); | 116 | BinaryRegisterStg rstg = generatePopRegisterStg(r); |
553 | 111 | popRegisterMap.put(r, rstg); | 117 | groupComponentStg(rstg); |
554 | 118 | putPopRegisterStg(r, rstg); | ||
555 | 112 | } | 119 | } |
556 | 113 | 120 | ||
558 | 114 | for(VisualLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualLogic.class)) { | 121 | for(VisualLogic l : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualLogic.class)) { |
559 | 115 | connectLogicStg(l); | 122 | connectLogicStg(l); |
560 | 116 | } | 123 | } |
562 | 117 | for(VisualRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualRegister.class)) { | 124 | for(VisualRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualRegister.class)) { |
563 | 118 | connectRegisterStg(r); | 125 | connectRegisterStg(r); |
564 | 119 | } | 126 | } |
565 | 120 | 127 | ||
567 | 121 | for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowLogic.class)) { | 128 | for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualCounterflowLogic.class)) { |
568 | 122 | connectCounterflowLogicStg(l); | 129 | connectCounterflowLogicStg(l); |
569 | 123 | } | 130 | } |
571 | 124 | for(VisualCounterflowRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowRegister.class)) { | 131 | for(VisualCounterflowRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualCounterflowRegister.class)) { |
572 | 125 | connectCounterflowRegisterStg(r); | 132 | connectCounterflowRegisterStg(r); |
573 | 126 | } | 133 | } |
574 | 127 | 134 | ||
576 | 128 | for(VisualControlRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualControlRegister.class)) { | 135 | for(VisualControlRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualControlRegister.class)) { |
577 | 129 | connectControlRegisterStg(r); | 136 | connectControlRegisterStg(r); |
578 | 130 | } | 137 | } |
580 | 131 | for(VisualPushRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualPushRegister.class)) { | 138 | for(VisualPushRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualPushRegister.class)) { |
581 | 132 | connectPushRegisterStg(r); | 139 | connectPushRegisterStg(r); |
582 | 133 | } | 140 | } |
584 | 134 | for(VisualPopRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualPopRegister.class)) { | 141 | for(VisualPopRegister r : Hierarchy.getDescendantsOfType(getDfsModel().getRoot(), VisualPopRegister.class)) { |
585 | 135 | connectPopRegisterStg(r); | 142 | connectPopRegisterStg(r); |
586 | 136 | } | 143 | } |
587 | 137 | } catch (InvalidConnectionException e) { | 144 | } catch (InvalidConnectionException e) { |
588 | 138 | throw new RuntimeException(e); | 145 | throw new RuntimeException(e); |
589 | 139 | } | 146 | } |
590 | 140 | } | 147 | } |
592 | 141 | 148 | ||
593 | 142 | static Color[] tokenColors = DfsSettings.getTokenPalette().getColors(); | 149 | static Color[] tokenColors = DfsSettings.getTokenPalette().getColors(); |
594 | 143 | private ColorGenerator createColorGenerator(boolean required) { | 150 | private ColorGenerator createColorGenerator(boolean required) { |
595 | 144 | ColorGenerator result = null; | 151 | ColorGenerator result = null; |
596 | @@ -150,55 +157,21 @@ | |||
597 | 150 | } | 157 | } |
598 | 151 | return result; | 158 | return result; |
599 | 152 | } | 159 | } |
636 | 153 | 160 | ||
637 | 154 | public VisualSTG getStg() { | 161 | |
602 | 155 | return stg; | ||
603 | 156 | } | ||
604 | 157 | |||
605 | 158 | static void setPosition(Movable node, double x, double y) { | ||
606 | 159 | TransformHelper.applyTransform(node, AffineTransform.getTranslateInstance(x, y)); | ||
607 | 160 | } | ||
608 | 161 | |||
609 | 162 | private void createConsumingArc(VisualPlace p, VisualSignalTransition t, boolean propagateTokenColor) throws InvalidConnectionException { | ||
610 | 163 | if (p != null && t != null) { | ||
611 | 164 | VisualConnection connection = stg.connect(p, t); | ||
612 | 165 | connection.setTokenColorPropagator(propagateTokenColor); | ||
613 | 166 | } | ||
614 | 167 | } | ||
615 | 168 | |||
616 | 169 | private void createProducingArc(VisualSignalTransition t, VisualPlace p, boolean propagateTokenColor) throws InvalidConnectionException { | ||
617 | 170 | if (p != null && t != null) { | ||
618 | 171 | VisualConnection connection = stg.connect(t, p); | ||
619 | 172 | connection.setTokenColorPropagator(propagateTokenColor); | ||
620 | 173 | } | ||
621 | 174 | } | ||
622 | 175 | |||
623 | 176 | private void createReadArc(VisualPlace p, VisualSignalTransition t, boolean propagateTokenColor) throws InvalidConnectionException { | ||
624 | 177 | if (p != null && t != null) { | ||
625 | 178 | VisualConnection connection = stg.connectUndirected(p, t); | ||
626 | 179 | connection.setTokenColorPropagator(propagateTokenColor); | ||
627 | 180 | } | ||
628 | 181 | } | ||
629 | 182 | |||
630 | 183 | private void createReadArcs(VisualPlace p, Collection<VisualSignalTransition> ts, boolean propagateTokenColor) throws InvalidConnectionException { | ||
631 | 184 | for (VisualSignalTransition t : new HashSet<VisualSignalTransition>(ts)) { | ||
632 | 185 | createReadArc(p, t, propagateTokenColor); | ||
633 | 186 | } | ||
634 | 187 | } | ||
635 | 188 | |||
638 | 189 | private LogicStg generateLogicStg(VisualLogic l) throws InvalidConnectionException { | 162 | private LogicStg generateLogicStg(VisualLogic l) throws InvalidConnectionException { |
643 | 190 | String name = dfs.getName(l); | 163 | String name = getDfsModel().getName(l); |
644 | 191 | AffineTransform transform = TransformHelper.getTransformToRoot(l); | 164 | Point2D pos = getComponentPosition(l); |
645 | 192 | double x = xScaling * (transform.getTranslateX() + l.getX()); | 165 | double x = pos.getX(); |
646 | 193 | double y = yScaling * (transform.getTranslateY() + l.getY()); | 166 | double y = pos.getY(); |
647 | 194 | Collection<Node> nodes = new LinkedList<Node>(); | 167 | Collection<Node> nodes = new LinkedList<Node>(); |
648 | 195 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; | 168 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; |
650 | 196 | ColorGenerator tokenColorGenerator = createColorGenerator(dfs.getPreset(l).size() == 0); | 169 | ColorGenerator tokenColorGenerator = createColorGenerator(getDfsModel().getPreset(l).size() == 0); |
651 | 197 | 170 | ||
652 | 198 | 171 | ||
653 | 199 | Container curContainer = null; | 172 | Container curContainer = null; |
654 | 200 | 173 | ||
656 | 201 | VisualPlace C0 = stg.createPlace(nameC + name + name0, curContainer); | 174 | VisualPlace C0 = getStgModel().createPlace(nameC + name + name0, curContainer); |
657 | 202 | C0.setLabel(labelC + name + label0); | 175 | C0.setLabel(labelC + name + label0); |
658 | 203 | C0.setLabelPositioning(Positioning.BOTTOM); | 176 | C0.setLabelPositioning(Positioning.BOTTOM); |
659 | 204 | if (!l.getReferencedLogic().isComputed()) { | 177 | if (!l.getReferencedLogic().isComputed()) { |
660 | @@ -209,7 +182,7 @@ | |||
661 | 209 | setPosition(C0, x + 2.0, y + 1.0); | 182 | setPosition(C0, x + 2.0, y + 1.0); |
662 | 210 | nodes.add(C0); | 183 | nodes.add(C0); |
663 | 211 | 184 | ||
665 | 212 | VisualPlace C1 = stg.createPlace(nameC + name + name1, curContainer); | 185 | VisualPlace C1 = getStgModel().createPlace(nameC + name + name1, curContainer); |
666 | 213 | C1.setLabel(labelC + name + label1); | 186 | C1.setLabel(labelC + name + label1); |
667 | 214 | C1.setLabelPositioning(Positioning.TOP); | 187 | C1.setLabelPositioning(Positioning.TOP); |
668 | 215 | if (l.getReferencedLogic().isComputed()) { | 188 | if (l.getReferencedLogic().isComputed()) { |
669 | @@ -221,11 +194,11 @@ | |||
670 | 221 | nodes.add(C1); | 194 | nodes.add(C1); |
671 | 222 | 195 | ||
672 | 223 | Set<Node> preset = new HashSet<Node>(); | 196 | Set<Node> preset = new HashSet<Node>(); |
678 | 224 | preset.addAll(dfs.getPreset(l, VisualLogic.class)); | 197 | preset.addAll(getDfsModel().getPreset(l, VisualLogic.class)); |
679 | 225 | preset.addAll(dfs.getPreset(l, VisualRegister.class)); | 198 | preset.addAll(getDfsModel().getPreset(l, VisualRegister.class)); |
680 | 226 | preset.addAll(dfs.getPreset(l, VisualControlRegister.class)); | 199 | preset.addAll(getDfsModel().getPreset(l, VisualControlRegister.class)); |
681 | 227 | preset.addAll(dfs.getPreset(l, VisualPushRegister.class)); | 200 | preset.addAll(getDfsModel().getPreset(l, VisualPushRegister.class)); |
682 | 228 | preset.addAll(dfs.getPreset(l, VisualPopRegister.class)); | 201 | preset.addAll(getDfsModel().getPreset(l, VisualPopRegister.class)); |
683 | 229 | if (preset.size() == 0) { | 202 | if (preset.size() == 0) { |
684 | 230 | preset.add(l); | 203 | preset.add(l); |
685 | 231 | } | 204 | } |
686 | @@ -236,7 +209,7 @@ | |||
687 | 236 | double dy = 0.0; | 209 | double dy = 0.0; |
688 | 237 | for (Node n: preset) { | 210 | for (Node n: preset) { |
689 | 238 | if (CR == null || l.getReferencedLogic().isEarlyEvaluation()) { | 211 | if (CR == null || l.getReferencedLogic().isEarlyEvaluation()) { |
691 | 239 | CR = stg.createSignalTransition(nameC + name, type, SignalTransition.Direction.PLUS, curContainer); | 212 | CR = getStgModel().createSignalTransition(nameC + name, type, SignalTransition.Direction.PLUS, curContainer); |
692 | 240 | CR.setTokenColorGenerator(tokenColorGenerator); | 213 | CR.setTokenColorGenerator(tokenColorGenerator); |
693 | 241 | createConsumingArc(C0, CR, false); | 214 | createConsumingArc(C0, CR, false); |
694 | 242 | createProducingArc(CR, C1, true); | 215 | createProducingArc(CR, C1, true); |
695 | @@ -245,7 +218,7 @@ | |||
696 | 245 | } | 218 | } |
697 | 246 | CRs.put(n, CR); | 219 | CRs.put(n, CR); |
698 | 247 | if (CF == null) { | 220 | if (CF == null) { |
700 | 248 | CF = stg.createSignalTransition(nameC + name, type, SignalTransition.Direction.MINUS, curContainer); | 221 | CF = getStgModel().createSignalTransition(nameC + name, type, SignalTransition.Direction.MINUS, curContainer); |
701 | 249 | createConsumingArc(C1, CF, false); | 222 | createConsumingArc(C1, CF, false); |
702 | 250 | createProducingArc(CF, C0, false); | 223 | createProducingArc(CF, C0, false); |
703 | 251 | setPosition(CF, x - 2.0, y - 1.0 - dy); | 224 | setPosition(CF, x - 2.0, y - 1.0 - dy); |
704 | @@ -255,34 +228,32 @@ | |||
705 | 255 | dy += 1.0; | 228 | dy += 1.0; |
706 | 256 | } | 229 | } |
707 | 257 | 230 | ||
708 | 258 | stg.select(nodes); | ||
709 | 259 | stg.groupSelection(); | ||
710 | 260 | return new LogicStg(C0, C1, CRs, CFs); | 231 | return new LogicStg(C0, C1, CRs, CFs); |
711 | 261 | } | 232 | } |
712 | 262 | 233 | ||
713 | 263 | private void connectLogicStg(VisualLogic l) throws InvalidConnectionException { | 234 | private void connectLogicStg(VisualLogic l) throws InvalidConnectionException { |
714 | 264 | LogicStg lstg = getLogicStg(l); | 235 | LogicStg lstg = getLogicStg(l); |
716 | 265 | for (VisualLogic n: dfs.getPreset(l, VisualLogic.class)) { | 236 | for (VisualLogic n: getDfsModel().getPreset(l, VisualLogic.class)) { |
717 | 266 | LogicStg nstg = getLogicStg(n); | 237 | LogicStg nstg = getLogicStg(n); |
718 | 267 | createReadArc(nstg.C1, lstg.CRs.get(n), true); | 238 | createReadArc(nstg.C1, lstg.CRs.get(n), true); |
719 | 268 | createReadArc(nstg.C0, lstg.CFs.get(n), false); | 239 | createReadArc(nstg.C0, lstg.CFs.get(n), false); |
720 | 269 | } | 240 | } |
722 | 270 | for (VisualRegister n: dfs.getPreset(l, VisualRegister.class)) { | 241 | for (VisualRegister n: getDfsModel().getPreset(l, VisualRegister.class)) { |
723 | 271 | RegisterStg nstg = getRegisterStg(n); | 242 | RegisterStg nstg = getRegisterStg(n); |
724 | 272 | createReadArc(nstg.M1, lstg.CRs.get(n), true); | 243 | createReadArc(nstg.M1, lstg.CRs.get(n), true); |
725 | 273 | createReadArc(nstg.M0, lstg.CFs.get(n), false); | 244 | createReadArc(nstg.M0, lstg.CFs.get(n), false); |
726 | 274 | } | 245 | } |
728 | 275 | for (VisualControlRegister n: dfs.getPreset(l, VisualControlRegister.class)) { | 246 | for (VisualControlRegister n: getDfsModel().getPreset(l, VisualControlRegister.class)) { |
729 | 276 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 247 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
730 | 277 | createReadArc(nstg.M1, lstg.CRs.get(n), true); | 248 | createReadArc(nstg.M1, lstg.CRs.get(n), true); |
731 | 278 | createReadArc(nstg.M0, lstg.CFs.get(n), false); | 249 | createReadArc(nstg.M0, lstg.CFs.get(n), false); |
732 | 279 | } | 250 | } |
734 | 280 | for (VisualPushRegister n: dfs.getPreset(l, VisualPushRegister.class)) { | 251 | for (VisualPushRegister n: getDfsModel().getPreset(l, VisualPushRegister.class)) { |
735 | 281 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 252 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
736 | 282 | createReadArc(nstg.tM1, lstg.CRs.get(n), true); | 253 | createReadArc(nstg.tM1, lstg.CRs.get(n), true); |
737 | 283 | createReadArc(nstg.tM0, lstg.CFs.get(n), false); | 254 | createReadArc(nstg.tM0, lstg.CFs.get(n), false); |
738 | 284 | } | 255 | } |
740 | 285 | for (VisualPopRegister n: dfs.getPreset(l, VisualPopRegister.class)) { | 256 | for (VisualPopRegister n: getDfsModel().getPreset(l, VisualPopRegister.class)) { |
741 | 286 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 257 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
742 | 287 | createReadArc(nstg.M1, lstg.CRs.get(n), true); | 258 | createReadArc(nstg.M1, lstg.CRs.get(n), true); |
743 | 288 | createReadArc(nstg.M0, lstg.CFs.get(n), false); | 259 | createReadArc(nstg.M0, lstg.CFs.get(n), false); |
744 | @@ -290,25 +261,33 @@ | |||
745 | 290 | } | 261 | } |
746 | 291 | 262 | ||
747 | 292 | public LogicStg getLogicStg(VisualLogic logic) { | 263 | public LogicStg getLogicStg(VisualLogic logic) { |
751 | 293 | return logicMap.get(logic); | 264 | return ((logicMap == null) ? null : logicMap.get(logic)); |
752 | 294 | } | 265 | } |
753 | 295 | 266 | ||
754 | 267 | public void putLogicStg(VisualLogic logic, LogicStg stg) { | ||
755 | 268 | if (logicMap == null) { | ||
756 | 269 | logicMap = new HashMap<>(); | ||
757 | 270 | } | ||
758 | 271 | logicMap.put(logic, stg); | ||
759 | 272 | } | ||
760 | 273 | |||
761 | 274 | |||
762 | 296 | private RegisterStg generateRegisterSTG(VisualRegister r) throws InvalidConnectionException { | 275 | private RegisterStg generateRegisterSTG(VisualRegister r) throws InvalidConnectionException { |
767 | 297 | String name = dfs.getName(r); | 276 | String name = getDfsModel().getName(r); |
768 | 298 | AffineTransform transform = TransformHelper.getTransformToRoot(r); | 277 | Point2D pos = getComponentPosition(r); |
769 | 299 | double x = xScaling * (transform.getTranslateX() + r.getX()); | 278 | double x = pos.getX(); |
770 | 300 | double y = yScaling * (transform.getTranslateY() + r.getY()); | 279 | double y = pos.getY(); |
771 | 301 | Collection<Node> nodes = new LinkedList<Node>(); | 280 | Collection<Node> nodes = new LinkedList<Node>(); |
772 | 302 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; | 281 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; |
774 | 303 | if (dfs.getPreset(r).size() == 0) { | 282 | if (getDfsModel().getPreset(r).size() == 0) { |
775 | 304 | type = SignalTransition.Type.INPUT; | 283 | type = SignalTransition.Type.INPUT; |
777 | 305 | } else if (dfs.getPostset(r).size() == 0) { | 284 | } else if (getDfsModel().getPostset(r).size() == 0) { |
778 | 306 | type = SignalTransition.Type.OUTPUT; | 285 | type = SignalTransition.Type.OUTPUT; |
779 | 307 | } | 286 | } |
781 | 308 | ColorGenerator tokenColorGenerator = createColorGenerator(dfs.getPreset(r).size() == 0); | 287 | ColorGenerator tokenColorGenerator = createColorGenerator(getDfsModel().getPreset(r).size() == 0); |
782 | 309 | Container curContainer = null; | 288 | Container curContainer = null; |
783 | 310 | 289 | ||
785 | 311 | VisualPlace M0 = stg.createPlace(nameM + name + name0, curContainer); | 290 | VisualPlace M0 = getStgModel().createPlace(nameM + name + name0, curContainer); |
786 | 312 | M0.setLabel(labelM + name + label0); | 291 | M0.setLabel(labelM + name + label0); |
787 | 313 | M0.setLabelPositioning(Positioning.BOTTOM); | 292 | M0.setLabelPositioning(Positioning.BOTTOM); |
788 | 314 | if (!r.getReferencedRegister().isMarked()) { | 293 | if (!r.getReferencedRegister().isMarked()) { |
789 | @@ -319,7 +298,7 @@ | |||
790 | 319 | setPosition(M0, x + 2.0, y + 1.0); | 298 | setPosition(M0, x + 2.0, y + 1.0); |
791 | 320 | nodes.add(M0); | 299 | nodes.add(M0); |
792 | 321 | 300 | ||
794 | 322 | VisualPlace M1 = stg.createPlace(nameM + name + name1, curContainer); | 301 | VisualPlace M1 = getStgModel().createPlace(nameM + name + name1, curContainer); |
795 | 323 | M1.setLabel(labelM + name + label1); | 302 | M1.setLabel(labelM + name + label1); |
796 | 324 | M1.setLabelPositioning(Positioning.TOP); | 303 | M1.setLabelPositioning(Positioning.TOP); |
797 | 325 | if (r.getReferencedRegister().isMarked()) { | 304 | if (r.getReferencedRegister().isMarked()) { |
798 | @@ -329,82 +308,80 @@ | |||
799 | 329 | setPosition(M1, x + 2.0, y - 1.0); | 308 | setPosition(M1, x + 2.0, y - 1.0); |
800 | 330 | nodes.add(M1); | 309 | nodes.add(M1); |
801 | 331 | 310 | ||
803 | 332 | VisualSignalTransition MR = stg.createSignalTransition(nameM + name, type, SignalTransition.Direction.PLUS, curContainer); | 311 | VisualSignalTransition MR = getStgModel().createSignalTransition(nameM + name, type, SignalTransition.Direction.PLUS, curContainer); |
804 | 333 | MR.setTokenColorGenerator(tokenColorGenerator); | 312 | MR.setTokenColorGenerator(tokenColorGenerator); |
805 | 334 | createConsumingArc(M0, MR, false); | 313 | createConsumingArc(M0, MR, false); |
806 | 335 | createProducingArc(MR, M1, true); | 314 | createProducingArc(MR, M1, true); |
807 | 336 | setPosition(MR, x - 2.0, y + 1.0); | 315 | setPosition(MR, x - 2.0, y + 1.0); |
808 | 337 | nodes.add(MR); | 316 | nodes.add(MR); |
809 | 338 | 317 | ||
811 | 339 | VisualSignalTransition MF = stg.createSignalTransition(nameM + name, type, SignalTransition.Direction.MINUS, curContainer); | 318 | VisualSignalTransition MF = getStgModel().createSignalTransition(nameM + name, type, SignalTransition.Direction.MINUS, curContainer); |
812 | 340 | createConsumingArc(M1, MF, false); | 319 | createConsumingArc(M1, MF, false); |
813 | 341 | createProducingArc(MF, M0, false); | 320 | createProducingArc(MF, M0, false); |
814 | 342 | setPosition(MF, x - 2.0, y - 1.0); | 321 | setPosition(MF, x - 2.0, y - 1.0); |
815 | 343 | nodes.add(MF); | 322 | nodes.add(MF); |
816 | 344 | 323 | ||
817 | 345 | stg.select(nodes); | ||
818 | 346 | stg.groupSelection(); | ||
819 | 347 | return new RegisterStg(M0, M1, MR, MF); | 324 | return new RegisterStg(M0, M1, MR, MF); |
820 | 348 | } | 325 | } |
821 | 349 | 326 | ||
822 | 350 | private void connectRegisterStg(VisualRegister r) throws InvalidConnectionException { | 327 | private void connectRegisterStg(VisualRegister r) throws InvalidConnectionException { |
823 | 351 | RegisterStg rstg = getRegisterStg(r); | 328 | RegisterStg rstg = getRegisterStg(r); |
824 | 352 | // preset | 329 | // preset |
826 | 353 | for (VisualLogic n: dfs.getPreset(r, VisualLogic.class)) { | 330 | for (VisualLogic n: getDfsModel().getPreset(r, VisualLogic.class)) { |
827 | 354 | LogicStg nstg = getLogicStg(n); | 331 | LogicStg nstg = getLogicStg(n); |
828 | 355 | createReadArc(nstg.C1, rstg.MR, true); | 332 | createReadArc(nstg.C1, rstg.MR, true); |
829 | 356 | createReadArc(nstg.C0, rstg.MF, false); | 333 | createReadArc(nstg.C0, rstg.MF, false); |
830 | 357 | } | 334 | } |
831 | 358 | // R-preset | 335 | // R-preset |
833 | 359 | for (VisualRegister n: dfs.getRPreset(r, VisualRegister.class)) { | 336 | for (VisualRegister n: getDfsModel().getRPreset(r, VisualRegister.class)) { |
834 | 360 | RegisterStg nstg = getRegisterStg(n); | 337 | RegisterStg nstg = getRegisterStg(n); |
835 | 361 | createReadArc(nstg.M1, rstg.MR, true); | 338 | createReadArc(nstg.M1, rstg.MR, true); |
836 | 362 | createReadArc(nstg.M0, rstg.MF, false); | 339 | createReadArc(nstg.M0, rstg.MF, false); |
837 | 363 | } | 340 | } |
839 | 364 | for (VisualCounterflowRegister n: dfs.getRPreset(r, VisualCounterflowRegister.class)) { | 341 | for (VisualCounterflowRegister n: getDfsModel().getRPreset(r, VisualCounterflowRegister.class)) { |
840 | 365 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 342 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
841 | 366 | createReadArc(nstg.orM1, rstg.MR, true); | 343 | createReadArc(nstg.orM1, rstg.MR, true); |
842 | 367 | createReadArc(nstg.orM0, rstg.MF, false); | 344 | createReadArc(nstg.orM0, rstg.MF, false); |
843 | 368 | createReadArc(nstg.andM1, rstg.MF, false); | 345 | createReadArc(nstg.andM1, rstg.MF, false); |
844 | 369 | createReadArc(nstg.andM0, rstg.MR, false); | 346 | createReadArc(nstg.andM0, rstg.MR, false); |
845 | 370 | } | 347 | } |
847 | 371 | for (VisualControlRegister n: dfs.getRPreset(r, VisualControlRegister.class)) { | 348 | for (VisualControlRegister n: getDfsModel().getRPreset(r, VisualControlRegister.class)) { |
848 | 372 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 349 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
849 | 373 | createReadArc(nstg.M1, rstg.MR, true); | 350 | createReadArc(nstg.M1, rstg.MR, true); |
850 | 374 | createReadArc(nstg.M0, rstg.MF, false); | 351 | createReadArc(nstg.M0, rstg.MF, false); |
851 | 375 | } | 352 | } |
853 | 376 | for (VisualPushRegister n: dfs.getRPreset(r, VisualPushRegister.class)) { | 353 | for (VisualPushRegister n: getDfsModel().getRPreset(r, VisualPushRegister.class)) { |
854 | 377 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 354 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
855 | 378 | createReadArc(nstg.tM1, rstg.MR, true); | 355 | createReadArc(nstg.tM1, rstg.MR, true); |
856 | 379 | createReadArc(nstg.tM0, rstg.MF, false); | 356 | createReadArc(nstg.tM0, rstg.MF, false); |
857 | 380 | } | 357 | } |
859 | 381 | for (VisualPopRegister n: dfs.getRPreset(r, VisualPopRegister.class)) { | 358 | for (VisualPopRegister n: getDfsModel().getRPreset(r, VisualPopRegister.class)) { |
860 | 382 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 359 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
861 | 383 | createReadArc(nstg.M1, rstg.MR, true); | 360 | createReadArc(nstg.M1, rstg.MR, true); |
862 | 384 | createReadArc(nstg.M0, rstg.MF, false); | 361 | createReadArc(nstg.M0, rstg.MF, false); |
863 | 385 | } | 362 | } |
864 | 386 | // R-postset | 363 | // R-postset |
866 | 387 | for (VisualRegister n: dfs.getRPostset(r, VisualRegister.class)) { | 364 | for (VisualRegister n: getDfsModel().getRPostset(r, VisualRegister.class)) { |
867 | 388 | RegisterStg nstg = getRegisterStg(n); | 365 | RegisterStg nstg = getRegisterStg(n); |
868 | 389 | createReadArc(nstg.M1, rstg.MF, false); | 366 | createReadArc(nstg.M1, rstg.MF, false); |
869 | 390 | createReadArc(nstg.M0, rstg.MR, false); | 367 | createReadArc(nstg.M0, rstg.MR, false); |
870 | 391 | } | 368 | } |
872 | 392 | for (VisualCounterflowRegister n: dfs.getRPostset(r, VisualCounterflowRegister.class)) { | 369 | for (VisualCounterflowRegister n: getDfsModel().getRPostset(r, VisualCounterflowRegister.class)) { |
873 | 393 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 370 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
874 | 394 | createReadArc(nstg.andM1, rstg.MF, false); | 371 | createReadArc(nstg.andM1, rstg.MF, false); |
875 | 395 | createReadArc(nstg.andM0, rstg.MR, false); | 372 | createReadArc(nstg.andM0, rstg.MR, false); |
876 | 396 | } | 373 | } |
878 | 397 | for (VisualControlRegister n: dfs.getRPostset(r, VisualControlRegister.class)) { | 374 | for (VisualControlRegister n: getDfsModel().getRPostset(r, VisualControlRegister.class)) { |
879 | 398 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 375 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
880 | 399 | createReadArc(nstg.M1, rstg.MF, false); | 376 | createReadArc(nstg.M1, rstg.MF, false); |
881 | 400 | createReadArc(nstg.M0, rstg.MR, false); | 377 | createReadArc(nstg.M0, rstg.MR, false); |
882 | 401 | } | 378 | } |
884 | 402 | for (VisualPushRegister n: dfs.getRPostset(r, VisualPushRegister.class)) { | 379 | for (VisualPushRegister n: getDfsModel().getRPostset(r, VisualPushRegister.class)) { |
885 | 403 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 380 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
886 | 404 | createReadArc(nstg.M1, rstg.MF, false); | 381 | createReadArc(nstg.M1, rstg.MF, false); |
887 | 405 | createReadArc(nstg.M0, rstg.MR, false); | 382 | createReadArc(nstg.M0, rstg.MR, false); |
888 | 406 | } | 383 | } |
890 | 407 | for (VisualPopRegister n: dfs.getRPostset(r, VisualPopRegister.class)) { | 384 | for (VisualPopRegister n: getDfsModel().getRPostset(r, VisualPopRegister.class)) { |
891 | 408 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 385 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
892 | 409 | createReadArc(nstg.tM1, rstg.MF, false); | 386 | createReadArc(nstg.tM1, rstg.MF, false); |
893 | 410 | createReadArc(nstg.tM0, rstg.MR, false); | 387 | createReadArc(nstg.tM0, rstg.MR, false); |
894 | @@ -412,22 +389,30 @@ | |||
895 | 412 | } | 389 | } |
896 | 413 | 390 | ||
897 | 414 | public RegisterStg getRegisterStg(VisualRegister register) { | 391 | public RegisterStg getRegisterStg(VisualRegister register) { |
901 | 415 | return registerMap.get(register); | 392 | return ((registerMap == null) ? null : registerMap.get(register)); |
902 | 416 | } | 393 | } |
903 | 417 | 394 | ||
904 | 395 | public void putRegisterStg(VisualRegister register, RegisterStg stg) { | ||
905 | 396 | if (registerMap == null) { | ||
906 | 397 | registerMap = new HashMap<>(); | ||
907 | 398 | } | ||
908 | 399 | registerMap.put(register, stg); | ||
909 | 400 | } | ||
910 | 401 | |||
911 | 402 | |||
912 | 418 | private CounterflowLogicStg generateCounterflowLogicStg(VisualCounterflowLogic l) throws InvalidConnectionException { | 403 | private CounterflowLogicStg generateCounterflowLogicStg(VisualCounterflowLogic l) throws InvalidConnectionException { |
917 | 419 | String name = dfs.getName(l); | 404 | String name = getDfsModel().getName(l); |
918 | 420 | AffineTransform transform = TransformHelper.getTransformToRoot(l); | 405 | Point2D pos = getComponentPosition(l); |
919 | 421 | double x = xScaling * (transform.getTranslateX() + l.getX()); | 406 | double x = pos.getX(); |
920 | 422 | double y = yScaling * (transform.getTranslateY() + l.getY()); | 407 | double y = pos.getY(); |
921 | 423 | Collection<Node> nodes = new LinkedList<Node>(); | 408 | Collection<Node> nodes = new LinkedList<Node>(); |
922 | 424 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; | 409 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; |
925 | 425 | ColorGenerator presetTokenColorGenerator = createColorGenerator(dfs.getPreset(l).size() == 0); | 410 | ColorGenerator presetTokenColorGenerator = createColorGenerator(getDfsModel().getPreset(l).size() == 0); |
926 | 426 | ColorGenerator postsetTokenColorGenerator = createColorGenerator(dfs.getPostset(l).size() == 0); | 411 | ColorGenerator postsetTokenColorGenerator = createColorGenerator(getDfsModel().getPostset(l).size() == 0); |
927 | 427 | 412 | ||
928 | 428 | Container curContainer = null; | 413 | Container curContainer = null; |
929 | 429 | 414 | ||
931 | 430 | VisualPlace fwC0 = stg.createPlace(nameFwC + name + name0, curContainer); | 415 | VisualPlace fwC0 = getStgModel().createPlace(nameFwC + name + name0, curContainer); |
932 | 431 | fwC0.setLabel(labelFwC + name + label0); | 416 | fwC0.setLabel(labelFwC + name + label0); |
933 | 432 | fwC0.setLabelPositioning(Positioning.BOTTOM); | 417 | fwC0.setLabelPositioning(Positioning.BOTTOM); |
934 | 433 | if (!l.getReferencedCounterflowLogic().isForwardComputed()) { | 418 | if (!l.getReferencedCounterflowLogic().isForwardComputed()) { |
935 | @@ -438,7 +423,7 @@ | |||
936 | 438 | setPosition(fwC0, x + 2.0, y - 2.0); | 423 | setPosition(fwC0, x + 2.0, y - 2.0); |
937 | 439 | nodes.add(fwC0); | 424 | nodes.add(fwC0); |
938 | 440 | 425 | ||
940 | 441 | VisualPlace fwC1 = stg.createPlace(nameFwC + name + name1, curContainer); | 426 | VisualPlace fwC1 = getStgModel().createPlace(nameFwC + name + name1, curContainer); |
941 | 442 | fwC1.setLabel(labelFwC + name + label1); | 427 | fwC1.setLabel(labelFwC + name + label1); |
942 | 443 | fwC1.setLabelPositioning(Positioning.TOP); | 428 | fwC1.setLabelPositioning(Positioning.TOP); |
943 | 444 | if (l.getReferencedCounterflowLogic().isForwardComputed()) { | 429 | if (l.getReferencedCounterflowLogic().isForwardComputed()) { |
944 | @@ -450,8 +435,8 @@ | |||
945 | 450 | nodes.add(fwC1); | 435 | nodes.add(fwC1); |
946 | 451 | 436 | ||
947 | 452 | Set<Node> preset = new HashSet<Node>(); | 437 | Set<Node> preset = new HashSet<Node>(); |
950 | 453 | preset.addAll(dfs.getPreset(l, VisualCounterflowLogic.class)); | 438 | preset.addAll(getDfsModel().getPreset(l, VisualCounterflowLogic.class)); |
951 | 454 | preset.addAll(dfs.getPreset(l, VisualCounterflowRegister.class)); | 439 | preset.addAll(getDfsModel().getPreset(l, VisualCounterflowRegister.class)); |
952 | 455 | if (preset.size() == 0) { | 440 | if (preset.size() == 0) { |
953 | 456 | preset.add(l); | 441 | preset.add(l); |
954 | 457 | } | 442 | } |
955 | @@ -463,7 +448,7 @@ | |||
956 | 463 | double dy = 0.0; | 448 | double dy = 0.0; |
957 | 464 | for (Node n: preset) { | 449 | for (Node n: preset) { |
958 | 465 | if (fwCR == null || l.getReferencedCounterflowLogic().isForwardEarlyEvaluation()) { | 450 | if (fwCR == null || l.getReferencedCounterflowLogic().isForwardEarlyEvaluation()) { |
960 | 466 | fwCR = stg.createSignalTransition(nameFwC + name, type, SignalTransition.Direction.PLUS, curContainer); | 451 | fwCR = getStgModel().createSignalTransition(nameFwC + name, type, SignalTransition.Direction.PLUS, curContainer); |
961 | 467 | fwCR.setTokenColorGenerator(presetTokenColorGenerator); | 452 | fwCR.setTokenColorGenerator(presetTokenColorGenerator); |
962 | 468 | createConsumingArc(fwC0, fwCR, false); | 453 | createConsumingArc(fwC0, fwCR, false); |
963 | 469 | createProducingArc(fwCR, fwC1, true); | 454 | createProducingArc(fwCR, fwC1, true); |
964 | @@ -472,7 +457,7 @@ | |||
965 | 472 | } | 457 | } |
966 | 473 | fwCRs.put(n, fwCR); | 458 | fwCRs.put(n, fwCR); |
967 | 474 | if (fwCF == null) { | 459 | if (fwCF == null) { |
969 | 475 | fwCF = stg.createSignalTransition(nameFwC + name, type, SignalTransition.Direction.MINUS, curContainer); | 460 | fwCF = getStgModel().createSignalTransition(nameFwC + name, type, SignalTransition.Direction.MINUS, curContainer); |
970 | 476 | createConsumingArc(fwC1, fwCF, false); | 461 | createConsumingArc(fwC1, fwCF, false); |
971 | 477 | createProducingArc(fwCF, fwC0, false); | 462 | createProducingArc(fwCF, fwC0, false); |
972 | 478 | setPosition(fwCF, x - 2.0, y - 4.0 - dy); | 463 | setPosition(fwCF, x - 2.0, y - 4.0 - dy); |
973 | @@ -483,7 +468,7 @@ | |||
974 | 483 | } | 468 | } |
975 | 484 | } | 469 | } |
976 | 485 | 470 | ||
978 | 486 | VisualPlace bwC0 = stg.createPlace(nameBwC + name + name0, curContainer); | 471 | VisualPlace bwC0 = getStgModel().createPlace(nameBwC + name + name0, curContainer); |
979 | 487 | bwC0.setLabel(labelBwC + name + label0); | 472 | bwC0.setLabel(labelBwC + name + label0); |
980 | 488 | bwC0.setLabelPositioning(Positioning.BOTTOM); | 473 | bwC0.setLabelPositioning(Positioning.BOTTOM); |
981 | 489 | if (!l.getReferencedCounterflowLogic().isBackwardComputed()) { | 474 | if (!l.getReferencedCounterflowLogic().isBackwardComputed()) { |
982 | @@ -494,7 +479,7 @@ | |||
983 | 494 | setPosition(bwC0, x + 2.0, y + 4.0); | 479 | setPosition(bwC0, x + 2.0, y + 4.0); |
984 | 495 | nodes.add(bwC0); | 480 | nodes.add(bwC0); |
985 | 496 | 481 | ||
987 | 497 | VisualPlace bwC1 = stg.createPlace(nameBwC + name + name1, curContainer); | 482 | VisualPlace bwC1 = getStgModel().createPlace(nameBwC + name + name1, curContainer); |
988 | 498 | bwC1.setLabel(labelBwC + name + label1); | 483 | bwC1.setLabel(labelBwC + name + label1); |
989 | 499 | bwC1.setLabelPositioning(Positioning.TOP); | 484 | bwC1.setLabelPositioning(Positioning.TOP); |
990 | 500 | if (l.getReferencedCounterflowLogic().isBackwardComputed()) { | 485 | if (l.getReferencedCounterflowLogic().isBackwardComputed()) { |
991 | @@ -506,8 +491,8 @@ | |||
992 | 506 | nodes.add(bwC1); | 491 | nodes.add(bwC1); |
993 | 507 | 492 | ||
994 | 508 | Set<Node> postset = new HashSet<Node>(); | 493 | Set<Node> postset = new HashSet<Node>(); |
997 | 509 | postset.addAll(dfs.getPostset(l, VisualCounterflowLogic.class)); | 494 | postset.addAll(getDfsModel().getPostset(l, VisualCounterflowLogic.class)); |
998 | 510 | postset.addAll(dfs.getPostset(l, VisualCounterflowRegister.class)); | 495 | postset.addAll(getDfsModel().getPostset(l, VisualCounterflowRegister.class)); |
999 | 511 | if (postset.size() == 0) { | 496 | if (postset.size() == 0) { |
1000 | 512 | postset.add(l); | 497 | postset.add(l); |
1001 | 513 | } | 498 | } |
1002 | @@ -519,7 +504,7 @@ | |||
1003 | 519 | double dy = 0.0; | 504 | double dy = 0.0; |
1004 | 520 | for (Node n: postset) { | 505 | for (Node n: postset) { |
1005 | 521 | if (bwCR == null || l.getReferencedCounterflowLogic().isBackwardEarlyEvaluation()) { | 506 | if (bwCR == null || l.getReferencedCounterflowLogic().isBackwardEarlyEvaluation()) { |
1007 | 522 | bwCR = stg.createSignalTransition(nameBwC + name, type, SignalTransition.Direction.PLUS, curContainer); | 507 | bwCR = getStgModel().createSignalTransition(nameBwC + name, type, SignalTransition.Direction.PLUS, curContainer); |
1008 | 523 | bwCR.setTokenColorGenerator(postsetTokenColorGenerator); | 508 | bwCR.setTokenColorGenerator(postsetTokenColorGenerator); |
1009 | 524 | createConsumingArc(bwC0, bwCR, false); | 509 | createConsumingArc(bwC0, bwCR, false); |
1010 | 525 | createProducingArc(bwCR, bwC1, false); | 510 | createProducingArc(bwCR, bwC1, false); |
1011 | @@ -528,7 +513,7 @@ | |||
1012 | 528 | } | 513 | } |
1013 | 529 | bwCRs.put(n, bwCR); | 514 | bwCRs.put(n, bwCR); |
1014 | 530 | if (bwCF == null) { | 515 | if (bwCF == null) { |
1016 | 531 | bwCF = stg.createSignalTransition(nameBwC + name, type, SignalTransition.Direction.MINUS, curContainer); | 516 | bwCF = getStgModel().createSignalTransition(nameBwC + name, type, SignalTransition.Direction.MINUS, curContainer); |
1017 | 532 | createConsumingArc(bwC1, bwCF, false); | 517 | createConsumingArc(bwC1, bwCF, false); |
1018 | 533 | createProducingArc(bwCF, bwC0, false); | 518 | createProducingArc(bwCF, bwC0, false); |
1019 | 534 | setPosition(bwCF, x - 2.0, y + 2.0 - dy); | 519 | setPosition(bwCF, x - 2.0, y + 2.0 - dy); |
1020 | @@ -538,32 +523,30 @@ | |||
1021 | 538 | dy += 1.0; | 523 | dy += 1.0; |
1022 | 539 | } | 524 | } |
1023 | 540 | } | 525 | } |
1027 | 541 | 526 | ||
1025 | 542 | stg.select(nodes); | ||
1026 | 543 | stg.groupSelection(); | ||
1028 | 544 | return new CounterflowLogicStg(fwC0, fwC1, fwCRs, fwCFs, bwC0, bwC1, bwCRs, bwCFs); | 527 | return new CounterflowLogicStg(fwC0, fwC1, fwCRs, fwCFs, bwC0, bwC1, bwCRs, bwCFs); |
1029 | 545 | } | 528 | } |
1030 | 546 | 529 | ||
1031 | 547 | private void connectCounterflowLogicStg(VisualCounterflowLogic l) throws InvalidConnectionException { | 530 | private void connectCounterflowLogicStg(VisualCounterflowLogic l) throws InvalidConnectionException { |
1032 | 548 | CounterflowLogicStg lstg = getCounterflowLogicStg(l); | 531 | CounterflowLogicStg lstg = getCounterflowLogicStg(l); |
1033 | 549 | // preset | 532 | // preset |
1035 | 550 | for (VisualCounterflowLogic n: dfs.getPreset(l, VisualCounterflowLogic.class)) { | 533 | for (VisualCounterflowLogic n: getDfsModel().getPreset(l, VisualCounterflowLogic.class)) { |
1036 | 551 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); | 534 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); |
1037 | 552 | createReadArc(nstg.fwC1, lstg.fwCRs.get(n), true); | 535 | createReadArc(nstg.fwC1, lstg.fwCRs.get(n), true); |
1038 | 553 | createReadArc(nstg.fwC0, lstg.fwCFs.get(n), false); | 536 | createReadArc(nstg.fwC0, lstg.fwCFs.get(n), false); |
1039 | 554 | } | 537 | } |
1041 | 555 | for (VisualCounterflowRegister n: dfs.getPreset(l, VisualCounterflowRegister.class)) { | 538 | for (VisualCounterflowRegister n: getDfsModel().getPreset(l, VisualCounterflowRegister.class)) { |
1042 | 556 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 539 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
1043 | 557 | createReadArc(nstg.orM1, lstg.fwCRs.get(n), true); | 540 | createReadArc(nstg.orM1, lstg.fwCRs.get(n), true); |
1044 | 558 | createReadArc(nstg.orM0, lstg.fwCFs.get(n), false); | 541 | createReadArc(nstg.orM0, lstg.fwCFs.get(n), false); |
1045 | 559 | } | 542 | } |
1046 | 560 | // postset | 543 | // postset |
1048 | 561 | for (VisualCounterflowLogic n: dfs.getPostset(l, VisualCounterflowLogic.class)) { | 544 | for (VisualCounterflowLogic n: getDfsModel().getPostset(l, VisualCounterflowLogic.class)) { |
1049 | 562 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); | 545 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); |
1050 | 563 | createReadArc(nstg.bwC1, lstg.bwCRs.get(n), false); | 546 | createReadArc(nstg.bwC1, lstg.bwCRs.get(n), false); |
1051 | 564 | createReadArc(nstg.bwC0, lstg.bwCFs.get(n), false); | 547 | createReadArc(nstg.bwC0, lstg.bwCFs.get(n), false); |
1052 | 565 | } | 548 | } |
1054 | 566 | for (VisualCounterflowRegister n: dfs.getPostset(l, VisualCounterflowRegister.class)) { | 549 | for (VisualCounterflowRegister n: getDfsModel().getPostset(l, VisualCounterflowRegister.class)) { |
1055 | 567 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 550 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
1056 | 568 | createReadArc(nstg.orM1, lstg.bwCRs.get(n), false); | 551 | createReadArc(nstg.orM1, lstg.bwCRs.get(n), false); |
1057 | 569 | createReadArc(nstg.orM0, lstg.bwCFs.get(n), false); | 552 | createReadArc(nstg.orM0, lstg.bwCFs.get(n), false); |
1058 | @@ -571,25 +554,33 @@ | |||
1059 | 571 | } | 554 | } |
1060 | 572 | 555 | ||
1061 | 573 | public CounterflowLogicStg getCounterflowLogicStg(VisualCounterflowLogic logic) { | 556 | public CounterflowLogicStg getCounterflowLogicStg(VisualCounterflowLogic logic) { |
1064 | 574 | return counterflowLogicMap.get(logic); | 557 | return ((counterflowLogicMap == null) ? null : counterflowLogicMap.get(logic)); |
1065 | 575 | } | 558 | } |
1066 | 559 | |||
1067 | 560 | public void putCounterflowLogicStg(VisualCounterflowLogic logic, CounterflowLogicStg stg) { | ||
1068 | 561 | if (counterflowLogicMap == null) { | ||
1069 | 562 | counterflowLogicMap = new HashMap<>(); | ||
1070 | 563 | } | ||
1071 | 564 | counterflowLogicMap.put(logic, stg); | ||
1072 | 565 | } | ||
1073 | 566 | |||
1074 | 576 | 567 | ||
1075 | 577 | private CounterflowRegisterStg generateCounterflowRegisterSTG(VisualCounterflowRegister r) throws InvalidConnectionException { | 568 | private CounterflowRegisterStg generateCounterflowRegisterSTG(VisualCounterflowRegister r) throws InvalidConnectionException { |
1080 | 578 | String name = dfs.getName(r); | 569 | String name = getDfsModel().getName(r); |
1081 | 579 | AffineTransform transform = TransformHelper.getTransformToRoot(r); | 570 | Point2D pos = getComponentPosition(r); |
1082 | 580 | double x = xScaling * (transform.getTranslateX() + r.getX()); | 571 | double x = pos.getX(); |
1083 | 581 | double y = yScaling * (transform.getTranslateY() + r.getY()); | 572 | double y = pos.getY(); |
1084 | 582 | Collection<Node> nodes = new LinkedList<Node>(); | 573 | Collection<Node> nodes = new LinkedList<Node>(); |
1085 | 583 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; | 574 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; |
1087 | 584 | if (dfs.getPreset(r).size() == 0 || dfs.getPostset(r).size() == 0) { | 575 | if (getDfsModel().getPreset(r).size() == 0 || getDfsModel().getPostset(r).size() == 0) { |
1088 | 585 | type = SignalTransition.Type.INPUT; | 576 | type = SignalTransition.Type.INPUT; |
1089 | 586 | } | 577 | } |
1092 | 587 | ColorGenerator presetTokenColorGenerator = createColorGenerator(dfs.getPreset(r).size() == 0); | 578 | ColorGenerator presetTokenColorGenerator = createColorGenerator(getDfsModel().getPreset(r).size() == 0); |
1093 | 588 | ColorGenerator postsetTokenColorGenerator = createColorGenerator(dfs.getPostset(r).size() == 0); | 579 | ColorGenerator postsetTokenColorGenerator = createColorGenerator(getDfsModel().getPostset(r).size() == 0); |
1094 | 589 | 580 | ||
1095 | 590 | Container curContainer = null; | 581 | Container curContainer = null; |
1096 | 591 | 582 | ||
1098 | 592 | VisualPlace orM0 = stg.createPlace(nameOrM + name + name0, curContainer); | 583 | VisualPlace orM0 = getStgModel().createPlace(nameOrM + name + name0, curContainer); |
1099 | 593 | orM0.setLabel(labelOrM + name + label0); | 584 | orM0.setLabel(labelOrM + name + label0); |
1100 | 594 | orM0.setLabelPositioning(Positioning.BOTTOM); | 585 | orM0.setLabelPositioning(Positioning.BOTTOM); |
1101 | 595 | if (!r.getReferencedCounterflowRegister().isOrMarked()) { | 586 | if (!r.getReferencedCounterflowRegister().isOrMarked()) { |
1102 | @@ -600,7 +591,7 @@ | |||
1103 | 600 | setPosition(orM0, x + 2.0, y - 2.0); | 591 | setPosition(orM0, x + 2.0, y - 2.0); |
1104 | 601 | nodes.add(orM0); | 592 | nodes.add(orM0); |
1105 | 602 | 593 | ||
1107 | 603 | VisualPlace orM1 = stg.createPlace(nameOrM + name + name1, curContainer); | 594 | VisualPlace orM1 = getStgModel().createPlace(nameOrM + name + name1, curContainer); |
1108 | 604 | orM1.setLabel(labelOrM + name + label1); | 595 | orM1.setLabel(labelOrM + name + label1); |
1109 | 605 | orM1.setLabelPositioning(Positioning.TOP); | 596 | orM1.setLabelPositioning(Positioning.TOP); |
1110 | 606 | if (r.getReferencedCounterflowRegister().isOrMarked()) { | 597 | if (r.getReferencedCounterflowRegister().isOrMarked()) { |
1111 | @@ -611,33 +602,33 @@ | |||
1112 | 611 | setPosition(orM1, x + 2.0, y - 4.0); | 602 | setPosition(orM1, x + 2.0, y - 4.0); |
1113 | 612 | nodes.add(orM1); | 603 | nodes.add(orM1); |
1114 | 613 | 604 | ||
1116 | 614 | VisualSignalTransition orMRfw = stg.createSignalTransition(nameOrM + name, type, SignalTransition.Direction.PLUS, curContainer); | 605 | VisualSignalTransition orMRfw = getStgModel().createSignalTransition(nameOrM + name, type, SignalTransition.Direction.PLUS, curContainer); |
1117 | 615 | orMRfw.setTokenColorGenerator(presetTokenColorGenerator); | 606 | orMRfw.setTokenColorGenerator(presetTokenColorGenerator); |
1118 | 616 | createConsumingArc(orM0, orMRfw, false); | 607 | createConsumingArc(orM0, orMRfw, false); |
1119 | 617 | createProducingArc(orMRfw, orM1, true); | 608 | createProducingArc(orMRfw, orM1, true); |
1120 | 618 | setPosition(orMRfw, x - 2.0, y - 2.5); | 609 | setPosition(orMRfw, x - 2.0, y - 2.5); |
1121 | 619 | nodes.add(orMRfw); | 610 | nodes.add(orMRfw); |
1122 | 620 | 611 | ||
1124 | 621 | VisualSignalTransition orMRbw = stg.createSignalTransition(nameOrM + name, type, SignalTransition.Direction.PLUS, curContainer); | 612 | VisualSignalTransition orMRbw = getStgModel().createSignalTransition(nameOrM + name, type, SignalTransition.Direction.PLUS, curContainer); |
1125 | 622 | orMRbw.setTokenColorGenerator(postsetTokenColorGenerator); | 613 | orMRbw.setTokenColorGenerator(postsetTokenColorGenerator); |
1126 | 623 | createConsumingArc(orM0, orMRbw, false); | 614 | createConsumingArc(orM0, orMRbw, false); |
1127 | 624 | createProducingArc(orMRbw, orM1, true); | 615 | createProducingArc(orMRbw, orM1, true); |
1128 | 625 | setPosition(orMRbw, x - 2.0, y - 1.5); | 616 | setPosition(orMRbw, x - 2.0, y - 1.5); |
1129 | 626 | nodes.add(orMRbw); | 617 | nodes.add(orMRbw); |
1130 | 627 | 618 | ||
1132 | 628 | VisualSignalTransition orMFfw = stg.createSignalTransition(nameOrM + name, type, SignalTransition.Direction.MINUS, curContainer); | 619 | VisualSignalTransition orMFfw = getStgModel().createSignalTransition(nameOrM + name, type, SignalTransition.Direction.MINUS, curContainer); |
1133 | 629 | createConsumingArc(orM1, orMFfw, false); | 620 | createConsumingArc(orM1, orMFfw, false); |
1134 | 630 | createProducingArc(orMFfw, orM0, false); | 621 | createProducingArc(orMFfw, orM0, false); |
1135 | 631 | setPosition(orMFfw, x - 2.0, y - 4.5); | 622 | setPosition(orMFfw, x - 2.0, y - 4.5); |
1136 | 632 | nodes.add(orMFfw); | 623 | nodes.add(orMFfw); |
1137 | 633 | 624 | ||
1139 | 634 | VisualSignalTransition orMFbw = stg.createSignalTransition(nameOrM + name, type, SignalTransition.Direction.MINUS, curContainer); | 625 | VisualSignalTransition orMFbw = getStgModel().createSignalTransition(nameOrM + name, type, SignalTransition.Direction.MINUS, curContainer); |
1140 | 635 | createConsumingArc(orM1, orMFbw, false); | 626 | createConsumingArc(orM1, orMFbw, false); |
1141 | 636 | createProducingArc(orMFbw, orM0, false); | 627 | createProducingArc(orMFbw, orM0, false); |
1142 | 637 | setPosition(orMFbw, x - 2.0, y - 3.5); | 628 | setPosition(orMFbw, x - 2.0, y - 3.5); |
1143 | 638 | nodes.add(orMFbw); | 629 | nodes.add(orMFbw); |
1144 | 639 | 630 | ||
1146 | 640 | VisualPlace andM0 = stg.createPlace(nameAndM + name + name0, curContainer); | 631 | VisualPlace andM0 = getStgModel().createPlace(nameAndM + name + name0, curContainer); |
1147 | 641 | andM0.setLabel(labelAndM + name + label0); | 632 | andM0.setLabel(labelAndM + name + label0); |
1148 | 642 | andM0.setLabelPositioning(Positioning.BOTTOM); | 633 | andM0.setLabelPositioning(Positioning.BOTTOM); |
1149 | 643 | if (!r.getReferencedCounterflowRegister().isAndMarked()) { | 634 | if (!r.getReferencedCounterflowRegister().isAndMarked()) { |
1150 | @@ -648,7 +639,7 @@ | |||
1151 | 648 | setPosition(andM0, x + 2.0, y + 4.0); | 639 | setPosition(andM0, x + 2.0, y + 4.0); |
1152 | 649 | nodes.add(andM0); | 640 | nodes.add(andM0); |
1153 | 650 | 641 | ||
1155 | 651 | VisualPlace andM1 = stg.createPlace(nameAndM + name + name1, curContainer); | 642 | VisualPlace andM1 = getStgModel().createPlace(nameAndM + name + name1, curContainer); |
1156 | 652 | andM1.setLabel(labelAndM + name + label1); | 643 | andM1.setLabel(labelAndM + name + label1); |
1157 | 653 | andM1.setLabelPositioning(Positioning.TOP); | 644 | andM1.setLabelPositioning(Positioning.TOP); |
1158 | 654 | if (r.getReferencedCounterflowRegister().isAndMarked()) { | 645 | if (r.getReferencedCounterflowRegister().isAndMarked()) { |
1159 | @@ -659,34 +650,32 @@ | |||
1160 | 659 | setPosition(andM1, x + 2.0, y + 2.0); | 650 | setPosition(andM1, x + 2.0, y + 2.0); |
1161 | 660 | nodes.add(andM1); | 651 | nodes.add(andM1); |
1162 | 661 | 652 | ||
1164 | 662 | VisualSignalTransition andMR = stg.createSignalTransition(nameAndM + name, type, SignalTransition.Direction.PLUS, curContainer); | 653 | VisualSignalTransition andMR = getStgModel().createSignalTransition(nameAndM + name, type, SignalTransition.Direction.PLUS, curContainer); |
1165 | 663 | createConsumingArc(andM0, andMR, false); | 654 | createConsumingArc(andM0, andMR, false); |
1166 | 664 | createProducingArc(andMR, andM1, false); | 655 | createProducingArc(andMR, andM1, false); |
1167 | 665 | setPosition(andMR, x - 2.0, y + 4.0); | 656 | setPosition(andMR, x - 2.0, y + 4.0); |
1168 | 666 | nodes.add(andMR); | 657 | nodes.add(andMR); |
1169 | 667 | 658 | ||
1171 | 668 | VisualSignalTransition andMF = stg.createSignalTransition(nameAndM + name, type, SignalTransition.Direction.MINUS, curContainer); | 659 | VisualSignalTransition andMF = getStgModel().createSignalTransition(nameAndM + name, type, SignalTransition.Direction.MINUS, curContainer); |
1172 | 669 | createConsumingArc(andM1, andMF, false); | 660 | createConsumingArc(andM1, andMF, false); |
1173 | 670 | createProducingArc(andMF, andM0, false); | 661 | createProducingArc(andMF, andM0, false); |
1174 | 671 | setPosition(andMF, x - 2.0, y + 2.0); | 662 | setPosition(andMF, x - 2.0, y + 2.0); |
1175 | 672 | nodes.add(andMF); | 663 | nodes.add(andMF); |
1176 | 673 | 664 | ||
1177 | 674 | stg.select(nodes); | ||
1178 | 675 | stg.groupSelection(); | ||
1179 | 676 | return new CounterflowRegisterStg(orM0, orM1, orMRfw, orMRbw, orMFfw, orMFbw, andM0, andM1, andMR, andMF); | 665 | return new CounterflowRegisterStg(orM0, orM1, orMRfw, orMRbw, orMFfw, orMFbw, andM0, andM1, andMR, andMF); |
1180 | 677 | } | 666 | } |
1181 | 678 | 667 | ||
1182 | 679 | private void connectCounterflowRegisterStg(VisualCounterflowRegister r) throws InvalidConnectionException { | 668 | private void connectCounterflowRegisterStg(VisualCounterflowRegister r) throws InvalidConnectionException { |
1183 | 680 | CounterflowRegisterStg rstg = getCounterflowRegisterStg(r); | 669 | CounterflowRegisterStg rstg = getCounterflowRegisterStg(r); |
1184 | 681 | 670 | ||
1186 | 682 | for (VisualRegister n: dfs.getPreset(r, VisualRegister.class)) { | 671 | for (VisualRegister n: getDfsModel().getPreset(r, VisualRegister.class)) { |
1187 | 683 | RegisterStg nstg = getRegisterStg(n); | 672 | RegisterStg nstg = getRegisterStg(n); |
1188 | 684 | createReadArc(nstg.M1, rstg.orMRfw, true); | 673 | createReadArc(nstg.M1, rstg.orMRfw, true); |
1189 | 685 | createReadArc(nstg.M1, rstg.andMR, false); | 674 | createReadArc(nstg.M1, rstg.andMR, false); |
1190 | 686 | createReadArc(nstg.M0, rstg.orMFfw, false); | 675 | createReadArc(nstg.M0, rstg.orMFfw, false); |
1191 | 687 | createReadArc(nstg.M0, rstg.andMF, false); | 676 | createReadArc(nstg.M0, rstg.andMF, false); |
1192 | 688 | } | 677 | } |
1194 | 689 | for (VisualRegister n: dfs.getPostset(r, VisualRegister.class)) { | 678 | for (VisualRegister n: getDfsModel().getPostset(r, VisualRegister.class)) { |
1195 | 690 | RegisterStg nstg = getRegisterStg(n); | 679 | RegisterStg nstg = getRegisterStg(n); |
1196 | 691 | createReadArc(nstg.M1, rstg.orMRbw, true); | 680 | createReadArc(nstg.M1, rstg.orMRbw, true); |
1197 | 692 | createReadArc(nstg.M1, rstg.andMR, false); | 681 | createReadArc(nstg.M1, rstg.andMR, false); |
1198 | @@ -694,14 +683,14 @@ | |||
1199 | 694 | createReadArc(nstg.M0, rstg.andMF, false); | 683 | createReadArc(nstg.M0, rstg.andMF, false); |
1200 | 695 | } | 684 | } |
1201 | 696 | 685 | ||
1203 | 697 | for (VisualCounterflowLogic n: dfs.getPreset(r, VisualCounterflowLogic.class)) { | 686 | for (VisualCounterflowLogic n: getDfsModel().getPreset(r, VisualCounterflowLogic.class)) { |
1204 | 698 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); | 687 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); |
1205 | 699 | createReadArc(nstg.fwC1, rstg.orMRfw, true); | 688 | createReadArc(nstg.fwC1, rstg.orMRfw, true); |
1206 | 700 | createReadArc(nstg.fwC0, rstg.orMFfw, false); | 689 | createReadArc(nstg.fwC0, rstg.orMFfw, false); |
1207 | 701 | createReadArc(nstg.fwC1, rstg.andMR, false); | 690 | createReadArc(nstg.fwC1, rstg.andMR, false); |
1208 | 702 | createReadArc(nstg.fwC0, rstg.andMF, false); | 691 | createReadArc(nstg.fwC0, rstg.andMF, false); |
1209 | 703 | } | 692 | } |
1211 | 704 | for (VisualCounterflowLogic n: dfs.getPostset(r, VisualCounterflowLogic.class)) { | 693 | for (VisualCounterflowLogic n: getDfsModel().getPostset(r, VisualCounterflowLogic.class)) { |
1212 | 705 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); | 694 | CounterflowLogicStg nstg = getCounterflowLogicStg(n); |
1213 | 706 | createReadArc(nstg.bwC1, rstg.orMRbw, true); | 695 | createReadArc(nstg.bwC1, rstg.orMRbw, true); |
1214 | 707 | createReadArc(nstg.bwC0, rstg.orMFbw, false); | 696 | createReadArc(nstg.bwC0, rstg.orMFbw, false); |
1215 | @@ -709,12 +698,12 @@ | |||
1216 | 709 | createReadArc(nstg.bwC0, rstg.andMF, false); | 698 | createReadArc(nstg.bwC0, rstg.andMF, false); |
1217 | 710 | } | 699 | } |
1218 | 711 | 700 | ||
1220 | 712 | for (VisualCounterflowRegister n: dfs.getPreset(r, VisualCounterflowRegister.class)) { | 701 | for (VisualCounterflowRegister n: getDfsModel().getPreset(r, VisualCounterflowRegister.class)) { |
1221 | 713 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 702 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
1222 | 714 | createReadArc(nstg.orM1, rstg.orMRfw, true); | 703 | createReadArc(nstg.orM1, rstg.orMRfw, true); |
1223 | 715 | createReadArc(nstg.orM0, rstg.orMFfw, false); | 704 | createReadArc(nstg.orM0, rstg.orMFfw, false); |
1224 | 716 | } | 705 | } |
1226 | 717 | for (VisualCounterflowRegister n: dfs.getPostset(r, VisualCounterflowRegister.class)) { | 706 | for (VisualCounterflowRegister n: getDfsModel().getPostset(r, VisualCounterflowRegister.class)) { |
1227 | 718 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 707 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
1228 | 719 | createReadArc(nstg.orM1, rstg.orMRbw, true); | 708 | createReadArc(nstg.orM1, rstg.orMRbw, true); |
1229 | 720 | createReadArc(nstg.orM0, rstg.orMFbw, false); | 709 | createReadArc(nstg.orM0, rstg.orMFbw, false); |
1230 | @@ -722,8 +711,8 @@ | |||
1231 | 722 | 711 | ||
1232 | 723 | Set<VisualCounterflowRegister> rSet = new HashSet<VisualCounterflowRegister>(); | 712 | Set<VisualCounterflowRegister> rSet = new HashSet<VisualCounterflowRegister>(); |
1233 | 724 | rSet.add(r); | 713 | rSet.add(r); |
1236 | 725 | rSet.addAll(dfs.getRPreset(r, VisualCounterflowRegister.class)); | 714 | rSet.addAll(getDfsModel().getRPreset(r, VisualCounterflowRegister.class)); |
1237 | 726 | rSet.addAll(dfs.getRPostset(r, VisualCounterflowRegister.class)); | 715 | rSet.addAll(getDfsModel().getRPostset(r, VisualCounterflowRegister.class)); |
1238 | 727 | for (VisualCounterflowRegister n: rSet) { | 716 | for (VisualCounterflowRegister n: rSet) { |
1239 | 728 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); | 717 | CounterflowRegisterStg nstg = getCounterflowRegisterStg(n); |
1240 | 729 | createReadArc(nstg.orM1, rstg.andMR, true); | 718 | createReadArc(nstg.orM1, rstg.andMR, true); |
1241 | @@ -736,26 +725,34 @@ | |||
1242 | 736 | } | 725 | } |
1243 | 737 | 726 | ||
1244 | 738 | public CounterflowRegisterStg getCounterflowRegisterStg(VisualCounterflowRegister register) { | 727 | public CounterflowRegisterStg getCounterflowRegisterStg(VisualCounterflowRegister register) { |
1247 | 739 | return counterflowRegisterMap.get(register); | 728 | return ((counterflowRegisterMap == null) ? null: counterflowRegisterMap.get(register)); |
1248 | 740 | } | 729 | } |
1249 | 730 | |||
1250 | 731 | public void putCounterflowRegisterStg(VisualCounterflowRegister register, CounterflowRegisterStg stg) { | ||
1251 | 732 | if (counterflowRegisterMap == null) { | ||
1252 | 733 | counterflowRegisterMap = new HashMap<>(); | ||
1253 | 734 | } | ||
1254 | 735 | counterflowRegisterMap.put(register, stg); | ||
1255 | 736 | } | ||
1256 | 737 | |||
1257 | 741 | 738 | ||
1258 | 742 | private BinaryRegisterStg generateBinaryRegisterSTG(VisualBinaryRegister r, | 739 | private BinaryRegisterStg generateBinaryRegisterSTG(VisualBinaryRegister r, |
1259 | 743 | boolean andSync, boolean orSync) throws InvalidConnectionException { | 740 | boolean andSync, boolean orSync) throws InvalidConnectionException { |
1260 | 744 | Collection<Node> nodes = new LinkedList<Node>(); | 741 | Collection<Node> nodes = new LinkedList<Node>(); |
1265 | 745 | String name = dfs.getName(r); | 742 | String name = getDfsModel().getName(r); |
1266 | 746 | AffineTransform transform = TransformHelper.getTransformToRoot(r); | 743 | Point2D pos = getComponentPosition(r); |
1267 | 747 | double x = xScaling * (transform.getTranslateX() + r.getX()); | 744 | double x = pos.getX(); |
1268 | 748 | double y = yScaling * (transform.getTranslateY() + r.getY()); | 745 | double y = pos.getY(); |
1269 | 749 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; | 746 | SignalTransition.Type type = SignalTransition.Type.INTERNAL; |
1271 | 750 | if (dfs.getPreset(r, VisualControlRegister.class).size() == 0) { | 747 | if (getDfsModel().getPreset(r, VisualControlRegister.class).size() == 0) { |
1272 | 751 | type = SignalTransition.Type.INPUT; | 748 | type = SignalTransition.Type.INPUT; |
1274 | 752 | } else if (dfs.getPostset(r).size() == 0) { | 749 | } else if (getDfsModel().getPostset(r).size() == 0) { |
1275 | 753 | type = SignalTransition.Type.OUTPUT; | 750 | type = SignalTransition.Type.OUTPUT; |
1276 | 754 | } | 751 | } |
1278 | 755 | ColorGenerator tokenColorGenerator = createColorGenerator(dfs.getPreset(r).size() == 0); | 752 | ColorGenerator tokenColorGenerator = createColorGenerator(getDfsModel().getPreset(r).size() == 0); |
1279 | 756 | Container curContainer = null; | 753 | Container curContainer = null; |
1280 | 757 | 754 | ||
1282 | 758 | VisualPlace M0 = stg.createPlace(nameM + name + name0, curContainer); | 755 | VisualPlace M0 = getStgModel().createPlace(nameM + name + name0, curContainer); |
1283 | 759 | M0.setLabel(labelM + name + label0); | 756 | M0.setLabel(labelM + name + label0); |
1284 | 760 | M0.setLabelPositioning(Positioning.BOTTOM); | 757 | M0.setLabelPositioning(Positioning.BOTTOM); |
1285 | 761 | if (!r.getReferencedBinaryRegister().isTrueMarked() && !r.getReferencedBinaryRegister().isFalseMarked()) { | 758 | if (!r.getReferencedBinaryRegister().isTrueMarked() && !r.getReferencedBinaryRegister().isFalseMarked()) { |
1286 | @@ -766,7 +763,7 @@ | |||
1287 | 766 | setPosition(M0, x - 4.0, y + 1.0); | 763 | setPosition(M0, x - 4.0, y + 1.0); |
1288 | 767 | nodes.add(M0); | 764 | nodes.add(M0); |
1289 | 768 | 765 | ||
1291 | 769 | VisualPlace M1 = stg.createPlace(nameM + name + name1, curContainer); | 766 | VisualPlace M1 = getStgModel().createPlace(nameM + name + name1, curContainer); |
1292 | 770 | M1.setLabel(labelM + name + label1); | 767 | M1.setLabel(labelM + name + label1); |
1293 | 771 | M1.setLabelPositioning(Positioning.TOP); | 768 | M1.setLabelPositioning(Positioning.TOP); |
1294 | 772 | if (r.getReferencedBinaryRegister().isTrueMarked() || r.getReferencedBinaryRegister().isFalseMarked()) { | 769 | if (r.getReferencedBinaryRegister().isTrueMarked() || r.getReferencedBinaryRegister().isFalseMarked()) { |
1295 | @@ -777,7 +774,7 @@ | |||
1296 | 777 | setPosition(M1, x - 4.0, y - 1.0); | 774 | setPosition(M1, x - 4.0, y - 1.0); |
1297 | 778 | nodes.add(M1); | 775 | nodes.add(M1); |
1298 | 779 | 776 | ||
1300 | 780 | VisualPlace tM0 = stg.createPlace(nameTrueM + name + name0, curContainer); | 777 | VisualPlace tM0 = getStgModel().createPlace(nameTrueM + name + name0, curContainer); |
1301 | 781 | tM0.setLabel(labelTrueM + name + label0); | 778 | tM0.setLabel(labelTrueM + name + label0); |
1302 | 782 | tM0.setLabelPositioning(Positioning.BOTTOM); | 779 | tM0.setLabelPositioning(Positioning.BOTTOM); |
1303 | 783 | if (!r.getReferencedBinaryRegister().isTrueMarked()) { | 780 | if (!r.getReferencedBinaryRegister().isTrueMarked()) { |
1304 | @@ -788,7 +785,7 @@ | |||
1305 | 788 | setPosition(tM0, x + 4.0, y - 2.0); | 785 | setPosition(tM0, x + 4.0, y - 2.0); |
1306 | 789 | nodes.add(tM0); | 786 | nodes.add(tM0); |
1307 | 790 | 787 | ||
1309 | 791 | VisualPlace tM1 = stg.createPlace(nameTrueM + name + name1, curContainer); | 788 | VisualPlace tM1 = getStgModel().createPlace(nameTrueM + name + name1, curContainer); |
1310 | 792 | tM1.setLabel(labelTrueM + name + label1); | 789 | tM1.setLabel(labelTrueM + name + label1); |
1311 | 793 | tM1.setLabelPositioning(Positioning.TOP); | 790 | tM1.setLabelPositioning(Positioning.TOP); |
1312 | 794 | if (r.getReferencedBinaryRegister().isTrueMarked()) { | 791 | if (r.getReferencedBinaryRegister().isTrueMarked()) { |
1313 | @@ -800,7 +797,7 @@ | |||
1314 | 800 | nodes.add(tM1); | 797 | nodes.add(tM1); |
1315 | 801 | 798 | ||
1316 | 802 | Set<Node> preset = new HashSet<Node>(); | 799 | Set<Node> preset = new HashSet<Node>(); |
1318 | 803 | preset.addAll(dfs.getRPreset(r, VisualControlRegister.class)); | 800 | preset.addAll(getDfsModel().getRPreset(r, VisualControlRegister.class)); |
1319 | 804 | if (preset.size() == 0) { | 801 | if (preset.size() == 0) { |
1320 | 805 | preset.add(r); | 802 | preset.add(r); |
1321 | 806 | } | 803 | } |
1322 | @@ -810,7 +807,7 @@ | |||
1323 | 810 | double dy = 0.0; | 807 | double dy = 0.0; |
1324 | 811 | for (Node n: preset) { | 808 | for (Node n: preset) { |
1325 | 812 | if (tMR == null || orSync) { | 809 | if (tMR == null || orSync) { |
1327 | 813 | tMR = stg.createSignalTransition(nameTrueM + name, type, SignalTransition.Direction.PLUS, curContainer); | 810 | tMR = getStgModel().createSignalTransition(nameTrueM + name, type, SignalTransition.Direction.PLUS, curContainer); |
1328 | 814 | tMR.setTokenColorGenerator(tokenColorGenerator); | 811 | tMR.setTokenColorGenerator(tokenColorGenerator); |
1329 | 815 | createConsumingArc(tM0, tMR, false); | 812 | createConsumingArc(tM0, tMR, false); |
1330 | 816 | createProducingArc(tMR, tM1, true); | 813 | createProducingArc(tMR, tM1, true); |
1331 | @@ -822,7 +819,7 @@ | |||
1332 | 822 | tMRs.put(n, tMR); | 819 | tMRs.put(n, tMR); |
1333 | 823 | dy += 1.0; | 820 | dy += 1.0; |
1334 | 824 | } | 821 | } |
1336 | 825 | VisualSignalTransition tMF = stg.createSignalTransition(nameTrueM + name, type, SignalTransition.Direction.MINUS, curContainer); | 822 | VisualSignalTransition tMF = getStgModel().createSignalTransition(nameTrueM + name, type, SignalTransition.Direction.MINUS, curContainer); |
1337 | 826 | createConsumingArc(tM1, tMF, false); | 823 | createConsumingArc(tM1, tMF, false); |
1338 | 827 | createProducingArc(tMF, tM0, false); | 824 | createProducingArc(tMF, tM0, false); |
1339 | 828 | createConsumingArc(M1, tMF, false); | 825 | createConsumingArc(M1, tMF, false); |
1340 | @@ -831,7 +828,7 @@ | |||
1341 | 831 | nodes.add(tMF); | 828 | nodes.add(tMF); |
1342 | 832 | 829 | ||
1343 | 833 | 830 | ||
1345 | 834 | VisualPlace fM0 = stg.createPlace(nameFalseM + name + name0, curContainer); | 831 | VisualPlace fM0 = getStgModel().createPlace(nameFalseM + name + name0, curContainer); |
1346 | 835 | fM0.setLabel(labelFalseM + name + label0); | 832 | fM0.setLabel(labelFalseM + name + label0); |
1347 | 836 | fM0.setLabelPositioning(Positioning.BOTTOM); | 833 | fM0.setLabelPositioning(Positioning.BOTTOM); |
1348 | 837 | if (!r.getReferencedBinaryRegister().isFalseMarked()) { | 834 | if (!r.getReferencedBinaryRegister().isFalseMarked()) { |
1349 | @@ -842,7 +839,7 @@ | |||
1350 | 842 | setPosition(fM0, x + 4.0, y + 4.0); | 839 | setPosition(fM0, x + 4.0, y + 4.0); |
1351 | 843 | nodes.add(fM0); | 840 | nodes.add(fM0); |
1352 | 844 | 841 | ||
1354 | 845 | VisualPlace fM1 = stg.createPlace(nameFalseM + name + name1, curContainer); | 842 | VisualPlace fM1 = getStgModel().createPlace(nameFalseM + name + name1, curContainer); |
1355 | 846 | fM1.setLabel(labelFalseM + name + label1); | 843 | fM1.setLabel(labelFalseM + name + label1); |
1356 | 847 | fM1.setLabelPositioning(Positioning.TOP); | 844 | fM1.setLabelPositioning(Positioning.TOP); |
1357 | 848 | if (r.getReferencedBinaryRegister().isFalseMarked()) { | 845 | if (r.getReferencedBinaryRegister().isFalseMarked()) { |
1358 | @@ -858,7 +855,7 @@ | |||
1359 | 858 | dy = 0.0; | 855 | dy = 0.0; |
1360 | 859 | for (Node n: preset) { | 856 | for (Node n: preset) { |
1361 | 860 | if (fMR == null || andSync) { | 857 | if (fMR == null || andSync) { |
1363 | 861 | fMR = stg.createSignalTransition(nameFalseM + name, type, SignalTransition.Direction.PLUS, curContainer); | 858 | fMR = getStgModel().createSignalTransition(nameFalseM + name, type, SignalTransition.Direction.PLUS, curContainer); |
1364 | 862 | fMR.setTokenColorGenerator(tokenColorGenerator); | 859 | fMR.setTokenColorGenerator(tokenColorGenerator); |
1365 | 863 | createConsumingArc(fM0, fMR, false); | 860 | createConsumingArc(fM0, fMR, false); |
1366 | 864 | createProducingArc(fMR, fM1, true); | 861 | createProducingArc(fMR, fM1, true); |
1367 | @@ -870,7 +867,7 @@ | |||
1368 | 870 | fMRs.put(n, fMR); | 867 | fMRs.put(n, fMR); |
1369 | 871 | dy += 1.0; | 868 | dy += 1.0; |
1370 | 872 | } | 869 | } |
1372 | 873 | VisualSignalTransition fMF = stg.createSignalTransition(nameFalseM + name, type, SignalTransition.Direction.MINUS, curContainer); | 870 | VisualSignalTransition fMF = getStgModel().createSignalTransition(nameFalseM + name, type, SignalTransition.Direction.MINUS, curContainer); |
1373 | 874 | createConsumingArc(fM1, fMF, false); | 871 | createConsumingArc(fM1, fMF, false); |
1374 | 875 | createProducingArc(fMF, fM0, false); | 872 | createProducingArc(fMF, fM0, false); |
1375 | 876 | createConsumingArc(M1, fMF, false); | 873 | createConsumingArc(M1, fMF, false); |
1376 | @@ -882,8 +879,6 @@ | |||
1377 | 882 | createReadArcs(tM0, fMRs.values(), false); | 879 | createReadArcs(tM0, fMRs.values(), false); |
1378 | 883 | createReadArcs(fM0, tMRs.values(), false); | 880 | createReadArcs(fM0, tMRs.values(), false); |
1379 | 884 | 881 | ||
1380 | 885 | stg.select(nodes); | ||
1381 | 886 | stg.groupSelection(); | ||
1382 | 887 | return new BinaryRegisterStg(M0, M1, tM0, tM1, tMRs, tMF, fM0, fM1, fMRs, fMF); | 882 | return new BinaryRegisterStg(M0, M1, tM0, tM1, tMRs, tMF, fM0, fM1, fMRs, fMF); |
1383 | 888 | } | 883 | } |
1384 | 889 | 884 | ||
1385 | @@ -896,7 +891,7 @@ | |||
1386 | 896 | private void connectControlRegisterStg(VisualControlRegister r) throws InvalidConnectionException { | 891 | private void connectControlRegisterStg(VisualControlRegister r) throws InvalidConnectionException { |
1387 | 897 | BinaryRegisterStg rstg = getControlRegisterStg(r); | 892 | BinaryRegisterStg rstg = getControlRegisterStg(r); |
1388 | 898 | // preset | 893 | // preset |
1390 | 899 | for (VisualLogic n: dfs.getPreset(r, VisualLogic.class)) { | 894 | for (VisualLogic n: getDfsModel().getPreset(r, VisualLogic.class)) { |
1391 | 900 | LogicStg nstg = getLogicStg(n); | 895 | LogicStg nstg = getLogicStg(n); |
1392 | 901 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); | 896 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); |
1393 | 902 | createReadArcs(nstg.C1, rstg.fMRs.values(), true); | 897 | createReadArcs(nstg.C1, rstg.fMRs.values(), true); |
1394 | @@ -904,17 +899,17 @@ | |||
1395 | 904 | createReadArc(nstg.C0, rstg.fMF, false); | 899 | createReadArc(nstg.C0, rstg.fMF, false); |
1396 | 905 | } | 900 | } |
1397 | 906 | // R-preset | 901 | // R-preset |
1399 | 907 | for (VisualRegister n: dfs.getRPreset(r, VisualRegister.class)) { | 902 | for (VisualRegister n: getDfsModel().getRPreset(r, VisualRegister.class)) { |
1400 | 908 | RegisterStg nstg = getRegisterStg(n); | 903 | RegisterStg nstg = getRegisterStg(n); |
1401 | 909 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 904 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1402 | 910 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); | 905 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); |
1403 | 911 | createReadArc(nstg.M0, rstg.tMF, false); | 906 | createReadArc(nstg.M0, rstg.tMF, false); |
1404 | 912 | createReadArc(nstg.M0, rstg.fMF, false); | 907 | createReadArc(nstg.M0, rstg.fMF, false); |
1405 | 913 | } | 908 | } |
1407 | 914 | Collection<VisualControlRegister> crPreset = dfs.getRPreset(r, VisualControlRegister.class); | 909 | Collection<VisualControlRegister> crPreset = getDfsModel().getRPreset(r, VisualControlRegister.class); |
1408 | 915 | for (VisualControlRegister n: crPreset) { | 910 | for (VisualControlRegister n: crPreset) { |
1409 | 916 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 911 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1411 | 917 | Connection connection = dfs.getConnection(n, r); | 912 | Connection connection = getDfsModel().getConnection(n, r); |
1412 | 918 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { | 913 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { |
1413 | 919 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); | 914 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); |
1414 | 920 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); | 915 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); |
1415 | @@ -937,14 +932,14 @@ | |||
1416 | 937 | createReadArc(nstg.M0, rstg.tMF, false); | 932 | createReadArc(nstg.M0, rstg.tMF, false); |
1417 | 938 | createReadArc(nstg.M0, rstg.fMF, false); | 933 | createReadArc(nstg.M0, rstg.fMF, false); |
1418 | 939 | } | 934 | } |
1420 | 940 | for (VisualPushRegister n: dfs.getRPreset(r, VisualPushRegister.class)) { | 935 | for (VisualPushRegister n: getDfsModel().getRPreset(r, VisualPushRegister.class)) { |
1421 | 941 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 936 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1422 | 942 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); | 937 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); |
1423 | 943 | createReadArcs(nstg.tM1, rstg.fMRs.values(), true); | 938 | createReadArcs(nstg.tM1, rstg.fMRs.values(), true); |
1424 | 944 | createReadArc(nstg.tM0, rstg.tMF, false); | 939 | createReadArc(nstg.tM0, rstg.tMF, false); |
1425 | 945 | createReadArc(nstg.tM0, rstg.fMF, false); | 940 | createReadArc(nstg.tM0, rstg.fMF, false); |
1426 | 946 | } | 941 | } |
1428 | 947 | for (VisualPopRegister n: dfs.getRPreset(r, VisualPopRegister.class)) { | 942 | for (VisualPopRegister n: getDfsModel().getRPreset(r, VisualPopRegister.class)) { |
1429 | 948 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 943 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1430 | 949 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 944 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1431 | 950 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); | 945 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); |
1432 | @@ -952,23 +947,23 @@ | |||
1433 | 952 | createReadArc(nstg.M0, rstg.fMF, false); | 947 | createReadArc(nstg.M0, rstg.fMF, false); |
1434 | 953 | } | 948 | } |
1435 | 954 | // R-postset | 949 | // R-postset |
1437 | 955 | for (VisualRegister n: dfs.getRPostset(r, VisualRegister.class)) { | 950 | for (VisualRegister n: getDfsModel().getRPostset(r, VisualRegister.class)) { |
1438 | 956 | RegisterStg nstg = getRegisterStg(n); | 951 | RegisterStg nstg = getRegisterStg(n); |
1439 | 957 | createReadArc(nstg.M1, rstg.tMF, false); | 952 | createReadArc(nstg.M1, rstg.tMF, false); |
1440 | 958 | createReadArc(nstg.M1, rstg.fMF, false); | 953 | createReadArc(nstg.M1, rstg.fMF, false); |
1441 | 959 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 954 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1442 | 960 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 955 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1443 | 961 | } | 956 | } |
1445 | 962 | for (VisualControlRegister n: dfs.getRPostset(r, VisualControlRegister.class)) { | 957 | for (VisualControlRegister n: getDfsModel().getRPostset(r, VisualControlRegister.class)) { |
1446 | 963 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 958 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1447 | 964 | createReadArc(nstg.M1, rstg.tMF, false); | 959 | createReadArc(nstg.M1, rstg.tMF, false); |
1448 | 965 | createReadArc(nstg.M1, rstg.fMF, false); | 960 | createReadArc(nstg.M1, rstg.fMF, false); |
1449 | 966 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 961 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1450 | 967 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 962 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1451 | 968 | } | 963 | } |
1453 | 969 | for (VisualPushRegister n: dfs.getRPostset(r, VisualPushRegister.class)) { | 964 | for (VisualPushRegister n: getDfsModel().getRPostset(r, VisualPushRegister.class)) { |
1454 | 970 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 965 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1456 | 971 | Connection connection = dfs.getConnection(r, n); | 966 | Connection connection = getDfsModel().getConnection(r, n); |
1457 | 972 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { | 967 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { |
1458 | 973 | createReadArc(nstg.tM1, rstg.fMF, false); | 968 | createReadArc(nstg.tM1, rstg.fMF, false); |
1459 | 974 | createReadArc(nstg.fM1, rstg.tMF, false); | 969 | createReadArc(nstg.fM1, rstg.tMF, false); |
1460 | @@ -979,9 +974,9 @@ | |||
1461 | 979 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 974 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1462 | 980 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 975 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1463 | 981 | } | 976 | } |
1465 | 982 | for (VisualPopRegister n: dfs.getRPostset(r, VisualPopRegister.class)) { | 977 | for (VisualPopRegister n: getDfsModel().getRPostset(r, VisualPopRegister.class)) { |
1466 | 983 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 978 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1468 | 984 | Connection connection = dfs.getConnection(r, n); | 979 | Connection connection = getDfsModel().getConnection(r, n); |
1469 | 985 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { | 980 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { |
1470 | 986 | createReadArc(nstg.tM1, rstg.fMF, false); | 981 | createReadArc(nstg.tM1, rstg.fMF, false); |
1471 | 987 | createReadArc(nstg.fM1, rstg.tMF, false); | 982 | createReadArc(nstg.fM1, rstg.tMF, false); |
1472 | @@ -995,8 +990,16 @@ | |||
1473 | 995 | } | 990 | } |
1474 | 996 | 991 | ||
1475 | 997 | public BinaryRegisterStg getControlRegisterStg(VisualControlRegister register) { | 992 | public BinaryRegisterStg getControlRegisterStg(VisualControlRegister register) { |
1478 | 998 | return controlRegisterMap.get(register); | 993 | return ((controlRegisterMap == null) ? null : controlRegisterMap.get(register)); |
1479 | 999 | } | 994 | } |
1480 | 995 | |||
1481 | 996 | public void putControlRegisterStg(VisualControlRegister register, BinaryRegisterStg stg) { | ||
1482 | 997 | if (controlRegisterMap == null) { | ||
1483 | 998 | controlRegisterMap = new HashMap<>(); | ||
1484 | 999 | } | ||
1485 | 1000 | controlRegisterMap.put(register, stg); | ||
1486 | 1001 | } | ||
1487 | 1002 | |||
1488 | 1000 | 1003 | ||
1489 | 1001 | private BinaryRegisterStg generatePushRegisterStg(VisualPushRegister r) throws InvalidConnectionException { | 1004 | private BinaryRegisterStg generatePushRegisterStg(VisualPushRegister r) throws InvalidConnectionException { |
1490 | 1002 | return generateBinaryRegisterSTG(r, false, false); | 1005 | return generateBinaryRegisterSTG(r, false, false); |
1491 | @@ -1005,7 +1008,7 @@ | |||
1492 | 1005 | private void connectPushRegisterStg(VisualPushRegister r) throws InvalidConnectionException { | 1008 | private void connectPushRegisterStg(VisualPushRegister r) throws InvalidConnectionException { |
1493 | 1006 | BinaryRegisterStg rstg = getPushRegisterStg(r); | 1009 | BinaryRegisterStg rstg = getPushRegisterStg(r); |
1494 | 1007 | // preset | 1010 | // preset |
1496 | 1008 | for (VisualLogic n: dfs.getPreset(r, VisualLogic.class)) { | 1011 | for (VisualLogic n: getDfsModel().getPreset(r, VisualLogic.class)) { |
1497 | 1009 | LogicStg nstg = getLogicStg(n); | 1012 | LogicStg nstg = getLogicStg(n); |
1498 | 1010 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); | 1013 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); |
1499 | 1011 | createReadArcs(nstg.C1, rstg.fMRs.values(), true); | 1014 | createReadArcs(nstg.C1, rstg.fMRs.values(), true); |
1500 | @@ -1013,16 +1016,16 @@ | |||
1501 | 1013 | createReadArc(nstg.C0, rstg.fMF, false); | 1016 | createReadArc(nstg.C0, rstg.fMF, false); |
1502 | 1014 | } | 1017 | } |
1503 | 1015 | // R-preset | 1018 | // R-preset |
1505 | 1016 | for (VisualRegister n: dfs.getRPreset(r, VisualRegister.class)) { | 1019 | for (VisualRegister n: getDfsModel().getRPreset(r, VisualRegister.class)) { |
1506 | 1017 | RegisterStg nstg = getRegisterStg(n); | 1020 | RegisterStg nstg = getRegisterStg(n); |
1507 | 1018 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 1021 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1508 | 1019 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); | 1022 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); |
1509 | 1020 | createReadArc(nstg.M0, rstg.tMF, false); | 1023 | createReadArc(nstg.M0, rstg.tMF, false); |
1510 | 1021 | createReadArc(nstg.M0, rstg.fMF, false); | 1024 | createReadArc(nstg.M0, rstg.fMF, false); |
1511 | 1022 | } | 1025 | } |
1513 | 1023 | for (VisualControlRegister n: dfs.getRPreset(r, VisualControlRegister.class)) { | 1026 | for (VisualControlRegister n: getDfsModel().getRPreset(r, VisualControlRegister.class)) { |
1514 | 1024 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 1027 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1516 | 1025 | Connection connection = dfs.getConnection(n, r); | 1028 | Connection connection = getDfsModel().getConnection(n, r); |
1517 | 1026 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { | 1029 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { |
1518 | 1027 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); | 1030 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); |
1519 | 1028 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); | 1031 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); |
1520 | @@ -1035,14 +1038,14 @@ | |||
1521 | 1035 | createReadArc(nstg.fM0, rstg.fMF, false); | 1038 | createReadArc(nstg.fM0, rstg.fMF, false); |
1522 | 1036 | } | 1039 | } |
1523 | 1037 | } | 1040 | } |
1525 | 1038 | for (VisualPushRegister n: dfs.getRPreset(r, VisualPushRegister.class)) { | 1041 | for (VisualPushRegister n: getDfsModel().getRPreset(r, VisualPushRegister.class)) { |
1526 | 1039 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 1042 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1527 | 1040 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); | 1043 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); |
1528 | 1041 | createReadArcs(nstg.tM1, rstg.fMRs.values(), true); | 1044 | createReadArcs(nstg.tM1, rstg.fMRs.values(), true); |
1529 | 1042 | createReadArc(nstg.tM0, rstg.tMF, false); | 1045 | createReadArc(nstg.tM0, rstg.tMF, false); |
1530 | 1043 | createReadArc(nstg.tM0, rstg.fMF, false); | 1046 | createReadArc(nstg.tM0, rstg.fMF, false); |
1531 | 1044 | } | 1047 | } |
1533 | 1045 | for (VisualPopRegister n: dfs.getRPreset(r, VisualPopRegister.class)) { | 1048 | for (VisualPopRegister n: getDfsModel().getRPreset(r, VisualPopRegister.class)) { |
1534 | 1046 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 1049 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1535 | 1047 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 1050 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1536 | 1048 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); | 1051 | createReadArcs(nstg.M1, rstg.fMRs.values(), true); |
1537 | @@ -1050,22 +1053,22 @@ | |||
1538 | 1050 | createReadArc(nstg.M0, rstg.fMF, false); | 1053 | createReadArc(nstg.M0, rstg.fMF, false); |
1539 | 1051 | } | 1054 | } |
1540 | 1052 | // R-postset | 1055 | // R-postset |
1542 | 1053 | for (VisualRegister n: dfs.getRPostset(r, VisualRegister.class)) { | 1056 | for (VisualRegister n: getDfsModel().getRPostset(r, VisualRegister.class)) { |
1543 | 1054 | RegisterStg nstg = getRegisterStg(n); | 1057 | RegisterStg nstg = getRegisterStg(n); |
1544 | 1055 | createReadArc(nstg.M1, rstg.tMF, false); // register M1 in R-postset is read only by tMF | 1058 | createReadArc(nstg.M1, rstg.tMF, false); // register M1 in R-postset is read only by tMF |
1545 | 1056 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); // register M0 in R-postset is read only by tMR | 1059 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); // register M0 in R-postset is read only by tMR |
1546 | 1057 | } | 1060 | } |
1548 | 1058 | for (VisualControlRegister n: dfs.getRPostset(r, VisualControlRegister.class)) { | 1061 | for (VisualControlRegister n: getDfsModel().getRPostset(r, VisualControlRegister.class)) { |
1549 | 1059 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 1062 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1550 | 1060 | createReadArc(nstg.M1, rstg.tMF, false); | 1063 | createReadArc(nstg.M1, rstg.tMF, false); |
1551 | 1061 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 1064 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1552 | 1062 | } | 1065 | } |
1554 | 1063 | for (VisualPushRegister n: dfs.getRPostset(r, VisualPushRegister.class)) { | 1066 | for (VisualPushRegister n: getDfsModel().getRPostset(r, VisualPushRegister.class)) { |
1555 | 1064 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 1067 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1556 | 1065 | createReadArc(nstg.M1, rstg.tMF, false); | 1068 | createReadArc(nstg.M1, rstg.tMF, false); |
1557 | 1066 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 1069 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1558 | 1067 | } | 1070 | } |
1560 | 1068 | for (VisualPopRegister n: dfs.getRPostset(r, VisualPopRegister.class)) { | 1071 | for (VisualPopRegister n: getDfsModel().getRPostset(r, VisualPopRegister.class)) { |
1561 | 1069 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 1072 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1562 | 1070 | createReadArc(nstg.tM1, rstg.tMF, false); // pop tM1 in R-postset is read only by tMF | 1073 | createReadArc(nstg.tM1, rstg.tMF, false); // pop tM1 in R-postset is read only by tMF |
1563 | 1071 | createReadArcs(nstg.tM0, rstg.tMRs.values(), false); // pop tM0 in R-postset is read only by tMR | 1074 | createReadArcs(nstg.tM0, rstg.tMRs.values(), false); // pop tM0 in R-postset is read only by tMR |
1564 | @@ -1073,7 +1076,14 @@ | |||
1565 | 1073 | } | 1076 | } |
1566 | 1074 | 1077 | ||
1567 | 1075 | public BinaryRegisterStg getPushRegisterStg(VisualPushRegister register) { | 1078 | public BinaryRegisterStg getPushRegisterStg(VisualPushRegister register) { |
1569 | 1076 | return pushRegisterMap.get(register); | 1079 | return ((pushRegisterMap == null) ? null : pushRegisterMap.get(register)); |
1570 | 1080 | } | ||
1571 | 1081 | |||
1572 | 1082 | public void putPushRegisterStg(VisualPushRegister register, BinaryRegisterStg stg) { | ||
1573 | 1083 | if (pushRegisterMap == null) { | ||
1574 | 1084 | pushRegisterMap = new HashMap<>(); | ||
1575 | 1085 | } | ||
1576 | 1086 | pushRegisterMap.put(register, stg); | ||
1577 | 1077 | } | 1087 | } |
1578 | 1078 | 1088 | ||
1579 | 1079 | 1089 | ||
1580 | @@ -1084,20 +1094,20 @@ | |||
1581 | 1084 | private void connectPopRegisterStg(VisualPopRegister r) throws InvalidConnectionException { | 1094 | private void connectPopRegisterStg(VisualPopRegister r) throws InvalidConnectionException { |
1582 | 1085 | BinaryRegisterStg rstg = getPopRegisterStg(r); | 1095 | BinaryRegisterStg rstg = getPopRegisterStg(r); |
1583 | 1086 | // preset | 1096 | // preset |
1585 | 1087 | for (VisualLogic n: dfs.getPreset(r, VisualLogic.class)) { | 1097 | for (VisualLogic n: getDfsModel().getPreset(r, VisualLogic.class)) { |
1586 | 1088 | LogicStg nstg = getLogicStg(n); | 1098 | LogicStg nstg = getLogicStg(n); |
1587 | 1089 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); | 1099 | createReadArcs(nstg.C1, rstg.tMRs.values(), true); |
1588 | 1090 | createReadArc(nstg.C0, rstg.tMF, false); | 1100 | createReadArc(nstg.C0, rstg.tMF, false); |
1589 | 1091 | } | 1101 | } |
1590 | 1092 | // R-preset | 1102 | // R-preset |
1592 | 1093 | for (VisualRegister n: dfs.getRPreset(r, VisualRegister.class)) { | 1103 | for (VisualRegister n: getDfsModel().getRPreset(r, VisualRegister.class)) { |
1593 | 1094 | RegisterStg nstg = getRegisterStg(n); | 1104 | RegisterStg nstg = getRegisterStg(n); |
1594 | 1095 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 1105 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1595 | 1096 | createReadArc(nstg.M0, rstg.tMF, false); | 1106 | createReadArc(nstg.M0, rstg.tMF, false); |
1596 | 1097 | } | 1107 | } |
1598 | 1098 | for (VisualControlRegister n: dfs.getRPreset(r, VisualControlRegister.class)) { | 1108 | for (VisualControlRegister n: getDfsModel().getRPreset(r, VisualControlRegister.class)) { |
1599 | 1099 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 1109 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1601 | 1100 | Connection connection = dfs.getConnection(n, r); | 1110 | Connection connection = getDfsModel().getConnection(n, r); |
1602 | 1101 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { | 1111 | if (connection instanceof VisualControlConnection && ((VisualControlConnection)connection).getReferencedControlConnection().isInverting()) { |
1603 | 1102 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); | 1112 | createReadArc(nstg.tM1, rstg.fMRs.get(n), true); |
1604 | 1103 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); | 1113 | createReadArc(nstg.fM1, rstg.tMRs.get(n), true); |
1605 | @@ -1110,39 +1120,39 @@ | |||
1606 | 1110 | createReadArc(nstg.fM0, rstg.fMF, false); | 1120 | createReadArc(nstg.fM0, rstg.fMF, false); |
1607 | 1111 | } | 1121 | } |
1608 | 1112 | } | 1122 | } |
1610 | 1113 | for (VisualPushRegister n: dfs.getRPreset(r, VisualPushRegister.class)) { | 1123 | for (VisualPushRegister n: getDfsModel().getRPreset(r, VisualPushRegister.class)) { |
1611 | 1114 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 1124 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1612 | 1115 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); | 1125 | createReadArcs(nstg.tM1, rstg.tMRs.values(), true); |
1613 | 1116 | createReadArc(nstg.tM0, rstg.tMF, false); | 1126 | createReadArc(nstg.tM0, rstg.tMF, false); |
1614 | 1117 | } | 1127 | } |
1616 | 1118 | for (VisualPopRegister n: dfs.getRPreset(r, VisualPopRegister.class)) { | 1128 | for (VisualPopRegister n: getDfsModel().getRPreset(r, VisualPopRegister.class)) { |
1617 | 1119 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 1129 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1618 | 1120 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); | 1130 | createReadArcs(nstg.M1, rstg.tMRs.values(), true); |
1619 | 1121 | createReadArc(nstg.M0, rstg.tMF, false); | 1131 | createReadArc(nstg.M0, rstg.tMF, false); |
1620 | 1122 | } | 1132 | } |
1621 | 1123 | // R-postset | 1133 | // R-postset |
1623 | 1124 | for (VisualRegister n: dfs.getRPostset(r, VisualRegister.class)) { | 1134 | for (VisualRegister n: getDfsModel().getRPostset(r, VisualRegister.class)) { |
1624 | 1125 | RegisterStg nstg = getRegisterStg(n); | 1135 | RegisterStg nstg = getRegisterStg(n); |
1625 | 1126 | createReadArc(nstg.M1, rstg.tMF, false); | 1136 | createReadArc(nstg.M1, rstg.tMF, false); |
1626 | 1127 | createReadArc(nstg.M1, rstg.fMF, false); | 1137 | createReadArc(nstg.M1, rstg.fMF, false); |
1627 | 1128 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 1138 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1628 | 1129 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 1139 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1629 | 1130 | } | 1140 | } |
1631 | 1131 | for (VisualControlRegister n: dfs.getRPostset(r, VisualControlRegister.class)) { | 1141 | for (VisualControlRegister n: getDfsModel().getRPostset(r, VisualControlRegister.class)) { |
1632 | 1132 | BinaryRegisterStg nstg = getControlRegisterStg(n); | 1142 | BinaryRegisterStg nstg = getControlRegisterStg(n); |
1633 | 1133 | createReadArc(nstg.M1, rstg.tMF, false); | 1143 | createReadArc(nstg.M1, rstg.tMF, false); |
1634 | 1134 | createReadArc(nstg.M1, rstg.fMF, false); | 1144 | createReadArc(nstg.M1, rstg.fMF, false); |
1635 | 1135 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 1145 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1636 | 1136 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 1146 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1637 | 1137 | } | 1147 | } |
1639 | 1138 | for (VisualPushRegister n: dfs.getRPostset(r, VisualPushRegister.class)) { | 1148 | for (VisualPushRegister n: getDfsModel().getRPostset(r, VisualPushRegister.class)) { |
1640 | 1139 | BinaryRegisterStg nstg = getPushRegisterStg(n); | 1149 | BinaryRegisterStg nstg = getPushRegisterStg(n); |
1641 | 1140 | createReadArc(nstg.M1, rstg.tMF, false); | 1150 | createReadArc(nstg.M1, rstg.tMF, false); |
1642 | 1141 | createReadArc(nstg.M1, rstg.fMF, false); | 1151 | createReadArc(nstg.M1, rstg.fMF, false); |
1643 | 1142 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); | 1152 | createReadArcs(nstg.M0, rstg.tMRs.values(), false); |
1644 | 1143 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); | 1153 | createReadArcs(nstg.M0, rstg.fMRs.values(), false); |
1645 | 1144 | } | 1154 | } |
1647 | 1145 | for (VisualPopRegister n: dfs.getRPostset(r, VisualPopRegister.class)) { | 1155 | for (VisualPopRegister n: getDfsModel().getRPostset(r, VisualPopRegister.class)) { |
1648 | 1146 | BinaryRegisterStg nstg = getPopRegisterStg(n); | 1156 | BinaryRegisterStg nstg = getPopRegisterStg(n); |
1649 | 1147 | createReadArc(nstg.tM1, rstg.tMF, false); | 1157 | createReadArc(nstg.tM1, rstg.tMF, false); |
1650 | 1148 | createReadArc(nstg.tM1, rstg.fMF, false); | 1158 | createReadArc(nstg.tM1, rstg.fMF, false); |
1651 | @@ -1152,8 +1162,16 @@ | |||
1652 | 1152 | } | 1162 | } |
1653 | 1153 | 1163 | ||
1654 | 1154 | public BinaryRegisterStg getPopRegisterStg(VisualPopRegister register) { | 1164 | public BinaryRegisterStg getPopRegisterStg(VisualPopRegister register) { |
1657 | 1155 | return popRegisterMap.get(register); | 1165 | return ((popRegisterMap == null) ? null : popRegisterMap.get(register)); |
1658 | 1156 | } | 1166 | } |
1659 | 1167 | |||
1660 | 1168 | public void putPopRegisterStg(VisualPopRegister register, BinaryRegisterStg stg) { | ||
1661 | 1169 | if (popRegisterMap == null) { | ||
1662 | 1170 | popRegisterMap = new HashMap<>(); | ||
1663 | 1171 | } | ||
1664 | 1172 | popRegisterMap.put(register, stg); | ||
1665 | 1173 | } | ||
1666 | 1174 | |||
1667 | 1157 | 1175 | ||
1668 | 1158 | public boolean isRelated(Node highLevelNode, Node node) { | 1176 | public boolean isRelated(Node highLevelNode, Node node) { |
1669 | 1159 | NodeStg nodeStg = null; | 1177 | NodeStg nodeStg = null; |
1670 | 1160 | 1178 | ||
1671 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java' | |||
1672 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2015-04-30 23:14:48 +0000 | |||
1673 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2015-09-25 14:54:20 +0000 | |||
1674 | @@ -43,7 +43,7 @@ | |||
1675 | 43 | final Framework framework = Framework.getInstance(); | 43 | final Framework framework = Framework.getInstance(); |
1676 | 44 | try { | 44 | try { |
1677 | 45 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); | 45 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
1679 | 46 | STGModel model = (STGModel)generator.getStg().getMathModel(); | 46 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
1680 | 47 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); | 47 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
1681 | 48 | if (exporter == null) { | 48 | if (exporter == null) { |
1682 | 49 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); | 49 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
1683 | 50 | 50 | ||
1684 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java' | |||
1685 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2015-04-30 23:14:48 +0000 | |||
1686 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2015-09-25 14:54:20 +0000 | |||
1687 | @@ -43,7 +43,7 @@ | |||
1688 | 43 | final Framework framework = Framework.getInstance(); | 43 | final Framework framework = Framework.getInstance(); |
1689 | 44 | try { | 44 | try { |
1690 | 45 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); | 45 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
1692 | 46 | STGModel model = (STGModel)generator.getStg().getMathModel(); | 46 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
1693 | 47 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); | 47 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
1694 | 48 | if (exporter == null) { | 48 | if (exporter == null) { |
1695 | 49 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); | 49 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
1696 | 50 | 50 | ||
1697 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java' | |||
1698 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2015-04-30 23:14:48 +0000 | |||
1699 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2015-09-25 14:54:20 +0000 | |||
1700 | @@ -48,7 +48,7 @@ | |||
1701 | 48 | final Framework framework = Framework.getInstance(); | 48 | final Framework framework = Framework.getInstance(); |
1702 | 49 | try { | 49 | try { |
1703 | 50 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); | 50 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
1705 | 51 | STGModel model = (STGModel)generator.getStg().getMathModel(); | 51 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
1706 | 52 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); | 52 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
1707 | 53 | if (exporter == null) { | 53 | if (exporter == null) { |
1708 | 54 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); | 54 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
1709 | 55 | 55 | ||
1710 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java' | |||
1711 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-08-27 21:29:15 +0000 | |||
1712 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-09-25 14:54:20 +0000 | |||
1713 | @@ -64,7 +64,7 @@ | |||
1714 | 64 | @Override | 64 | @Override |
1715 | 65 | public VisualModel getUnderlyingModel(VisualModel model) { | 65 | public VisualModel getUnderlyingModel(VisualModel model) { |
1716 | 66 | generator = new StgGenerator((VisualDfs)model); | 66 | generator = new StgGenerator((VisualDfs)model); |
1718 | 67 | return generator.getStg(); | 67 | return generator.getStgModel(); |
1719 | 68 | } | 68 | } |
1720 | 69 | 69 | ||
1721 | 70 | private VisualPlace getVisualPlace(Place place) { | 70 | private VisualPlace getVisualPlace(Place place) { |
1722 | 71 | 71 | ||
1723 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/StgGeneratorTool.java' | |||
1724 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tools/StgGeneratorTool.java 2015-07-30 15:45:39 +0000 | |||
1725 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/StgGeneratorTool.java 2015-09-25 14:54:20 +0000 | |||
1726 | @@ -37,7 +37,7 @@ | |||
1727 | 37 | final Workspace workspace = framework.getWorkspace(); | 37 | final Workspace workspace = framework.getWorkspace(); |
1728 | 38 | final Path<String> directory = we.getWorkspacePath().getParent(); | 38 | final Path<String> directory = we.getWorkspacePath().getParent(); |
1729 | 39 | final String desiredName = we.getWorkspacePath().getNode(); | 39 | final String desiredName = we.getWorkspacePath().getNode(); |
1731 | 40 | final ModelEntry me = new ModelEntry(new StgDescriptor(), generator.getStg()); | 40 | final ModelEntry me = new ModelEntry(new StgDescriptor(), generator.getStgModel()); |
1732 | 41 | boolean openInEditor = (me.isVisual() || CommonEditorSettings.getOpenNonvisual()); | 41 | boolean openInEditor = (me.isVisual() || CommonEditorSettings.getOpenNonvisual()); |
1733 | 42 | workspace.add(directory, desiredName, me, false, openInEditor); | 42 | workspace.add(directory, desiredName, me, false, openInEditor); |
1734 | 43 | } | 43 | } |
1735 | 44 | 44 | ||
1736 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java' | |||
1737 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2015-08-03 12:45:13 +0000 | |||
1738 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2015-09-25 14:54:20 +0000 | |||
1739 | @@ -34,7 +34,7 @@ | |||
1740 | 34 | 34 | ||
1741 | 35 | @Override | 35 | @Override |
1742 | 36 | public Result<? extends ExternalProcessResult> run(ProgressMonitor<? super ExternalProcessResult> monitor) { | 36 | public Result<? extends ExternalProcessResult> run(ProgressMonitor<? super ExternalProcessResult> monitor) { |
1744 | 37 | ArrayList<String> command = new ArrayList<String>(); | 37 | ArrayList<String> command = new ArrayList<>(); |
1745 | 38 | // Name of the executable | 38 | // Name of the executable |
1746 | 39 | command.add(MpsatUtilitySettings.getCommand() + MpsatUtilitySettings.getCommandSuffix(tryPnml)); | 39 | command.add(MpsatUtilitySettings.getCommand() + MpsatUtilitySettings.getCommandSuffix(tryPnml)); |
1747 | 40 | // Built-in arguments | 40 | // Built-in arguments |
1748 | 41 | 41 | ||
1749 | === modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java' | |||
1750 | --- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-09-10 22:34:47 +0000 | |||
1751 | +++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-09-25 14:54:20 +0000 | |||
1752 | @@ -48,6 +48,7 @@ | |||
1753 | 48 | import javax.swing.JButton; | 48 | import javax.swing.JButton; |
1754 | 49 | import javax.swing.JLabel; | 49 | import javax.swing.JLabel; |
1755 | 50 | import javax.swing.JPanel; | 50 | import javax.swing.JPanel; |
1756 | 51 | import javax.swing.JScrollBar; | ||
1757 | 51 | import javax.swing.JScrollPane; | 52 | import javax.swing.JScrollPane; |
1758 | 52 | import javax.swing.JSeparator; | 53 | import javax.swing.JSeparator; |
1759 | 53 | import javax.swing.JSlider; | 54 | import javax.swing.JSlider; |
1760 | @@ -70,6 +71,7 @@ | |||
1761 | 70 | import org.workcraft.dom.visual.HitMan; | 71 | import org.workcraft.dom.visual.HitMan; |
1762 | 71 | import org.workcraft.dom.visual.VisualGroup; | 72 | import org.workcraft.dom.visual.VisualGroup; |
1763 | 72 | import org.workcraft.dom.visual.VisualModel; | 73 | import org.workcraft.dom.visual.VisualModel; |
1764 | 74 | import org.workcraft.dom.visual.VisualNode; | ||
1765 | 73 | import org.workcraft.dom.visual.VisualPage; | 75 | import org.workcraft.dom.visual.VisualPage; |
1766 | 74 | import org.workcraft.dom.visual.connections.VisualConnection; | 76 | import org.workcraft.dom.visual.connections.VisualConnection; |
1767 | 75 | import org.workcraft.gui.Coloriser; | 77 | import org.workcraft.gui.Coloriser; |
1768 | @@ -88,6 +90,7 @@ | |||
1769 | 88 | import org.workcraft.plugins.petri.Transition; | 90 | import org.workcraft.plugins.petri.Transition; |
1770 | 89 | import org.workcraft.plugins.petri.VisualPetriNet; | 91 | import org.workcraft.plugins.petri.VisualPetriNet; |
1771 | 90 | import org.workcraft.plugins.petri.VisualPlace; | 92 | import org.workcraft.plugins.petri.VisualPlace; |
1772 | 93 | import org.workcraft.plugins.petri.VisualReplicaPlace; | ||
1773 | 91 | import org.workcraft.plugins.petri.VisualTransition; | 94 | import org.workcraft.plugins.petri.VisualTransition; |
1774 | 92 | import org.workcraft.plugins.shared.CommonSimulationSettings; | 95 | import org.workcraft.plugins.shared.CommonSimulationSettings; |
1775 | 93 | import org.workcraft.util.ColorGenerator; | 96 | import org.workcraft.util.ColorGenerator; |
1776 | @@ -213,6 +216,7 @@ | |||
1777 | 213 | timer.start(); | 216 | timer.start(); |
1778 | 214 | } | 217 | } |
1779 | 215 | updateState(editor); | 218 | updateState(editor); |
1780 | 219 | editor.requestFocus(); | ||
1781 | 216 | } | 220 | } |
1782 | 217 | }); | 221 | }); |
1783 | 218 | 222 | ||
1784 | @@ -236,6 +240,7 @@ | |||
1785 | 236 | random = true; | 240 | random = true; |
1786 | 237 | } | 241 | } |
1787 | 238 | updateState(editor); | 242 | updateState(editor); |
1788 | 243 | editor.requestFocus(); | ||
1789 | 239 | } | 244 | } |
1790 | 240 | }); | 245 | }); |
1791 | 241 | 246 | ||
1792 | @@ -259,6 +264,7 @@ | |||
1793 | 259 | random = false; | 264 | random = false; |
1794 | 260 | } | 265 | } |
1795 | 261 | updateState(editor); | 266 | updateState(editor); |
1796 | 267 | editor.requestFocus(); | ||
1797 | 262 | } | 268 | } |
1798 | 263 | }); | 269 | }); |
1799 | 264 | 270 | ||
1800 | @@ -266,6 +272,7 @@ | |||
1801 | 266 | @Override | 272 | @Override |
1802 | 267 | public void actionPerformed(ActionEvent e) { | 273 | public void actionPerformed(ActionEvent e) { |
1803 | 268 | clearTraces(editor); | 274 | clearTraces(editor); |
1804 | 275 | editor.requestFocus(); | ||
1805 | 269 | } | 276 | } |
1806 | 270 | }); | 277 | }); |
1807 | 271 | 278 | ||
1808 | @@ -273,6 +280,7 @@ | |||
1809 | 273 | @Override | 280 | @Override |
1810 | 274 | public void actionPerformed(ActionEvent e) { | 281 | public void actionPerformed(ActionEvent e) { |
1811 | 275 | stepBack(editor); | 282 | stepBack(editor); |
1812 | 283 | editor.requestFocus(); | ||
1813 | 276 | } | 284 | } |
1814 | 277 | }); | 285 | }); |
1815 | 278 | 286 | ||
1816 | @@ -280,6 +288,7 @@ | |||
1817 | 280 | @Override | 288 | @Override |
1818 | 281 | public void actionPerformed(ActionEvent e) { | 289 | public void actionPerformed(ActionEvent e) { |
1819 | 282 | step(editor); | 290 | step(editor); |
1820 | 291 | editor.requestFocus(); | ||
1821 | 283 | } | 292 | } |
1822 | 284 | }); | 293 | }); |
1823 | 285 | 294 | ||
1824 | @@ -287,6 +296,7 @@ | |||
1825 | 287 | @Override | 296 | @Override |
1826 | 288 | public void actionPerformed(ActionEvent e) { | 297 | public void actionPerformed(ActionEvent e) { |
1827 | 289 | copyState(editor); | 298 | copyState(editor); |
1828 | 299 | editor.requestFocus(); | ||
1829 | 290 | } | 300 | } |
1830 | 291 | }); | 301 | }); |
1831 | 292 | 302 | ||
1832 | @@ -294,6 +304,7 @@ | |||
1833 | 294 | @Override | 304 | @Override |
1834 | 295 | public void actionPerformed(ActionEvent e) { | 305 | public void actionPerformed(ActionEvent e) { |
1835 | 296 | pasteState(editor); | 306 | pasteState(editor); |
1836 | 307 | editor.requestFocus(); | ||
1837 | 297 | } | 308 | } |
1838 | 298 | }); | 309 | }); |
1839 | 299 | 310 | ||
1840 | @@ -301,6 +312,7 @@ | |||
1841 | 301 | @Override | 312 | @Override |
1842 | 302 | public void actionPerformed(ActionEvent e) { | 313 | public void actionPerformed(ActionEvent e) { |
1843 | 303 | mergeTrace(editor); | 314 | mergeTrace(editor); |
1844 | 315 | editor.requestFocus(); | ||
1845 | 304 | } | 316 | } |
1846 | 305 | }); | 317 | }); |
1847 | 306 | 318 | ||
1848 | @@ -308,6 +320,7 @@ | |||
1849 | 308 | @Override | 320 | @Override |
1850 | 309 | public void actionPerformed(ActionEvent e) { | 321 | public void actionPerformed(ActionEvent e) { |
1851 | 310 | saveInitState(editor); | 322 | saveInitState(editor); |
1852 | 323 | editor.requestFocus(); | ||
1853 | 311 | } | 324 | } |
1854 | 312 | }); | 325 | }); |
1855 | 313 | 326 | ||
1856 | @@ -341,6 +354,7 @@ | |||
1857 | 341 | } | 354 | } |
1858 | 342 | } | 355 | } |
1859 | 343 | updateState(editor); | 356 | updateState(editor); |
1860 | 357 | editor.requestFocus(); | ||
1861 | 344 | } | 358 | } |
1862 | 345 | 359 | ||
1863 | 346 | @Override | 360 | @Override |
1864 | @@ -432,9 +446,13 @@ | |||
1865 | 432 | backwardButton.setEnabled((mainTrace.getPosition() > 0) || (branchTrace.getPosition() > 0)); | 446 | backwardButton.setEnabled((mainTrace.getPosition() > 0) || (branchTrace.getPosition() > 0)); |
1866 | 433 | forwardButton.setEnabled(branchTrace.canProgress() || (branchTrace.isEmpty() && mainTrace.canProgress())); | 447 | forwardButton.setEnabled(branchTrace.canProgress() || (branchTrace.isEmpty() && mainTrace.canProgress())); |
1867 | 434 | traceTable.tableChanged(new TableModelEvent(traceTable.getModel())); | 448 | traceTable.tableChanged(new TableModelEvent(traceTable.getModel())); |
1868 | 435 | editor.requestFocus(); | ||
1869 | 436 | editor.repaint(); | 449 | editor.repaint(); |
1870 | 437 | } | 450 | } |
1871 | 451 | |||
1872 | 452 | public void scrollTraceToBottom() { | ||
1873 | 453 | JScrollBar verticalScrollBar = tracePane.getVerticalScrollBar(); | ||
1874 | 454 | verticalScrollBar.setValue(verticalScrollBar.getMaximum()); | ||
1875 | 455 | } | ||
1876 | 438 | 456 | ||
1877 | 439 | private boolean quietStepBack() { | 457 | private boolean quietStepBack() { |
1878 | 440 | excitedContainers.clear(); | 458 | excitedContainers.clear(); |
1879 | @@ -786,11 +804,11 @@ | |||
1880 | 786 | if (t == null) return; | 804 | if (t == null) return; |
1881 | 787 | 805 | ||
1882 | 788 | String transitionId = null; | 806 | String transitionId = null; |
1884 | 789 | // if clicked on the trace event, do the step forward | 807 | // If clicked on the trace event, do the step forward. |
1885 | 790 | if (branchTrace.isEmpty() && !mainTrace.isEmpty() && (mainTrace.getPosition() < mainTrace.size())) { | 808 | if (branchTrace.isEmpty() && !mainTrace.isEmpty() && (mainTrace.getPosition() < mainTrace.size())) { |
1886 | 791 | transitionId = mainTrace.get(mainTrace.getPosition()); | 809 | transitionId = mainTrace.get(mainTrace.getPosition()); |
1887 | 792 | } | 810 | } |
1889 | 793 | // otherwise form/use the branch trace | 811 | // Otherwise form/use the branch trace. |
1890 | 794 | if (!branchTrace.isEmpty() && (branchTrace.getPosition() < branchTrace.size())) { | 812 | if (!branchTrace.isEmpty() && (branchTrace.getPosition() < branchTrace.size())) { |
1891 | 795 | transitionId = branchTrace.get(branchTrace.getPosition()); | 813 | transitionId = branchTrace.get(branchTrace.getPosition()); |
1892 | 796 | } | 814 | } |
1893 | @@ -806,7 +824,7 @@ | |||
1894 | 806 | } | 824 | } |
1895 | 807 | branchTrace.add(net.getNodeReference(t)); | 825 | branchTrace.add(net.getNodeReference(t)); |
1896 | 808 | step(editor); | 826 | step(editor); |
1898 | 809 | return; | 827 | scrollTraceToBottom(); |
1899 | 810 | } | 828 | } |
1900 | 811 | 829 | ||
1901 | 812 | @Override | 830 | @Override |
1902 | @@ -897,7 +915,7 @@ | |||
1903 | 897 | @Override | 915 | @Override |
1904 | 898 | public Decoration getDecoration(Node node) { | 916 | public Decoration getDecoration(Node node) { |
1905 | 899 | 917 | ||
1907 | 900 | if(node instanceof VisualTransition) { | 918 | if (node instanceof VisualTransition) { |
1908 | 901 | Transition transition = ((VisualTransition)node).getReferencedTransition(); | 919 | Transition transition = ((VisualTransition)node).getReferencedTransition(); |
1909 | 902 | Node currentTraceTransition = getTraceCurrentNode(); | 920 | Node currentTraceTransition = getTraceCurrentNode(); |
1910 | 903 | if (transition == currentTraceTransition) { | 921 | if (transition == currentTraceTransition) { |
1911 | @@ -927,7 +945,7 @@ | |||
1912 | 927 | } | 945 | } |
1913 | 928 | } | 946 | } |
1914 | 929 | 947 | ||
1916 | 930 | if (node instanceof VisualPage || node instanceof VisualGroup) { | 948 | if ((node instanceof VisualPage) || (node instanceof VisualGroup)) { |
1917 | 931 | final boolean ret = isContainerExcited((Container)node); | 949 | final boolean ret = isContainerExcited((Container)node); |
1918 | 932 | return new ContainerDecoration() { | 950 | return new ContainerDecoration() { |
1919 | 933 | 951 | ||
1920 | @@ -947,12 +965,40 @@ | |||
1921 | 947 | } | 965 | } |
1922 | 948 | }; | 966 | }; |
1923 | 949 | } | 967 | } |
1924 | 968 | |||
1925 | 969 | if (node instanceof VisualConnection) { | ||
1926 | 970 | if (isArcExcited((VisualConnection)node)) { | ||
1927 | 971 | return new Decoration() { | ||
1928 | 972 | |||
1929 | 973 | @Override | ||
1930 | 974 | public Color getColorisation() { | ||
1931 | 975 | return CommonSimulationSettings.getEnabledForegroundColor(); | ||
1932 | 976 | } | ||
1933 | 977 | |||
1934 | 978 | @Override | ||
1935 | 979 | public Color getBackground() { | ||
1936 | 980 | return CommonSimulationSettings.getEnabledBackgroundColor(); | ||
1937 | 981 | } | ||
1938 | 982 | }; | ||
1939 | 983 | } | ||
1940 | 984 | } | ||
1941 | 950 | 985 | ||
1942 | 951 | return null; | 986 | return null; |
1943 | 952 | } | 987 | } |
1944 | 953 | }; | 988 | }; |
1945 | 954 | } | 989 | } |
1946 | 955 | 990 | ||
1947 | 991 | private boolean isArcExcited(VisualConnection connection) { | ||
1948 | 992 | VisualNode first = connection.getFirst(); | ||
1949 | 993 | Place place = null; | ||
1950 | 994 | if (first instanceof VisualPlace) { | ||
1951 | 995 | place = ((VisualPlace)first).getReferencedPlace(); | ||
1952 | 996 | } else if (first instanceof VisualReplicaPlace) { | ||
1953 | 997 | place = ((VisualReplicaPlace)first).getReferencedPlace(); | ||
1954 | 998 | } | ||
1955 | 999 | return ((place != null) && (place.getTokens() > 0)); | ||
1956 | 1000 | } | ||
1957 | 1001 | |||
1958 | 956 | @Override | 1002 | @Override |
1959 | 957 | public void lostOwnership(Clipboard clip, Transferable arg) { | 1003 | public void lostOwnership(Clipboard clip, Transferable arg) { |
1960 | 958 | } | 1004 | } |
1961 | 959 | 1005 | ||
1962 | === modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java' | |||
1963 | --- SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java 2015-09-14 20:30:27 +0000 | |||
1964 | +++ SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java 2015-09-25 14:54:20 +0000 | |||
1965 | @@ -215,6 +215,7 @@ | |||
1966 | 215 | timer = null; | 215 | timer = null; |
1967 | 216 | } | 216 | } |
1968 | 217 | updateState(editor); | 217 | updateState(editor); |
1969 | 218 | editor.requestFocus(); | ||
1970 | 218 | } | 219 | } |
1971 | 219 | }); | 220 | }); |
1972 | 220 | 221 | ||
1973 | @@ -248,6 +249,7 @@ | |||
1974 | 248 | setDecoration(simuAlg.getEnabledNodes(sync, phases, isRev)); | 249 | setDecoration(simuAlg.getEnabledNodes(sync, phases, isRev)); |
1975 | 249 | excitedContainers.clear(); | 250 | excitedContainers.clear(); |
1976 | 250 | updateState(editor); | 251 | updateState(editor); |
1977 | 252 | editor.requestFocus(); | ||
1978 | 251 | } | 253 | } |
1979 | 252 | }); | 254 | }); |
1980 | 253 | 255 | ||
1981 | @@ -320,6 +322,7 @@ | |||
1982 | 320 | } | 322 | } |
1983 | 321 | } | 323 | } |
1984 | 322 | updateState(editor); | 324 | updateState(editor); |
1985 | 325 | editor.requestFocus(); | ||
1986 | 323 | } | 326 | } |
1987 | 324 | 327 | ||
1988 | 325 | @Override | 328 | @Override |
1989 | @@ -360,6 +363,7 @@ | |||
1990 | 360 | net.resetConditionErrStates(); | 363 | net.resetConditionErrStates(); |
1991 | 361 | } | 364 | } |
1992 | 362 | updateState(editor); | 365 | updateState(editor); |
1993 | 366 | editor.requestFocus(); | ||
1994 | 363 | editor.forceRedraw(); | 367 | editor.forceRedraw(); |
1995 | 364 | editor.getModel().setTemplateNode(null); | 368 | editor.getModel().setTemplateNode(null); |
1996 | 365 | } | 369 | } |
1997 | @@ -418,8 +422,6 @@ | |||
1998 | 418 | reverseButton.setIcon(GUI.createIconFromSVG("images/icons/svg/son-reverse-simulation.svg")); | 422 | reverseButton.setIcon(GUI.createIconFromSVG("images/icons/svg/son-reverse-simulation.svg")); |
1999 | 419 | reverseButton.setToolTipText("Switch to forward simulation"); | 423 | reverseButton.setToolTipText("Switch to forward simulation"); |
2000 | 420 | } | 424 | } |
2001 | 421 | |||
2002 | 422 | editor.requestFocus(); | ||
2003 | 423 | editor.repaint(); | 425 | editor.repaint(); |
2004 | 424 | } | 426 | } |
2005 | 425 | 427 | ||
2006 | 426 | 428 | ||
2007 | === added directory 'STGPlugin/src/org/workcraft/plugins/stg/generator' | |||
2008 | === added file 'STGPlugin/src/org/workcraft/plugins/stg/generator/NodeStg.java' | |||
2009 | --- STGPlugin/src/org/workcraft/plugins/stg/generator/NodeStg.java 1970-01-01 00:00:00 +0000 | |||
2010 | +++ STGPlugin/src/org/workcraft/plugins/stg/generator/NodeStg.java 2015-09-25 14:54:20 +0000 | |||
2011 | @@ -0,0 +1,38 @@ | |||
2012 | 1 | package org.workcraft.plugins.stg.generator; | ||
2013 | 2 | |||
2014 | 3 | import java.util.Collection; | ||
2015 | 4 | import java.util.HashSet; | ||
2016 | 5 | |||
2017 | 6 | import org.workcraft.dom.Node; | ||
2018 | 7 | import org.workcraft.plugins.petri.VisualPlace; | ||
2019 | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
2020 | 9 | |||
2021 | 10 | public abstract class NodeStg { | ||
2022 | 11 | public abstract Collection<VisualSignalTransition> getAllTransitions(); | ||
2023 | 12 | |||
2024 | 13 | public abstract Collection<VisualPlace> getAllPlaces(); | ||
2025 | 14 | |||
2026 | 15 | public Collection<Node> getAllNodes() { | ||
2027 | 16 | HashSet<Node> result = new HashSet<>(); | ||
2028 | 17 | result.addAll(getAllPlaces()); | ||
2029 | 18 | result.addAll(getAllTransitions()); | ||
2030 | 19 | return result; | ||
2031 | 20 | } | ||
2032 | 21 | |||
2033 | 22 | public boolean contains(Node n) { | ||
2034 | 23 | if (n != null) { | ||
2035 | 24 | for (VisualPlace p: getAllPlaces()) { | ||
2036 | 25 | if ((n == p) || ((p != null) && (n == p.getReferencedPlace()))) { | ||
2037 | 26 | return true; | ||
2038 | 27 | } | ||
2039 | 28 | } | ||
2040 | 29 | for (VisualSignalTransition t: getAllTransitions()) { | ||
2041 | 30 | if ((n == t) || ((t != null) && (n == t.getReferencedTransition()))) { | ||
2042 | 31 | return true; | ||
2043 | 32 | } | ||
2044 | 33 | } | ||
2045 | 34 | } | ||
2046 | 35 | return false; | ||
2047 | 36 | } | ||
2048 | 37 | |||
2049 | 38 | } | ||
2050 | 0 | 39 | ||
2051 | === added file 'STGPlugin/src/org/workcraft/plugins/stg/generator/SignalStg.java' | |||
2052 | --- STGPlugin/src/org/workcraft/plugins/stg/generator/SignalStg.java 1970-01-01 00:00:00 +0000 | |||
2053 | +++ STGPlugin/src/org/workcraft/plugins/stg/generator/SignalStg.java 2015-09-25 14:54:20 +0000 | |||
2054 | @@ -0,0 +1,52 @@ | |||
2055 | 1 | package org.workcraft.plugins.stg.generator; | ||
2056 | 2 | |||
2057 | 3 | import java.util.ArrayList; | ||
2058 | 4 | import java.util.Arrays; | ||
2059 | 5 | import java.util.Collection; | ||
2060 | 6 | import java.util.HashSet; | ||
2061 | 7 | import java.util.List; | ||
2062 | 8 | |||
2063 | 9 | import org.workcraft.plugins.petri.VisualPlace; | ||
2064 | 10 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
2065 | 11 | |||
2066 | 12 | public class SignalStg extends NodeStg { | ||
2067 | 13 | public final VisualPlace zero; | ||
2068 | 14 | public final VisualPlace one; | ||
2069 | 15 | public final ArrayList<VisualSignalTransition> fallList = new ArrayList<>(); | ||
2070 | 16 | public final ArrayList<VisualSignalTransition> riseList = new ArrayList<>(); | ||
2071 | 17 | |||
2072 | 18 | public SignalStg(VisualPlace zero, VisualPlace one) { | ||
2073 | 19 | this.zero = zero; | ||
2074 | 20 | this.one = one; | ||
2075 | 21 | } | ||
2076 | 22 | |||
2077 | 23 | public SignalStg(VisualPlace zero, VisualPlace one, VisualSignalTransition fall, VisualSignalTransition rise) { | ||
2078 | 24 | this.zero = zero; | ||
2079 | 25 | this.one = one; | ||
2080 | 26 | this.fallList.add(fall); | ||
2081 | 27 | this.riseList.add(rise); | ||
2082 | 28 | } | ||
2083 | 29 | |||
2084 | 30 | public SignalStg(VisualPlace zero, VisualPlace one, ArrayList<VisualSignalTransition> fallList, ArrayList<VisualSignalTransition> riseList) { | ||
2085 | 31 | this.zero = zero; | ||
2086 | 32 | this.one = one; | ||
2087 | 33 | this.fallList.addAll(fallList); | ||
2088 | 34 | this.riseList.addAll(riseList); | ||
2089 | 35 | } | ||
2090 | 36 | |||
2091 | 37 | @Override | ||
2092 | 38 | public Collection<VisualSignalTransition> getAllTransitions() { | ||
2093 | 39 | HashSet<VisualSignalTransition> tmp = new HashSet<>(); | ||
2094 | 40 | tmp.addAll(fallList); | ||
2095 | 41 | tmp.addAll(riseList); | ||
2096 | 42 | List<VisualSignalTransition> result = new ArrayList<>(); | ||
2097 | 43 | result.addAll(tmp); | ||
2098 | 44 | return result; | ||
2099 | 45 | } | ||
2100 | 46 | |||
2101 | 47 | @Override | ||
2102 | 48 | public Collection<VisualPlace> getAllPlaces() { | ||
2103 | 49 | return Arrays.asList(zero, one); | ||
2104 | 50 | } | ||
2105 | 51 | |||
2106 | 52 | } | ||
2107 | 0 | 53 | ||
2108 | === added file 'STGPlugin/src/org/workcraft/plugins/stg/generator/StgGenerator.java' | |||
2109 | --- STGPlugin/src/org/workcraft/plugins/stg/generator/StgGenerator.java 1970-01-01 00:00:00 +0000 | |||
2110 | +++ STGPlugin/src/org/workcraft/plugins/stg/generator/StgGenerator.java 2015-09-25 14:54:20 +0000 | |||
2111 | @@ -0,0 +1,294 @@ | |||
2112 | 1 | package org.workcraft.plugins.stg.generator; | ||
2113 | 2 | |||
2114 | 3 | import java.awt.geom.AffineTransform; | ||
2115 | 4 | import java.awt.geom.Point2D; | ||
2116 | 5 | import java.util.ArrayList; | ||
2117 | 6 | import java.util.Arrays; | ||
2118 | 7 | import java.util.Collection; | ||
2119 | 8 | import java.util.HashSet; | ||
2120 | 9 | import java.util.List; | ||
2121 | 10 | |||
2122 | 11 | import org.workcraft.dom.Container; | ||
2123 | 12 | import org.workcraft.dom.Node; | ||
2124 | 13 | import org.workcraft.dom.visual.Movable; | ||
2125 | 14 | import org.workcraft.dom.visual.Positioning; | ||
2126 | 15 | import org.workcraft.dom.visual.TransformHelper; | ||
2127 | 16 | import org.workcraft.dom.visual.VisualComponent; | ||
2128 | 17 | import org.workcraft.dom.visual.VisualModel; | ||
2129 | 18 | import org.workcraft.dom.visual.connections.VisualConnection; | ||
2130 | 19 | import org.workcraft.exceptions.InvalidConnectionException; | ||
2131 | 20 | import org.workcraft.plugins.petri.VisualPlace; | ||
2132 | 21 | import org.workcraft.plugins.petri.VisualReplicaPlace; | ||
2133 | 22 | import org.workcraft.plugins.stg.STG; | ||
2134 | 23 | import org.workcraft.plugins.stg.SignalTransition; | ||
2135 | 24 | import org.workcraft.plugins.stg.VisualSTG; | ||
2136 | 25 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
2137 | 26 | import org.workcraft.util.Hierarchy; | ||
2138 | 27 | |||
2139 | 28 | abstract public class StgGenerator { | ||
2140 | 29 | |||
2141 | 30 | public enum SignalLayoutType { LEFT_TO_RIGHT, RIGHT_TO_LEFT, LEFT_TO_RIGHT_INVERTED, RIGHT_TO_LEFT_INVERTED } | ||
2142 | 31 | |||
2143 | 32 | public static final String _NAME0 = "_0"; | ||
2144 | 33 | public static final String _NAME1 = "_1"; | ||
2145 | 34 | |||
2146 | 35 | private final VisualModel src; | ||
2147 | 36 | private final VisualSTG stg; | ||
2148 | 37 | |||
2149 | 38 | public StgGenerator(VisualModel src) { | ||
2150 | 39 | this.src = src; | ||
2151 | 40 | this.stg = new VisualSTG(new STG()); | ||
2152 | 41 | convert(); | ||
2153 | 42 | } | ||
2154 | 43 | |||
2155 | 44 | public VisualModel getSrcModel() { | ||
2156 | 45 | return src; | ||
2157 | 46 | } | ||
2158 | 47 | |||
2159 | 48 | public VisualSTG getStgModel() { | ||
2160 | 49 | return stg; | ||
2161 | 50 | } | ||
2162 | 51 | |||
2163 | 52 | abstract public void convert(); | ||
2164 | 53 | |||
2165 | 54 | public void setPosition(Movable node, double x, double y) { | ||
2166 | 55 | TransformHelper.applyTransform(node, AffineTransform.getTranslateInstance(x, y)); | ||
2167 | 56 | } | ||
2168 | 57 | |||
2169 | 58 | |||
2170 | 59 | public VisualConnection createConsumingArc(VisualPlace p, VisualSignalTransition t) throws InvalidConnectionException { | ||
2171 | 60 | VisualConnection connection = null; | ||
2172 | 61 | if (p != null && t != null) { | ||
2173 | 62 | connection = stg.connect(p, t); | ||
2174 | 63 | } | ||
2175 | 64 | return connection; | ||
2176 | 65 | } | ||
2177 | 66 | |||
2178 | 67 | public VisualConnection createConsumingArc(VisualPlace p, VisualSignalTransition t, boolean propagateTokenColor) throws InvalidConnectionException { | ||
2179 | 68 | VisualConnection connection = null; | ||
2180 | 69 | if (p != null && t != null) { | ||
2181 | 70 | connection = stg.connect(p, t); | ||
2182 | 71 | connection.setTokenColorPropagator(propagateTokenColor); | ||
2183 | 72 | } | ||
2184 | 73 | return connection; | ||
2185 | 74 | } | ||
2186 | 75 | |||
2187 | 76 | |||
2188 | 77 | public VisualConnection createProducingArc(VisualSignalTransition t, VisualPlace p) throws InvalidConnectionException { | ||
2189 | 78 | VisualConnection connection = null; | ||
2190 | 79 | if (p != null && t != null) { | ||
2191 | 80 | connection = stg.connect(t, p); | ||
2192 | 81 | } | ||
2193 | 82 | return connection; | ||
2194 | 83 | } | ||
2195 | 84 | |||
2196 | 85 | public VisualConnection createProducingArc(VisualSignalTransition t, VisualPlace p, boolean propagateTokenColor) throws InvalidConnectionException { | ||
2197 | 86 | VisualConnection connection = null; | ||
2198 | 87 | if (p != null && t != null) { | ||
2199 | 88 | connection = stg.connect(t, p); | ||
2200 | 89 | connection.setTokenColorPropagator(propagateTokenColor); | ||
2201 | 90 | } | ||
2202 | 91 | return connection; | ||
2203 | 92 | } | ||
2204 | 93 | |||
2205 | 94 | public VisualConnection createReadArc(VisualPlace p, VisualSignalTransition t) throws InvalidConnectionException { | ||
2206 | 95 | VisualConnection connection = null; | ||
2207 | 96 | if (p != null && t != null) { | ||
2208 | 97 | connection = stg.connectUndirected(p, t); | ||
2209 | 98 | } | ||
2210 | 99 | return connection; | ||
2211 | 100 | } | ||
2212 | 101 | |||
2213 | 102 | public VisualConnection createReadArc(VisualPlace p, VisualSignalTransition t, boolean propagateTokenColor) throws InvalidConnectionException { | ||
2214 | 103 | VisualConnection connection = null; | ||
2215 | 104 | if (p != null && t != null) { | ||
2216 | 105 | connection = stg.connectUndirected(p, t); | ||
2217 | 106 | connection.setTokenColorPropagator(propagateTokenColor); | ||
2218 | 107 | } | ||
2219 | 108 | return connection; | ||
2220 | 109 | } | ||
2221 | 110 | |||
2222 | 111 | public void createReadArcs(VisualPlace p, Collection<VisualSignalTransition> ts) throws InvalidConnectionException { | ||
2223 | 112 | if (ts != null) { | ||
2224 | 113 | for (VisualSignalTransition t: ts) { | ||
2225 | 114 | stg.connectUndirected(p, t); | ||
2226 | 115 | } | ||
2227 | 116 | } | ||
2228 | 117 | } | ||
2229 | 118 | |||
2230 | 119 | public void createReadArcs(VisualPlace p, Collection<VisualSignalTransition> ts, boolean propagateTokenColor) throws InvalidConnectionException { | ||
2231 | 120 | for (VisualSignalTransition t : new HashSet<VisualSignalTransition>(ts)) { | ||
2232 | 121 | createReadArc(p, t, propagateTokenColor); | ||
2233 | 122 | } | ||
2234 | 123 | } | ||
2235 | 124 | |||
2236 | 125 | public void createReadArcsBetweenSignals(SignalStg from, SignalStg to) throws InvalidConnectionException { | ||
2237 | 126 | if ((from != null) && (to != null)) { | ||
2238 | 127 | createReadArcs(from.one, to.riseList); | ||
2239 | 128 | createReadArcs(from.zero, to.fallList); | ||
2240 | 129 | } | ||
2241 | 130 | } | ||
2242 | 131 | |||
2243 | 132 | |||
2244 | 133 | public void createReplicaReadArc(VisualPlace p, VisualSignalTransition t) throws InvalidConnectionException { | ||
2245 | 134 | double dx = ((p.getRootSpaceX() > t.getRootSpaceX()) ? 6.0 : -6.0); | ||
2246 | 135 | createReplicaReadArc(p, t, dx, 0.0); | ||
2247 | 136 | } | ||
2248 | 137 | |||
2249 | 138 | public void createReplicaReadArc(VisualPlace p, VisualSignalTransition t, double xOffset, double yOffset) throws InvalidConnectionException { | ||
2250 | 139 | Point2D replicaPosition = new Point2D.Double(t.getRootSpaceX() + xOffset, t.getRootSpaceY() + yOffset); | ||
2251 | 140 | createReplicaReadArcs(p, Arrays.asList(t), replicaPosition); | ||
2252 | 141 | } | ||
2253 | 142 | |||
2254 | 143 | public void createReplicaReadArcs(VisualPlace p, List<VisualSignalTransition> ts, double xOffset, double yOffset) throws InvalidConnectionException { | ||
2255 | 144 | if ((p != null) && (ts != null)) { | ||
2256 | 145 | VisualReplicaPlace replicaPlace = null; | ||
2257 | 146 | for (VisualSignalTransition t: ts) { | ||
2258 | 147 | if (replicaPlace == null) { | ||
2259 | 148 | Container container = Hierarchy.getNearestContainer(new HashSet<Node>(ts)); | ||
2260 | 149 | replicaPlace = stg.createVisualReplica(p, container, VisualReplicaPlace.class); | ||
2261 | 150 | Point2D pos = new Point2D.Double(t.getRootSpaceX() + xOffset, t.getRootSpaceY() + yOffset); | ||
2262 | 151 | replicaPlace.setRootSpacePosition(pos); | ||
2263 | 152 | } | ||
2264 | 153 | stg.connectUndirected(replicaPlace, t); | ||
2265 | 154 | } | ||
2266 | 155 | } | ||
2267 | 156 | } | ||
2268 | 157 | |||
2269 | 158 | public void createReplicaReadArcs(VisualPlace p, Collection<VisualSignalTransition> ts, Point2D replicaPosition) throws InvalidConnectionException { | ||
2270 | 159 | if ((p != null) && (ts != null)) { | ||
2271 | 160 | Container container = Hierarchy.getNearestContainer(new HashSet<Node>(ts)); | ||
2272 | 161 | VisualReplicaPlace replicaPlace = stg.createVisualReplica(p, container, VisualReplicaPlace.class); | ||
2273 | 162 | if (replicaPosition != null) { | ||
2274 | 163 | replicaPlace.setRootSpacePosition(replicaPosition); | ||
2275 | 164 | } | ||
2276 | 165 | for (VisualSignalTransition t: ts) { | ||
2277 | 166 | stg.connectUndirected(replicaPlace, t); | ||
2278 | 167 | } | ||
2279 | 168 | } | ||
2280 | 169 | } | ||
2281 | 170 | |||
2282 | 171 | public void createReplicaReadArcBetweenSignals(SignalStg from, SignalStg to) throws InvalidConnectionException { | ||
2283 | 172 | double xT = to.fallList.get(0).getRootSpaceX(); | ||
2284 | 173 | double xP = to.one.getRootSpaceX(); | ||
2285 | 174 | double yZero = to.zero.getRootSpaceY(); | ||
2286 | 175 | double yOne = to.one.getRootSpaceY(); | ||
2287 | 176 | double x = ((xT > xP) ? xT + 6.0 : xT - 6.0); | ||
2288 | 177 | createReplicaReadArcs(from.zero, to.fallList, new Point2D.Double(x, yZero)); | ||
2289 | 178 | createReplicaReadArcs(from.one, to.riseList, new Point2D.Double(x, yOne)); | ||
2290 | 179 | } | ||
2291 | 180 | |||
2292 | 181 | public Point2D getSignalCenterPosition(SignalStg signal) { | ||
2293 | 182 | double x = 0.0; | ||
2294 | 183 | for (VisualSignalTransition t: signal.getAllTransitions()) { | ||
2295 | 184 | x += t.getRootSpaceX(); | ||
2296 | 185 | } | ||
2297 | 186 | x /= signal.getAllTransitions().size(); | ||
2298 | 187 | |||
2299 | 188 | double y = 0.0; | ||
2300 | 189 | for (VisualPlace p: signal.getAllPlaces()) { | ||
2301 | 190 | y += p.getRootSpaceY(); | ||
2302 | 191 | } | ||
2303 | 192 | y /= signal.getAllPlaces().size(); | ||
2304 | 193 | |||
2305 | 194 | return new Point2D.Double(x, y); | ||
2306 | 195 | } | ||
2307 | 196 | |||
2308 | 197 | public SignalStg generateBasicSignalStg(String signalName, double x, double y, SignalTransition.Type type) throws InvalidConnectionException { | ||
2309 | 198 | VisualPlace zero = stg.createPlace(signalName + _NAME0, null); | ||
2310 | 199 | zero.getReferencedPlace().setTokens(1); | ||
2311 | 200 | zero.setNamePositioning(Positioning.BOTTOM); | ||
2312 | 201 | zero.setLabelPositioning(Positioning.TOP); | ||
2313 | 202 | setPosition(zero, x + 0.0, y + 2.0); | ||
2314 | 203 | |||
2315 | 204 | VisualPlace one = stg.createPlace(signalName + _NAME1, null); | ||
2316 | 205 | one.getReferencedPlace().setTokens(0); | ||
2317 | 206 | one.setNamePositioning(Positioning.TOP); | ||
2318 | 207 | one.setLabelPositioning(Positioning.BOTTOM); | ||
2319 | 208 | setPosition(one, x + 0.0, y - 2.0); | ||
2320 | 209 | |||
2321 | 210 | VisualSignalTransition fall = stg.createSignalTransition(signalName, type, SignalTransition.Direction.MINUS, null); | ||
2322 | 211 | createConsumingArc(one, fall); | ||
2323 | 212 | createProducingArc(fall, zero); | ||
2324 | 213 | setPosition(fall, x + 4.0, y + 0.0); | ||
2325 | 214 | |||
2326 | 215 | VisualSignalTransition rise = stg.createSignalTransition(signalName, type, SignalTransition.Direction.PLUS, null); | ||
2327 | 216 | createConsumingArc(zero, rise); | ||
2328 | 217 | createProducingArc(rise, one); | ||
2329 | 218 | setPosition(rise, x - 4.0, y - 0.0); | ||
2330 | 219 | |||
2331 | 220 | return new SignalStg(zero, one, fall, rise); | ||
2332 | 221 | } | ||
2333 | 222 | |||
2334 | 223 | public SignalStg generateSignalStg(SignalLayoutType layoutType, String signalName, Point2D pos, SignalTransition.Type type, int fallCount, int riseCount) throws InvalidConnectionException { | ||
2335 | 224 | double x = pos.getX(); | ||
2336 | 225 | double y = pos.getY(); | ||
2337 | 226 | int xSign = 1; | ||
2338 | 227 | if ( (layoutType == SignalLayoutType.RIGHT_TO_LEFT) || (layoutType == SignalLayoutType.RIGHT_TO_LEFT_INVERTED) ) { | ||
2339 | 228 | xSign = -1; | ||
2340 | 229 | } | ||
2341 | 230 | int ySign = 1; | ||
2342 | 231 | if ( (layoutType == SignalLayoutType.LEFT_TO_RIGHT_INVERTED) || (layoutType == SignalLayoutType.RIGHT_TO_LEFT_INVERTED) ) { | ||
2343 | 232 | ySign = -1; | ||
2344 | 233 | } | ||
2345 | 234 | |||
2346 | 235 | VisualPlace zero = stg.createPlace(signalName + _NAME0, null); | ||
2347 | 236 | zero.getReferencedPlace().setTokens(1); | ||
2348 | 237 | zero.setNamePositioning((ySign < 0) ? Positioning.BOTTOM : Positioning.TOP); | ||
2349 | 238 | zero.setLabelPositioning((ySign < 0) ? Positioning.TOP : Positioning.BOTTOM); | ||
2350 | 239 | setPosition(zero, x + xSign * 4.0, y + ySign * 2.0); | ||
2351 | 240 | |||
2352 | 241 | VisualPlace one = stg.createPlace(signalName + _NAME1, null); | ||
2353 | 242 | one.getReferencedPlace().setTokens(0); | ||
2354 | 243 | one.setNamePositioning((ySign < 0) ? Positioning.TOP : Positioning.BOTTOM); | ||
2355 | 244 | one.setLabelPositioning((ySign < 0) ? Positioning.BOTTOM : Positioning.TOP); | ||
2356 | 245 | setPosition(one, x + xSign * 4.0, y - ySign * 2.0); | ||
2357 | 246 | |||
2358 | 247 | ArrayList<VisualSignalTransition> fallList = new ArrayList<>(fallCount); | ||
2359 | 248 | for (int i = fallCount-1; i >= 0; --i) { | ||
2360 | 249 | VisualSignalTransition fall = stg.createSignalTransition(signalName, type, SignalTransition.Direction.MINUS, null); | ||
2361 | 250 | createConsumingArc(one, fall); | ||
2362 | 251 | createProducingArc(fall, zero); | ||
2363 | 252 | setPosition(fall, x + 0.0, y + ySign * (2.0 + i)); | ||
2364 | 253 | fallList.add(fall); | ||
2365 | 254 | } | ||
2366 | 255 | |||
2367 | 256 | ArrayList<VisualSignalTransition> riseList = new ArrayList<>(riseCount); | ||
2368 | 257 | for (int i = riseCount-1; i >= 0; --i) { | ||
2369 | 258 | VisualSignalTransition rise = stg.createSignalTransition(signalName, type, SignalTransition.Direction.PLUS, null); | ||
2370 | 259 | createConsumingArc(zero, rise); | ||
2371 | 260 | createProducingArc(rise, one); | ||
2372 | 261 | setPosition(rise, x + 0.0, y - ySign * (2.0 + i)); | ||
2373 | 262 | riseList.add(rise); | ||
2374 | 263 | } | ||
2375 | 264 | |||
2376 | 265 | return new SignalStg(zero, one, fallList, riseList); | ||
2377 | 266 | } | ||
2378 | 267 | |||
2379 | 268 | public void setSignalInitialState(SignalStg signalStg, boolean initToOne) { | ||
2380 | 269 | if (initToOne) { | ||
2381 | 270 | signalStg.one.getReferencedPlace().setTokens(1); | ||
2382 | 271 | signalStg.zero.getReferencedPlace().setTokens(0); | ||
2383 | 272 | } else { | ||
2384 | 273 | signalStg.one.getReferencedPlace().setTokens(0); | ||
2385 | 274 | signalStg.zero.getReferencedPlace().setTokens(1); | ||
2386 | 275 | } | ||
2387 | 276 | } | ||
2388 | 277 | |||
2389 | 278 | public Point2D getComponentPosition(VisualComponent component) { | ||
2390 | 279 | AffineTransform transform = TransformHelper.getTransformToRoot(component); | ||
2391 | 280 | double x = getScale().getX() * (transform.getTranslateX() + component.getX()); | ||
2392 | 281 | double y = getScale().getY() * (transform.getTranslateY() + component.getY()); | ||
2393 | 282 | return new Point2D.Double(x, y); | ||
2394 | 283 | } | ||
2395 | 284 | |||
2396 | 285 | public Point2D getScale() { | ||
2397 | 286 | return new Point2D.Double(10.0, 10.0); | ||
2398 | 287 | } | ||
2399 | 288 | |||
2400 | 289 | public void groupComponentStg(NodeStg nodeStg) { | ||
2401 | 290 | stg.select(nodeStg.getAllNodes()); | ||
2402 | 291 | stg.groupSelection(); | ||
2403 | 292 | } | ||
2404 | 293 | |||
2405 | 294 | } | ||
2406 | 0 | 295 | ||
2407 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/shared/CommonVisualSettings.java' | |||
2408 | --- WorkcraftCore/src/org/workcraft/plugins/shared/CommonVisualSettings.java 2015-07-22 17:40:16 +0000 | |||
2409 | +++ WorkcraftCore/src/org/workcraft/plugins/shared/CommonVisualSettings.java 2015-09-25 14:54:20 +0000 | |||
2410 | @@ -61,7 +61,7 @@ | |||
2411 | 61 | private static final Color defaultLabelColor = Color.BLACK; | 61 | private static final Color defaultLabelColor = Color.BLACK; |
2412 | 62 | private static final boolean defaultNameVisibility = true; | 62 | private static final boolean defaultNameVisibility = true; |
2413 | 63 | private static final Positioning defaultNamePositioning = Positioning.BOTTOM; | 63 | private static final Positioning defaultNamePositioning = Positioning.BOTTOM; |
2415 | 64 | private static final Color defaultNameColor = Color.BLUE.darker(); | 64 | private static final Color defaultNameColor = Color.GRAY.darker(); |
2416 | 65 | private static final Integer defaultRedrawInterval = 20; | 65 | private static final Integer defaultRedrawInterval = 20; |
2417 | 66 | 66 | ||
2418 | 67 | private static double baseSize = defaultBaseSize; | 67 | private static double baseSize = defaultBaseSize; |
2419 | 68 | 68 | ||
2420 | === removed file 'WorkcraftRunner/.fatjar' | |||
2421 | --- WorkcraftRunner/.fatjar 2013-07-11 11:26:55 +0000 | |||
2422 | +++ WorkcraftRunner/.fatjar 1970-01-01 00:00:00 +0000 | |||
2423 | @@ -1,14 +0,0 @@ | |||
2424 | 1 | #Fat Jar Configuration File | ||
2425 | 2 | #Wed Jul 25 12:13:21 BST 2012 | ||
2426 | 3 | onejar.license.required=false | ||
2427 | 4 | manifest.classpath=./Workcraft/bin\:./ThirdParty/batik/batik-anim.jar\:./ThirdParty/batik/batik-awt-util.jar\:./ThirdParty/batik/batik-bridge.jar\:./ThirdParty/batik/bati\nk-codec.jar\:./ThirdParty/batik/batik-css.jar\:./ThirdParty/batik/batik-dom.jar\:./ThirdParty/batik/batik-ext.jar\:./ThirdParty/batik/batik-extension.jar\:./Third\nParty/batik/batik-gui-util.jar\:./ThirdParty/batik/batik-gvt.jar\:./ThirdParty/batik/batik-parser.jar\:./ThirdParty/batik/batik-script.jar\:./ThirdParty/batik/ba\ntik-svg-dom.jar\:./ThirdParty/batik/batik-svggen.jar\:./ThirdParty/batik/batik-swing.jar\:./ThirdParty/batik/batik-transcoder.jar\:./ThirdParty/batik/batik-util.\njar\:./ThirdParty/batik/batik-xml.jar\:./ThirdParty/batik/xml-apis-ext.jar\:./ThirdParty/batik/xml-apis.jar\:./ThirdParty/commons-logging-1.1.jar\:./ThirdParty/fl\nexdock-0.5.1.jar\:./ThirdParty/javaparser-1.0.7.jar\:./ThirdParty/jedit.jar\:./ThirdParty/jga-0.8-lgpl.jar\:./ThirdParty/js.jar\:./ThirdParty/junit-4.5.jar\:./Thir\ndParty/pcollections-1.0.0.jar\:./ThirdParty/substance.jar\:./ThirdParty/TableLayout-bin-jdk1.5-2009-08-26.jar\:./ThirdParty/desij.jar\:./CpogsPlugin/bin\:./Circui\ntPlugin/bin\:./STGPlugin/bin\:./PetriNetPlugin/bin\:./GatesPlugin/bin\:./GraphPlugin/bin\:./MpsatPlugin/bin\:./PetrifyPlugin/bin | ||
2428 | 5 | manifest.removesigners=true | ||
2429 | 6 | onejar.checkbox=false | ||
2430 | 7 | jarname=/home/danil/workspace/workcraft/src-danilovesky/Workcraf.jar | ||
2431 | 8 | manifest.mergeall=true | ||
2432 | 9 | manifest.mainclass=org.workcraft.Console | ||
2433 | 10 | manifest.file=<createnew> | ||
2434 | 11 | jarname.isextern=true | ||
2435 | 12 | onejar.expand= | ||
2436 | 13 | excludes= | ||
2437 | 14 | includes= | ||
2438 | 15 | 0 | ||
2439 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/XmasSettings.java' | |||
2440 | --- XmasPlugin/src/org/workcraft/plugins/xmas/XmasSettings.java 2015-09-03 15:25:56 +0000 | |||
2441 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/XmasSettings.java 2015-09-25 14:54:20 +0000 | |||
2442 | @@ -16,19 +16,19 @@ | |||
2443 | 16 | private static final String keyShowContacts = prefix + ".showContacts"; | 16 | private static final String keyShowContacts = prefix + ".showContacts"; |
2444 | 17 | private static final String keyBorderWidth = prefix + ".borderWidth"; | 17 | private static final String keyBorderWidth = prefix + ".borderWidth"; |
2445 | 18 | private static final String keyWireWidth = prefix + ".wireWidth"; | 18 | private static final String keyWireWidth = prefix + ".wireWidth"; |
2447 | 19 | private static final String keyJasonFileName = prefix + ".jasonFileName"; | 19 | private static final String keyVxmDirectory = prefix + ".vxmDirectory"; |
2448 | 20 | 20 | ||
2449 | 21 | private static final boolean defaultShowContacts = false; | 21 | private static final boolean defaultShowContacts = false; |
2450 | 22 | private static final double defaultBorderWidth = 0.06; | 22 | private static final double defaultBorderWidth = 0.06; |
2453 | 23 | private static final double defaultWireWidth = 0.04; | 23 | private static final double defaultWireWidth = 0.06; |
2454 | 24 | private static final String defaultJasonFileName = ""; | 24 | private static final String defaultVxmDirectory = "tools/vxm/"; |
2455 | 25 | 25 | ||
2456 | 26 | private static boolean showContacts = defaultShowContacts; | 26 | private static boolean showContacts = defaultShowContacts; |
2457 | 27 | private static double borderWidth = defaultBorderWidth; | 27 | private static double borderWidth = defaultBorderWidth; |
2458 | 28 | private static double wireWidth = defaultWireWidth; | 28 | private static double wireWidth = defaultWireWidth; |
2461 | 29 | private static String jasonFileName = defaultJasonFileName; | 29 | private static String vxmDirectory = defaultVxmDirectory; |
2460 | 30 | |||
2462 | 31 | 30 | ||
2463 | 31 | |||
2464 | 32 | public XmasSettings() { | 32 | public XmasSettings() { |
2465 | 33 | properties.add(new PropertyDeclaration<XmasSettings, Boolean>( | 33 | properties.add(new PropertyDeclaration<XmasSettings, Boolean>( |
2466 | 34 | this, "Show contacts", Boolean.class, true, false, false) { | 34 | this, "Show contacts", Boolean.class, true, false, false) { |
2467 | @@ -61,12 +61,12 @@ | |||
2468 | 61 | }); | 61 | }); |
2469 | 62 | 62 | ||
2470 | 63 | properties.add(new PropertyDeclaration<XmasSettings, String>( | 63 | properties.add(new PropertyDeclaration<XmasSettings, String>( |
2472 | 64 | this, "JSON conversion file", String.class, true, false, false) { | 64 | this, "VXM working directory", String.class, true, false, false) { |
2473 | 65 | protected void setter(XmasSettings object, String value) { | 65 | protected void setter(XmasSettings object, String value) { |
2475 | 66 | XmasSettings.setJasonFileName(value); | 66 | XmasSettings.setVxmDirectory(value); |
2476 | 67 | } | 67 | } |
2477 | 68 | protected String getter(XmasSettings object) { | 68 | protected String getter(XmasSettings object) { |
2479 | 69 | return XmasSettings.getJasonFileName(); | 69 | return XmasSettings.getVxmDirectory(); |
2480 | 70 | } | 70 | } |
2481 | 71 | }); | 71 | }); |
2482 | 72 | } | 72 | } |
2483 | @@ -81,7 +81,7 @@ | |||
2484 | 81 | setShowContacts(config.getBoolean(keyShowContacts, defaultShowContacts)); | 81 | setShowContacts(config.getBoolean(keyShowContacts, defaultShowContacts)); |
2485 | 82 | setBorderWidth (config.getDouble(keyBorderWidth, defaultBorderWidth)); | 82 | setBorderWidth (config.getDouble(keyBorderWidth, defaultBorderWidth)); |
2486 | 83 | setWireWidth(config.getDouble(keyWireWidth, defaultWireWidth)); | 83 | setWireWidth(config.getDouble(keyWireWidth, defaultWireWidth)); |
2488 | 84 | setJasonFileName(config.getString(keyJasonFileName, defaultJasonFileName)); | 84 | setVxmDirectory(config.getString(keyVxmDirectory, defaultVxmDirectory)); |
2489 | 85 | } | 85 | } |
2490 | 86 | 86 | ||
2491 | 87 | @Override | 87 | @Override |
2492 | @@ -89,7 +89,7 @@ | |||
2493 | 89 | config.setBoolean(keyShowContacts, getShowContacts()); | 89 | config.setBoolean(keyShowContacts, getShowContacts()); |
2494 | 90 | config.setDouble(keyBorderWidth, getBorderWidth()); | 90 | config.setDouble(keyBorderWidth, getBorderWidth()); |
2495 | 91 | config.setDouble(keyWireWidth, getWireWidth()); | 91 | config.setDouble(keyWireWidth, getWireWidth()); |
2497 | 92 | config.set(keyJasonFileName, getJasonFileName()); | 92 | config.set(keyVxmDirectory, getVxmDirectory()); |
2498 | 93 | } | 93 | } |
2499 | 94 | 94 | ||
2500 | 95 | @Override | 95 | @Override |
2501 | @@ -126,12 +126,12 @@ | |||
2502 | 126 | wireWidth = value; | 126 | wireWidth = value; |
2503 | 127 | } | 127 | } |
2504 | 128 | 128 | ||
2507 | 129 | public static String getJasonFileName() { | 129 | public static String getVxmDirectory() { |
2508 | 130 | return jasonFileName; | 130 | return vxmDirectory; |
2509 | 131 | } | 131 | } |
2510 | 132 | 132 | ||
2513 | 133 | public static void setJasonFileName(String value) { | 133 | public static void setVxmDirectory(String value) { |
2514 | 134 | jasonFileName = value; | 134 | vxmDirectory = value; |
2515 | 135 | } | 135 | } |
2516 | 136 | 136 | ||
2517 | 137 | } | 137 | } |
2518 | 138 | 138 | ||
2519 | === added file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/StateDecoration.java' | |||
2520 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/StateDecoration.java 1970-01-01 00:00:00 +0000 | |||
2521 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/StateDecoration.java 2015-09-25 14:54:20 +0000 | |||
2522 | @@ -0,0 +1,7 @@ | |||
2523 | 1 | package org.workcraft.plugins.xmas.components; | ||
2524 | 2 | |||
2525 | 3 | import org.workcraft.gui.graph.tools.Decoration; | ||
2526 | 4 | |||
2527 | 5 | public interface StateDecoration extends Decoration { | ||
2528 | 6 | public boolean getState(); | ||
2529 | 7 | } | ||
2530 | 0 | 8 | ||
2531 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualQueueComponent.java' | |||
2532 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualQueueComponent.java 2015-09-05 22:18:55 +0000 | |||
2533 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualQueueComponent.java 2015-09-25 14:54:20 +0000 | |||
2534 | @@ -46,13 +46,13 @@ | |||
2535 | 46 | 46 | ||
2536 | 47 | public static final String PROPERTY_FOREGROUND_COLOR = "Foreground color"; | 47 | public static final String PROPERTY_FOREGROUND_COLOR = "Foreground color"; |
2537 | 48 | 48 | ||
2545 | 49 | private final double slotWidth = 0.35 * size; | 49 | public final double slotWidth = 0.35 * size; |
2546 | 50 | private final double slotHeight = 0.8 * size; | 50 | public final double slotHeight = 1.0 * size; |
2547 | 51 | private final double contactLength = 0.5 * size - slotWidth; | 51 | public final double contactLength = 0.5 * size - slotWidth; |
2548 | 52 | private final double tokenSize = 0.5 * slotWidth; | 52 | public final double tokenSize = 0.5 * slotWidth; |
2549 | 53 | private final double headSize = 0.15 * size; | 53 | public final double headSize = 0.15 * size; |
2550 | 54 | private final double tailSize = 0.15 * size; | 54 | public final double tailSize = 0.15 * size; |
2551 | 55 | 55 | ||
2552 | 56 | public Color color = new Color(0, 0, 0, 255); | 56 | public Color color = new Color(0, 0, 0, 255); |
2553 | 57 | 57 | ||
2554 | 58 | public VisualQueueComponent(QueueComponent component) { | 58 | public VisualQueueComponent(QueueComponent component) { |
2555 | @@ -188,18 +188,22 @@ | |||
2556 | 188 | g.setColor(getForegroundColor()); | 188 | g.setColor(getForegroundColor()); |
2557 | 189 | for (int i = 0; i < capacity; i++) { | 189 | for (int i = 0; i < capacity; i++) { |
2558 | 190 | SlotState slot = ((QueueDecoration)d).getSlotState(i); | 190 | SlotState slot = ((QueueDecoration)d).getSlotState(i); |
2560 | 191 | g.draw(getSlotShape(i)); | 191 | Shape slotShape = transformShape(getSlotShape(i)); |
2561 | 192 | g.draw(slotShape); | ||
2562 | 192 | if (!slot.isMemExcited && slot.isFull) { | 193 | if (!slot.isMemExcited && slot.isFull) { |
2565 | 193 | g.draw(getTokenShape(i)); | 194 | Shape tokenShape = transformShape(getTokenShape(i)); |
2566 | 194 | g.fill(getTokenShape(i)); | 195 | g.draw(tokenShape); |
2567 | 196 | g.fill(tokenShape); | ||
2568 | 195 | } | 197 | } |
2569 | 196 | if (!slot.isHeadExcited && slot.isHead) { | 198 | if (!slot.isHeadExcited && slot.isHead) { |
2572 | 197 | g.draw(getHeadShape(i)); | 199 | Shape headShape = transformShape(getHeadShape(i)); |
2573 | 198 | g.fill(getHeadShape(i)); | 200 | g.draw(headShape); |
2574 | 201 | g.fill(headShape); | ||
2575 | 199 | } | 202 | } |
2576 | 200 | if (!slot.isTailExcited && slot.isTail) { | 203 | if (!slot.isTailExcited && slot.isTail) { |
2579 | 201 | g.draw(getTailShape(i)); | 204 | Shape tailShape = transformShape(getTailShape(i)); |
2580 | 202 | g.fill(getTailShape(i)); | 205 | g.draw(tailShape); |
2581 | 206 | g.fill(tailShape); | ||
2582 | 203 | } | 207 | } |
2583 | 204 | } | 208 | } |
2584 | 205 | // Excited elements | 209 | // Excited elements |
2585 | @@ -207,21 +211,24 @@ | |||
2586 | 207 | for (int i = 0; i < capacity; i++) { | 211 | for (int i = 0; i < capacity; i++) { |
2587 | 208 | SlotState slot = ((QueueDecoration)d).getSlotState(i); | 212 | SlotState slot = ((QueueDecoration)d).getSlotState(i); |
2588 | 209 | if (slot.isMemExcited) { | 213 | if (slot.isMemExcited) { |
2590 | 210 | g.draw(getTokenShape(i)); | 214 | Shape tokenShape = transformShape(getTokenShape(i)); |
2591 | 215 | g.draw(tokenShape); | ||
2592 | 211 | if (slot.isFull) { | 216 | if (slot.isFull) { |
2594 | 212 | g.fill(getTokenShape(i)); | 217 | g.fill(tokenShape); |
2595 | 213 | } | 218 | } |
2596 | 214 | } | 219 | } |
2597 | 215 | if (slot.isHeadExcited) { | 220 | if (slot.isHeadExcited) { |
2599 | 216 | g.draw(getHeadShape(i)); | 221 | Shape headShape = transformShape(getHeadShape(i)); |
2600 | 222 | g.draw(headShape); | ||
2601 | 217 | if (slot.isHead) { | 223 | if (slot.isHead) { |
2603 | 218 | g.fill(getHeadShape(i)); | 224 | g.fill(headShape); |
2604 | 219 | } | 225 | } |
2605 | 220 | } | 226 | } |
2606 | 221 | if (slot.isTailExcited) { | 227 | if (slot.isTailExcited) { |
2608 | 222 | g.draw(getTailShape(i)); | 228 | Shape tailShape = transformShape(getTailShape(i)); |
2609 | 229 | g.draw(tailShape); | ||
2610 | 223 | if (slot.isTail) { | 230 | if (slot.isTail) { |
2612 | 224 | g.fill(getTailShape(i)); | 231 | g.fill(tailShape); |
2613 | 225 | } | 232 | } |
2614 | 226 | } | 233 | } |
2615 | 227 | } | 234 | } |
2616 | 228 | 235 | ||
2617 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSinkComponent.java' | |||
2618 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSinkComponent.java 2015-09-03 15:25:56 +0000 | |||
2619 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSinkComponent.java 2015-09-25 14:54:20 +0000 | |||
2620 | @@ -21,20 +21,29 @@ | |||
2621 | 21 | 21 | ||
2622 | 22 | package org.workcraft.plugins.xmas.components; | 22 | package org.workcraft.plugins.xmas.components; |
2623 | 23 | 23 | ||
2624 | 24 | import java.awt.BasicStroke; | ||
2625 | 25 | import java.awt.Graphics2D; | ||
2626 | 24 | import java.awt.Shape; | 26 | import java.awt.Shape; |
2627 | 25 | import java.awt.event.KeyEvent; | 27 | import java.awt.event.KeyEvent; |
2628 | 28 | import java.awt.geom.Ellipse2D; | ||
2629 | 26 | import java.awt.geom.Path2D; | 29 | import java.awt.geom.Path2D; |
2630 | 27 | 30 | ||
2631 | 28 | import org.workcraft.annotations.DisplayName; | 31 | import org.workcraft.annotations.DisplayName; |
2632 | 29 | import org.workcraft.annotations.Hotkey; | 32 | import org.workcraft.annotations.Hotkey; |
2633 | 30 | import org.workcraft.annotations.SVGIcon; | 33 | import org.workcraft.annotations.SVGIcon; |
2634 | 34 | import org.workcraft.dom.visual.DrawRequest; | ||
2635 | 31 | import org.workcraft.dom.visual.Positioning; | 35 | import org.workcraft.dom.visual.Positioning; |
2636 | 36 | import org.workcraft.gui.Coloriser; | ||
2637 | 37 | import org.workcraft.gui.graph.tools.Decoration; | ||
2638 | 38 | import org.workcraft.plugins.xmas.XmasSettings; | ||
2639 | 32 | 39 | ||
2640 | 33 | @DisplayName("Sink") | 40 | @DisplayName("Sink") |
2641 | 34 | @Hotkey(KeyEvent.VK_O) | 41 | @Hotkey(KeyEvent.VK_O) |
2642 | 35 | @SVGIcon("images/icons/svg/xmas-sink.svg") | 42 | @SVGIcon("images/icons/svg/xmas-sink.svg") |
2643 | 36 | public class VisualSinkComponent extends VisualXmasComponent { | 43 | public class VisualSinkComponent extends VisualXmasComponent { |
2644 | 37 | 44 | ||
2645 | 45 | public final double tokenSize = 0.18 * size; | ||
2646 | 46 | |||
2647 | 38 | public VisualSinkComponent(SinkComponent component) { | 47 | public VisualSinkComponent(SinkComponent component) { |
2648 | 39 | super(component); | 48 | super(component); |
2649 | 40 | if (component.getChildren().isEmpty()) { | 49 | if (component.getChildren().isEmpty()) { |
2650 | @@ -64,5 +73,24 @@ | |||
2651 | 64 | 73 | ||
2652 | 65 | return shape; | 74 | return shape; |
2653 | 66 | } | 75 | } |
2654 | 76 | |||
2655 | 77 | public Shape getTokenShape() { | ||
2656 | 78 | return new Ellipse2D.Double(+1.4 * tokenSize, +0.6 * tokenSize, tokenSize, tokenSize); | ||
2657 | 79 | } | ||
2658 | 80 | |||
2659 | 81 | @Override | ||
2660 | 82 | public void draw(DrawRequest r) { | ||
2661 | 83 | super.draw(r); | ||
2662 | 84 | Graphics2D g = r.getGraphics(); | ||
2663 | 85 | Decoration d = r.getDecoration(); | ||
2664 | 86 | if (d instanceof StateDecoration) { | ||
2665 | 87 | if (((StateDecoration)d).getState()) { | ||
2666 | 88 | g.setStroke(new BasicStroke((float)XmasSettings.getBorderWidth())); | ||
2667 | 89 | g.setColor(Coloriser.colorise(getForegroundColor(), d.getColorisation())); | ||
2668 | 90 | Shape shape = transformShape(getTokenShape()); | ||
2669 | 91 | g.draw(shape); | ||
2670 | 92 | } | ||
2671 | 93 | } | ||
2672 | 94 | } | ||
2673 | 67 | 95 | ||
2674 | 68 | } | 96 | } |
2675 | 69 | 97 | ||
2676 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSourceComponent.java' | |||
2677 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSourceComponent.java 2015-09-03 15:25:56 +0000 | |||
2678 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSourceComponent.java 2015-09-25 14:54:20 +0000 | |||
2679 | @@ -21,19 +21,24 @@ | |||
2680 | 21 | 21 | ||
2681 | 22 | package org.workcraft.plugins.xmas.components; | 22 | package org.workcraft.plugins.xmas.components; |
2682 | 23 | 23 | ||
2683 | 24 | import java.awt.BasicStroke; | ||
2684 | 24 | import java.awt.Color; | 25 | import java.awt.Color; |
2685 | 26 | import java.awt.Graphics2D; | ||
2686 | 25 | import java.awt.Shape; | 27 | import java.awt.Shape; |
2687 | 26 | import java.awt.event.KeyEvent; | 28 | import java.awt.event.KeyEvent; |
2689 | 27 | import java.awt.geom.AffineTransform; | 29 | import java.awt.geom.Ellipse2D; |
2690 | 28 | import java.awt.geom.Path2D; | 30 | import java.awt.geom.Path2D; |
2691 | 29 | 31 | ||
2692 | 30 | import org.workcraft.annotations.DisplayName; | 32 | import org.workcraft.annotations.DisplayName; |
2693 | 31 | import org.workcraft.annotations.Hotkey; | 33 | import org.workcraft.annotations.Hotkey; |
2694 | 32 | import org.workcraft.annotations.SVGIcon; | 34 | import org.workcraft.annotations.SVGIcon; |
2695 | 35 | import org.workcraft.dom.visual.DrawRequest; | ||
2696 | 33 | import org.workcraft.dom.visual.Positioning; | 36 | import org.workcraft.dom.visual.Positioning; |
2697 | 34 | import org.workcraft.dom.visual.Stylable; | 37 | import org.workcraft.dom.visual.Stylable; |
2699 | 35 | import org.workcraft.dom.visual.TransformHelper; | 38 | import org.workcraft.gui.Coloriser; |
2700 | 39 | import org.workcraft.gui.graph.tools.Decoration; | ||
2701 | 36 | import org.workcraft.gui.propertyeditor.PropertyDeclaration; | 40 | import org.workcraft.gui.propertyeditor.PropertyDeclaration; |
2702 | 41 | import org.workcraft.plugins.xmas.XmasSettings; | ||
2703 | 37 | import org.workcraft.plugins.xmas.components.SourceComponent.Mode; | 42 | import org.workcraft.plugins.xmas.components.SourceComponent.Mode; |
2704 | 38 | import org.workcraft.plugins.xmas.components.SourceComponent.Type; | 43 | import org.workcraft.plugins.xmas.components.SourceComponent.Type; |
2705 | 39 | 44 | ||
2706 | @@ -46,6 +51,8 @@ | |||
2707 | 46 | 51 | ||
2708 | 47 | public Color color = new Color(0, 255, 0, 255); | 52 | public Color color = new Color(0, 255, 0, 255); |
2709 | 48 | private VisualXmasContact oContact = null; | 53 | private VisualXmasContact oContact = null; |
2710 | 54 | public final double tokenSize = 0.18 * size; | ||
2711 | 55 | |||
2712 | 49 | 56 | ||
2713 | 50 | public VisualSourceComponent(SourceComponent component) { | 57 | public VisualSourceComponent(SourceComponent component) { |
2714 | 51 | super(component); | 58 | super(component); |
2715 | @@ -96,6 +103,26 @@ | |||
2716 | 96 | 103 | ||
2717 | 97 | return shape; | 104 | return shape; |
2718 | 98 | } | 105 | } |
2719 | 106 | |||
2720 | 107 | public Shape getTokenShape() { | ||
2721 | 108 | return new Ellipse2D.Double(-1.8 * tokenSize, -2.5 * tokenSize, tokenSize, tokenSize); | ||
2722 | 109 | } | ||
2723 | 110 | |||
2724 | 111 | @Override | ||
2725 | 112 | public void draw(DrawRequest r) { | ||
2726 | 113 | super.draw(r); | ||
2727 | 114 | Graphics2D g = r.getGraphics(); | ||
2728 | 115 | Decoration d = r.getDecoration(); | ||
2729 | 116 | if (d instanceof StateDecoration) { | ||
2730 | 117 | if (((StateDecoration)d).getState()) { | ||
2731 | 118 | g.setStroke(new BasicStroke((float)XmasSettings.getBorderWidth())); | ||
2732 | 119 | g.setColor(Coloriser.colorise(getForegroundColor(), d.getColorisation())); | ||
2733 | 120 | Shape shape = transformShape(getTokenShape()); | ||
2734 | 121 | g.fill(shape); | ||
2735 | 122 | g.draw(shape); | ||
2736 | 123 | } | ||
2737 | 124 | } | ||
2738 | 125 | } | ||
2739 | 99 | 126 | ||
2740 | 100 | @Override | 127 | @Override |
2741 | 101 | public void copyStyle(Stylable src) { | 128 | public void copyStyle(Stylable src) { |
2742 | 102 | 129 | ||
2743 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSwitchComponent.java' | |||
2744 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSwitchComponent.java 2015-09-03 15:25:56 +0000 | |||
2745 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualSwitchComponent.java 2015-09-25 14:54:20 +0000 | |||
2746 | @@ -21,18 +21,27 @@ | |||
2747 | 21 | 21 | ||
2748 | 22 | package org.workcraft.plugins.xmas.components; | 22 | package org.workcraft.plugins.xmas.components; |
2749 | 23 | 23 | ||
2750 | 24 | import java.awt.BasicStroke; | ||
2751 | 25 | import java.awt.Graphics2D; | ||
2752 | 24 | import java.awt.Shape; | 26 | import java.awt.Shape; |
2753 | 27 | import java.awt.geom.Ellipse2D; | ||
2754 | 25 | import java.awt.geom.Path2D; | 28 | import java.awt.geom.Path2D; |
2755 | 26 | 29 | ||
2756 | 27 | import org.workcraft.annotations.DisplayName; | 30 | import org.workcraft.annotations.DisplayName; |
2757 | 28 | import org.workcraft.annotations.SVGIcon; | 31 | import org.workcraft.annotations.SVGIcon; |
2758 | 32 | import org.workcraft.dom.visual.DrawRequest; | ||
2759 | 29 | import org.workcraft.dom.visual.Positioning; | 33 | import org.workcraft.dom.visual.Positioning; |
2760 | 34 | import org.workcraft.gui.Coloriser; | ||
2761 | 35 | import org.workcraft.gui.graph.tools.Decoration; | ||
2762 | 36 | import org.workcraft.plugins.xmas.XmasSettings; | ||
2763 | 30 | 37 | ||
2764 | 31 | 38 | ||
2765 | 32 | @DisplayName("Switch") | 39 | @DisplayName("Switch") |
2766 | 33 | @SVGIcon("images/icons/svg/xmas-switch.svg") | 40 | @SVGIcon("images/icons/svg/xmas-switch.svg") |
2767 | 34 | public class VisualSwitchComponent extends VisualXmasComponent { | 41 | public class VisualSwitchComponent extends VisualXmasComponent { |
2768 | 35 | 42 | ||
2769 | 43 | public final double pointerSize = 0.20 * size; | ||
2770 | 44 | |||
2771 | 36 | public VisualSwitchComponent(SwitchComponent component) { | 45 | public VisualSwitchComponent(SwitchComponent component) { |
2772 | 37 | super(component); | 46 | super(component); |
2773 | 38 | if (component.getChildren().isEmpty()) { | 47 | if (component.getChildren().isEmpty()) { |
2774 | @@ -45,6 +54,44 @@ | |||
2775 | 45 | public SwitchComponent getReferencedSwitchComponent() { | 54 | public SwitchComponent getReferencedSwitchComponent() { |
2776 | 46 | return (SwitchComponent)getReferencedComponent(); | 55 | return (SwitchComponent)getReferencedComponent(); |
2777 | 47 | } | 56 | } |
2778 | 57 | |||
2779 | 58 | public Shape getUpPointerShape() { | ||
2780 | 59 | Path2D shape = new Path2D.Double(); | ||
2781 | 60 | shape.moveTo(+0.50 * size, -0.28 * size); | ||
2782 | 61 | shape.lineTo(+0.50 * size + 0.7 * pointerSize, -0.28 * size + pointerSize); | ||
2783 | 62 | shape.lineTo(+0.50 * size - 0.7 * pointerSize, -0.28 * size + pointerSize); | ||
2784 | 63 | shape.closePath(); | ||
2785 | 64 | return shape; | ||
2786 | 65 | } | ||
2787 | 66 | |||
2788 | 67 | public Shape getDownPointerShape() { | ||
2789 | 68 | Path2D shape = new Path2D.Double(); | ||
2790 | 69 | shape.moveTo(+0.50 * size, +0.28 * size); | ||
2791 | 70 | shape.lineTo(+0.50 * size + 0.7 * pointerSize, +0.28 * size - pointerSize); | ||
2792 | 71 | shape.lineTo(+0.50 * size - 0.7 * pointerSize, +0.28 * size - pointerSize); | ||
2793 | 72 | shape.closePath(); | ||
2794 | 73 | return shape; | ||
2795 | 74 | } | ||
2796 | 75 | |||
2797 | 76 | @Override | ||
2798 | 77 | public void draw(DrawRequest r) { | ||
2799 | 78 | super.draw(r); | ||
2800 | 79 | Graphics2D g = r.getGraphics(); | ||
2801 | 80 | Decoration d = r.getDecoration(); | ||
2802 | 81 | if (d instanceof StateDecoration) { | ||
2803 | 82 | g.setStroke(new BasicStroke((float)XmasSettings.getBorderWidth())); | ||
2804 | 83 | g.setColor(Coloriser.colorise(getForegroundColor(), d.getColorisation())); | ||
2805 | 84 | if (((StateDecoration)d).getState()) { | ||
2806 | 85 | Shape shape = transformShape(getUpPointerShape()); | ||
2807 | 86 | g.fill(shape); | ||
2808 | 87 | g.draw(shape); | ||
2809 | 88 | } else { | ||
2810 | 89 | Shape shape = transformShape(getDownPointerShape()); | ||
2811 | 90 | g.fill(shape); | ||
2812 | 91 | g.draw(shape); | ||
2813 | 92 | } | ||
2814 | 93 | } | ||
2815 | 94 | } | ||
2816 | 48 | 95 | ||
2817 | 49 | @Override | 96 | @Override |
2818 | 50 | public Shape getShape() { | 97 | public Shape getShape() { |
2819 | 51 | 98 | ||
2820 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasComponent.java' | |||
2821 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasComponent.java 2015-09-03 15:25:56 +0000 | |||
2822 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasComponent.java 2015-09-25 14:54:20 +0000 | |||
2823 | @@ -178,7 +178,7 @@ | |||
2824 | 178 | 178 | ||
2825 | 179 | @Override | 179 | @Override |
2826 | 180 | public Rectangle2D getInternalBoundingBoxInLocalSpace() { | 180 | public Rectangle2D getInternalBoundingBoxInLocalSpace() { |
2828 | 181 | return getTransformedShape().getBounds2D(); | 181 | return transformShape(getShape()).getBounds2D(); |
2829 | 182 | } | 182 | } |
2830 | 183 | 183 | ||
2831 | 184 | public Rectangle2D getBoundingBoxInLocalSpace() { | 184 | public Rectangle2D getBoundingBoxInLocalSpace() { |
2832 | @@ -272,12 +272,12 @@ | |||
2833 | 272 | 272 | ||
2834 | 273 | abstract public Shape getShape(); | 273 | abstract public Shape getShape(); |
2835 | 274 | 274 | ||
2837 | 275 | public Shape getTransformedShape() { | 275 | public Shape transformShape(Shape shape) { |
2838 | 276 | AffineTransform rotateTransform = new AffineTransform(); | 276 | AffineTransform rotateTransform = new AffineTransform(); |
2839 | 277 | if (orientation != null) { | 277 | if (orientation != null) { |
2840 | 278 | rotateTransform.quadrantRotate(orientation.getQuadrant()); | 278 | rotateTransform.quadrantRotate(orientation.getQuadrant()); |
2841 | 279 | } | 279 | } |
2843 | 280 | return rotateTransform.createTransformedShape(getShape()); | 280 | return rotateTransform.createTransformedShape(shape); |
2844 | 281 | } | 281 | } |
2845 | 282 | 282 | ||
2846 | 283 | @Override | 283 | @Override |
2847 | @@ -287,7 +287,7 @@ | |||
2848 | 287 | 287 | ||
2849 | 288 | g.setColor(Coloriser.colorise(getForegroundColor(), d.getColorisation())); | 288 | g.setColor(Coloriser.colorise(getForegroundColor(), d.getColorisation())); |
2850 | 289 | g.setStroke(new BasicStroke((float)XmasSettings.getBorderWidth())); | 289 | g.setStroke(new BasicStroke((float)XmasSettings.getBorderWidth())); |
2852 | 290 | g.draw(getTransformedShape()); | 290 | g.draw(transformShape(getShape())); |
2853 | 291 | 291 | ||
2854 | 292 | drawNameInLocalSpace(r); | 292 | drawNameInLocalSpace(r); |
2855 | 293 | drawLabelInLocalSpace(r); | 293 | drawLabelInLocalSpace(r); |
2856 | 294 | 294 | ||
2857 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasConnection.java' | |||
2858 | --- XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasConnection.java 2015-09-03 15:25:56 +0000 | |||
2859 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualXmasConnection.java 2015-09-25 14:54:20 +0000 | |||
2860 | @@ -16,11 +16,11 @@ | |||
2861 | 16 | public class VisualXmasConnection extends VisualConnection { | 16 | public class VisualXmasConnection extends VisualConnection { |
2862 | 17 | 17 | ||
2863 | 18 | public VisualXmasConnection() { | 18 | public VisualXmasConnection() { |
2865 | 19 | super(); | 19 | this(null, null, null); |
2866 | 20 | } | 20 | } |
2867 | 21 | 21 | ||
2870 | 22 | public VisualXmasConnection(MathConnection c) { | 22 | public VisualXmasConnection(MathConnection con) { |
2871 | 23 | super(); | 23 | this(con, null, null); |
2872 | 24 | } | 24 | } |
2873 | 25 | 25 | ||
2874 | 26 | public VisualXmasConnection(MathConnection con, VisualComponent c1, VisualComponent c2) { | 26 | public VisualXmasConnection(MathConnection con, VisualComponent c1, VisualComponent c2) { |
2875 | 27 | 27 | ||
2876 | === added file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/ContactStg.java' | |||
2877 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/ContactStg.java 1970-01-01 00:00:00 +0000 | |||
2878 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/ContactStg.java 2015-09-25 14:54:20 +0000 | |||
2879 | @@ -0,0 +1,36 @@ | |||
2880 | 1 | package org.workcraft.plugins.xmas.stg; | ||
2881 | 2 | |||
2882 | 3 | import java.util.Collection; | ||
2883 | 4 | import java.util.HashSet; | ||
2884 | 5 | |||
2885 | 6 | import org.workcraft.plugins.petri.VisualPlace; | ||
2886 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
2887 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
2888 | 9 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
2889 | 10 | |||
2890 | 11 | public class ContactStg extends NodeStg { | ||
2891 | 12 | public final SignalStg rdy; | ||
2892 | 13 | public final SignalStg dn; | ||
2893 | 14 | |||
2894 | 15 | public ContactStg(SignalStg rdy, SignalStg dn) { | ||
2895 | 16 | this.rdy = rdy; | ||
2896 | 17 | this.dn = dn; | ||
2897 | 18 | } | ||
2898 | 19 | |||
2899 | 20 | @Override | ||
2900 | 21 | public Collection<VisualSignalTransition> getAllTransitions() { | ||
2901 | 22 | HashSet<VisualSignalTransition> result = new HashSet<>(); | ||
2902 | 23 | result.addAll(rdy.getAllTransitions()); | ||
2903 | 24 | result.addAll(dn.getAllTransitions()); | ||
2904 | 25 | return result; | ||
2905 | 26 | } | ||
2906 | 27 | |||
2907 | 28 | @Override | ||
2908 | 29 | public Collection<VisualPlace> getAllPlaces() { | ||
2909 | 30 | HashSet<VisualPlace> result = new HashSet<>(); | ||
2910 | 31 | result.addAll(rdy.getAllPlaces()); | ||
2911 | 32 | result.addAll(dn.getAllPlaces()); | ||
2912 | 33 | return result; | ||
2913 | 34 | } | ||
2914 | 35 | |||
2915 | 36 | } | ||
2916 | 0 | 37 | ||
2917 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/ForkStg.java' | |||
2918 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/ForkStg.java 2015-09-03 15:25:56 +0000 | |||
2919 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/ForkStg.java 2015-09-25 14:54:20 +0000 | |||
2920 | @@ -5,13 +5,14 @@ | |||
2921 | 5 | 5 | ||
2922 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 6 | import org.workcraft.plugins.petri.VisualPlace; |
2923 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; |
2924 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
2925 | 8 | 9 | ||
2926 | 9 | public class ForkStg extends NodeStg { | 10 | public class ForkStg extends NodeStg { |
2930 | 10 | public final SignalStg i; | 11 | public final ContactStg i; |
2931 | 11 | public final SignalStg a; | 12 | public final ContactStg a; |
2932 | 12 | public final SignalStg b; | 13 | public final ContactStg b; |
2933 | 13 | 14 | ||
2935 | 14 | public ForkStg(SignalStg i, SignalStg a, SignalStg b) { | 15 | public ForkStg(ContactStg i, ContactStg a, ContactStg b) { |
2936 | 15 | this.i = i; | 16 | this.i = i; |
2937 | 16 | this.a = a; | 17 | this.a = a; |
2938 | 17 | this.b = b; | 18 | this.b = b; |
2939 | 18 | 19 | ||
2940 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/FunctionStg.java' | |||
2941 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/FunctionStg.java 2015-09-03 15:25:56 +0000 | |||
2942 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/FunctionStg.java 2015-09-25 14:54:20 +0000 | |||
2943 | @@ -5,12 +5,13 @@ | |||
2944 | 5 | 5 | ||
2945 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 6 | import org.workcraft.plugins.petri.VisualPlace; |
2946 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; |
2947 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
2948 | 8 | 9 | ||
2949 | 9 | public class FunctionStg extends NodeStg { | 10 | public class FunctionStg extends NodeStg { |
2952 | 10 | public final SignalStg i; | 11 | public final ContactStg i; |
2953 | 11 | public final SignalStg o; | 12 | public final ContactStg o; |
2954 | 12 | 13 | ||
2956 | 13 | public FunctionStg(SignalStg i, SignalStg o) { | 14 | public FunctionStg(ContactStg i, ContactStg o) { |
2957 | 14 | this.i = i; | 15 | this.i = i; |
2958 | 15 | this.o = o; | 16 | this.o = o; |
2959 | 16 | } | 17 | } |
2960 | 17 | 18 | ||
2961 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/JoinStg.java' | |||
2962 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/JoinStg.java 2015-09-03 15:25:56 +0000 | |||
2963 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/JoinStg.java 2015-09-25 14:54:20 +0000 | |||
2964 | @@ -5,13 +5,14 @@ | |||
2965 | 5 | 5 | ||
2966 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 6 | import org.workcraft.plugins.petri.VisualPlace; |
2967 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; |
2968 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
2969 | 8 | 9 | ||
2970 | 9 | public class JoinStg extends NodeStg { | 10 | public class JoinStg extends NodeStg { |
2974 | 10 | public final SignalStg a; | 11 | public final ContactStg a; |
2975 | 11 | public final SignalStg b; | 12 | public final ContactStg b; |
2976 | 12 | public final SignalStg o; | 13 | public final ContactStg o; |
2977 | 13 | 14 | ||
2979 | 14 | public JoinStg(SignalStg a, SignalStg b, SignalStg o) { | 15 | public JoinStg(ContactStg a, ContactStg b, ContactStg o) { |
2980 | 15 | this.a = a; | 16 | this.a = a; |
2981 | 16 | this.b = b; | 17 | this.b = b; |
2982 | 17 | this.o = o; | 18 | this.o = o; |
2983 | 18 | 19 | ||
2984 | === added file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/MergeStg.java' | |||
2985 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/MergeStg.java 1970-01-01 00:00:00 +0000 | |||
2986 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/MergeStg.java 2015-09-25 14:54:20 +0000 | |||
2987 | @@ -0,0 +1,39 @@ | |||
2988 | 1 | package org.workcraft.plugins.xmas.stg; | ||
2989 | 2 | |||
2990 | 3 | import java.util.Collection; | ||
2991 | 4 | import java.util.HashSet; | ||
2992 | 5 | |||
2993 | 6 | import org.workcraft.plugins.petri.VisualPlace; | ||
2994 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
2995 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
2996 | 9 | |||
2997 | 10 | public class MergeStg extends NodeStg { | ||
2998 | 11 | public final ContactStg a; | ||
2999 | 12 | public final ContactStg b; | ||
3000 | 13 | public final ContactStg o; | ||
3001 | 14 | |||
3002 | 15 | public MergeStg(ContactStg a, ContactStg b, ContactStg o) { | ||
3003 | 16 | this.a = a; | ||
3004 | 17 | this.b = b; | ||
3005 | 18 | this.o = o; | ||
3006 | 19 | } | ||
3007 | 20 | |||
3008 | 21 | @Override | ||
3009 | 22 | public Collection<VisualSignalTransition> getAllTransitions() { | ||
3010 | 23 | HashSet<VisualSignalTransition> result = new HashSet<>(); | ||
3011 | 24 | result.addAll(a.getAllTransitions()); | ||
3012 | 25 | result.addAll(b.getAllTransitions()); | ||
3013 | 26 | result.addAll(o.getAllTransitions()); | ||
3014 | 27 | return result; | ||
3015 | 28 | } | ||
3016 | 29 | |||
3017 | 30 | @Override | ||
3018 | 31 | public Collection<VisualPlace> getAllPlaces() { | ||
3019 | 32 | HashSet<VisualPlace> result = new HashSet<>(); | ||
3020 | 33 | result.addAll(a.getAllPlaces()); | ||
3021 | 34 | result.addAll(b.getAllPlaces()); | ||
3022 | 35 | result.addAll(o.getAllPlaces()); | ||
3023 | 36 | return result; | ||
3024 | 37 | } | ||
3025 | 38 | |||
3026 | 39 | } | ||
3027 | 0 | 40 | ||
3028 | === removed file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/NodeStg.java' | |||
3029 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/NodeStg.java 2015-08-28 17:16:49 +0000 | |||
3030 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/NodeStg.java 1970-01-01 00:00:00 +0000 | |||
3031 | @@ -1,38 +0,0 @@ | |||
3032 | 1 | package org.workcraft.plugins.xmas.stg; | ||
3033 | 2 | |||
3034 | 3 | import java.util.Collection; | ||
3035 | 4 | import java.util.HashSet; | ||
3036 | 5 | |||
3037 | 6 | import org.workcraft.dom.Node; | ||
3038 | 7 | import org.workcraft.plugins.petri.VisualPlace; | ||
3039 | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
3040 | 9 | |||
3041 | 10 | public abstract class NodeStg { | ||
3042 | 11 | public abstract Collection<VisualSignalTransition> getAllTransitions(); | ||
3043 | 12 | |||
3044 | 13 | public abstract Collection<VisualPlace> getAllPlaces(); | ||
3045 | 14 | |||
3046 | 15 | public Collection<Node> getAllNodes() { | ||
3047 | 16 | HashSet<Node> result = new HashSet<>(); | ||
3048 | 17 | result.addAll(getAllPlaces()); | ||
3049 | 18 | result.addAll(getAllTransitions()); | ||
3050 | 19 | return result; | ||
3051 | 20 | } | ||
3052 | 21 | |||
3053 | 22 | public boolean contains(Node n) { | ||
3054 | 23 | if (n != null) { | ||
3055 | 24 | for (VisualPlace p: getAllPlaces()) { | ||
3056 | 25 | if (n == p || (p != null && n == p.getReferencedPlace())) { | ||
3057 | 26 | return true; | ||
3058 | 27 | } | ||
3059 | 28 | } | ||
3060 | 29 | for (VisualSignalTransition t: getAllTransitions()) { | ||
3061 | 30 | if (n == t || (t != null && n == t.getReferencedTransition())) { | ||
3062 | 31 | return true; | ||
3063 | 32 | } | ||
3064 | 33 | } | ||
3065 | 34 | } | ||
3066 | 35 | return false; | ||
3067 | 36 | } | ||
3068 | 37 | |||
3069 | 38 | } | ||
3070 | 39 | 0 | ||
3071 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/QueueStg.java' | |||
3072 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/QueueStg.java 2015-09-05 22:18:55 +0000 | |||
3073 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/QueueStg.java 2015-09-25 14:54:20 +0000 | |||
3074 | @@ -1,24 +1,22 @@ | |||
3075 | 1 | package org.workcraft.plugins.xmas.stg; | 1 | package org.workcraft.plugins.xmas.stg; |
3076 | 2 | 2 | ||
3077 | 3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
3078 | 4 | import java.util.Collection; | ||
3079 | 4 | import java.util.List; | 5 | import java.util.List; |
3080 | 5 | 6 | ||
3081 | 6 | import org.workcraft.plugins.petri.VisualPlace; | 7 | import org.workcraft.plugins.petri.VisualPlace; |
3082 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; |
3083 | 9 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
3084 | 8 | 10 | ||
3085 | 9 | public class QueueStg extends NodeStg { | 11 | public class QueueStg extends NodeStg { |
3091 | 10 | public final SignalStg i; | 12 | public final ContactStg i; |
3092 | 11 | public final SignalStg o; | 13 | public final ContactStg o; |
3093 | 12 | public final ArrayList<SignalStg> memList = new ArrayList<>(); | 14 | public final ArrayList<SlotStg> slotList = new ArrayList<>(); |
3089 | 13 | public final ArrayList<SignalStg> headList = new ArrayList<>(); | ||
3090 | 14 | public final ArrayList<SignalStg> tailList = new ArrayList<>(); | ||
3094 | 15 | 15 | ||
3096 | 16 | public QueueStg(SignalStg i, SignalStg o, ArrayList<SignalStg> memList, ArrayList<SignalStg> headList, ArrayList<SignalStg> tailList) { | 16 | public QueueStg(ContactStg i, ContactStg o, ArrayList<SlotStg> slotList) { |
3097 | 17 | this.i = i; | 17 | this.i = i; |
3098 | 18 | this.o = o; | 18 | this.o = o; |
3102 | 19 | this.memList.addAll(memList); | 19 | this.slotList.addAll(slotList); |
3100 | 20 | this.headList.addAll(headList); | ||
3101 | 21 | this.tailList.addAll(tailList); | ||
3103 | 22 | } | 20 | } |
3104 | 23 | 21 | ||
3105 | 24 | @Override | 22 | @Override |
3106 | @@ -26,68 +24,55 @@ | |||
3107 | 26 | List<VisualSignalTransition> result = new ArrayList<>(); | 24 | List<VisualSignalTransition> result = new ArrayList<>(); |
3108 | 27 | result.addAll(i.getAllTransitions()); | 25 | result.addAll(i.getAllTransitions()); |
3109 | 28 | result.addAll(o.getAllTransitions()); | 26 | result.addAll(o.getAllTransitions()); |
3140 | 29 | result.addAll(getMemTransitions()); | 27 | result.addAll(getSlotTransitions()); |
3141 | 30 | result.addAll(getHeadTransitions()); | 28 | return result; |
3142 | 31 | result.addAll(getTailTransitions()); | 29 | } |
3143 | 32 | return result; | 30 | |
3144 | 33 | } | 31 | public List<VisualSignalTransition> getSlotTransitions() { |
3145 | 34 | 32 | List<VisualSignalTransition> result = new ArrayList<>(); | |
3146 | 35 | public List<VisualSignalTransition> getMemTransitions() { | 33 | for (SlotStg slot: slotList) { |
3147 | 36 | List<VisualSignalTransition> result = new ArrayList<>(); | 34 | result.addAll(slot.getAllTransitions()); |
3148 | 37 | for (SignalStg mem: memList) { | 35 | } |
3149 | 38 | result.addAll(mem.getAllTransitions()); | 36 | return result; |
3150 | 39 | } | 37 | } |
3121 | 40 | return result; | ||
3122 | 41 | } | ||
3123 | 42 | |||
3124 | 43 | public List<VisualSignalTransition> getHeadTransitions() { | ||
3125 | 44 | List<VisualSignalTransition> result = new ArrayList<>(); | ||
3126 | 45 | for (SignalStg head: headList) { | ||
3127 | 46 | result.addAll(head.getAllTransitions()); | ||
3128 | 47 | } | ||
3129 | 48 | return result; | ||
3130 | 49 | } | ||
3131 | 50 | |||
3132 | 51 | public List<VisualSignalTransition> getTailTransitions() { | ||
3133 | 52 | List<VisualSignalTransition> result = new ArrayList<>(); | ||
3134 | 53 | for (SignalStg tail: tailList) { | ||
3135 | 54 | result.addAll(tail.getAllTransitions()); | ||
3136 | 55 | } | ||
3137 | 56 | return result; | ||
3138 | 57 | } | ||
3139 | 58 | |||
3151 | 59 | 38 | ||
3152 | 60 | @Override | 39 | @Override |
3153 | 61 | public List<VisualPlace> getAllPlaces() { | 40 | public List<VisualPlace> getAllPlaces() { |
3154 | 62 | List<VisualPlace> result = new ArrayList<>(); | 41 | List<VisualPlace> result = new ArrayList<>(); |
3155 | 63 | result.addAll(i.getAllPlaces()); | 42 | result.addAll(i.getAllPlaces()); |
3156 | 64 | result.addAll(o.getAllPlaces()); | 43 | result.addAll(o.getAllPlaces()); |
3183 | 65 | result.addAll(getMemPlaces()); | 44 | result.addAll(getSlotPlaces()); |
3184 | 66 | result.addAll(getHeadPlaces()); | 45 | return result; |
3185 | 67 | result.addAll(getTailPlaces()); | 46 | } |
3186 | 68 | return result; | 47 | |
3187 | 69 | } | 48 | public List<VisualPlace> getSlotPlaces() { |
3188 | 70 | 49 | List<VisualPlace> result = new ArrayList<>(); | |
3189 | 71 | public List<VisualPlace> getMemPlaces() { | 50 | for (SlotStg slot: slotList) { |
3190 | 72 | List<VisualPlace> result = new ArrayList<>(); | 51 | result.addAll(slot.getAllPlaces()); |
3191 | 73 | for (SignalStg mem: memList) { | 52 | } |
3192 | 74 | result.addAll(mem.getAllPlaces()); | 53 | return result; |
3193 | 75 | } | 54 | } |
3194 | 76 | return result; | 55 | |
3195 | 77 | } | 56 | public Collection<VisualSignalTransition> getMemTransitions() { |
3196 | 78 | 57 | List<VisualSignalTransition> result = new ArrayList<>(); | |
3197 | 79 | public List<VisualPlace> getHeadPlaces() { | 58 | for (SlotStg slot: slotList) { |
3198 | 80 | List<VisualPlace> result = new ArrayList<>(); | 59 | result.addAll(slot.mem.getAllTransitions()); |
3199 | 81 | for (SignalStg head: headList) { | 60 | } |
3200 | 82 | result.addAll(head.getAllPlaces()); | 61 | return result; |
3201 | 83 | } | 62 | } |
3202 | 84 | return result; | 63 | |
3203 | 85 | } | 64 | public Collection<VisualSignalTransition> getHeadTransitions() { |
3204 | 86 | 65 | List<VisualSignalTransition> result = new ArrayList<>(); | |
3205 | 87 | public List<VisualPlace> getTailPlaces() { | 66 | for (SlotStg slot: slotList) { |
3206 | 88 | List<VisualPlace> result = new ArrayList<>(); | 67 | result.addAll(slot.hd.getAllTransitions()); |
3207 | 89 | for (SignalStg tail: tailList) { | 68 | } |
3208 | 90 | result.addAll(tail.getAllPlaces()); | 69 | return result; |
3209 | 70 | } | ||
3210 | 71 | |||
3211 | 72 | public Collection<VisualSignalTransition> getTailTransitions() { | ||
3212 | 73 | List<VisualSignalTransition> result = new ArrayList<>(); | ||
3213 | 74 | for (SlotStg slot: slotList) { | ||
3214 | 75 | result.addAll(slot.tl.getAllTransitions()); | ||
3215 | 91 | } | 76 | } |
3216 | 92 | return result; | 77 | return result; |
3217 | 93 | } | 78 | } |
3218 | 94 | 79 | ||
3219 | === removed file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/SignalStg.java' | |||
3220 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/SignalStg.java 2015-09-03 15:25:56 +0000 | |||
3221 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/SignalStg.java 1970-01-01 00:00:00 +0000 | |||
3222 | @@ -1,47 +0,0 @@ | |||
3223 | 1 | package org.workcraft.plugins.xmas.stg; | ||
3224 | 2 | |||
3225 | 3 | import java.util.ArrayList; | ||
3226 | 4 | import java.util.Arrays; | ||
3227 | 5 | import java.util.Collection; | ||
3228 | 6 | import java.util.HashSet; | ||
3229 | 7 | import java.util.List; | ||
3230 | 8 | |||
3231 | 9 | import org.workcraft.plugins.petri.VisualPlace; | ||
3232 | 10 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
3233 | 11 | |||
3234 | 12 | public class SignalStg extends NodeStg { | ||
3235 | 13 | public final VisualPlace zero; | ||
3236 | 14 | public final VisualPlace one; | ||
3237 | 15 | public final ArrayList<VisualSignalTransition> fallList = new ArrayList<>(); | ||
3238 | 16 | public final ArrayList<VisualSignalTransition> riseList = new ArrayList<>(); | ||
3239 | 17 | |||
3240 | 18 | public SignalStg(VisualPlace zero, VisualPlace one, VisualSignalTransition fall, VisualSignalTransition rise) { | ||
3241 | 19 | this.zero = zero; | ||
3242 | 20 | this.one = one; | ||
3243 | 21 | this.fallList.add(fall); | ||
3244 | 22 | this.riseList.add(rise); | ||
3245 | 23 | } | ||
3246 | 24 | |||
3247 | 25 | public SignalStg(VisualPlace zero, VisualPlace one, ArrayList<VisualSignalTransition> fallList, ArrayList<VisualSignalTransition> riseList) { | ||
3248 | 26 | this.zero = zero; | ||
3249 | 27 | this.one = one; | ||
3250 | 28 | this.fallList.addAll(fallList); | ||
3251 | 29 | this.riseList.addAll(riseList); | ||
3252 | 30 | } | ||
3253 | 31 | |||
3254 | 32 | @Override | ||
3255 | 33 | public Collection<VisualSignalTransition> getAllTransitions() { | ||
3256 | 34 | HashSet<VisualSignalTransition> tmp = new HashSet<>(); | ||
3257 | 35 | tmp.addAll(fallList); | ||
3258 | 36 | tmp.addAll(riseList); | ||
3259 | 37 | List<VisualSignalTransition> result = new ArrayList<>(); | ||
3260 | 38 | result.addAll(tmp); | ||
3261 | 39 | return result; | ||
3262 | 40 | } | ||
3263 | 41 | |||
3264 | 42 | @Override | ||
3265 | 43 | public Collection<VisualPlace> getAllPlaces() { | ||
3266 | 44 | return Arrays.asList(zero, one); | ||
3267 | 45 | } | ||
3268 | 46 | |||
3269 | 47 | } | ||
3270 | 48 | 0 | ||
3271 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/SinkStg.java' | |||
3272 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/SinkStg.java 2015-09-05 22:18:55 +0000 | |||
3273 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/SinkStg.java 2015-09-25 14:54:20 +0000 | |||
3274 | @@ -6,12 +6,14 @@ | |||
3275 | 6 | 6 | ||
3276 | 7 | import org.workcraft.plugins.petri.VisualPlace; | 7 | import org.workcraft.plugins.petri.VisualPlace; |
3277 | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; |
3278 | 9 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
3279 | 10 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
3280 | 9 | 11 | ||
3281 | 10 | public class SinkStg extends NodeStg { | 12 | public class SinkStg extends NodeStg { |
3283 | 11 | public final SignalStg i; | 13 | public final ContactStg i; |
3284 | 12 | public final SignalStg oracle; | 14 | public final SignalStg oracle; |
3285 | 13 | 15 | ||
3287 | 14 | public SinkStg(SignalStg i, SignalStg oracle) { | 16 | public SinkStg(ContactStg i, SignalStg oracle) { |
3288 | 15 | this.i = i; | 17 | this.i = i; |
3289 | 16 | this.oracle = oracle; | 18 | this.oracle = oracle; |
3290 | 17 | } | 19 | } |
3291 | 18 | 20 | ||
3292 | === added file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/SlotStg.java' | |||
3293 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/SlotStg.java 1970-01-01 00:00:00 +0000 | |||
3294 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/SlotStg.java 2015-09-25 14:54:20 +0000 | |||
3295 | @@ -0,0 +1,40 @@ | |||
3296 | 1 | package org.workcraft.plugins.xmas.stg; | ||
3297 | 2 | |||
3298 | 3 | import java.util.Collection; | ||
3299 | 4 | import java.util.HashSet; | ||
3300 | 5 | |||
3301 | 6 | import org.workcraft.plugins.petri.VisualPlace; | ||
3302 | 7 | import org.workcraft.plugins.stg.VisualSignalTransition; | ||
3303 | 8 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
3304 | 9 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
3305 | 10 | |||
3306 | 11 | public class SlotStg extends NodeStg { | ||
3307 | 12 | public final SignalStg mem; | ||
3308 | 13 | public final ContactStg hd; | ||
3309 | 14 | public final ContactStg tl; | ||
3310 | 15 | |||
3311 | 16 | public SlotStg(SignalStg mem, ContactStg hd, ContactStg tl) { | ||
3312 | 17 | this.mem = mem; | ||
3313 | 18 | this.hd = hd; | ||
3314 | 19 | this.tl = tl; | ||
3315 | 20 | } | ||
3316 | 21 | |||
3317 | 22 | @Override | ||
3318 | 23 | public Collection<VisualSignalTransition> getAllTransitions() { | ||
3319 | 24 | HashSet<VisualSignalTransition> result = new HashSet<>(); | ||
3320 | 25 | result.addAll(mem.getAllTransitions()); | ||
3321 | 26 | result.addAll(hd.getAllTransitions()); | ||
3322 | 27 | result.addAll(tl.getAllTransitions()); | ||
3323 | 28 | return result; | ||
3324 | 29 | } | ||
3325 | 30 | |||
3326 | 31 | @Override | ||
3327 | 32 | public Collection<VisualPlace> getAllPlaces() { | ||
3328 | 33 | HashSet<VisualPlace> result = new HashSet<>(); | ||
3329 | 34 | result.addAll(mem.getAllPlaces()); | ||
3330 | 35 | result.addAll(hd.getAllPlaces()); | ||
3331 | 36 | result.addAll(tl.getAllPlaces()); | ||
3332 | 37 | return result; | ||
3333 | 38 | } | ||
3334 | 39 | |||
3335 | 40 | } | ||
3336 | 0 | 41 | ||
3337 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/SourceStg.java' | |||
3338 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/SourceStg.java 2015-09-05 22:18:55 +0000 | |||
3339 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/SourceStg.java 2015-09-25 14:54:20 +0000 | |||
3340 | @@ -6,12 +6,14 @@ | |||
3341 | 6 | 6 | ||
3342 | 7 | import org.workcraft.plugins.petri.VisualPlace; | 7 | import org.workcraft.plugins.petri.VisualPlace; |
3343 | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; | 8 | import org.workcraft.plugins.stg.VisualSignalTransition; |
3344 | 9 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
3345 | 10 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
3346 | 9 | 11 | ||
3347 | 10 | public class SourceStg extends NodeStg { | 12 | public class SourceStg extends NodeStg { |
3349 | 11 | public final SignalStg o; | 13 | public final ContactStg o; |
3350 | 12 | public final SignalStg oracle; | 14 | public final SignalStg oracle; |
3351 | 13 | 15 | ||
3353 | 14 | public SourceStg(SignalStg o, SignalStg oracle) { | 16 | public SourceStg(ContactStg o, SignalStg oracle) { |
3354 | 15 | this.o = o; | 17 | this.o = o; |
3355 | 16 | this.oracle = oracle; | 18 | this.oracle = oracle; |
3356 | 17 | } | 19 | } |
3357 | 18 | 20 | ||
3358 | === modified file 'XmasPlugin/src/org/workcraft/plugins/xmas/stg/StgGenerator.java' | |||
3359 | --- XmasPlugin/src/org/workcraft/plugins/xmas/stg/StgGenerator.java 2015-09-14 16:35:29 +0000 | |||
3360 | +++ XmasPlugin/src/org/workcraft/plugins/xmas/stg/StgGenerator.java 2015-09-25 14:54:20 +0000 | |||
3361 | @@ -1,662 +1,1259 @@ | |||
3362 | 1 | package org.workcraft.plugins.xmas.stg; | 1 | package org.workcraft.plugins.xmas.stg; |
3363 | 2 | 2 | ||
3364 | 3 | import java.awt.geom.AffineTransform; | ||
3365 | 4 | import java.awt.geom.Point2D; | 3 | import java.awt.geom.Point2D; |
3366 | 5 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
3367 | 5 | import java.util.Arrays; | ||
3368 | 6 | import java.util.HashMap; | 6 | import java.util.HashMap; |
3369 | 7 | import java.util.HashSet; | ||
3370 | 7 | import java.util.Map; | 8 | import java.util.Map; |
3371 | 9 | import java.util.Set; | ||
3372 | 8 | 10 | ||
3373 | 9 | import org.workcraft.dom.Container; | ||
3374 | 10 | import org.workcraft.dom.Node; | 11 | import org.workcraft.dom.Node; |
3378 | 11 | import org.workcraft.dom.visual.Movable; | 12 | import org.workcraft.dom.visual.VisualComponent; |
3376 | 12 | import org.workcraft.dom.visual.Positioning; | ||
3377 | 13 | import org.workcraft.dom.visual.TransformHelper; | ||
3379 | 14 | import org.workcraft.exceptions.InvalidConnectionException; | 13 | import org.workcraft.exceptions.InvalidConnectionException; |
3380 | 15 | import org.workcraft.plugins.petri.VisualPlace; | 14 | import org.workcraft.plugins.petri.VisualPlace; |
3381 | 16 | import org.workcraft.plugins.petri.VisualReplicaPlace; | ||
3382 | 17 | import org.workcraft.plugins.stg.STG; | ||
3383 | 18 | import org.workcraft.plugins.stg.SignalTransition; | 15 | import org.workcraft.plugins.stg.SignalTransition; |
3384 | 19 | import org.workcraft.plugins.stg.SignalTransition.Type; | 16 | import org.workcraft.plugins.stg.SignalTransition.Type; |
3385 | 20 | import org.workcraft.plugins.stg.VisualSTG; | ||
3386 | 21 | import org.workcraft.plugins.stg.VisualSignalTransition; | 17 | import org.workcraft.plugins.stg.VisualSignalTransition; |
3387 | 18 | import org.workcraft.plugins.stg.generator.NodeStg; | ||
3388 | 19 | import org.workcraft.plugins.stg.generator.SignalStg; | ||
3389 | 22 | import org.workcraft.plugins.xmas.VisualXmas; | 20 | import org.workcraft.plugins.xmas.VisualXmas; |
3390 | 23 | import org.workcraft.plugins.xmas.XmasUtils; | 21 | import org.workcraft.plugins.xmas.XmasUtils; |
3391 | 24 | import org.workcraft.plugins.xmas.components.VisualForkComponent; | 22 | import org.workcraft.plugins.xmas.components.VisualForkComponent; |
3392 | 25 | import org.workcraft.plugins.xmas.components.VisualFunctionComponent; | 23 | import org.workcraft.plugins.xmas.components.VisualFunctionComponent; |
3393 | 26 | import org.workcraft.plugins.xmas.components.VisualJoinComponent; | 24 | import org.workcraft.plugins.xmas.components.VisualJoinComponent; |
3394 | 25 | import org.workcraft.plugins.xmas.components.VisualMergeComponent; | ||
3395 | 27 | import org.workcraft.plugins.xmas.components.VisualQueueComponent; | 26 | import org.workcraft.plugins.xmas.components.VisualQueueComponent; |
3396 | 28 | import org.workcraft.plugins.xmas.components.VisualSinkComponent; | 27 | import org.workcraft.plugins.xmas.components.VisualSinkComponent; |
3397 | 29 | import org.workcraft.plugins.xmas.components.VisualSourceComponent; | 28 | import org.workcraft.plugins.xmas.components.VisualSourceComponent; |
3398 | 29 | import org.workcraft.plugins.xmas.components.VisualSwitchComponent; | ||
3399 | 30 | import org.workcraft.plugins.xmas.components.VisualXmasComponent; | 30 | import org.workcraft.plugins.xmas.components.VisualXmasComponent; |
3400 | 31 | import org.workcraft.plugins.xmas.components.VisualXmasContact; | 31 | import org.workcraft.plugins.xmas.components.VisualXmasContact; |
3401 | 32 | import org.workcraft.util.Hierarchy; | 32 | import org.workcraft.util.Hierarchy; |
3402 | 33 | 33 | ||
3428 | 34 | public class StgGenerator { | 34 | public class StgGenerator extends org.workcraft.plugins.stg.generator.StgGenerator { |
3429 | 35 | public static final String nameOirdy = "_Oirdy"; | 35 | |
3430 | 36 | public static final String nameAirdy = "_Airdy"; | 36 | private enum XmasStgType { IORACLE, TORACLE, IRDY, IDN, TRDY, TDN } |
3431 | 37 | public static final String nameBirdy = "_Birdy"; | 37 | |
3432 | 38 | public static final String nameItrdy = "_Itrdy"; | 38 | private static final String _INITIATOR = "I"; |
3433 | 39 | public static final String nameAtrdy = "_Atrdy"; | 39 | private static final String _TARGET = "T"; |
3434 | 40 | public static final String nameBtrdy = "_Btrdy"; | 40 | private static final String _RDY = "Rdy"; |
3435 | 41 | public static final String nameOracle = "_oracle"; | 41 | private static final String _DN = "Dn"; |
3436 | 42 | public static final String nameMem = "_mem"; | 42 | private static final String _ORACLE = "_oracle"; |
3437 | 43 | public static final String nameHead = "_hd"; | 43 | private static final String _MEM = "_mem"; |
3438 | 44 | public static final String nameTail = "_tl"; | 44 | private static final String _HEAD = "_hd"; |
3439 | 45 | public static final String name0 = "_0"; | 45 | private static final String _TAIL = "_tl"; |
3440 | 46 | public static final String name1 = "_1"; | 46 | private static final String _PORT_I = "_i"; |
3441 | 47 | private static final double xScaling = 6; | 47 | private static final String _PORT_O = "_o"; |
3442 | 48 | private static final double yScaling = 6; | 48 | private static final String _PORT_A = "_a"; |
3443 | 49 | 49 | private static final String _PORT_B = "_b"; | |
3444 | 50 | private Map<VisualXmasContact, SignalStg> contactMap = new HashMap<>(); | 50 | |
3445 | 51 | private Map<VisualSourceComponent, SourceStg> sourceMap = new HashMap<>(); | 51 | private static final String _O_IRDY = _PORT_O + _INITIATOR + _RDY; |
3446 | 52 | private Map<VisualSinkComponent, SinkStg> sinkMap = new HashMap<>(); | 52 | private static final String _O_IDN = _PORT_O + _INITIATOR + _DN; |
3447 | 53 | private Map<VisualFunctionComponent, FunctionStg> functionMap = new HashMap<>(); | 53 | private static final String _A_IRDY = _PORT_A + _INITIATOR + _RDY; |
3448 | 54 | private Map<VisualForkComponent, ForkStg> forkMap = new HashMap<>(); | 54 | private static final String _A_IDN = _PORT_A + _INITIATOR + _DN; |
3449 | 55 | private Map<VisualJoinComponent, JoinStg> joinMap = new HashMap<>(); | 55 | private static final String _B_IRDY = _PORT_B + _INITIATOR + _RDY; |
3450 | 56 | private Map<VisualQueueComponent, QueueStg> queueMap = new HashMap<>(); | 56 | private static final String _B_IDN = _PORT_B + _INITIATOR + _DN; |
3451 | 57 | private final VisualXmas xmas; | 57 | |
3452 | 58 | private final VisualSTG stg; | 58 | private static final String _I_TRDY = _PORT_I + _TARGET + _RDY; |
3453 | 59 | private static final String _I_TDN = _PORT_I + _TARGET + _DN; | ||
3454 | 60 | private static final String _A_TRDY = _PORT_A + _TARGET + _RDY; | ||
3455 | 61 | private static final String _A_TDN = _PORT_A + _TARGET + _DN; | ||
3456 | 62 | private static final String _B_TRDY = _PORT_B + _TARGET + _RDY; | ||
3457 | 63 | private static final String _B_TDN = _PORT_B + _TARGET + _DN; | ||
3458 | 64 | |||
3459 | 65 | private static final double QUEUE_SLOT_SPACING = 20.0; | ||
3460 | 66 | |||
3461 | 67 | private SignalStg clockStg; | ||
3462 | 68 | private Set<SignalStg> clockControlSignals; | ||
3463 | 69 | private Map<VisualXmasContact, ContactStg> contactMap; | ||
3464 | 70 | private Map<VisualSourceComponent, SourceStg> sourceMap; | ||
3465 | 71 | private Map<VisualSinkComponent, SinkStg> sinkMap; | ||
3466 | 72 | private Map<VisualFunctionComponent, FunctionStg> functionMap; | ||
3467 | 73 | private Map<VisualForkComponent, ForkStg> forkMap; | ||
3468 | 74 | private Map<VisualJoinComponent, JoinStg> joinMap; | ||
3469 | 75 | private Map<VisualSwitchComponent, SwitchStg> switchMap; | ||
3470 | 76 | private Map<VisualMergeComponent, MergeStg> mergeMap; | ||
3471 | 77 | private Map<VisualQueueComponent, QueueStg> queueMap; | ||
3472 | 59 | 78 | ||
3473 | 60 | public StgGenerator(VisualXmas xmas) { | 79 | public StgGenerator(VisualXmas xmas) { |
3477 | 61 | this.xmas = xmas; | 80 | super(xmas); |
3478 | 62 | this.stg = new VisualSTG(new STG()); | 81 | } |
3479 | 63 | convert(); | 82 | |
3480 | 83 | private VisualXmas getXmasModel() { | ||
3481 | 84 | return (VisualXmas)getSrcModel(); | ||
3482 | 64 | } | 85 | } |
3483 | 65 | 86 | ||
3485 | 66 | private void convert() { | 87 | @Override |
3486 | 88 | public void convert() { | ||
3487 | 89 | HashSet<VisualXmasComponent> remainingComponents = new HashSet<>(); | ||
3488 | 90 | remainingComponents.addAll(Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualXmasComponent.class)); | ||
3489 | 67 | try { | 91 | try { |
3513 | 68 | for(VisualSourceComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualSourceComponent.class)) { | 92 | { |
3514 | 69 | SourceStg sourceStg = generateSourceStg(component); | 93 | clockStg = generateClockStg(); |
3515 | 70 | sourceMap.put(component, sourceStg); | 94 | clockControlSignals = new HashSet<>(); |
3516 | 71 | } | 95 | groupComponentStg(clockStg); |
3517 | 72 | for(VisualSinkComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualSinkComponent.class)) { | 96 | } |
3518 | 73 | SinkStg sinkStg = generateSinkStg(component); | 97 | for(VisualSourceComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSourceComponent.class)) { |
3519 | 74 | sinkMap.put(component, sinkStg); | 98 | SourceStg stg = generateSourceStg(component); |
3520 | 75 | } | 99 | groupComponentStg(stg); |
3521 | 76 | for(VisualFunctionComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualFunctionComponent.class)) { | 100 | putSourceStg(component, stg); |
3522 | 77 | FunctionStg functionStg = generateFunctionStg(component); | 101 | remainingComponents.remove(component); |
3523 | 78 | functionMap.put(component, functionStg); | 102 | } |
3524 | 79 | } | 103 | for(VisualSinkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSinkComponent.class)) { |
3525 | 80 | for(VisualForkComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualForkComponent.class)) { | 104 | SinkStg stg = generateSinkStg(component); |
3526 | 81 | ForkStg forkStg = generateForkStg(component); | 105 | groupComponentStg(stg); |
3527 | 82 | forkMap.put(component, forkStg); | 106 | putSinkStg(component, stg); |
3528 | 83 | } | 107 | remainingComponents.remove(component); |
3529 | 84 | for(VisualJoinComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualJoinComponent.class)) { | 108 | } |
3530 | 85 | JoinStg joinStg = generateJoinStg(component); | 109 | for(VisualFunctionComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualFunctionComponent.class)) { |
3531 | 86 | joinMap.put(component, joinStg); | 110 | FunctionStg stg = generateFunctionStg(component); |
3532 | 87 | } | 111 | groupComponentStg(stg); |
3533 | 88 | for(VisualQueueComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualQueueComponent.class)) { | 112 | putFunctionStg(component, stg); |
3534 | 89 | QueueStg queueStg = generateQueueStg(component); | 113 | remainingComponents.remove(component); |
3535 | 90 | queueMap.put(component, queueStg); | 114 | } |
3536 | 115 | for(VisualForkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualForkComponent.class)) { | ||
3537 | 116 | ForkStg stg = generateForkStg(component); | ||
3538 | 117 | groupComponentStg(stg); | ||
3539 | 118 | putForkStg(component, stg); | ||
3540 | 119 | remainingComponents.remove(component); | ||
3541 | 120 | } | ||
3542 | 121 | for(VisualJoinComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualJoinComponent.class)) { | ||
3543 | 122 | JoinStg stg = generateJoinStg(component); | ||
3544 | 123 | groupComponentStg(stg); | ||
3545 | 124 | putJoinStg(component, stg); | ||
3546 | 125 | remainingComponents.remove(component); | ||
3547 | 126 | } | ||
3548 | 127 | for(VisualSwitchComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSwitchComponent.class)) { | ||
3549 | 128 | SwitchStg stg = generateSwitchStg(component); | ||
3550 | 129 | groupComponentStg(stg); | ||
3551 | 130 | putSwitchStg(component, stg); | ||
3552 | 131 | remainingComponents.remove(component); | ||
3553 | 132 | } | ||
3554 | 133 | for(VisualMergeComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualMergeComponent.class)) { | ||
3555 | 134 | MergeStg stg = generateMergeStg(component); | ||
3556 | 135 | groupComponentStg(stg); | ||
3557 | 136 | putMergeStg(component, stg); | ||
3558 | 137 | remainingComponents.remove(component); | ||
3559 | 138 | } | ||
3560 | 139 | for(VisualQueueComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualQueueComponent.class)) { | ||
3561 | 140 | QueueStg stg = generateQueueStg(component); | ||
3562 | 141 | groupComponentStg(stg); | ||
3563 | 142 | putQueueStg(component, stg); | ||
3564 | 143 | remainingComponents.remove(component); | ||
3565 | 91 | } | 144 | } |
3566 | 92 | 145 | ||
3568 | 93 | for(VisualSourceComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualSourceComponent.class)) { | 146 | connectClockStg(); |
3569 | 147 | for(VisualSourceComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSourceComponent.class)) { | ||
3570 | 94 | connectSourceStg(component); | 148 | connectSourceStg(component); |
3571 | 95 | } | 149 | } |
3573 | 96 | for(VisualSinkComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualSinkComponent.class)) { | 150 | for(VisualSinkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSinkComponent.class)) { |
3574 | 97 | connectSinkStg(component); | 151 | connectSinkStg(component); |
3575 | 98 | } | 152 | } |
3577 | 99 | for(VisualFunctionComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualFunctionComponent.class)) { | 153 | for(VisualFunctionComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualFunctionComponent.class)) { |
3578 | 100 | connectFunctionStg(component); | 154 | connectFunctionStg(component); |
3579 | 101 | } | 155 | } |
3581 | 102 | for(VisualForkComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualForkComponent.class)) { | 156 | for(VisualForkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualForkComponent.class)) { |
3582 | 103 | connectForkStg(component); | 157 | connectForkStg(component); |
3583 | 104 | } | 158 | } |
3585 | 105 | for(VisualJoinComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualJoinComponent.class)) { | 159 | for(VisualJoinComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualJoinComponent.class)) { |
3586 | 106 | connectJoinStg(component); | 160 | connectJoinStg(component); |
3587 | 107 | } | 161 | } |
3589 | 108 | for(VisualQueueComponent component : Hierarchy.getDescendantsOfType(xmas.getRoot(), VisualQueueComponent.class)) { | 162 | for(VisualSwitchComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSwitchComponent.class)) { |
3590 | 163 | connectSwitchStg(component); | ||
3591 | 164 | } | ||
3592 | 165 | for(VisualMergeComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualMergeComponent.class)) { | ||
3593 | 166 | connectMergeStg(component); | ||
3594 | 167 | } | ||
3595 | 168 | for(VisualQueueComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualQueueComponent.class)) { | ||
3596 | 109 | connectQueueStg(component); | 169 | connectQueueStg(component); |
3597 | 110 | } | 170 | } |
3598 | 111 | } catch (InvalidConnectionException e) { | 171 | } catch (InvalidConnectionException e) { |
3599 | 112 | throw new RuntimeException(e); | 172 | throw new RuntimeException(e); |
3600 | 113 | } | 173 | } |
3783 | 114 | stg.selectNone(); | 174 | for (VisualComponent component: remainingComponents) { |
3784 | 115 | } | 175 | String name = getXmasModel().getNodeMathReference(component); |
3785 | 116 | 176 | System.out.println("ERROR: Cannot derive an STG for xMAS component '" + name +"' of type " + component.getClass().getName()); | |
3786 | 117 | public VisualSTG getStg() { | 177 | } |
3787 | 118 | return stg; | 178 | getXmasModel().selectNone(); |
3788 | 119 | } | 179 | } |
3789 | 120 | 180 | ||
3790 | 121 | static void setPosition(Movable node, double x, double y) { | 181 | private void createReplicaReadArcBetweenDoneSignals(SignalStg from, SignalStg to, double yOffset) throws InvalidConnectionException { |
3791 | 122 | TransformHelper.applyTransform(node, AffineTransform.getTranslateInstance(x, y)); | 182 | double xT = to.fallList.get(0).getRootSpaceX(); |
3792 | 123 | } | 183 | double xP = to.one.getRootSpaceX(); |
3793 | 124 | 184 | double yZero = to.zero.getRootSpaceY(); | |
3794 | 125 | private void createConsumingArc(VisualPlace p, VisualSignalTransition t) throws InvalidConnectionException { | 185 | double yOne = to.one.getRootSpaceY(); |
3795 | 126 | if (p != null && t != null) { | 186 | double xFall = ((xT > xP) ? xT + 6.0 : xT - 6.0); |
3796 | 127 | stg.connect(p, t); | 187 | double yFall = yZero; |
3797 | 128 | } | 188 | double xRise = ((xT < xP) ? xT + 6.0 : xT - 6.0); |
3798 | 129 | } | 189 | double yRise = ((yOne > yZero) ? yOne + 1.0 : yOne - 1.0); |
3799 | 130 | 190 | createReplicaReadArcs(from.zero, to.fallList, new Point2D.Double(xFall, yFall + yOffset)); | |
3800 | 131 | private void createProducingArc(VisualSignalTransition t, VisualPlace p) throws InvalidConnectionException { | 191 | createReplicaReadArcs(from.one, to.riseList, new Point2D.Double(xRise, yRise + yOffset)); |
3801 | 132 | if (p != null && t != null) { | 192 | } |
3802 | 133 | stg.connect(t, p); | 193 | |
3803 | 134 | } | 194 | |
3804 | 135 | } | 195 | private void createReplicaReadArcsFromDoneToClock(SignalStg dn) throws InvalidConnectionException { |
3805 | 136 | 196 | clockControlSignals.add(dn); | |
3806 | 137 | private void createReadArc(VisualPlace p, VisualSignalTransition t) throws InvalidConnectionException { | 197 | int cnt = clockControlSignals.size(); |
3807 | 138 | if (p != null && t != null) { | 198 | double dx = 4.0; |
3808 | 139 | stg.connectUndirected(p, t); | 199 | int dy = (cnt % 2 == 0 ? 1 : -1) * cnt / 2; |
3809 | 140 | } | 200 | for (VisualSignalTransition t: clockStg.fallList) { |
3810 | 141 | } | 201 | createReplicaReadArc(dn.zero, t, dx, dy); |
3811 | 142 | 202 | } | |
3812 | 143 | private void createReplicaReadArc(VisualPlace p, VisualSignalTransition t, Point2D replicaPosition) throws InvalidConnectionException { | 203 | for (VisualSignalTransition t: clockStg.riseList) { |
3813 | 144 | if (p != null && t != null) { | 204 | createReplicaReadArc(dn.one, t, -dx, dy); |
3814 | 145 | Container container = Hierarchy.getNearestContainer(t); | 205 | } |
3815 | 146 | VisualReplicaPlace replicaPlace = stg.createVisualReplica(p, container, VisualReplicaPlace.class); | 206 | } |
3816 | 147 | if (replicaPosition != null) { | 207 | |
3817 | 148 | replicaPlace.setRootSpacePosition(replicaPosition); | 208 | private void createReplicaReadArcsFromClockToDone(SignalStg dn) throws InvalidConnectionException { |
3818 | 149 | } | 209 | double xt = 0.0; |
3819 | 150 | stg.connectUndirected(replicaPlace, t); | 210 | for (VisualSignalTransition t: dn.getAllTransitions()) { |
3820 | 151 | } | 211 | xt += t.getRootSpaceX(); |
3821 | 152 | } | 212 | } |
3822 | 153 | 213 | xt /= dn.getAllTransitions().size(); | |
3823 | 154 | private SignalStg generateInputContactStg(String signalName, double x, double y) throws InvalidConnectionException { | 214 | double xp = 0.0; |
3824 | 155 | return generateInputContactStg(signalName, x, y, false, Type.INTERNAL, 1, 1); | 215 | for (VisualPlace p: dn.getAllPlaces()) { |
3825 | 156 | } | 216 | xp += p.getRootSpaceX(); |
3826 | 157 | 217 | } | |
3827 | 158 | private SignalStg generateInputContactStg(String signalName, double x, double y, boolean initToOne, | 218 | xp /= dn.getAllPlaces().size(); |
3828 | 159 | SignalTransition.Type type, int fallCount, int riseCount) throws InvalidConnectionException { | 219 | Point2D centerPos = getSignalCenterPosition(dn); |
3829 | 160 | 220 | Point2D clk1Pos = centerPos; | |
3830 | 161 | VisualPlace zero = stg.createPlace(signalName + name0, null); | 221 | if (dn.fallList.size() > 1) { |
3831 | 162 | zero.setNamePositioning(Positioning.BOTTOM); | 222 | clk1Pos = new Point2D.Double(centerPos.getX() + (xt - xp), centerPos.getY()); |
3832 | 163 | zero.setLabelPositioning(Positioning.TOP); | 223 | } |
3833 | 164 | setPosition(zero, x - 4.0, y + 1.0); | 224 | Point2D clk0Pos = new Point2D.Double(centerPos.getX() + (xt - xp) / 2.0, centerPos.getY()); |
3834 | 165 | 225 | createReplicaReadArcs(clockStg.one, dn.fallList, clk1Pos); | |
3835 | 166 | VisualPlace one = stg.createPlace(signalName + name1, null); | 226 | createReplicaReadArcs(clockStg.zero, dn.riseList, clk0Pos); |
3836 | 167 | one.setNamePositioning(Positioning.TOP); | 227 | } |
3837 | 168 | one.setLabelPositioning(Positioning.BOTTOM); | 228 | |
3838 | 169 | setPosition(one, x - 4.0, y - 1.0); | 229 | private void createReplicaReadArcFromSignalToOracle(SignalStg signal, SignalStg oracle) throws InvalidConnectionException { |
3839 | 170 | 230 | double x = oracle.fallList.get(0).getRootSpaceX(); | |
3840 | 171 | if (initToOne) { | 231 | double yFall = oracle.fallList.get(0).getRootSpaceY(); |
3841 | 172 | one.getReferencedPlace().setTokens(1); | 232 | double yRise = oracle.riseList.get(0).getRootSpaceY(); |
3842 | 173 | zero.getReferencedPlace().setTokens(0); | 233 | double y = ((yFall > yRise) ? yFall + 2.0 : yFall - 2.0); |
3843 | 174 | } else { | 234 | createReplicaReadArcs(signal.one, oracle.fallList, new Point2D.Double(x, y)); |
3844 | 175 | one.getReferencedPlace().setTokens(0); | 235 | } |
3845 | 176 | zero.getReferencedPlace().setTokens(1); | 236 | |
3846 | 177 | } | 237 | private void createReplicaReadArcsFromClockToCombinational(SignalStg rdy) throws InvalidConnectionException { |
3847 | 178 | 238 | double xt = 0.0; | |
3848 | 179 | ArrayList<VisualSignalTransition> fallList = new ArrayList<>(fallCount); | 239 | for (VisualSignalTransition t: rdy.getAllTransitions()) { |
3849 | 180 | for (int i = 0; i < fallCount; i++) { | 240 | xt += t.getRootSpaceX(); |
3850 | 181 | VisualSignalTransition fall = stg.createSignalTransition(signalName, type, SignalTransition.Direction.MINUS, null); | 241 | } |
3851 | 182 | createConsumingArc(one, fall); | 242 | xt /= rdy.getAllTransitions().size(); |
3852 | 183 | createProducingArc(fall, zero); | 243 | double xp = 0.0; |
3853 | 184 | setPosition(fall, x + 0.0, y + 1.0 + i); | 244 | double yp = 0.0; |
3854 | 185 | fallList.add(fall); | 245 | for (VisualPlace p: rdy.getAllPlaces()) { |
3855 | 186 | } | 246 | xp += p.getRootSpaceX(); |
3856 | 187 | 247 | yp += p.getRootSpaceY(); | |
3857 | 188 | ArrayList<VisualSignalTransition> riseList = new ArrayList<>(riseCount); | 248 | } |
3858 | 189 | for (int i = 0; i < riseCount; i++) { | 249 | xp /= rdy.getAllPlaces().size(); |
3859 | 190 | VisualSignalTransition rise = stg.createSignalTransition(signalName, type, SignalTransition.Direction.PLUS, null); | 250 | yp /= rdy.getAllPlaces().size(); |
3860 | 191 | createConsumingArc(zero, rise); | 251 | Point2D clk0Pos = new Point2D.Double(xt + (xt - xp) / 2.0, yp); |
3861 | 192 | createProducingArc(rise, one); | 252 | createReplicaReadArcs(clockStg.zero, rdy.getAllTransitions(), clk0Pos); |
3862 | 193 | setPosition(rise, x + 0.0, y - 1.0 - i); | 253 | } |
3863 | 194 | riseList.add(rise); | 254 | |
3864 | 195 | } | 255 | private void createReplicaReadArcsFromClockToSequential(SignalStg rdy) throws InvalidConnectionException { |
3865 | 196 | 256 | createReplicaReadArcs(clockStg.one, rdy.getAllTransitions(), getSignalCenterPosition(rdy)); | |
3866 | 197 | return new SignalStg(zero, one, fallList, riseList); | 257 | } |
3867 | 198 | } | 258 | |
3868 | 199 | 259 | private SignalStg generateSignalStg(XmasStgType xmasSignalType, String signalName, double x, double y) throws InvalidConnectionException { | |
3869 | 200 | private SignalStg generateOutputContactStg(String signalName, double x, double y) throws InvalidConnectionException { | 260 | return generateSignalStg(xmasSignalType, signalName, new Point2D.Double(x, y), 1, 1); |
3870 | 201 | return generateOutputContactStg(signalName, x, y, false, Type.INTERNAL, 1, 1); | 261 | } |
3871 | 202 | } | 262 | |
3872 | 203 | 263 | private SignalStg generateSignalStg(XmasStgType xmasSignalType, String signalName, double x, double y, int fallCount, int riseCount) throws InvalidConnectionException { | |
3873 | 204 | private SignalStg generateOutputContactStg(String signalName, double x, double y, boolean initToOne, | 264 | return generateSignalStg(xmasSignalType, signalName, new Point2D.Double(x, y), fallCount, riseCount); |
3874 | 205 | SignalTransition.Type type, int fallCount, int riseCount) throws InvalidConnectionException { | 265 | } |
3875 | 206 | 266 | ||
3876 | 207 | VisualPlace zero = stg.createPlace(signalName + name0, null); | 267 | private SignalStg generateSignalStg(XmasStgType xmasSignalType, String signalName, Point2D pos, int fallCount, int riseCount) throws InvalidConnectionException { |
3877 | 208 | zero.setNamePositioning(Positioning.BOTTOM); | 268 | SignalLayoutType layoutType = SignalLayoutType.LEFT_TO_RIGHT; |
3878 | 209 | zero.setLabelPositioning(Positioning.TOP); | 269 | SignalTransition.Type type = Type.INTERNAL; |
3879 | 210 | setPosition(zero, x + 4.0, y + 1.0); | 270 | switch (xmasSignalType) { |
3880 | 211 | 271 | case IDN: | |
3881 | 212 | VisualPlace one = stg.createPlace(signalName + name1, null); | 272 | layoutType = SignalLayoutType.LEFT_TO_RIGHT_INVERTED; |
3882 | 213 | one.setNamePositioning(Positioning.TOP); | 273 | type = Type.OUTPUT; |
3883 | 214 | one.setLabelPositioning(Positioning.BOTTOM); | 274 | break; |
3884 | 215 | setPosition(one, x + 4.0, y - 1.0); | 275 | case IORACLE: |
3885 | 216 | 276 | layoutType = SignalLayoutType.LEFT_TO_RIGHT; | |
3886 | 217 | if (initToOne) { | 277 | type = Type.INPUT; |
3887 | 218 | one.getReferencedPlace().setTokens(1); | 278 | break; |
3888 | 219 | zero.getReferencedPlace().setTokens(0); | 279 | case IRDY: |
3889 | 220 | } else { | 280 | layoutType = SignalLayoutType.LEFT_TO_RIGHT; |
3890 | 221 | one.getReferencedPlace().setTokens(0); | 281 | type = Type.INTERNAL; |
3891 | 222 | zero.getReferencedPlace().setTokens(1); | 282 | break; |
3892 | 223 | } | 283 | case TDN: |
3893 | 224 | 284 | layoutType = SignalLayoutType.RIGHT_TO_LEFT; | |
3894 | 225 | ArrayList<VisualSignalTransition> fallList = new ArrayList<>(fallCount); | 285 | type = Type.OUTPUT; |
3895 | 226 | for (int i = 0; i < fallCount; i++) { | 286 | break; |
3896 | 227 | VisualSignalTransition fall = stg.createSignalTransition(signalName, type, SignalTransition.Direction.MINUS, null); | 287 | case TORACLE: |
3897 | 228 | createConsumingArc(one, fall); | 288 | layoutType = SignalLayoutType.RIGHT_TO_LEFT_INVERTED; |
3898 | 229 | createProducingArc(fall, zero); | 289 | type = Type.INPUT; |
3899 | 230 | setPosition(fall, x - 0.0, y + 1.0 + i); | 290 | break; |
3900 | 231 | fallList.add(fall); | 291 | case TRDY: |
3901 | 232 | } | 292 | layoutType = SignalLayoutType.RIGHT_TO_LEFT_INVERTED; |
3902 | 233 | 293 | type = Type.INTERNAL; | |
3903 | 234 | ArrayList<VisualSignalTransition> riseList = new ArrayList<>(riseCount); | 294 | break; |
3904 | 235 | for (int i = 0; i < riseCount; i++) { | 295 | default: |
3905 | 236 | VisualSignalTransition rise = stg.createSignalTransition(signalName, type, SignalTransition.Direction.PLUS, null); | 296 | layoutType = SignalLayoutType.LEFT_TO_RIGHT; |
3906 | 237 | createConsumingArc(zero, rise); | 297 | type = Type.INTERNAL; |
3907 | 238 | createProducingArc(rise, one); | 298 | break; |
3908 | 239 | setPosition(rise, x - 0.0, y - 1.0 - i); | 299 | } |
3909 | 240 | riseList.add(rise); | 300 | return generateSignalStg(layoutType, signalName, pos, type, fallCount, riseCount); |
3910 | 241 | } | 301 | } |
3911 | 242 | 302 | ||
3912 | 243 | return new SignalStg(zero, one, fallList, riseList); | 303 | public ContactStg getContactStg(VisualXmasContact contact) { |
3913 | 244 | } | 304 | return ((contactMap == null) ? null : contactMap.get(contact)); |
3914 | 245 | 305 | } | |
3915 | 246 | private SignalStg generateSignalStg(String signalName, double x, double y, boolean initToOne, SignalTransition.Type type) throws InvalidConnectionException { | 306 | |
3916 | 247 | VisualPlace zero = stg.createPlace(signalName + name0, null); | 307 | private void putContactStg(VisualXmasContact contact, ContactStg s) { |
3917 | 248 | zero.setNamePositioning(Positioning.BOTTOM); | 308 | if (contactMap == null) { |
3918 | 249 | zero.setLabelPositioning(Positioning.TOP); | 309 | contactMap = new HashMap<>(); |
3919 | 250 | setPosition(zero, x + 0.0, y + 2.0); | 310 | } |
3920 | 251 | 311 | contactMap.put(contact, s); | |
3921 | 252 | VisualPlace one = stg.createPlace(signalName + name1, null); | 312 | } |
3922 | 253 | one.setNamePositioning(Positioning.TOP); | 313 | |
3923 | 254 | one.setLabelPositioning(Positioning.BOTTOM); | 314 | private SignalStg generateClockStg() throws InvalidConnectionException { |
3924 | 255 | setPosition(one, x + 0.0, y - 2.0); | 315 | String name = "clk"; |
3925 | 256 | 316 | SignalStg clockStg = generateBasicSignalStg(name, 60.0, 25.0, Type.INPUT); | |
3926 | 257 | if (initToOne) { | 317 | setSignalInitialState(clockStg, true); |
3927 | 258 | one.getReferencedPlace().setTokens(1); | 318 | return clockStg; |
3928 | 259 | zero.getReferencedPlace().setTokens(0); | 319 | } |
3929 | 260 | } else { | 320 | |
3930 | 261 | one.getReferencedPlace().setTokens(0); | 321 | private void connectClockStg() throws InvalidConnectionException { |
3931 | 262 | zero.getReferencedPlace().setTokens(1); | 322 | for(VisualSourceComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSourceComponent.class)) { |
3932 | 263 | } | 323 | SourceStg sourceStg = getSourceStg(component); |
3933 | 264 | 324 | if (sourceStg != null) { | |
3934 | 265 | VisualSignalTransition fall = stg.createSignalTransition(signalName, type, SignalTransition.Direction.MINUS, null); | 325 | createReplicaReadArcsFromDoneToClock(sourceStg.o.dn); |
3935 | 266 | createConsumingArc(one, fall); | 326 | } |
3936 | 267 | createProducingArc(fall, zero); | 327 | } |
3937 | 268 | setPosition(fall, x + 3.0, y + 0.0); | 328 | for(VisualSinkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSinkComponent.class)) { |
3938 | 269 | 329 | SinkStg sinkStg = getSinkStg(component); | |
3939 | 270 | VisualSignalTransition rise = stg.createSignalTransition(signalName, type, SignalTransition.Direction.PLUS, null); | 330 | if (sinkStg != null) { |
3940 | 271 | createConsumingArc(zero, rise); | 331 | createReplicaReadArcsFromDoneToClock(sinkStg.i.dn); |
3941 | 272 | createProducingArc(rise, one); | 332 | } |
3942 | 273 | setPosition(rise, x - 3.0, y - 0.0); | 333 | } |
3943 | 274 | 334 | for(VisualFunctionComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualFunctionComponent.class)) { | |
3944 | 275 | return new SignalStg(zero, one, fall, rise); | 335 | FunctionStg funcStg = getFunctionStg(component); |
3945 | 276 | } | 336 | if (funcStg != null) { |
3946 | 277 | 337 | createReplicaReadArcsFromDoneToClock(funcStg.i.dn); | |
3947 | 278 | 338 | createReplicaReadArcsFromDoneToClock(funcStg.o.dn); | |
3948 | 279 | public SignalStg getContactStg(VisualXmasContact contact) { | 339 | } |
3949 | 280 | return contactMap.get(contact); | 340 | } |
3950 | 281 | } | 341 | for(VisualForkComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualForkComponent.class)) { |
3951 | 282 | 342 | ForkStg forkStg = getForkStg(component); | |
3952 | 283 | private Point2D getComponentPosition(VisualXmasComponent component) { | 343 | if (forkStg != null) { |
3953 | 284 | AffineTransform transform = TransformHelper.getTransformToRoot(component); | 344 | createReplicaReadArcsFromDoneToClock(forkStg.i.dn); |
3954 | 285 | double x = xScaling * (transform.getTranslateX() + component.getX()); | 345 | createReplicaReadArcsFromDoneToClock(forkStg.a.dn); |
3955 | 286 | double y = yScaling * (transform.getTranslateY() + component.getY()); | 346 | createReplicaReadArcsFromDoneToClock(forkStg.b.dn); |
3956 | 287 | return new Point2D.Double(x, y); | 347 | } |
3957 | 288 | } | 348 | } |
3958 | 289 | 349 | for(VisualJoinComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualJoinComponent.class)) { | |
3959 | 290 | private void groupComponentStg(NodeStg nodeStg) { | 350 | JoinStg joinStg = getJoinStg(component); |
3960 | 291 | stg.select(nodeStg.getAllNodes()); | 351 | if (joinStg != null) { |
3961 | 292 | stg.groupSelection(); | 352 | createReplicaReadArcsFromDoneToClock(joinStg.a.dn); |
3962 | 293 | } | 353 | createReplicaReadArcsFromDoneToClock(joinStg.b.dn); |
3963 | 294 | 354 | createReplicaReadArcsFromDoneToClock(joinStg.o.dn); | |
3964 | 295 | 355 | } | |
3965 | 356 | } | ||
3966 | 357 | for(VisualSwitchComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualSwitchComponent.class)) { | ||
3967 | 358 | SwitchStg switchStg = getSwitchStg(component); | ||
3968 | 359 | if (switchStg != null) { | ||
3969 | 360 | createReplicaReadArcsFromDoneToClock(switchStg.i.dn); | ||
3970 | 361 | createReplicaReadArcsFromDoneToClock(switchStg.a.dn); | ||
3971 | 362 | createReplicaReadArcsFromDoneToClock(switchStg.b.dn); | ||
3972 | 363 | } | ||
3973 | 364 | } | ||
3974 | 365 | for(VisualMergeComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualMergeComponent.class)) { | ||
3975 | 366 | MergeStg mergeStg = getMergeStg(component); | ||
3976 | 367 | if (mergeStg != null) { | ||
3977 | 368 | createReplicaReadArcsFromDoneToClock(mergeStg.a.dn); | ||
3978 | 369 | createReplicaReadArcsFromDoneToClock(mergeStg.b.dn); | ||
3979 | 370 | createReplicaReadArcsFromDoneToClock(mergeStg.o.dn); | ||
3980 | 371 | } | ||
3981 | 372 | } | ||
3982 | 373 | for(VisualQueueComponent component : Hierarchy.getDescendantsOfType(getXmasModel().getRoot(), VisualQueueComponent.class)) { | ||
3983 | 374 | QueueStg queueStg = getQueueStg(component); | ||
3984 | 375 | if (queueStg != null) { | ||
3985 | 376 | createReplicaReadArcsFromDoneToClock(queueStg.i.dn); | ||
3986 | 377 | createReplicaReadArcsFromDoneToClock(queueStg.o.dn); | ||
3987 | 378 | } | ||
3988 | 379 | } | ||
3989 | 380 | } | ||
3990 | 381 | |||
3991 | 382 | public SignalStg getClockStg() { | ||
3992 | 383 | return clockStg; | ||
3993 | 384 | } | ||
3994 | 385 | |||
3995 | 386 | |||
3996 | 296 | private SourceStg generateSourceStg(VisualSourceComponent component) throws InvalidConnectionException { | 387 | private SourceStg generateSourceStg(VisualSourceComponent component) throws InvalidConnectionException { |
3998 | 297 | String name = xmas.getMathName(component); | 388 | String name = getXmasModel().getMathName(component); |
3999 | 298 | Point2D pos = getComponentPosition(component); | 389 | Point2D pos = getComponentPosition(component); |
4002 | 299 | SignalStg oracleStg = generateOutputContactStg(name + nameOracle, pos.getX() - 4.0, pos.getY(), false, Type.INPUT, 1, 1); | 390 | SignalStg oracle = generateSignalStg(XmasStgType.IORACLE, name + _ORACLE, pos.getX() - 10.0, pos.getY()); |
4003 | 300 | SignalStg oStg = null; | 391 | ContactStg o = null; |
4004 | 301 | for (VisualXmasContact contact: component.getContacts()) { | 392 | for (VisualXmasContact contact: component.getContacts()) { |
4005 | 302 | if (contact.isOutput()) { | 393 | if (contact.isOutput()) { |
4017 | 303 | oStg = generateOutputContactStg(name + nameOirdy, pos.getX() + 4.0, pos.getY()); | 394 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _O_IRDY, pos.getX() + 0.0, pos.getY()); |
4018 | 304 | contactMap.put(contact, oStg); | 395 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _O_IDN, pos.getX() + 0.0, pos.getY() - 8.0, 1, 2); |
4019 | 305 | } | 396 | o = new ContactStg(rdy, dn); |
4020 | 306 | } | 397 | putContactStg(contact, o); |
4021 | 307 | if ((oStg != null) && (oracleStg != null)) { | 398 | } |
4022 | 308 | createReadArc(oracleStg.zero, oStg.fallList.get(0)); | 399 | } |
4023 | 309 | createReadArc(oracleStg.one, oStg.riseList.get(0)); | 400 | if (o != null) { |
4024 | 310 | } | 401 | if (oracle != null) { |
4025 | 311 | SourceStg sourceStg = new SourceStg(oStg, oracleStg); | 402 | createReadArc(oracle.zero, o.rdy.fallList.get(0)); |
4026 | 312 | groupComponentStg(sourceStg); | 403 | createReadArc(oracle.one, o.rdy.riseList.get(0)); |
4027 | 313 | return sourceStg; | 404 | createReadArc(oracle.zero, o.dn.riseList.get(0)); |
4028 | 405 | createReadArc(oracle.one, o.dn.riseList.get(1)); | ||
4029 | 406 | } | ||
4030 | 407 | createReadArc(o.rdy.zero, o.dn.riseList.get(0)); | ||
4031 | 408 | createReadArc(o.rdy.one, o.dn.riseList.get(1)); | ||
4032 | 409 | } | ||
4033 | 410 | return new SourceStg(o, oracle); | ||
4034 | 314 | } | 411 | } |
4035 | 315 | 412 | ||
4036 | 316 | private void connectSourceStg(VisualSourceComponent component) throws InvalidConnectionException { | 413 | private void connectSourceStg(VisualSourceComponent component) throws InvalidConnectionException { |
4037 | 317 | VisualXmasContact oContact = null; | ||
4038 | 318 | for (VisualXmasContact contact: component.getContacts()) { | ||
4039 | 319 | if (contact.isOutput()) { | ||
4040 | 320 | oContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4041 | 321 | } | ||
4042 | 322 | } | ||
4043 | 323 | SourceStg sourceStg = getSourceStg(component); | 414 | SourceStg sourceStg = getSourceStg(component); |
4047 | 324 | if ((sourceStg != null) && (oContact != null)) { | 415 | if (sourceStg != null) { |
4048 | 325 | SignalStg oStg = getContactStg(oContact); | 416 | VisualXmasContact oContact = null; |
4049 | 326 | createReadArc(oStg.one, sourceStg.oracle.fallList.get(0)); | 417 | for (VisualXmasContact contact: component.getContacts()) { |
4050 | 418 | if (contact.isOutput()) { | ||
4051 | 419 | oContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4052 | 420 | } | ||
4053 | 421 | } | ||
4054 | 422 | if (oContact != null) { | ||
4055 | 423 | ContactStg o = getContactStg(oContact); | ||
4056 | 424 | if (o != null) { | ||
4057 | 425 | createReplicaReadArcFromSignalToOracle(o.rdy, sourceStg.oracle); | ||
4058 | 426 | } | ||
4059 | 427 | if (clockStg != null) { | ||
4060 | 428 | createReplicaReadArcsFromClockToSequential(sourceStg.oracle); | ||
4061 | 429 | createReplicaReadArcsFromClockToCombinational(sourceStg.o.rdy); | ||
4062 | 430 | createReplicaReadArcsFromClockToDone(sourceStg.o.dn); | ||
4063 | 431 | } | ||
4064 | 432 | } | ||
4065 | 327 | } | 433 | } |
4066 | 328 | } | 434 | } |
4067 | 329 | 435 | ||
4068 | 330 | public SourceStg getSourceStg(VisualSourceComponent component) { | 436 | public SourceStg getSourceStg(VisualSourceComponent component) { |
4070 | 331 | return sourceMap.get(component); | 437 | return ((sourceMap == null) ? null : sourceMap.get(component)); |
4071 | 438 | } | ||
4072 | 439 | |||
4073 | 440 | public void putSourceStg(VisualSourceComponent component, SourceStg stg) { | ||
4074 | 441 | if (sourceMap == null) { | ||
4075 | 442 | sourceMap = new HashMap<>(); | ||
4076 | 443 | } | ||
4077 | 444 | sourceMap.put(component, stg); | ||
4078 | 332 | } | 445 | } |
4079 | 333 | 446 | ||
4080 | 334 | 447 | ||
4081 | 335 | private SinkStg generateSinkStg(VisualSinkComponent component) throws InvalidConnectionException { | 448 | private SinkStg generateSinkStg(VisualSinkComponent component) throws InvalidConnectionException { |
4083 | 336 | String name = xmas.getMathName(component); | 449 | String name = getXmasModel().getMathName(component); |
4084 | 337 | Point2D pos = getComponentPosition(component); | 450 | Point2D pos = getComponentPosition(component); |
4087 | 338 | SignalStg oracleStg = generateInputContactStg(name + nameOracle, pos.getX() + 4.0, pos.getY(), false, Type.INPUT, 1, 1); | 451 | SignalStg oracle = generateSignalStg(XmasStgType.TORACLE, name + _ORACLE, pos.getX() + 10.0, pos.getY()); |
4088 | 339 | SignalStg iStg = null; | 452 | ContactStg i = null; |
4089 | 340 | for (VisualXmasContact contact: component.getContacts()) { | 453 | for (VisualXmasContact contact: component.getContacts()) { |
4090 | 341 | if (contact.isInput()) { | 454 | if (contact.isInput()) { |
4102 | 342 | iStg = generateInputContactStg(name + nameItrdy, pos.getX() - 4.0, pos.getY()); | 455 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _I_TRDY, pos.getX() - 0.0, pos.getY()); |
4103 | 343 | contactMap.put(contact, iStg); | 456 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _I_TDN, pos.getX() - 0.0, pos.getY() + 8.0, 1, 2); |
4104 | 344 | } | 457 | i = new ContactStg(rdy, dn); |
4105 | 345 | } | 458 | putContactStg(contact, i); |
4106 | 346 | if ((iStg != null) && (oracleStg != null)) { | 459 | } |
4107 | 347 | createReadArc(oracleStg.zero, iStg.fallList.get(0)); | 460 | } |
4108 | 348 | createReadArc(oracleStg.one, iStg.riseList.get(0)); | 461 | if (i != null) { |
4109 | 349 | } | 462 | if (oracle != null) { |
4110 | 350 | SinkStg sinkStg = new SinkStg(iStg, oracleStg); | 463 | createReadArc(oracle.zero, i.rdy.fallList.get(0)); |
4111 | 351 | groupComponentStg(sinkStg); | 464 | createReadArc(oracle.one, i.rdy.riseList.get(0)); |
4112 | 352 | return sinkStg; | 465 | createReadArc(oracle.zero, i.dn.riseList.get(0)); |
4113 | 466 | createReadArc(oracle.one, i.dn.riseList.get(1)); | ||
4114 | 467 | } | ||
4115 | 468 | createReadArc(i.rdy.zero, i.dn.riseList.get(0)); | ||
4116 | 469 | createReadArc(i.rdy.one, i.dn.riseList.get(1)); | ||
4117 | 470 | } | ||
4118 | 471 | return new SinkStg(i, oracle); | ||
4119 | 353 | } | 472 | } |
4120 | 354 | 473 | ||
4121 | 355 | private void connectSinkStg(VisualSinkComponent component) throws InvalidConnectionException { | 474 | private void connectSinkStg(VisualSinkComponent component) throws InvalidConnectionException { |
4122 | 356 | VisualXmasContact iContact = null; | ||
4123 | 357 | for (VisualXmasContact contact: component.getContacts()) { | ||
4124 | 358 | if (contact.isInput()) { | ||
4125 | 359 | iContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4126 | 360 | } | ||
4127 | 361 | } | ||
4128 | 362 | SinkStg sinkStg = getSinkStg(component); | 475 | SinkStg sinkStg = getSinkStg(component); |
4133 | 363 | if (iContact != null) { | 476 | if (sinkStg != null) { |
4134 | 364 | SignalStg iStg = getContactStg(iContact); | 477 | VisualXmasContact iContact = null; |
4135 | 365 | if ((sinkStg != null) && (iStg !=null)) { | 478 | for (VisualXmasContact contact: component.getContacts()) { |
4136 | 366 | createReadArc(iStg.one, sinkStg.oracle.fallList.get(0)); | 479 | if (contact.isInput()) { |
4137 | 480 | iContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4138 | 481 | } | ||
4139 | 482 | } | ||
4140 | 483 | if (iContact != null) { | ||
4141 | 484 | ContactStg i = getContactStg(iContact); | ||
4142 | 485 | if (i != null) { | ||
4143 | 486 | createReplicaReadArcFromSignalToOracle(i.rdy, sinkStg.oracle); | ||
4144 | 487 | } | ||
4145 | 488 | if (clockStg != null) { | ||
4146 | 489 | createReplicaReadArcsFromClockToSequential(sinkStg.oracle); | ||
4147 | 490 | createReplicaReadArcsFromClockToCombinational(sinkStg.i.rdy); | ||
4148 | 491 | createReplicaReadArcsFromClockToDone(sinkStg.i.dn); | ||
4149 | 492 | } | ||
4150 | 367 | } | 493 | } |
4151 | 368 | } | 494 | } |
4152 | 369 | } | 495 | } |
4153 | 370 | 496 | ||
4154 | 371 | public SinkStg getSinkStg(VisualSinkComponent component) { | 497 | public SinkStg getSinkStg(VisualSinkComponent component) { |
4156 | 372 | return sinkMap.get(component); | 498 | return ((sinkMap == null) ? null : sinkMap.get(component)); |
4157 | 499 | } | ||
4158 | 500 | |||
4159 | 501 | public void putSinkStg(VisualSinkComponent component, SinkStg stg) { | ||
4160 | 502 | if (sinkMap == null) { | ||
4161 | 503 | sinkMap = new HashMap<>(); | ||
4162 | 504 | } | ||
4163 | 505 | sinkMap.put(component, stg); | ||
4164 | 373 | } | 506 | } |
4165 | 374 | 507 | ||
4166 | 375 | 508 | ||
4167 | 376 | private FunctionStg generateFunctionStg(VisualFunctionComponent component) throws InvalidConnectionException { | 509 | private FunctionStg generateFunctionStg(VisualFunctionComponent component) throws InvalidConnectionException { |
4169 | 377 | String name = xmas.getMathName(component); | 510 | String name = getXmasModel().getMathName(component); |
4170 | 378 | Point2D pos = getComponentPosition(component); | 511 | Point2D pos = getComponentPosition(component); |
4173 | 379 | SignalStg iStg = null; | 512 | ContactStg i = null; |
4174 | 380 | SignalStg oStg = null; | 513 | ContactStg o = null; |
4175 | 381 | for (VisualXmasContact contact: component.getContacts()) { | 514 | for (VisualXmasContact contact: component.getContacts()) { |
4176 | 382 | if (contact.isInput()) { | 515 | if (contact.isInput()) { |
4179 | 383 | iStg = generateInputContactStg(name + nameItrdy, pos.getX(), pos.getY() + 3.0); | 516 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _I_TRDY, pos.getX(), pos.getY() + 4.0); |
4180 | 384 | contactMap.put(contact, iStg); | 517 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _I_TDN, pos.getX(), pos.getY() + 12.0, 1, 2); |
4181 | 518 | i = new ContactStg(rdy, dn); | ||
4182 | 519 | putContactStg(contact, i); | ||
4183 | 385 | } else { | 520 | } else { |
4186 | 386 | oStg = generateOutputContactStg(name + nameOirdy, pos.getX(), pos.getY() - 3.0); | 521 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _O_IRDY, pos.getX(), pos.getY() - 4.0); |
4187 | 387 | contactMap.put(contact, oStg); | 522 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _O_IDN, pos.getX(), pos.getY() - 12.0, 1, 2); |
4188 | 523 | o = new ContactStg(rdy, dn); | ||
4189 | 524 | putContactStg(contact, o); | ||
4190 | 388 | } | 525 | } |
4191 | 389 | } | 526 | } |
4195 | 390 | FunctionStg functionStg = new FunctionStg(iStg, oStg); | 527 | if (i != null) { |
4196 | 391 | groupComponentStg(functionStg); | 528 | createReadArc(i.rdy.zero, i.dn.riseList.get(0)); |
4197 | 392 | return functionStg; | 529 | createReadArc(i.rdy.one, i.dn.riseList.get(1)); |
4198 | 530 | } | ||
4199 | 531 | if (o != null) { | ||
4200 | 532 | createReadArc(o.rdy.zero, o.dn.riseList.get(0)); | ||
4201 | 533 | createReadArc(o.rdy.one, o.dn.riseList.get(1)); | ||
4202 | 534 | } | ||
4203 | 535 | return new FunctionStg(i, o); | ||
4204 | 393 | } | 536 | } |
4205 | 394 | 537 | ||
4206 | 395 | private void connectFunctionStg(VisualFunctionComponent component) throws InvalidConnectionException { | 538 | private void connectFunctionStg(VisualFunctionComponent component) throws InvalidConnectionException { |
4207 | 396 | VisualXmasContact iContact = null; | ||
4208 | 397 | VisualXmasContact oContact = null; | ||
4209 | 398 | for (VisualXmasContact contact: component.getContacts()) { | ||
4210 | 399 | if (contact.isInput()) { | ||
4211 | 400 | iContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4212 | 401 | } else { | ||
4213 | 402 | oContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4214 | 403 | } | ||
4215 | 404 | } | ||
4216 | 405 | FunctionStg functionStg = getFunctionStg(component); | 539 | FunctionStg functionStg = getFunctionStg(component); |
4231 | 406 | if (iContact != null) { | 540 | if (functionStg != null) { |
4232 | 407 | SignalStg iStg = getContactStg(iContact); | 541 | VisualXmasContact iContact = null; |
4233 | 408 | if ((functionStg != null) && (iStg != null)) { | 542 | VisualXmasContact oContact = null; |
4234 | 409 | createReadArc(iStg.zero, functionStg.o.fallList.get(0)); | 543 | for (VisualXmasContact contact: component.getContacts()) { |
4235 | 410 | createReadArc(iStg.one, functionStg.o.riseList.get(0)); | 544 | if (contact.isInput()) { |
4236 | 411 | } | 545 | iContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4237 | 412 | } | 546 | } else { |
4238 | 413 | if (oContact != null) { | 547 | oContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4239 | 414 | SignalStg oStg = getContactStg(oContact); | 548 | } |
4240 | 415 | if ((functionStg != null) && (oStg != null)) { | 549 | } |
4241 | 416 | createReadArc(oStg.zero, functionStg.i.fallList.get(0)); | 550 | if (iContact != null) { |
4242 | 417 | createReadArc(oStg.one, functionStg.i.riseList.get(0)); | 551 | ContactStg i = getContactStg(iContact); |
4243 | 418 | } | 552 | if (i != null) { |
4244 | 419 | } | 553 | createReplicaReadArcBetweenSignals(i.rdy, functionStg.o.rdy); |
4245 | 554 | createReplicaReadArcBetweenDoneSignals(i.dn, functionStg.o.dn, 0.0); | ||
4246 | 555 | createReplicaReadArc(i.rdy.zero, functionStg.o.dn.riseList.get(0)); | ||
4247 | 556 | createReplicaReadArc(i.rdy.one, functionStg.o.dn.riseList.get(1)); | ||
4248 | 557 | } | ||
4249 | 558 | } | ||
4250 | 559 | if (oContact != null) { | ||
4251 | 560 | ContactStg o = getContactStg(oContact); | ||
4252 | 561 | if (o != null) { | ||
4253 | 562 | createReplicaReadArcBetweenSignals(o.rdy, functionStg.i.rdy); | ||
4254 | 563 | createReplicaReadArcBetweenDoneSignals(o.dn, functionStg.i.dn, 0.0); | ||
4255 | 564 | createReplicaReadArc(o.rdy.zero, functionStg.i.dn.riseList.get(0)); | ||
4256 | 565 | createReplicaReadArc(o.rdy.one, functionStg.i.dn.riseList.get(1)); | ||
4257 | 566 | } | ||
4258 | 567 | } | ||
4259 | 568 | if (clockStg != null) { | ||
4260 | 569 | createReplicaReadArcsFromClockToDone(functionStg.i.dn); | ||
4261 | 570 | createReplicaReadArcsFromClockToCombinational(functionStg.i.rdy); | ||
4262 | 571 | createReplicaReadArcsFromClockToDone(functionStg.o.dn); | ||
4263 | 572 | createReplicaReadArcsFromClockToCombinational(functionStg.o.rdy); | ||
4264 | 573 | } | ||
4265 | 574 | } | ||
4266 | 575 | |||
4267 | 420 | } | 576 | } |
4268 | 421 | 577 | ||
4269 | 422 | public FunctionStg getFunctionStg(VisualFunctionComponent component) { | 578 | public FunctionStg getFunctionStg(VisualFunctionComponent component) { |
4271 | 423 | return functionMap.get(component); | 579 | return ((functionMap == null) ? null : functionMap.get(component)); |
4272 | 580 | } | ||
4273 | 581 | |||
4274 | 582 | public void putFunctionStg(VisualFunctionComponent component, FunctionStg stg) { | ||
4275 | 583 | if (functionMap == null) { | ||
4276 | 584 | functionMap = new HashMap<>(); | ||
4277 | 585 | } | ||
4278 | 586 | functionMap.put(component, stg); | ||
4279 | 424 | } | 587 | } |
4280 | 425 | 588 | ||
4281 | 426 | 589 | ||
4282 | 427 | private ForkStg generateForkStg(VisualForkComponent component) throws InvalidConnectionException { | 590 | private ForkStg generateForkStg(VisualForkComponent component) throws InvalidConnectionException { |
4284 | 428 | String name = xmas.getMathName(component); | 591 | String name = getXmasModel().getMathName(component); |
4285 | 429 | Point2D pos = getComponentPosition(component); | 592 | Point2D pos = getComponentPosition(component); |
4289 | 430 | SignalStg iStg = null; | 593 | ContactStg i = null; |
4290 | 431 | SignalStg aStg = null; | 594 | ContactStg a = null; |
4291 | 432 | SignalStg bStg = null; | 595 | ContactStg b = null; |
4292 | 433 | for (VisualXmasContact contact: component.getContacts()) { | 596 | for (VisualXmasContact contact: component.getContacts()) { |
4293 | 434 | if (contact.isInput()) { | 597 | if (contact.isInput()) { |
4299 | 435 | iStg = generateInputContactStg(name + nameItrdy, pos.getX(), pos.getY(), false, Type.INTERNAL, 2, 1); | 598 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _I_TRDY, pos.getX(), pos.getY() - 4.0, 2, 1); |
4300 | 436 | contactMap.put(contact, iStg); | 599 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _I_TDN, pos.getX(), pos.getY() + 4.0, 1, 3); |
4301 | 437 | } else if (aStg == null) { | 600 | i = new ContactStg(rdy, dn); |
4302 | 438 | aStg = generateOutputContactStg(name + nameAirdy, pos.getX(), pos.getY() - 5.0, false, Type.INTERNAL, 2, 1); | 601 | putContactStg(contact, i); |
4303 | 439 | contactMap.put(contact, aStg); | 602 | } else if (a == null) { |
4304 | 603 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _A_IRDY, pos.getX(), pos.getY() - 12.0, 2, 1); | ||
4305 | 604 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _A_IDN, pos.getX(), pos.getY() - 20.0, 1, 3); | ||
4306 | 605 | a = new ContactStg(rdy, dn); | ||
4307 | 606 | putContactStg(contact, a); | ||
4308 | 440 | } else { | 607 | } else { |
4311 | 441 | bStg = generateOutputContactStg(name + nameBirdy, pos.getX(), pos.getY() + 5.0, false, Type.INTERNAL, 2, 1); | 608 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _B_IRDY, pos.getX(), pos.getY() + 20.0, 2, 1); |
4312 | 442 | contactMap.put(contact, bStg); | 609 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _B_IDN, pos.getX(), pos.getY() + 12.0, 1, 3); |
4313 | 610 | b = new ContactStg(rdy, dn); | ||
4314 | 611 | putContactStg(contact, b); | ||
4315 | 443 | } | 612 | } |
4316 | 444 | } | 613 | } |
4320 | 445 | ForkStg forkStg = new ForkStg(iStg, aStg, bStg); | 614 | if (i != null) { |
4321 | 446 | groupComponentStg(forkStg); | 615 | createReadArc(i.rdy.zero, i.dn.riseList.get(0)); |
4322 | 447 | return forkStg; | 616 | createReadArc(i.rdy.zero, i.dn.riseList.get(1)); |
4323 | 617 | createReadArc(i.rdy.one, i.dn.riseList.get(2)); | ||
4324 | 618 | } | ||
4325 | 619 | if (a != null) { | ||
4326 | 620 | createReadArc(a.rdy.zero, a.dn.riseList.get(0)); | ||
4327 | 621 | createReadArc(a.rdy.zero, a.dn.riseList.get(1)); | ||
4328 | 622 | createReadArc(a.rdy.one, a.dn.riseList.get(2)); | ||
4329 | 623 | } | ||
4330 | 624 | if (b != null) { | ||
4331 | 625 | createReadArc(b.rdy.zero, b.dn.riseList.get(0)); | ||
4332 | 626 | createReadArc(b.rdy.zero, b.dn.riseList.get(1)); | ||
4333 | 627 | createReadArc(b.rdy.one, b.dn.riseList.get(2)); | ||
4334 | 628 | } | ||
4335 | 629 | return new ForkStg(i, a, b); | ||
4336 | 448 | } | 630 | } |
4337 | 449 | 631 | ||
4338 | 450 | private void connectForkStg(VisualForkComponent component) throws InvalidConnectionException { | 632 | private void connectForkStg(VisualForkComponent component) throws InvalidConnectionException { |
4339 | 451 | VisualXmasContact iContact = null; | ||
4340 | 452 | VisualXmasContact aContact = null; | ||
4341 | 453 | VisualXmasContact bContact = null; | ||
4342 | 454 | for (VisualXmasContact contact: component.getContacts()) { | ||
4343 | 455 | if (contact.isInput()) { | ||
4344 | 456 | iContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4345 | 457 | } else if (aContact == null) { | ||
4346 | 458 | aContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4347 | 459 | } else { | ||
4348 | 460 | bContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4349 | 461 | } | ||
4350 | 462 | } | ||
4351 | 463 | ForkStg forkStg = getForkStg(component); | 633 | ForkStg forkStg = getForkStg(component); |
4377 | 464 | if (iContact != null) { | 634 | if (forkStg != null) { |
4378 | 465 | SignalStg iStg = getContactStg(iContact); | 635 | VisualXmasContact iContact = null; |
4379 | 466 | if ((forkStg != null) && (iStg != null)) { | 636 | VisualXmasContact aContact = null; |
4380 | 467 | createReadArc(iStg.zero, forkStg.a.fallList.get(0)); | 637 | VisualXmasContact bContact = null; |
4381 | 468 | createReadArc(iStg.zero, forkStg.b.fallList.get(0)); | 638 | for (VisualXmasContact contact: component.getContacts()) { |
4382 | 469 | createReadArc(iStg.one, forkStg.a.riseList.get(0)); | 639 | if (contact.isInput()) { |
4383 | 470 | createReadArc(iStg.one, forkStg.b.riseList.get(0)); | 640 | iContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4384 | 471 | } | 641 | } else if (aContact == null) { |
4385 | 472 | } | 642 | aContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4386 | 473 | if (aContact != null) { | 643 | } else { |
4387 | 474 | SignalStg aStg = getContactStg(aContact); | 644 | bContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4388 | 475 | if ((forkStg != null) && (aStg != null)) { | 645 | } |
4389 | 476 | createReadArc(aStg.zero, forkStg.i.fallList.get(0)); | 646 | } |
4390 | 477 | createReadArc(aStg.zero, forkStg.b.fallList.get(1)); | 647 | if (iContact != null) { |
4391 | 478 | createReadArc(aStg.one, forkStg.i.riseList.get(0)); | 648 | ContactStg i = getContactStg(iContact); |
4392 | 479 | createReadArc(aStg.one, forkStg.b.riseList.get(0)); | 649 | if (i != null) { |
4393 | 480 | } | 650 | createReplicaReadArc(i.rdy.zero, forkStg.a.rdy.fallList.get(1), -6.0, 0.0); |
4394 | 481 | } | 651 | createReplicaReadArc(i.rdy.zero, forkStg.b.rdy.fallList.get(1), -6.0, 0.0); |
4395 | 482 | if (bContact != null) { | 652 | createReplicaReadArc(i.rdy.one, forkStg.a.rdy.riseList.get(0), -6.0, 0.0); |
4396 | 483 | SignalStg bStg = getContactStg(bContact); | 653 | createReplicaReadArc(i.rdy.one, forkStg.b.rdy.riseList.get(0), -6.0, 0.0); |
4397 | 484 | if ((forkStg != null) && (bStg != null)) { | 654 | createReplicaReadArcBetweenDoneSignals(i.dn, forkStg.a.dn, 0.0); |
4398 | 485 | createReadArc(bStg.zero, forkStg.i.fallList.get(1)); | 655 | createReplicaReadArcBetweenDoneSignals(i.dn, forkStg.b.dn, 0.0); |
4399 | 486 | createReadArc(bStg.zero, forkStg.a.fallList.get(1)); | 656 | createReplicaReadArc(i.rdy.zero, forkStg.a.dn.riseList.get(1), -6.0, 0.0); |
4400 | 487 | createReadArc(bStg.one, forkStg.i.riseList.get(0)); | 657 | createReplicaReadArc(i.rdy.one, forkStg.a.dn.riseList.get(2), -6.0, -1.0); |
4401 | 488 | createReadArc(bStg.one, forkStg.a.riseList.get(0)); | 658 | createReplicaReadArc(i.rdy.zero, forkStg.b.dn.riseList.get(1), -6.0, 0.0); |
4402 | 659 | createReplicaReadArc(i.rdy.one, forkStg.b.dn.riseList.get(2), -6.0, -1.0); | ||
4403 | 660 | } | ||
4404 | 661 | } | ||
4405 | 662 | if (aContact != null) { | ||
4406 | 663 | ContactStg a = getContactStg(aContact); | ||
4407 | 664 | if (a != null) { | ||
4408 | 665 | createReplicaReadArc(a.rdy.zero, forkStg.i.rdy.fallList.get(0), +6.0, 0.0); | ||
4409 | 666 | createReplicaReadArc(a.rdy.zero, forkStg.b.rdy.fallList.get(0), -6.0, 0.0); | ||
4410 | 667 | createReplicaReadArc(a.rdy.one, forkStg.i.rdy.riseList.get(0), +6.0, -1.0); | ||
4411 | 668 | createReplicaReadArc(a.rdy.one, forkStg.b.rdy.riseList.get(0), -6.0, +1.0); | ||
4412 | 669 | createReplicaReadArcBetweenDoneSignals(a.dn, forkStg.i.dn, -1.0); | ||
4413 | 670 | createReplicaReadArc(a.rdy.zero, forkStg.b.dn.riseList.get(0), -6.0, 0.0); | ||
4414 | 671 | createReplicaReadArc(a.rdy.one, forkStg.b.dn.riseList.get(2), -6.0, 0.0); | ||
4415 | 672 | createReplicaReadArc(a.rdy.zero, forkStg.i.dn.riseList.get(0), +6.0, 0.0); | ||
4416 | 673 | createReplicaReadArc(a.rdy.one, forkStg.i.dn.riseList.get(2), +6.0, 0.0); | ||
4417 | 674 | } | ||
4418 | 675 | } | ||
4419 | 676 | if (bContact != null) { | ||
4420 | 677 | ContactStg b = getContactStg(bContact); | ||
4421 | 678 | if (b != null) { | ||
4422 | 679 | createReplicaReadArc(b.rdy.zero, forkStg.i.rdy.fallList.get(1), +6.0, 0.0); | ||
4423 | 680 | createReplicaReadArc(b.rdy.zero, forkStg.a.rdy.fallList.get(0), -6.0, 0.0); | ||
4424 | 681 | createReplicaReadArc(b.rdy.one, forkStg.i.rdy.riseList.get(0), +6.0, 0.0); | ||
4425 | 682 | createReplicaReadArc(b.rdy.one, forkStg.a.rdy.riseList.get(0), -6.0, +1.0); | ||
4426 | 683 | createReplicaReadArcBetweenDoneSignals(b.dn, forkStg.i.dn, 0.0); | ||
4427 | 684 | createReplicaReadArc(b.rdy.zero, forkStg.a.dn.riseList.get(0), -6.0, 0.0); | ||
4428 | 685 | createReplicaReadArc(b.rdy.one, forkStg.a.dn.riseList.get(2), -6.0, 0.0); | ||
4429 | 686 | createReplicaReadArc(b.rdy.zero, forkStg.i.dn.riseList.get(1), +6.0, 0.0); | ||
4430 | 687 | createReplicaReadArc(b.rdy.one, forkStg.i.dn.riseList.get(2), +6.0, +1.0); | ||
4431 | 688 | } | ||
4432 | 689 | } | ||
4433 | 690 | if (clockStg != null) { | ||
4434 | 691 | createReplicaReadArcsFromClockToDone(forkStg.i.dn); | ||
4435 | 692 | createReplicaReadArcsFromClockToCombinational(forkStg.i.rdy); | ||
4436 | 693 | createReplicaReadArcsFromClockToDone(forkStg.a.dn); | ||
4437 | 694 | createReplicaReadArcsFromClockToCombinational(forkStg.a.rdy); | ||
4438 | 695 | createReplicaReadArcsFromClockToDone(forkStg.b.dn); | ||
4439 | 696 | createReplicaReadArcsFromClockToCombinational(forkStg.b.rdy); | ||
4440 | 489 | } | 697 | } |
4441 | 490 | } | 698 | } |
4442 | 491 | } | 699 | } |
4443 | 492 | 700 | ||
4444 | 493 | public ForkStg getForkStg(VisualForkComponent component) { | 701 | public ForkStg getForkStg(VisualForkComponent component) { |
4446 | 494 | return forkMap.get(component); | 702 | return ((forkMap == null) ? null : forkMap.get(component)); |
4447 | 703 | } | ||
4448 | 704 | |||
4449 | 705 | public void putForkStg(VisualForkComponent component, ForkStg stg) { | ||
4450 | 706 | if (forkMap == null) { | ||
4451 | 707 | forkMap = new HashMap<>(); | ||
4452 | 708 | } | ||
4453 | 709 | forkMap.put(component, stg); | ||
4454 | 495 | } | 710 | } |
4455 | 496 | 711 | ||
4456 | 497 | 712 | ||
4457 | 498 | private JoinStg generateJoinStg(VisualJoinComponent component) throws InvalidConnectionException { | 713 | private JoinStg generateJoinStg(VisualJoinComponent component) throws InvalidConnectionException { |
4459 | 499 | String name = xmas.getMathName(component); | 714 | String name = getXmasModel().getMathName(component); |
4460 | 500 | Point2D pos = getComponentPosition(component); | 715 | Point2D pos = getComponentPosition(component); |
4464 | 501 | SignalStg aStg = null; | 716 | ContactStg a = null; |
4465 | 502 | SignalStg bStg = null; | 717 | ContactStg b = null; |
4466 | 503 | SignalStg oStg = null; | 718 | ContactStg o = null; |
4467 | 504 | for (VisualXmasContact contact: component.getContacts()) { | 719 | for (VisualXmasContact contact: component.getContacts()) { |
4468 | 505 | if (contact.isOutput()) { | 720 | if (contact.isOutput()) { |
4474 | 506 | oStg = generateOutputContactStg(name + nameOirdy, pos.getX(), pos.getY(), false, Type.INTERNAL, 2, 1); | 721 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _O_IRDY, pos.getX(), pos.getY() + 4.0, 2, 1); |
4475 | 507 | contactMap.put(contact, oStg); | 722 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _O_IDN, pos.getX(), pos.getY() - 4.0, 1, 3); |
4476 | 508 | } else if (aStg == null) { | 723 | o = new ContactStg(rdy, dn); |
4477 | 509 | aStg = generateInputContactStg(name + nameAtrdy, pos.getX(), pos.getY() - 5.0, false, Type.INTERNAL, 2, 1); | 724 | putContactStg(contact, o); |
4478 | 510 | contactMap.put(contact, aStg); | 725 | } else if (a == null) { |
4479 | 726 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _A_TRDY, pos.getX(), pos.getY() - 20.0, 2, 1); | ||
4480 | 727 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _A_TDN, pos.getX(), pos.getY() - 12.0, 1, 3); | ||
4481 | 728 | a = new ContactStg(rdy, dn); | ||
4482 | 729 | putContactStg(contact, a); | ||
4483 | 511 | } else { | 730 | } else { |
4486 | 512 | bStg = generateInputContactStg(name + nameBtrdy, pos.getX(), pos.getY() + 5.0, false, Type.INTERNAL, 2, 1); | 731 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _B_TRDY, pos.getX(), pos.getY() + 12.0, 2, 1); |
4487 | 513 | contactMap.put(contact, bStg); | 732 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _B_TDN, pos.getX(), pos.getY() + 20.0, 1, 3); |
4488 | 733 | b = new ContactStg(rdy, dn); | ||
4489 | 734 | putContactStg(contact, b); | ||
4490 | 514 | } | 735 | } |
4491 | 515 | } | 736 | } |
4495 | 516 | JoinStg joinStg = new JoinStg(aStg, bStg, oStg); | 737 | if (a != null) { |
4496 | 517 | groupComponentStg(joinStg); | 738 | createReadArc(a.rdy.zero, a.dn.riseList.get(0)); |
4497 | 518 | return joinStg; | 739 | createReadArc(a.rdy.zero, a.dn.riseList.get(1)); |
4498 | 740 | createReadArc(a.rdy.one, a.dn.riseList.get(2)); | ||
4499 | 741 | } | ||
4500 | 742 | if (b != null) { | ||
4501 | 743 | createReadArc(b.rdy.zero, b.dn.riseList.get(0)); | ||
4502 | 744 | createReadArc(b.rdy.zero, b.dn.riseList.get(1)); | ||
4503 | 745 | createReadArc(b.rdy.one, b.dn.riseList.get(2)); | ||
4504 | 746 | } | ||
4505 | 747 | if (o != null) { | ||
4506 | 748 | createReadArc(o.rdy.zero, o.dn.riseList.get(0)); | ||
4507 | 749 | createReadArc(o.rdy.zero, o.dn.riseList.get(1)); | ||
4508 | 750 | createReadArc(o.rdy.one, o.dn.riseList.get(2)); | ||
4509 | 751 | } | ||
4510 | 752 | return new JoinStg(a, b, o); | ||
4511 | 519 | } | 753 | } |
4512 | 520 | 754 | ||
4513 | 521 | private void connectJoinStg(VisualJoinComponent component) throws InvalidConnectionException { | 755 | private void connectJoinStg(VisualJoinComponent component) throws InvalidConnectionException { |
4514 | 522 | VisualXmasContact aContact = null; | ||
4515 | 523 | VisualXmasContact bContact = null; | ||
4516 | 524 | VisualXmasContact oContact = null; | ||
4517 | 525 | for (VisualXmasContact contact: component.getContacts()) { | ||
4518 | 526 | if (contact.isOutput()) { | ||
4519 | 527 | oContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4520 | 528 | } else if (aContact == null) { | ||
4521 | 529 | aContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4522 | 530 | } else { | ||
4523 | 531 | bContact = XmasUtils.getConnectedContact(xmas, contact); | ||
4524 | 532 | } | ||
4525 | 533 | } | ||
4526 | 534 | JoinStg joinStg = getJoinStg(component); | 756 | JoinStg joinStg = getJoinStg(component); |
4552 | 535 | if (aContact != null) { | 757 | if (joinStg != null) { |
4553 | 536 | SignalStg aStg = getContactStg(aContact); | 758 | VisualXmasContact aContact = null; |
4554 | 537 | if ((joinStg != null) && (aStg != null)) { | 759 | VisualXmasContact bContact = null; |
4555 | 538 | createReadArc(aStg.zero, joinStg.b.fallList.get(1)); | 760 | VisualXmasContact oContact = null; |
4556 | 539 | createReadArc(aStg.zero, joinStg.o.fallList.get(0)); | 761 | for (VisualXmasContact contact: component.getContacts()) { |
4557 | 540 | createReadArc(aStg.one, joinStg.b.riseList.get(0)); | 762 | if (contact.isOutput()) { |
4558 | 541 | createReadArc(aStg.one, joinStg.o.riseList.get(0)); | 763 | oContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4559 | 542 | } | 764 | } else if (aContact == null) { |
4560 | 543 | } | 765 | aContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4561 | 544 | if (bContact != null) { | 766 | } else { |
4562 | 545 | SignalStg bStg = getContactStg(bContact); | 767 | bContact = XmasUtils.getConnectedContact(getXmasModel(), contact); |
4563 | 546 | if ((joinStg != null) && (bStg != null)) { | 768 | } |
4564 | 547 | createReadArc(bStg.zero, joinStg.a.fallList.get(1)); | 769 | } |
4565 | 548 | createReadArc(bStg.zero, joinStg.o.fallList.get(1)); | 770 | if (aContact != null) { |
4566 | 549 | createReadArc(bStg.one, joinStg.a.riseList.get(0)); | 771 | ContactStg a = getContactStg(aContact); |
4567 | 550 | createReadArc(bStg.one, joinStg.o.riseList.get(0)); | 772 | if (a != null) { |
4568 | 551 | } | 773 | createReplicaReadArc(a.rdy.zero, joinStg.b.rdy.fallList.get(0), +6.0, 0.0); |
4569 | 552 | } | 774 | createReplicaReadArc(a.rdy.zero, joinStg.o.rdy.fallList.get(1), -6.0, 0.0); |
4570 | 553 | if (oContact != null) { | 775 | createReplicaReadArc(a.rdy.one, joinStg.b.rdy.riseList.get(0), +6.0, -1.0); |
4571 | 554 | SignalStg oStg = getContactStg(oContact); | 776 | createReplicaReadArc(a.rdy.one, joinStg.o.rdy.riseList.get(0), -6.0, 0.0); |
4572 | 555 | if ((joinStg != null) && (oStg != null)) { | 777 | createReplicaReadArcBetweenDoneSignals(a.dn, joinStg.o.dn, 0.0); |
4573 | 556 | createReadArc(oStg.zero, joinStg.a.fallList.get(0)); | 778 | createReplicaReadArc(a.rdy.zero, joinStg.o.dn.riseList.get(1), -6.0, 0.0); |
4574 | 557 | createReadArc(oStg.zero, joinStg.b.fallList.get(0)); | 779 | createReplicaReadArc(a.rdy.one, joinStg.o.dn.riseList.get(2), -6.0, -1.0); |
4575 | 558 | createReadArc(oStg.one, joinStg.a.riseList.get(0)); | 780 | createReplicaReadArc(a.rdy.zero, joinStg.b.dn.riseList.get(0), +6.0, 0.0); |
4576 | 559 | createReadArc(oStg.one, joinStg.b.riseList.get(0)); | 781 | createReplicaReadArc(a.rdy.one, joinStg.b.dn.riseList.get(2), +6.0, 0.0); |
4577 | 782 | } | ||
4578 | 783 | } | ||
4579 | 784 | if (bContact != null) { | ||
4580 | 785 | ContactStg b = getContactStg(bContact); | ||
4581 | 786 | if (b != null) { | ||
4582 | 787 | createReplicaReadArc(b.rdy.zero, joinStg.a.rdy.fallList.get(1), +6.0, 0.0); | ||
4583 | 788 | createReplicaReadArc(b.rdy.zero, joinStg.o.rdy.fallList.get(0), -6.0, 0.0); | ||
4584 | 789 | createReplicaReadArc(b.rdy.one, joinStg.a.rdy.riseList.get(0), +6.0, 0.0); | ||
4585 | 790 | createReplicaReadArc(b.rdy.one, joinStg.o.rdy.riseList.get(0), -6.0, +1.0); | ||
4586 | 791 | createReplicaReadArcBetweenDoneSignals(b.dn, joinStg.o.dn, +1.0); | ||
4587 | 792 | createReplicaReadArc(b.rdy.zero, joinStg.o.dn.riseList.get(0), -6.0, 0.0); | ||
4588 | 793 | createReplicaReadArc(b.rdy.one, joinStg.o.dn.riseList.get(2), -6.0, 0.0); | ||
4589 | 794 | createReplicaReadArc(b.rdy.zero, joinStg.a.dn.riseList.get(1), +6.0, 0.0); | ||
4590 | 795 | createReplicaReadArc(b.rdy.one, joinStg.a.dn.riseList.get(2), +6.0, +1.0); | ||
4591 | 796 | } | ||
4592 | 797 | } | ||
4593 | 798 | if (oContact != null) { | ||
4594 | 799 | ContactStg o = getContactStg(oContact); | ||
4595 | 800 | if (o != null) { | ||
4596 | 801 | createReplicaReadArc(o.rdy.zero, joinStg.a.rdy.fallList.get(0), +6.0, 0.0); | ||
4597 | 802 | createReplicaReadArc(o.rdy.zero, joinStg.b.rdy.fallList.get(1), +6.0, 0.0); | ||
4598 | 803 | createReplicaReadArc(o.rdy.one, joinStg.a.rdy.riseList.get(0), +6.0, -1.0); | ||
4599 | 804 | createReplicaReadArc(o.rdy.one, joinStg.b.rdy.riseList.get(0), +6.0, 0.0); | ||
4600 | 805 | createReplicaReadArcBetweenDoneSignals(o.dn, joinStg.a.dn, 0.0); | ||
4601 | 806 | createReplicaReadArcBetweenDoneSignals(o.dn, joinStg.b.dn, 0.0); | ||
4602 | 807 | createReplicaReadArc(o.rdy.zero, joinStg.a.dn.riseList.get(0), +6.0, 0.0); | ||
4603 | 808 | createReplicaReadArc(o.rdy.one, joinStg.a.dn.riseList.get(2), +6.0, 0.0); | ||
4604 | 809 | createReplicaReadArc(o.rdy.zero, joinStg.b.dn.riseList.get(1), +6.0, 0.0); | ||
4605 | 810 | createReplicaReadArc(o.rdy.one, joinStg.b.dn.riseList.get(2), +6.0, +1.0); | ||
4606 | 811 | } | ||
4607 | 560 | } | 812 | } |
4608 | 561 | } | 813 | } |
4609 | 562 | } | 814 | } |
4610 | 563 | 815 | ||
4611 | 564 | public JoinStg getJoinStg(VisualJoinComponent component) { | 816 | public JoinStg getJoinStg(VisualJoinComponent component) { |
4613 | 565 | return joinMap.get(component); | 817 | return ((joinMap == null) ? null : joinMap.get(component)); |
4614 | 818 | } | ||
4615 | 819 | |||
4616 | 820 | public void putJoinStg(VisualJoinComponent component, JoinStg stg) { | ||
4617 | 821 | if (joinMap == null) { | ||
4618 | 822 | joinMap = new HashMap<>(); | ||
4619 | 823 | } | ||
4620 | 824 | joinMap.put(component, stg); | ||
4621 | 825 | } | ||
4622 | 826 | |||
4623 | 827 | |||
4624 | 828 | private SwitchStg generateSwitchStg(VisualSwitchComponent component) throws InvalidConnectionException { | ||
4625 | 829 | String name = getXmasModel().getMathName(component); | ||
4626 | 830 | Point2D pos = getComponentPosition(component); | ||
4627 | 831 | ContactStg i = null; | ||
4628 | 832 | ContactStg a = null; | ||
4629 | 833 | ContactStg b = null; | ||
4630 | 834 | SignalStg oracle = generateSignalStg(XmasStgType.IORACLE, name + _ORACLE, pos.getX() + 12.0, pos.getY()); | ||
4631 | 835 | for (VisualXmasContact contact: component.getContacts()) { | ||
4632 | 836 | if (contact.isInput()) { | ||
4633 | 837 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _I_TRDY, pos.getX(), pos.getY() - 4.0, 1, 2); | ||
4634 | 838 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _I_TDN, pos.getX(), pos.getY() + 4.0, 1, 3); | ||
4635 | 839 | i = new ContactStg(rdy, dn); | ||
4636 | 840 | putContactStg(contact, i); | ||
4637 | 841 | } else if (a == null) { | ||
4638 | 842 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _A_IRDY, pos.getX(), pos.getY() - 12.0, 2, 1); | ||
4639 | 843 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _A_IDN, pos.getX(), pos.getY() - 20.0, 1, 3); | ||
4640 | 844 | a = new ContactStg(rdy, dn); | ||
4641 | 845 | putContactStg(contact, a); | ||
4642 | 846 | } else { | ||
4643 | 847 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _B_IRDY, pos.getX(), pos.getY() + 20.0, 2, 1); | ||
4644 | 848 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _B_IDN, pos.getX(), pos.getY() + 12.0, 1, 3); | ||
4645 | 849 | b = new ContactStg(rdy, dn); | ||
4646 | 850 | putContactStg(contact, b); | ||
4647 | 851 | } | ||
4648 | 852 | } | ||
4649 | 853 | if (i != null) { | ||
4650 | 854 | createReadArc(i.rdy.zero, i.dn.riseList.get(0)); | ||
4651 | 855 | createReadArc(i.rdy.one, i.dn.riseList.get(1)); | ||
4652 | 856 | createReadArc(i.rdy.one, i.dn.riseList.get(2)); | ||
4653 | 857 | } | ||
4654 | 858 | if (a != null) { | ||
4655 | 859 | createReadArc(a.rdy.zero, a.dn.riseList.get(0)); | ||
4656 | 860 | createReadArc(a.rdy.zero, a.dn.riseList.get(1)); | ||
4657 | 861 | createReadArc(a.rdy.one, a.dn.riseList.get(2)); | ||
4658 | 862 | } | ||
4659 | 863 | if (b != null) { | ||
4660 | 864 | createReadArc(b.rdy.zero, b.dn.riseList.get(0)); | ||
4661 | 865 | createReadArc(b.rdy.zero, b.dn.riseList.get(1)); | ||
4662 | 866 | createReadArc(b.rdy.one, b.dn.riseList.get(2)); | ||
4663 | 867 | } | ||
4664 | 868 | if ((oracle != null) && (a != null) && (b != null)) { | ||
4665 | 869 | createReadArcs(a.rdy.zero, oracle.getAllTransitions()); | ||
4666 | 870 | createReadArcs(b.rdy.zero, oracle.getAllTransitions()); | ||
4667 | 871 | createReplicaReadArc(oracle.zero, a.rdy.fallList.get(1), -6.0, 0.0); | ||
4668 | 872 | createReplicaReadArc(oracle.zero, a.dn.riseList.get(1), -6.0, 0.0); | ||
4669 | 873 | createReplicaReadArc(oracle.zero, b.rdy.riseList.get(0), -6.0, +1.0); | ||
4670 | 874 | createReplicaReadArc(oracle.zero, b.dn.riseList.get(2), -6.0, -1.0); | ||
4671 | 875 | createReplicaReadArc(oracle.one, a.rdy.riseList.get(0), -6.0, +1.0); | ||
4672 | 876 | createReplicaReadArc(oracle.one, a.dn.riseList.get(2), -6.0, -1.0); | ||
4673 | 877 | createReplicaReadArc(oracle.one, b.rdy.fallList.get(1), -6.0, 0.0); | ||
4674 | 878 | createReplicaReadArc(oracle.one, b.dn.riseList.get(1), -6.0, 0.0); | ||
4675 | 879 | } | ||
4676 | 880 | return new SwitchStg(i, a, b, oracle); | ||
4677 | 881 | } | ||
4678 | 882 | |||
4679 | 883 | private void connectSwitchStg(VisualSwitchComponent component) throws InvalidConnectionException { | ||
4680 | 884 | SwitchStg switchStg = getSwitchStg(component); | ||
4681 | 885 | if (switchStg != null) { | ||
4682 | 886 | VisualXmasContact iContact = null; | ||
4683 | 887 | VisualXmasContact aContact = null; | ||
4684 | 888 | VisualXmasContact bContact = null; | ||
4685 | 889 | for (VisualXmasContact contact: component.getContacts()) { | ||
4686 | 890 | if (contact.isInput()) { | ||
4687 | 891 | iContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4688 | 892 | } else if (aContact == null) { | ||
4689 | 893 | aContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4690 | 894 | } else { | ||
4691 | 895 | bContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4692 | 896 | } | ||
4693 | 897 | } | ||
4694 | 898 | if (iContact != null) { | ||
4695 | 899 | ContactStg i = getContactStg(iContact); | ||
4696 | 900 | if (i != null) { | ||
4697 | 901 | createReplicaReadArc(i.rdy.zero, switchStg.a.rdy.fallList.get(0), -6.0, 0.0); | ||
4698 | 902 | createReplicaReadArc(i.rdy.one, switchStg.a.rdy.riseList.get(0), -6.0, 0.0); | ||
4699 | 903 | createReplicaReadArc(i.rdy.zero, switchStg.b.rdy.fallList.get(0), -6.0, 0.0); | ||
4700 | 904 | createReplicaReadArc(i.rdy.one, switchStg.b.rdy.riseList.get(0), -6.0, 0.0); | ||
4701 | 905 | createReplicaReadArcBetweenDoneSignals(i.dn, switchStg.a.dn, 0.0); | ||
4702 | 906 | createReplicaReadArcBetweenDoneSignals(i.dn, switchStg.b.dn, 0.0); | ||
4703 | 907 | createReplicaReadArc(i.rdy.zero, switchStg.a.dn.riseList.get(0), -6.0, 0.0); | ||
4704 | 908 | createReplicaReadArc(i.rdy.one, switchStg.a.dn.riseList.get(2), -6.0, 0.0); | ||
4705 | 909 | createReplicaReadArc(i.rdy.zero, switchStg.b.dn.riseList.get(0), -6.0, 0.0); | ||
4706 | 910 | createReplicaReadArc(i.rdy.one, switchStg.b.dn.riseList.get(2), -6.0, 0.0); | ||
4707 | 911 | } | ||
4708 | 912 | } | ||
4709 | 913 | if (aContact != null) { | ||
4710 | 914 | ContactStg a = getContactStg(aContact); | ||
4711 | 915 | if (a != null) { | ||
4712 | 916 | createReplicaReadArc(a.rdy.zero, switchStg.i.rdy.fallList.get(0), +6.0, 0.0); | ||
4713 | 917 | createReplicaReadArc(a.rdy.one, switchStg.i.rdy.riseList.get(1), +6.0, 0.0); | ||
4714 | 918 | createReplicaReadArcBetweenDoneSignals(a.dn, switchStg.i.dn, -1.0); | ||
4715 | 919 | createReplicaReadArc(a.rdy.zero, switchStg.i.dn.riseList.get(0), +6.0, 0.0); | ||
4716 | 920 | createReplicaReadArc(a.rdy.one, switchStg.i.dn.riseList.get(1), +6.0, +1.0); | ||
4717 | 921 | } | ||
4718 | 922 | } | ||
4719 | 923 | if (bContact != null) { | ||
4720 | 924 | ContactStg b = getContactStg(bContact); | ||
4721 | 925 | if (b != null) { | ||
4722 | 926 | createReplicaReadArc(b.rdy.zero, switchStg.i.rdy.fallList.get(0), +6.0, +1.0); | ||
4723 | 927 | createReplicaReadArc(b.rdy.one, switchStg.i.rdy.riseList.get(0), +6.0, 0.0); | ||
4724 | 928 | createReplicaReadArcBetweenDoneSignals(b.dn, switchStg.i.dn, 0.0); | ||
4725 | 929 | createReplicaReadArc(b.rdy.zero, switchStg.i.dn.riseList.get(0), +6.0, +1.0); | ||
4726 | 930 | createReplicaReadArc(b.rdy.one, switchStg.i.dn.riseList.get(2), +6.0, +1.0); | ||
4727 | 931 | } | ||
4728 | 932 | } | ||
4729 | 933 | if (clockStg != null) { | ||
4730 | 934 | createReplicaReadArcsFromClockToDone(switchStg.i.dn); | ||
4731 | 935 | createReplicaReadArcsFromClockToCombinational(switchStg.i.rdy); | ||
4732 | 936 | createReplicaReadArcsFromClockToDone(switchStg.a.dn); | ||
4733 | 937 | createReplicaReadArcsFromClockToCombinational(switchStg.a.rdy); | ||
4734 | 938 | createReplicaReadArcsFromClockToDone(switchStg.b.dn); | ||
4735 | 939 | createReplicaReadArcsFromClockToCombinational(switchStg.b.rdy); | ||
4736 | 940 | createReplicaReadArcsFromClockToSequential(switchStg.oracle); | ||
4737 | 941 | } | ||
4738 | 942 | } | ||
4739 | 943 | } | ||
4740 | 944 | |||
4741 | 945 | public SwitchStg getSwitchStg(VisualSwitchComponent component) { | ||
4742 | 946 | return ((switchMap == null) ? null : switchMap.get(component)); | ||
4743 | 947 | } | ||
4744 | 948 | |||
4745 | 949 | public void putSwitchStg(VisualSwitchComponent component, SwitchStg stg) { | ||
4746 | 950 | if (switchMap == null) { | ||
4747 | 951 | switchMap = new HashMap<>(); | ||
4748 | 952 | } | ||
4749 | 953 | switchMap.put(component, stg); | ||
4750 | 954 | } | ||
4751 | 955 | |||
4752 | 956 | |||
4753 | 957 | private MergeStg generateMergeStg(VisualMergeComponent component) throws InvalidConnectionException { | ||
4754 | 958 | String name = getXmasModel().getMathName(component); | ||
4755 | 959 | Point2D pos = getComponentPosition(component); | ||
4756 | 960 | ContactStg a = null; | ||
4757 | 961 | ContactStg b = null; | ||
4758 | 962 | ContactStg o = null; | ||
4759 | 963 | for (VisualXmasContact contact: component.getContacts()) { | ||
4760 | 964 | if (contact.isOutput()) { | ||
4761 | 965 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _O_IRDY, pos.getX(), pos.getY() + 4.0, 1, 2); | ||
4762 | 966 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _O_IDN, pos.getX(), pos.getY() - 4.0, 1, 3); | ||
4763 | 967 | o = new ContactStg(rdy, dn); | ||
4764 | 968 | putContactStg(contact, o); | ||
4765 | 969 | } else if (a == null) { | ||
4766 | 970 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _A_TRDY, pos.getX(), pos.getY() - 20.0, 2, 1); | ||
4767 | 971 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _A_TDN, pos.getX(), pos.getY() - 12.0, 1, 3); | ||
4768 | 972 | a = new ContactStg(rdy, dn); | ||
4769 | 973 | putContactStg(contact, a); | ||
4770 | 974 | } else { | ||
4771 | 975 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _B_TRDY, pos.getX(), pos.getY() + 12.0, 2, 1); | ||
4772 | 976 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _B_TDN, pos.getX(), pos.getY() + 20.0, 1, 3); | ||
4773 | 977 | b = new ContactStg(rdy, dn); | ||
4774 | 978 | putContactStg(contact, b); | ||
4775 | 979 | } | ||
4776 | 980 | } | ||
4777 | 981 | if (a != null) { | ||
4778 | 982 | createReadArc(a.rdy.zero, a.dn.riseList.get(0)); | ||
4779 | 983 | createReadArc(a.rdy.zero, a.dn.riseList.get(1)); | ||
4780 | 984 | createReadArc(a.rdy.one, a.dn.riseList.get(2)); | ||
4781 | 985 | } | ||
4782 | 986 | if (b != null) { | ||
4783 | 987 | createReadArc(b.rdy.zero, b.dn.riseList.get(0)); | ||
4784 | 988 | createReadArc(b.rdy.zero, b.dn.riseList.get(1)); | ||
4785 | 989 | createReadArc(b.rdy.one, b.dn.riseList.get(2)); | ||
4786 | 990 | } | ||
4787 | 991 | if (o != null) { | ||
4788 | 992 | createReadArc(o.rdy.zero, o.dn.riseList.get(0)); | ||
4789 | 993 | createReadArc(o.rdy.one, o.dn.riseList.get(1)); | ||
4790 | 994 | createReadArc(o.rdy.one, o.dn.riseList.get(2)); | ||
4791 | 995 | } | ||
4792 | 996 | return new MergeStg(a, b, o); | ||
4793 | 997 | } | ||
4794 | 998 | |||
4795 | 999 | private void connectMergeStg(VisualMergeComponent component) throws InvalidConnectionException { | ||
4796 | 1000 | MergeStg mergeStg = getMergeStg(component); | ||
4797 | 1001 | if (mergeStg != null) { | ||
4798 | 1002 | VisualXmasContact aContact = null; | ||
4799 | 1003 | VisualXmasContact bContact = null; | ||
4800 | 1004 | VisualXmasContact oContact = null; | ||
4801 | 1005 | for (VisualXmasContact contact: component.getContacts()) { | ||
4802 | 1006 | if (contact.isOutput()) { | ||
4803 | 1007 | oContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4804 | 1008 | } else if (aContact == null) { | ||
4805 | 1009 | aContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4806 | 1010 | } else { | ||
4807 | 1011 | bContact = XmasUtils.getConnectedContact(getXmasModel(), contact); | ||
4808 | 1012 | } | ||
4809 | 1013 | } | ||
4810 | 1014 | if (aContact != null) { | ||
4811 | 1015 | ContactStg a = getContactStg(aContact); | ||
4812 | 1016 | if (a != null) { | ||
4813 | 1017 | createReplicaReadArc(a.rdy.zero, mergeStg.a.rdy.fallList.get(1), +6.0, 0.0); | ||
4814 | 1018 | createReplicaReadArc(a.rdy.zero, mergeStg.o.rdy.fallList.get(0), -6.0, -1.0); | ||
4815 | 1019 | createReplicaReadArc(a.rdy.one, mergeStg.a.rdy.riseList.get(0), +6.0, 0.0); | ||
4816 | 1020 | createReplicaReadArc(a.rdy.one, mergeStg.o.rdy.riseList.get(0), -6.0, 0.0); | ||
4817 | 1021 | createReplicaReadArcBetweenDoneSignals(a.dn, mergeStg.a.dn, -1.0); | ||
4818 | 1022 | createReplicaReadArcBetweenDoneSignals(a.dn, mergeStg.o.dn, 0.0); | ||
4819 | 1023 | createReplicaReadArc(a.rdy.zero, mergeStg.a.dn.riseList.get(1), +6.0, 0.0); | ||
4820 | 1024 | createReplicaReadArc(a.rdy.zero, mergeStg.o.dn.riseList.get(0), -6.0, -1.0); | ||
4821 | 1025 | createReplicaReadArc(a.rdy.one, mergeStg.a.dn.riseList.get(2), +6.0, +1.0); | ||
4822 | 1026 | createReplicaReadArc(a.rdy.one, mergeStg.o.dn.riseList.get(2), -6.0, -1.0); | ||
4823 | 1027 | } | ||
4824 | 1028 | } | ||
4825 | 1029 | if (bContact != null) { | ||
4826 | 1030 | ContactStg b = getContactStg(bContact); | ||
4827 | 1031 | if (b != null) { | ||
4828 | 1032 | createReplicaReadArc(b.rdy.zero, mergeStg.b.rdy.fallList.get(1), +6.0, 0.0); | ||
4829 | 1033 | createReplicaReadArc(b.rdy.zero, mergeStg.o.rdy.fallList.get(0), -6.0, 0.0); | ||
4830 | 1034 | createReplicaReadArc(b.rdy.one, mergeStg.b.rdy.riseList.get(0), +6.0, 0.0); | ||
4831 | 1035 | createReplicaReadArc(b.rdy.one, mergeStg.o.rdy.riseList.get(1), -6.0, 0.0); | ||
4832 | 1036 | createReplicaReadArcBetweenDoneSignals(b.dn, mergeStg.b.dn, -1.0); | ||
4833 | 1037 | createReplicaReadArcBetweenDoneSignals(b.dn, mergeStg.o.dn, +1.0); | ||
4834 | 1038 | createReplicaReadArc(b.rdy.zero, mergeStg.b.dn.riseList.get(1), +6.0, 0.0); | ||
4835 | 1039 | createReplicaReadArc(b.rdy.zero, mergeStg.o.dn.riseList.get(0), -6.0, 0.0); | ||
4836 | 1040 | createReplicaReadArc(b.rdy.one, mergeStg.b.dn.riseList.get(2), +6.0, +1.0); | ||
4837 | 1041 | createReplicaReadArc(b.rdy.one, mergeStg.o.dn.riseList.get(1), -6.0, -1.0); | ||
4838 | 1042 | } | ||
4839 | 1043 | } | ||
4840 | 1044 | if (oContact != null) { | ||
4841 | 1045 | ContactStg o = getContactStg(oContact); | ||
4842 | 1046 | if (o != null) { | ||
4843 | 1047 | createReplicaReadArc(o.rdy.zero, mergeStg.a.rdy.fallList.get(0), +6.0, 0.0); | ||
4844 | 1048 | createReplicaReadArc(o.rdy.zero, mergeStg.b.rdy.fallList.get(0), +6.0, 0.0); | ||
4845 | 1049 | createReplicaReadArc(o.rdy.one, mergeStg.a.rdy.riseList.get(0), +6.0, -1.0); | ||
4846 | 1050 | createReplicaReadArc(o.rdy.one, mergeStg.b.rdy.riseList.get(0), +6.0, -1.0); | ||
4847 | 1051 | createReplicaReadArcBetweenDoneSignals(o.dn, mergeStg.a.dn, 0.0); | ||
4848 | 1052 | createReplicaReadArcBetweenDoneSignals(o.dn, mergeStg.b.dn, 0.0); | ||
4849 | 1053 | createReplicaReadArc(o.rdy.zero, mergeStg.a.dn.riseList.get(0), +6.0, 0.0); | ||
4850 | 1054 | createReplicaReadArc(o.rdy.zero, mergeStg.b.dn.riseList.get(0), +6.0, 0.0); | ||
4851 | 1055 | createReplicaReadArc(o.rdy.one, mergeStg.a.dn.riseList.get(2), +6.0, 0.0); | ||
4852 | 1056 | createReplicaReadArc(o.rdy.one, mergeStg.b.dn.riseList.get(2), +6.0, 0.0); | ||
4853 | 1057 | } | ||
4854 | 1058 | } | ||
4855 | 1059 | } | ||
4856 | 1060 | } | ||
4857 | 1061 | |||
4858 | 1062 | public MergeStg getMergeStg(VisualMergeComponent component) { | ||
4859 | 1063 | return ((mergeMap == null) ? null : mergeMap.get(component)); | ||
4860 | 1064 | } | ||
4861 | 1065 | |||
4862 | 1066 | public void putMergeStg(VisualMergeComponent component, MergeStg stg) { | ||
4863 | 1067 | if (mergeMap == null) { | ||
4864 | 1068 | mergeMap = new HashMap<>(); | ||
4865 | 1069 | } | ||
4866 | 1070 | mergeMap.put(component, stg); | ||
4867 | 566 | } | 1071 | } |
4868 | 567 | 1072 | ||
4869 | 568 | 1073 | ||
4870 | 569 | private QueueStg generateQueueStg(VisualQueueComponent component) throws InvalidConnectionException { | 1074 | private QueueStg generateQueueStg(VisualQueueComponent component) throws InvalidConnectionException { |
4872 | 570 | String name = xmas.getMathName(component); | 1075 | String name = getXmasModel().getMathName(component); |
4873 | 571 | Point2D pos = getComponentPosition(component); | 1076 | Point2D pos = getComponentPosition(component); |
4874 | 572 | int capacity = component.getReferencedQueueComponent().getCapacity(); | 1077 | int capacity = component.getReferencedQueueComponent().getCapacity(); |
4881 | 573 | SignalStg iStg = null; | 1078 | ContactStg i = null; |
4882 | 574 | SignalStg oStg = null; | 1079 | ContactStg o = null; |
4883 | 575 | ArrayList<SignalStg> memList = new ArrayList<>(capacity); | 1080 | ArrayList<SlotStg> slotList = new ArrayList<>(capacity); |
4884 | 576 | ArrayList<SignalStg> headList = new ArrayList<>(capacity); | 1081 | double xContact = 0.5 * QUEUE_SLOT_SPACING * (capacity + 1); |
4879 | 577 | ArrayList<SignalStg> tailList = new ArrayList<>(capacity); | ||
4880 | 578 | double xContact = 5.0 * capacity + 5.0; | ||
4885 | 579 | for (VisualXmasContact contact: component.getContacts()) { | 1082 | for (VisualXmasContact contact: component.getContacts()) { |
4886 | 580 | if (contact.isOutput()) { | 1083 | if (contact.isOutput()) { |
4889 | 581 | oStg = generateOutputContactStg(name + nameOirdy, pos.getX() + xContact, pos.getY() - 5.0, false, Type.INTERNAL, 1, capacity); | 1084 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _O_IRDY, pos.getX() + xContact, pos.getY(), 1, capacity); |
4890 | 582 | contactMap.put(contact, oStg); | 1085 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _O_IDN, pos.getX() + xContact, pos.getY() - 12.0, 1, capacity + 1); |
4891 | 1086 | o = new ContactStg(rdy, dn); | ||
4892 | 1087 | putContactStg(contact, o); | ||
4893 | 583 | } else { | 1088 | } else { |
4937 | 584 | iStg = generateInputContactStg(name + nameItrdy, pos.getX() - xContact, pos.getY() + 5.0, true, Type.INTERNAL, 1, capacity); | 1089 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _I_TRDY, pos.getX() - xContact, pos.getY(), 1, capacity); |
4938 | 585 | contactMap.put(contact, iStg); | 1090 | setSignalInitialState(rdy, true); |
4939 | 586 | } | 1091 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _I_TDN, pos.getX() - xContact, pos.getY() + 12.0, 1, capacity + 1); |
4940 | 587 | } | 1092 | i = new ContactStg(rdy, dn); |
4941 | 588 | for (int i = 0; i < capacity; i++) { | 1093 | putContactStg(contact, i); |
4942 | 589 | double xSlot = 10.0 * (i - 0.5 * (capacity - 1)); | 1094 | } |
4943 | 590 | char c = (char)i; | 1095 | } |
4944 | 591 | c += 'A'; | 1096 | for (int idx = 0; idx < capacity; idx++) { |
4945 | 592 | SignalStg memStg = generateSignalStg(name + nameMem + c, pos.getX() + xSlot, pos.getY(), false, SignalTransition.Type.INPUT); | 1097 | double xSlot = QUEUE_SLOT_SPACING * (idx - 0.5 * (capacity - 1)); |
4946 | 593 | SignalStg headStg = generateSignalStg(name + nameHead + c, pos.getX() + xSlot, pos.getY() - 8.0, (i == 0), SignalTransition.Type.INTERNAL); | 1098 | char suffix = (char)idx; |
4947 | 594 | SignalStg tailStg = generateSignalStg(name + nameTail + c, pos.getX() + xSlot, pos.getY() + 8.0, false, SignalTransition.Type.INTERNAL); | 1099 | suffix += 'A'; |
4948 | 595 | memList.add(memStg); | 1100 | SignalStg mem = generateBasicSignalStg(name + _MEM + suffix, pos.getX() + xSlot, pos.getY(), SignalTransition.Type.INPUT); |
4949 | 596 | headList.add(headStg); | 1101 | ContactStg hd = null; |
4950 | 597 | tailList.add(tailStg); | 1102 | { |
4951 | 598 | } | 1103 | SignalStg rdy = generateSignalStg(XmasStgType.IRDY, name + _HEAD + suffix +_RDY, pos.getX() + xSlot, pos.getY() - 8.0); |
4952 | 599 | // Internal connections | 1104 | SignalStg dn = generateSignalStg(XmasStgType.IDN, name + _HEAD + suffix + _DN, pos.getX() + xSlot, pos.getY() - 16.0, 4, 3); |
4953 | 600 | for (int i = 0; i < capacity; i++) { | 1105 | hd = new ContactStg(rdy, dn); |
4954 | 601 | SignalStg mem = memList.get(i); | 1106 | } |
4955 | 602 | createReadArc(iStg.one, mem.riseList.get(0)); | 1107 | ContactStg tl = null; |
4956 | 603 | createReadArc(oStg.one, mem.fallList.get(0)); | 1108 | { |
4957 | 604 | createReadArc(mem.one, iStg.fallList.get(0)); | 1109 | SignalStg rdy = generateSignalStg(XmasStgType.TRDY, name + _TAIL + suffix +_RDY, pos.getX() + xSlot, pos.getY() + 8.0); |
4958 | 605 | createReadArc(mem.one, oStg.riseList.get(i)); | 1110 | SignalStg dn = generateSignalStg(XmasStgType.TDN, name + _TAIL + suffix + _DN, pos.getX() + xSlot, pos.getY() + 16.0, 4, 3); |
4959 | 606 | createReadArc(mem.zero, iStg.riseList.get(i)); | 1111 | setSignalInitialState(rdy, (idx == 0)); |
4960 | 607 | createReadArc(mem.zero, oStg.fallList.get(0)); | 1112 | tl = new ContactStg(rdy, dn); |
4961 | 608 | for (int j = 0; j < capacity; j++) { | 1113 | } |
4962 | 609 | SignalStg head = headList.get(j); | 1114 | SlotStg slot = new SlotStg(mem, hd, tl); |
4963 | 610 | SignalStg tail = tailList.get(j); | 1115 | slotList.add(slot); |
4964 | 611 | if (i == j) { | 1116 | // Connections of head within slot |
4965 | 612 | createReadArc(mem.one, head.fallList.get(0)); | 1117 | createReplicaReadArc(slot.hd.rdy.one, slot.mem.fallList.get(0), 0.0, -2.0); |
4966 | 613 | createReadArc(mem.one, tail.riseList.get(0)); | 1118 | createReplicaReadArc(slot.mem.zero, slot.hd.rdy.fallList.get(0), -6.0, 0.0); |
4967 | 614 | createReadArc(mem.zero, head.riseList.get(0)); | 1119 | createReplicaReadArc(slot.mem.one, slot.hd.rdy.riseList.get(0), -6.0, 0.0); |
4968 | 615 | createReadArc(mem.zero, tail.fallList.get(0)); | 1120 | createReplicaReadArc(slot.mem.zero, slot.hd.dn.fallList.get(1), +6.0, -1.0); |
4969 | 616 | createReadArc(head.one, mem.riseList.get(0)); | 1121 | createReplicaReadArc(slot.mem.zero, slot.hd.dn.riseList.get(0), -6.0, 0.0); |
4970 | 617 | createReadArc(tail.one, mem.fallList.get(0)); | 1122 | createReplicaReadArcs(slot.mem.one, Arrays.asList(slot.hd.dn.riseList.get(2), slot.hd.dn.riseList.get(1)), -6.0, 0.0); |
4971 | 618 | } else { | 1123 | createReplicaReadArc(slot.mem.one, slot.hd.dn.fallList.get(0), -6.0, 0.0); |
4972 | 619 | createReadArc(mem.one, head.riseList.get(0)); | 1124 | createReplicaReadArc(slot.mem.one, slot.hd.dn.fallList.get(2), -6.0, 0.0); |
4973 | 620 | createReadArc(mem.zero, tail.riseList.get(0)); | 1125 | createReadArc(slot.hd.rdy.zero, slot.hd.dn.riseList.get(0)); |
4974 | 621 | } | 1126 | createReadArc(slot.hd.rdy.zero, slot.hd.dn.fallList.get(3)); |
4975 | 622 | } | 1127 | createReadArc(slot.hd.rdy.one, slot.hd.dn.riseList.get(2)); |
4976 | 623 | } | 1128 | createReadArc(slot.hd.rdy.one, slot.hd.dn.fallList.get(2)); |
4977 | 624 | QueueStg queueStg = new QueueStg(iStg, oStg, memList, headList, tailList); | 1129 | createReadArc(slot.hd.rdy.one, slot.hd.dn.fallList.get(1)); |
4978 | 625 | groupComponentStg(queueStg); | 1130 | createReadArc(slot.hd.rdy.one, slot.hd.dn.fallList.get(0)); |
4979 | 626 | return queueStg; | 1131 | // Connection of tail within slot |
4980 | 1132 | createReplicaReadArc(slot.tl.rdy.one, slot.mem.riseList.get(0), 0.0, +2.0); | ||
4981 | 1133 | createReplicaReadArc(slot.mem.zero, slot.tl.rdy.riseList.get(0), +6.0, 0.0); | ||
4982 | 1134 | createReplicaReadArc(slot.mem.one, slot.tl.rdy.fallList.get(0), +6.0, 0.0); | ||
4983 | 1135 | createReplicaReadArc(slot.mem.one, slot.tl.dn.fallList.get(1), -6.0, +1.0); | ||
4984 | 1136 | createReplicaReadArc(slot.mem.one, slot.tl.dn.riseList.get(0), +6.0, 0.0); | ||
4985 | 1137 | createReplicaReadArcs(slot.mem.zero, Arrays.asList(slot.tl.dn.riseList.get(2), slot.tl.dn.riseList.get(1)), +6.0, 0.0); | ||
4986 | 1138 | createReplicaReadArc(slot.mem.zero, slot.tl.dn.fallList.get(0), +6.0, 0.0); | ||
4987 | 1139 | createReplicaReadArc(slot.mem.zero, slot.tl.dn.fallList.get(2), +6.0, 0.0); | ||
4988 | 1140 | createReadArc(slot.tl.rdy.zero, slot.tl.dn.riseList.get(0)); | ||
4989 | 1141 | createReadArc(slot.tl.rdy.zero, slot.tl.dn.fallList.get(3)); | ||
4990 | 1142 | createReadArc(slot.tl.rdy.one, slot.tl.dn.riseList.get(2)); | ||
4991 | 1143 | createReadArc(slot.tl.rdy.one, slot.tl.dn.fallList.get(2)); | ||
4992 | 1144 | createReadArc(slot.tl.rdy.one, slot.tl.dn.fallList.get(1)); | ||
4993 | 1145 | createReadArc(slot.tl.rdy.one, slot.tl.dn.fallList.get(0)); | ||
4994 | 1146 | } | ||
4995 | 1147 | for (int idx = 0; idx < capacity; idx++) { | ||
4996 | 1148 | SlotStg slot = slotList.get(idx); | ||
4997 | 1149 | // Connections with input port | ||
4998 | 1150 | createReplicaReadArc(i.rdy.one, slot.mem.riseList.get(0), -6.0, -1.0); | ||
4999 | 1151 | createReplicaReadArc(i.rdy.one, slot.tl.dn.fallList.get(1), -6.0, 0.0); | ||
5000 | 1152 | createReplicaReadArc(i.rdy.zero, slot.tl.dn.fallList.get(2), +6.0, -1.0); |
The diff has been truncated for viewing.