Merge lp:~libowen96/workcraft/trunk-son-time-intermediate into lp:~libowen96/workcraft/trunk-son-alter

Proposed by Bowen Li
Status: Merged
Approved by: Bowen Li
Approved revision: 666
Merged at revision: 667
Proposed branch: lp:~libowen96/workcraft/trunk-son-time-intermediate
Merge into: lp:~libowen96/workcraft/trunk-son-alter
Diff against target: 450 lines (+114/-42)
11 files modified
SONPlugin/src/org/workcraft/plugins/son/SON.java (+20/-1)
SONPlugin/src/org/workcraft/plugins/son/algorithm/EstimationAlg.java (+66/-21)
SONPlugin/src/org/workcraft/plugins/son/gui/ParallelSimDialog.java (+3/-3)
SONPlugin/src/org/workcraft/plugins/son/gui/TimeConsistencyDialog.java (+1/-1)
SONPlugin/src/org/workcraft/plugins/son/gui/TimeEstimatorDialog.java (+9/-4)
SONPlugin/src/org/workcraft/plugins/son/tools/ColorResetTool.java (+1/-1)
SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java (+1/-1)
SONPlugin/src/org/workcraft/plugins/son/tools/ScenarioGeneratorTool.java (+3/-3)
SONPlugin/src/org/workcraft/plugins/son/tools/StructurePropertyChecker.java (+2/-2)
SONPlugin/src/org/workcraft/plugins/son/tools/TimeConsistencyChecker.java (+2/-2)
SONPlugin/src/org/workcraft/plugins/son/tools/TimeValueSetterTool.java (+6/-3)
To merge this branch: bzr merge lp:~libowen96/workcraft/trunk-son-time-intermediate
Reviewer Review Type Date Requested Status
Bowen Li Pending
Review via email: mp+281354@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'SONPlugin/src/org/workcraft/plugins/son/SON.java'
2--- SONPlugin/src/org/workcraft/plugins/son/SON.java 2015-10-05 19:59:54 +0000
3+++ SONPlugin/src/org/workcraft/plugins/son/SON.java 2015-12-25 22:57:38 +0000
4@@ -185,7 +185,7 @@
5 }
6 }
7
8- public void refreshColor(){
9+ public void refreshAllColor(){
10 for(Node n: getComponents()){
11 setFillColor(n,CommonVisualSettings.getFillColor());
12 setForegroundColor(n, CommonVisualSettings.getBorderColor());
13@@ -206,6 +206,25 @@
14 }
15 }
16
17+ public void refreshNodeColor(){
18+ for(Node n: getComponents()){
19+ setFillColor(n,CommonVisualSettings.getFillColor());
20+ setForegroundColor(n, CommonVisualSettings.getBorderColor());
21+ setTokenColor(n, Color.BLACK);
22+ }
23+ for (ONGroup group : this.getGroups()){
24+ setForegroundColor(group, SONSettings.getGroupForegroundColor());
25+ }
26+
27+ for (SONConnection con : this.getSONConnections()){
28+ setForegroundColor(con, CommonVisualSettings.getBorderColor());
29+ }
30+ for (Block block : this.getBlocks()){
31+ setFillColor(block, CommonVisualSettings.getFillColor());
32+ setForegroundColor(block, CommonVisualSettings.getBorderColor());
33+ }
34+ }
35+
36 public void setTimeColor(Node n, Color color){
37 if(n instanceof PlaceNode){
38 ((PlaceNode) n).setDurationColor(color);
39
40=== modified file 'SONPlugin/src/org/workcraft/plugins/son/algorithm/EstimationAlg.java'
41--- SONPlugin/src/org/workcraft/plugins/son/algorithm/EstimationAlg.java 2015-10-09 16:21:17 +0000
42+++ SONPlugin/src/org/workcraft/plugins/son/algorithm/EstimationAlg.java 2015-12-25 22:57:38 +0000
43@@ -41,6 +41,8 @@
44 private Before before;
45 private Granularity g;
46 private Color color =Color.ORANGE;
47+ private Collection<Path> fwdPaths = new ArrayList<Path>();
48+ private Collection<Path> bwdPaths = new ArrayList<Path>();
49
50 public EstimationAlg(SON net, Interval d, Granularity g, ScenarioRef s) {
51 super(net);
52@@ -83,7 +85,7 @@
53 return scenario;
54 }
55
56- public void twoDirEstimation(Node n) throws AlternativeStructureException, TimeEstimationException, TimeOutOfBoundsException, TimeInconsistencyException{
57+ public void twoDirEstimation(Node n, boolean interm) throws AlternativeStructureException, TimeEstimationException, TimeOutOfBoundsException, TimeInconsistencyException{
58 ConsistencyAlg alg = new ConsistencyAlg(net);
59 Time node = null;
60
61@@ -242,7 +244,7 @@
62 }else if(start == null && end == null){
63 throw new TimeEstimationException("cannot find causally time values.");
64 }
65-
66+
67 if(iCons.size() == 0){
68 node.setStartTime(start);
69 if(node instanceof Condition){
70@@ -256,7 +258,7 @@
71 ((Condition) node).setEndTimeColor(color);
72 }
73 }
74-
75+
76 iCons.removeAll(iSpec);
77 for(SONConnection con : iCons){
78 con.setTime(start);
79@@ -268,12 +270,54 @@
80 con.setTime(end);
81 con.setTimeLabelColor(color);
82 }
83+
84+ if(interm) intermediateEst();
85+
86 if(!alg.nodeConsistency(node, start, end, node.getDuration(), g).isEmpty()){
87 throw new TimeInconsistencyException("Warning: Estimated start and end times are inconsistent.");
88 }
89 }
90 }
91+
92+ private void intermediateEst() throws TimeOutOfBoundsException{
93
94+ for(Path path : fwdPaths){
95+ for(int i = 1; i < path.size(); i++){
96+ Time n = (Time)path.get(i);
97+ if(!n.getDuration().isSpecified()){
98+ n.setDuration(defaultDuration);
99+ }
100+ SONConnection preCon = net.getSONConnection(path.get(i-1), path.get(i));
101+ Interval time = granularity.plusTD(preCon.getTime(), n.getDuration());
102+ if( (i+1) < path.size()){
103+ SONConnection postCon = net.getSONConnection(path.get(i), path.get(i+1));
104+ postCon.setTime(time);
105+ postCon.setTimeLabelColor(color);
106+ }
107+ }
108+ }
109+
110+ fwdPaths.clear();
111+
112+ for(Path path : bwdPaths){
113+ for(int i = 1; i < path.size(); i++){
114+ Time n = (Time)path.get(i);
115+ if(!n.getDuration().isSpecified()){
116+ n.setDuration(defaultDuration);
117+ }
118+ SONConnection preCon = net.getSONConnection(path.get(i-1), path.get(i));
119+ Interval time = granularity.subtractTD(preCon.getTime(), n.getDuration());
120+ if( (i+1) < path.size()){
121+ SONConnection postCon = net.getSONConnection(path.get(i), path.get(i+1));
122+ postCon.setTime(time);
123+ postCon.setTimeLabelColor(color);
124+ }
125+ }
126+ }
127+
128+ bwdPaths.clear();
129+
130+ }
131
132 private boolean hasConflict(){
133 RelationAlgorithm alg = new RelationAlgorithm(net);
134@@ -596,6 +640,10 @@
135 result[0] = visited.getLast().getEndTime();
136 result[1] = durationAccumulator1(visited);
137 resultTimeAndDuration.add(result);
138+
139+ Path path = new Path();
140+ path.addAll(visited);
141+ fwdPaths.add(path);
142 }
143
144 // examine post nodes
145@@ -611,6 +659,11 @@
146 result[0] = con.getTime();
147 result[1] = durationAccumulator1(visited);
148 resultTimeAndDuration.add(result);
149+
150+ Path path = new Path();
151+ visited.addLast(node);
152+ path.addAll(visited);
153+ fwdPaths.add(path);
154 }
155 }
156 // in depth-first, recursion needs to come after visiting post nodes
157@@ -633,8 +686,11 @@
158 Interval[] result = new Interval[2];
159 result[0] = visited.getLast().getStartTime();
160 result[1] = durationAccumulator1(visited);
161-
162 resultTimeAndDuration.add(result);
163+
164+ Path path = new Path();
165+ path.addAll(visited);
166+ bwdPaths.add(path);
167 }
168
169 // examine post nodes
170@@ -649,7 +705,12 @@
171 Interval[] result = new Interval[2];
172 result[0] = con.getTime();
173 result[1] = durationAccumulator1(visited);
174- resultTimeAndDuration.add(result);
175+ resultTimeAndDuration.add(result);
176+
177+ Path path = new Path();
178+ visited.addLast(node);
179+ path.addAll(visited);
180+ bwdPaths.add(path);
181 }
182 }
183 // in depth-first, recursion needs to come after visiting post nodes
184@@ -682,22 +743,6 @@
185 return result;
186 }
187
188-// private Interval durationAccumulator2 (LinkedList<Time> visited){
189-// Interval result = new Interval(0000, 0000);
190-// Time first = visited.getFirst();
191-// Time last = visited.getLast();
192-// for(Time time : visited){
193-// if(time != first || time != last){
194-// if (time.getDuration().isSpecified())
195-// result = result.add(time.getDuration());
196-// else{
197-// result = result.add(defaultDuration);
198-// }
199-// }
200-// }
201-// return result;
202-// }
203-
204 private LinkedList<Time> getCausalPreset(Time n, Collection<Node> nodes){
205 LinkedList<Time> preSet = new LinkedList<Time>();
206 LinkedList<Time> result = new LinkedList<Time>();
207
208=== modified file 'SONPlugin/src/org/workcraft/plugins/son/gui/ParallelSimDialog.java'
209--- SONPlugin/src/org/workcraft/plugins/son/gui/ParallelSimDialog.java 2015-10-05 19:59:54 +0000
210+++ SONPlugin/src/org/workcraft/plugins/son/gui/ParallelSimDialog.java 2015-12-25 22:57:38 +0000
211@@ -220,7 +220,7 @@
212 @Override
213 public void actionPerformed(ActionEvent e) {
214 run = 1;
215- net.refreshColor();
216+ net.refreshAllColor();
217 setVisible(false);
218 }
219 });
220@@ -231,7 +231,7 @@
221 @Override
222 public void actionPerformed(ActionEvent e) {
223 run = 2;
224- net.refreshColor();
225+ net.refreshAllColor();
226 setVisible(false);
227 }
228 });
229@@ -304,7 +304,7 @@
230 {
231 public void windowClosing(WindowEvent e)
232 {
233- getSONModel().refreshColor();
234+ getSONModel().refreshAllColor();
235 }
236 });
237
238
239=== modified file 'SONPlugin/src/org/workcraft/plugins/son/gui/TimeConsistencyDialog.java'
240--- SONPlugin/src/org/workcraft/plugins/son/gui/TimeConsistencyDialog.java 2015-10-05 19:59:54 +0000
241+++ SONPlugin/src/org/workcraft/plugins/son/gui/TimeConsistencyDialog.java 2015-12-25 22:57:38 +0000
242@@ -212,7 +212,7 @@
243
244 selectionTabbedPane.addChangeListener(new ChangeListener() {
245 public void stateChanged(ChangeEvent e) {
246- net.refreshColor();
247+ net.refreshAllColor();
248 addAllButton.setEnabled(true);
249 removeAllButton.setEnabled(true);
250 int index = getTabIndex();
251
252=== modified file 'SONPlugin/src/org/workcraft/plugins/son/gui/TimeEstimatorDialog.java'
253--- SONPlugin/src/org/workcraft/plugins/son/gui/TimeEstimatorDialog.java 2015-10-06 16:44:57 +0000
254+++ SONPlugin/src/org/workcraft/plugins/son/gui/TimeEstimatorDialog.java 2015-12-25 22:57:38 +0000
255@@ -49,7 +49,7 @@
256
257 protected JPanel buttonsPanel, durationPanel;
258 protected JButton runButton, cancelButton;
259- protected JCheckBox setDuration;
260+ protected JCheckBox setDuration, intermediate;
261 protected Dimension buttonSize = new Dimension(80, 25);
262 protected int run = 0;
263
264@@ -82,18 +82,23 @@
265 }
266
267 protected void createDurationPanel(){
268- setDuration = new JCheckBox("Set default value for all unspecifed nodes");
269+ setDuration = new JCheckBox("Set default duration for all unspecifed nodes");
270 setDuration.setSelected(false);
271 setDuration.setLayout(new FlowLayout(FlowLayout.LEFT));
272
273+ intermediate = new JCheckBox("Set values for intermediate nodes");
274+ intermediate.setSelected(false);
275+ intermediate.setLayout(new FlowLayout(FlowLayout.LEFT));
276+
277 defaultDurationPanel = new DefaultDurationPanel(settings.getDuration());
278 defaultDurationPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
279
280 durationPanel = new JPanel();
281 //durationPanel.setBorder(BorderFactory.createTitledBorder("Default Duration Setting"));
282- durationPanel.setLayout(new GridLayout(2,0));
283+ durationPanel.setLayout(new GridLayout(3,0));
284 durationPanel.add(defaultDurationPanel);
285 durationPanel.add(setDuration);
286+ durationPanel.add(intermediate);
287 }
288
289 protected void createScenarioTable(){
290@@ -173,7 +178,7 @@
291 alg.setDefaultDuration();
292
293 try {
294- alg.twoDirEstimation(selection);
295+ alg.twoDirEstimation(selection, intermediate.isSelected());
296 } catch (AlternativeStructureException e1) {
297 errMsg(e1.getMessage());
298 } catch (TimeEstimationException e1) {
299
300=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/ColorResetTool.java'
301--- SONPlugin/src/org/workcraft/plugins/son/tools/ColorResetTool.java 2014-09-29 17:07:11 +0000
302+++ SONPlugin/src/org/workcraft/plugins/son/tools/ColorResetTool.java 2015-12-25 22:57:38 +0000
303@@ -21,7 +21,7 @@
304
305 public void run(WorkspaceEntry we){
306 SON net=(SON)we.getModelEntry().getMathModel();
307- net.refreshColor();
308+ net.refreshAllColor();
309 }
310
311 }
312
313=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java'
314--- SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java 2015-10-14 18:26:17 +0000
315+++ SONPlugin/src/org/workcraft/plugins/son/tools/SONSimulationTool.java 2015-12-25 22:57:38 +0000
316@@ -863,7 +863,7 @@
317 }
318
319 protected void setDecoration(Step enabled){
320- net.refreshColor();
321+ net.refreshAllColor();
322
323 for(TransitionNode e : enabled){
324 //e.setFillColor(CommonSimulationSettings.getEnabledForegroundColor());
325
326=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/ScenarioGeneratorTool.java'
327--- SONPlugin/src/org/workcraft/plugins/son/tools/ScenarioGeneratorTool.java 2015-10-05 19:59:54 +0000
328+++ SONPlugin/src/org/workcraft/plugins/son/tools/ScenarioGeneratorTool.java 2015-12-25 22:57:38 +0000
329@@ -86,7 +86,7 @@
330 //workcraft invoke this method before activate method
331 visualNet = (VisualSON)editor.getModel();
332 net = (SON)visualNet.getMathModel();
333- net.refreshColor();
334+ net.refreshAllColor();
335
336 startButton = SONGUI.createIconToggleButton(GUI.createIconFromSVG("images/icons/svg/son-scenario-start.svg"), "Generate");
337 resetButton = GUI.createIconButton(GUI.createIconFromSVG("images/icons/svg/son-scenario-reset.svg"), "Reset");
338@@ -237,7 +237,7 @@
339 }else{
340 scenarioRef.clear();
341 net.clearMarking();
342- net.refreshColor();
343+ net.refreshAllColor();
344 scenarioTable.setIsCellColor(false);
345 saveList.setPosition(0);
346 scenarioGenerator(editor);
347@@ -272,7 +272,7 @@
348 BlockConnector.blockInternalConnector(visualNet);
349 exportScenarios();
350 scenarioRef.clear();
351- net.refreshColor();
352+ net.refreshAllColor();
353 net.clearMarking();
354 }
355
356
357=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/StructurePropertyChecker.java'
358--- SONPlugin/src/org/workcraft/plugins/son/tools/StructurePropertyChecker.java 2015-09-27 18:17:29 +0000
359+++ SONPlugin/src/org/workcraft/plugins/son/tools/StructurePropertyChecker.java 2015-12-25 22:57:38 +0000
360@@ -35,7 +35,7 @@
361 final Framework framework = Framework.getInstance();
362 final MainWindow mainWindow = framework.getMainWindow();
363
364- net.refreshColor();
365+ net.refreshAllColor();
366 StructureVerifyDialog dialog = new StructureVerifyDialog(mainWindow, we);
367 GUI.centerToParent(dialog, mainWindow);
368 dialog.setVisible(true);
369@@ -46,6 +46,6 @@
370 SONMainTask sonTask = new SONMainTask(dialog.getSettings(), we);
371 framework.getTaskManager().queue(sonTask, "Verification");
372 }
373- net.refreshColor();
374+ net.refreshAllColor();
375 }
376 }
377
378=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/TimeConsistencyChecker.java'
379--- SONPlugin/src/org/workcraft/plugins/son/tools/TimeConsistencyChecker.java 2015-09-27 18:17:29 +0000
380+++ SONPlugin/src/org/workcraft/plugins/son/tools/TimeConsistencyChecker.java 2015-12-25 22:57:38 +0000
381@@ -40,7 +40,7 @@
382 SON net = (SON)we.getModelEntry().getMathModel();
383
384 BlockConnector.blockBoundingConnector(visualNet);
385- net.refreshColor();
386+ net.refreshAllColor();
387 TimeConsistencyDialog dialog = new TimeConsistencyDialog(mainWindow, we);
388 GUI.centerToParent(dialog, mainWindow);
389 dialog.setVisible(true);
390@@ -52,7 +52,7 @@
391 }
392
393 if(dialog.getTabIndex() !=1){
394- net.refreshColor();
395+ net.refreshAllColor();
396 }
397
398 BlockConnector.blockInternalConnector(visualNet);
399
400=== modified file 'SONPlugin/src/org/workcraft/plugins/son/tools/TimeValueSetterTool.java'
401--- SONPlugin/src/org/workcraft/plugins/son/tools/TimeValueSetterTool.java 2015-10-06 23:26:41 +0000
402+++ SONPlugin/src/org/workcraft/plugins/son/tools/TimeValueSetterTool.java 2015-12-25 22:57:38 +0000
403@@ -553,7 +553,7 @@
404 timeAlg = new ConsistencyAlg(net);
405 settings = new TimeEstimatorSettings();
406
407- net.refreshColor();
408+ net.refreshAllColor();
409 net.clearMarking();
410
411 //set property states for initial and final states
412@@ -574,13 +574,13 @@
413 timeAlg.removeProperties();
414 }
415 SONSettings.setTimeVisibility(visibility);
416- net.refreshColor();
417+ net.refreshAllColor();
418 net.clearMarking();
419 }
420
421 @Override
422 public void mousePressed(GraphEditorMouseEvent e){
423- net.refreshColor();
424+ net.refreshNodeColor();
425
426 Node node = HitMan.hitTestForConnection(e.getPosition(), e.getModel().getRoot());
427 if( node instanceof VisualSONConnection){
428@@ -591,6 +591,7 @@
429 if(con.getSemantics()==Semantics.PNLINE){
430 ((VisualSONConnection) node).setColor(selectedColor);
431 updateTimePanel(e.getEditor(), node);
432+ net.setTimeColor(selection, Color.BLACK);
433 return;
434 }
435 }
436@@ -603,6 +604,7 @@
437 estimatorButton.setEnabled(true);
438 ((VisualBlock) node2).setForegroundColor(selectedColor);
439 updateTimePanel(e.getEditor(), node2);
440+ net.setTimeColor(selection, Color.BLACK);
441 return;
442 }
443 }
444@@ -622,6 +624,7 @@
445 visualSelection = node3;
446 ((VisualComponent) node3).setForegroundColor(selectedColor);
447 updateTimePanel(e.getEditor(), node3);
448+ net.setTimeColor(selection, Color.BLACK);
449 }
450 }
451

Subscribers

People subscribed via source and target branches

to all changes: