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