Merge lp:~danilovesky/workcraft/trunk-bug-1503646 into lp:workcraft
- trunk-bug-1503646
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 655 | ||||||||
Proposed branch: | lp:~danilovesky/workcraft/trunk-bug-1503646 | ||||||||
Merge into: | lp:workcraft | ||||||||
Diff against target: |
1430 lines (+366/-238) 22 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java (+116/-63) CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java (+31/-21) CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java (+40/-48) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java (+12/-8) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java (+12/-8) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java (+14/-10) FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java (+2/-3) MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java (+9/-5) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java (+1/-1) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java (+1/-1) MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java (+1/-0) PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java (+4/-1) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java (+6/-3) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawSgTask.java (+30/-18) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java (+2/-3) PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSg.java (+26/-21) PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSgBinary.java (+23/-0) PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java (+12/-8) STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java (+1/-0) WorkcraftCore/src/org/workcraft/gui/tasks/TaskControl.java (+3/-4) WorkcraftCore/src/org/workcraft/gui/tasks/TaskManagerWindow.java (+17/-10) WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java (+3/-2) |
||||||||
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-bug-1503646 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Approve | ||
Review via email: mp+274242@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Danil Sokolov (danilovesky) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java' |
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2015-08-03 12:45:13 +0000 |
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2015-10-13 11:40:49 +0000 |
4 | @@ -2,24 +2,31 @@ |
5 | |
6 | import java.io.File; |
7 | import java.io.IOException; |
8 | +import java.util.Collection; |
9 | +import java.util.Set; |
10 | |
11 | import org.workcraft.Framework; |
12 | +import org.workcraft.PluginManager; |
13 | import org.workcraft.exceptions.DeserialisationException; |
14 | import org.workcraft.interop.Exporter; |
15 | import org.workcraft.plugins.circuit.VisualCircuit; |
16 | +import org.workcraft.plugins.mpsat.tasks.MpsatChainResult; |
17 | import org.workcraft.plugins.pcomp.tasks.PcompTask; |
18 | import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode; |
19 | import org.workcraft.plugins.shared.CommonDebugSettings; |
20 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
21 | import org.workcraft.plugins.stg.STG; |
22 | +import org.workcraft.plugins.stg.SignalTransition.Type; |
23 | import org.workcraft.plugins.stg.StgUtils; |
24 | import org.workcraft.plugins.stg.VisualSTG; |
25 | import org.workcraft.serialisation.Format; |
26 | +import org.workcraft.tasks.ProgressMonitor; |
27 | import org.workcraft.tasks.Result; |
28 | -import org.workcraft.tasks.Result.Outcome; |
29 | +import org.workcraft.tasks.SubtaskMonitor; |
30 | import org.workcraft.util.Export; |
31 | import org.workcraft.util.Export.ExportTask; |
32 | import org.workcraft.util.FileUtils; |
33 | +import org.workcraft.workspace.ModelEntry; |
34 | import org.workcraft.workspace.WorkspaceEntry; |
35 | |
36 | public class CircuitStgUtils { |
37 | @@ -28,95 +35,141 @@ |
38 | CircuitToStgConverter generator = new CircuitToStgConverter(circuit); |
39 | File envFile = circuit.getEnvironmentFile(); |
40 | if ((envFile != null) && envFile.exists()) { |
41 | - VisualSTG devStg = generator.getStg(); |
42 | - VisualSTG systemStg = composeDevStgWithEvnFile(devStg, envFile, circuit.getTitle()); |
43 | + STG devStg = (STG)generator.getStg().getMathModel(); |
44 | + STG systemStg = createSystemStg(devStg, envFile, circuit.getTitle()); |
45 | if (systemStg != null) { |
46 | - generator = new CircuitToStgConverter(circuit, systemStg); |
47 | + generator = new CircuitToStgConverter(circuit, new VisualSTG(systemStg)); |
48 | } |
49 | } |
50 | return generator; |
51 | } |
52 | |
53 | - public static VisualSTG composeDevStgWithEvnFile(VisualSTG devStg, File envFile, String title) { |
54 | - VisualSTG resultStg = null; |
55 | - Framework framework = Framework.getInstance(); |
56 | + private static STG createSystemStg(STG devStg, File envFile, String title) { |
57 | + STG systemStg = null; |
58 | String prefix = FileUtils.getTempPrefix(title); |
59 | File directory = FileUtils.createTempDirectory(prefix); |
60 | try { |
61 | File devStgFile = exportDevStg(devStg, directory); |
62 | File envStgFile = exportEnvStg(envFile, directory); |
63 | - File stgFile = composeDevStgWithEnvStg(devStgFile, envStgFile, directory); |
64 | - if (stgFile != null) { |
65 | - WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); |
66 | - STG stg = (STG)stgWorkspaceEntry.getModelEntry().getMathModel(); |
67 | - resultStg = new VisualSTG(stg); |
68 | - framework.getWorkspace().close(stgWorkspaceEntry); |
69 | + File compStgFile = createComposedStg(devStgFile, envStgFile, directory); |
70 | + if (compStgFile != null) { |
71 | + systemStg = importStg(compStgFile); |
72 | + Set<String> inputSignalNames = devStg.getSignalNames(Type.INPUT, null); |
73 | + restoreInputSignals(systemStg, inputSignalNames); |
74 | } |
75 | } catch (Throwable e) { |
76 | } finally { |
77 | FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
78 | } |
79 | - return resultStg; |
80 | - } |
81 | - |
82 | - private static File composeDevStgWithEnvStg(File devStgFile, File envStgFile, File directory) throws IOException { |
83 | - File stgFile = null; |
84 | - Framework framework = Framework.getInstance(); |
85 | - if ((devStgFile != null) && (envStgFile != null)) { |
86 | - // Generating .g for the whole system (circuit and environment) |
87 | - stgFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
88 | - PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, |
89 | - ConversionMode.OUTPUT, true, false, directory); |
90 | - |
91 | - Result<? extends ExternalProcessResult> pcompResult = framework.getTaskManager().execute( |
92 | - pcompTask, "Running pcomp", null); |
93 | - |
94 | - if (pcompResult.getOutcome() == Outcome.FINISHED) { |
95 | - FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput())); |
96 | - } else { |
97 | - stgFile = null; |
98 | - } |
99 | - } |
100 | - return stgFile; |
101 | + return systemStg; |
102 | } |
103 | |
104 | private static File exportEnvStg(File envFile, File directory) throws DeserialisationException, IOException { |
105 | - Framework framework = Framework.getInstance(); |
106 | File envStgFile = null; |
107 | if (envFile.getName().endsWith(StgUtils.ASTG_FILE_EXT)) { |
108 | envStgFile = envFile; |
109 | } else { |
110 | - STG envStg = (STG)framework.loadFile(envFile).getMathModel(); |
111 | - Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG); |
112 | - envStgFile = new File(directory, StgUtils.ENVIRONMENT_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
113 | - ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath()); |
114 | - Result<? extends Object> envExportResult = framework.getTaskManager().execute( |
115 | - envExportTask, "Exporting environment .g", null); |
116 | - if (envExportResult.getOutcome() != Outcome.FINISHED) { |
117 | - envStgFile = null; |
118 | - } |
119 | + Framework framework = Framework.getInstance(); |
120 | + ModelEntry modelEntry = framework.loadFile(envFile); |
121 | + STG envStg = (STG)modelEntry.getMathModel(); |
122 | + envStgFile = exportStg(envStg, StgUtils.ENVIRONMENT_FILE_NAME + StgUtils.ASTG_FILE_EXT, directory); |
123 | } |
124 | return envStgFile; |
125 | } |
126 | |
127 | - private static File exportDevStg(VisualSTG visualStg, File directory) throws IOException { |
128 | - Framework framework = Framework.getInstance(); |
129 | - |
130 | - STG devStg = (STG)visualStg.getMathModel(); |
131 | - Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG); |
132 | - if (devStgExporter == null) { |
133 | - throw new RuntimeException("Exporter not available: model class " + devStg.getClass().getName() + " to .g format."); |
134 | - } |
135 | - |
136 | - File devStgFile = new File(directory, StgUtils.DEVICE_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
137 | - ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath()); |
138 | - Result<? extends Object> devExportResult = framework.getTaskManager().execute( |
139 | - devExportTask, "Exporting device .g", null); |
140 | - if (devExportResult.getOutcome() != Outcome.FINISHED) { |
141 | - devStgFile = null; |
142 | - } |
143 | - |
144 | - return devStgFile; |
145 | + private static File exportDevStg(STG devStg, File directory) throws IOException { |
146 | + return exportStg(devStg, StgUtils.DEVICE_FILE_NAME + StgUtils.ASTG_FILE_EXT, directory); |
147 | + } |
148 | + |
149 | + private static File exportSytemStg(STG systemStg, File directory) throws IOException { |
150 | + return exportStg(systemStg, StgUtils.SYSTEM_FILE_NAME + StgUtils.ASTG_FILE_EXT, directory); |
151 | + } |
152 | + |
153 | + private static File exportStg(STG stg, String fileName, File directory) throws IOException { |
154 | + File stgFile = new File(directory, fileName); |
155 | + Result<? extends Object> exportResult = exportStg(stg, stgFile, directory, null); |
156 | + |
157 | + switch (exportResult.getOutcome()) { |
158 | + case FINISHED: |
159 | + break; |
160 | + case CANCELLED: |
161 | + stgFile = null; |
162 | + break; |
163 | + case FAILED: |
164 | + throw new RuntimeException("Export failed for file '" + fileName + "':\n" + exportResult.getCause()); |
165 | + } |
166 | + return stgFile; |
167 | + } |
168 | + |
169 | + public static Result<? extends Object> exportStg(STG stg, File stgFile, File directory, |
170 | + ProgressMonitor<? super MpsatChainResult> monitor) throws IOException { |
171 | + |
172 | + Framework framework = Framework.getInstance(); |
173 | + PluginManager pluginManager = framework.getPluginManager(); |
174 | + Exporter stgExporter = Export.chooseBestExporter(pluginManager, stg, Format.STG); |
175 | + if (stgExporter == null) { |
176 | + throw new RuntimeException("Exporter not available: model class " + stg.getClass().getName() + " to .g format."); |
177 | + } |
178 | + |
179 | + ExportTask exportTask = new ExportTask(stgExporter, stg, stgFile.getCanonicalPath()); |
180 | + String description = "Exporting " + stgFile.getAbsolutePath(); |
181 | + SubtaskMonitor<Object> subtaskMonitor = null; |
182 | + if (monitor != null) { |
183 | + subtaskMonitor = new SubtaskMonitor<Object>(monitor); |
184 | + } |
185 | + return framework.getTaskManager().execute(exportTask, description, subtaskMonitor); |
186 | + } |
187 | + |
188 | + private static File createComposedStg(File devStgFile, File envStgFile, File directory) throws IOException { |
189 | + File compStgFile = null; |
190 | + if ((devStgFile != null) && (envStgFile != null)) { |
191 | + // Generating .g for the whole system (circuit and environment) |
192 | + compStgFile = new File(directory, StgUtils.COMPOSITION_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
193 | + Result<? extends ExternalProcessResult> pcompResult = composeDevWithEnv(devStgFile, envStgFile, directory, null); |
194 | + |
195 | + switch (pcompResult.getOutcome()) { |
196 | + case FINISHED: |
197 | + FileUtils.writeAllText(compStgFile, new String(pcompResult.getReturnValue().getOutput())); |
198 | + break; |
199 | + case CANCELLED: |
200 | + compStgFile = null; |
201 | + break; |
202 | + case FAILED: |
203 | + throw new RuntimeException("Composition failed:\n" + pcompResult.getCause()); |
204 | + } |
205 | + } |
206 | + return compStgFile; |
207 | + } |
208 | + |
209 | + public static Result<? extends ExternalProcessResult> composeDevWithEnv(File devStgFile, File envStgFile, File directory, |
210 | + ProgressMonitor<? super MpsatChainResult> monitor) { |
211 | + Framework framework = Framework.getInstance(); |
212 | + File[] inputFiles = new File[]{devStgFile, envStgFile}; |
213 | + PcompTask pcompTask = new PcompTask(inputFiles, ConversionMode.OUTPUT, true, false, directory); |
214 | + String description = "Running pcomp"; |
215 | + SubtaskMonitor<Object> subtaskMonitor = null; |
216 | + if (monitor != null) { |
217 | + subtaskMonitor = new SubtaskMonitor<Object>(monitor); |
218 | + } |
219 | + return framework.getTaskManager().execute(pcompTask, description, subtaskMonitor); |
220 | + } |
221 | + |
222 | + public static STG importStg(File stgFile) { |
223 | + STG stg = null; |
224 | + try { |
225 | + Framework framework = Framework.getInstance(); |
226 | + WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); |
227 | + stg = (STG)stgWorkspaceEntry.getModelEntry().getMathModel(); |
228 | + framework.getWorkspace().close(stgWorkspaceEntry); |
229 | + } catch (DeserialisationException e) { |
230 | + } |
231 | + return stg; |
232 | + } |
233 | + |
234 | + public static void restoreInputSignals(STG stg, Collection<String> inputSignalNames) { |
235 | + for (String inputName: inputSignalNames) { |
236 | + stg.setSignalType(inputName, Type.INPUT, null); |
237 | + } |
238 | } |
239 | |
240 | } |
241 | |
242 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java' |
243 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-09-25 14:43:34 +0000 |
244 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitToStgConverter.java 2015-10-13 11:40:49 +0000 |
245 | @@ -242,17 +242,10 @@ |
246 | String signalName = CircuitUtils.getSignalName(circuit, signal); |
247 | SignalTransition.Type signalType = CircuitUtils.getSignalType(circuit, signal); |
248 | for(DnfClause clause : clauses) { |
249 | - VisualSignalTransition transition = stg.createSignalTransition(signalName, signalType, direction, container); |
250 | - transition.setLabel(FormulaToString.toString(clause)); |
251 | - transitions.add(transition); |
252 | - |
253 | - try { |
254 | - stg.connect(predPlace, transition); |
255 | - stg.connect(transition, succPlace); |
256 | - } catch (InvalidConnectionException e) { |
257 | - throw new RuntimeException(e); |
258 | - } |
259 | - |
260 | + // In self-looped signals the read-arcs will clash with producing/consuming arcs: |
261 | + // 1) a read-arc from a preset place is redundant (is superseded by a consuming arc); |
262 | + // 2) a read-arc from a postset place makes the transition dead. |
263 | + boolean isDeadTransition = false; |
264 | HashSet<VisualPlace> placesToRead = new HashSet<VisualPlace>(); |
265 | for (Literal literal : clause.getLiterals()) { |
266 | BooleanVariable variable = literal.getVariable(); |
267 | @@ -263,23 +256,40 @@ |
268 | throw new RuntimeException("No source for '" + circuit.getMathName(sourceContact) + "' while generating '" + signalName + "'."); |
269 | } |
270 | VisualPlace place = literal.getNegation() ? sourceDriverStg.zero : sourceDriverStg.one; |
271 | - placesToRead.add(place); |
272 | - } |
273 | - |
274 | - if (placesToRead.remove(predPlace)) { |
275 | - System.out.println("Warning: signal '" + signalName + "' depends on itself."); |
276 | - } |
277 | - |
278 | - for (VisualPlace place : placesToRead) { |
279 | + if (place != predPlace) { |
280 | + // 1) a read-arc from a preset place is redundant (is superseded by a consuming arc); |
281 | + placesToRead.add(place); |
282 | + } |
283 | + |
284 | + if (place == succPlace) { |
285 | + // 2) a read-arc from a postset place makes the transition dead. |
286 | + isDeadTransition = true; |
287 | + } |
288 | + } |
289 | + |
290 | + if ( !isDeadTransition ) { |
291 | + VisualSignalTransition transition = stg.createSignalTransition(signalName, signalType, direction, container); |
292 | + transition.setLabel(FormulaToString.toString(clause)); |
293 | + transitions.add(transition); |
294 | + // Create read-arcs. |
295 | + for (VisualPlace place : placesToRead) { |
296 | + try { |
297 | + stg.connectUndirected(place, transition); |
298 | + } catch (InvalidConnectionException e) { |
299 | + throw new RuntimeException(e); |
300 | + } |
301 | + } |
302 | + // Create producing/consuming arcs. |
303 | try { |
304 | - stg.connectUndirected(place, transition); |
305 | + stg.connect(predPlace, transition); |
306 | + stg.connect(transition, succPlace); |
307 | } catch (InvalidConnectionException e) { |
308 | throw new RuntimeException(e); |
309 | } |
310 | } |
311 | } |
312 | } |
313 | - |
314 | + |
315 | |
316 | private TwoWayMap<VisualContact, SignalStg> associateDriversToStgs(HashSet<VisualContact> drivers) { |
317 | TwoWayMap<VisualContact, SignalStg> result = new TwoWayMap<>(); |
318 | |
319 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java' |
320 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2015-08-03 12:45:13 +0000 |
321 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2015-10-13 11:40:49 +0000 |
322 | @@ -10,8 +10,8 @@ |
323 | import java.util.Set; |
324 | |
325 | import org.workcraft.Framework; |
326 | -import org.workcraft.interop.Exporter; |
327 | import org.workcraft.plugins.circuit.VisualCircuit; |
328 | +import org.workcraft.plugins.circuit.stg.CircuitStgUtils; |
329 | import org.workcraft.plugins.circuit.stg.CircuitToStgConverter; |
330 | import org.workcraft.plugins.mpsat.MpsatMode; |
331 | import org.workcraft.plugins.mpsat.MpsatResultParser; |
332 | @@ -21,20 +21,15 @@ |
333 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; |
334 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; |
335 | import org.workcraft.plugins.mpsat.tasks.PunfTask; |
336 | -import org.workcraft.plugins.pcomp.tasks.PcompTask; |
337 | -import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode; |
338 | import org.workcraft.plugins.shared.CommonDebugSettings; |
339 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
340 | import org.workcraft.plugins.stg.STG; |
341 | import org.workcraft.plugins.stg.SignalTransition.Type; |
342 | import org.workcraft.plugins.stg.StgUtils; |
343 | -import org.workcraft.serialisation.Format; |
344 | import org.workcraft.tasks.ProgressMonitor; |
345 | import org.workcraft.tasks.Result; |
346 | import org.workcraft.tasks.Result.Outcome; |
347 | import org.workcraft.tasks.SubtaskMonitor; |
348 | -import org.workcraft.util.Export; |
349 | -import org.workcraft.util.Export.ExportTask; |
350 | import org.workcraft.util.FileUtils; |
351 | import org.workcraft.workspace.WorkspaceEntry; |
352 | |
353 | @@ -83,20 +78,9 @@ |
354 | |
355 | CircuitToStgConverter generator = new CircuitToStgConverter(visualCircuit); |
356 | STG devStg = (STG)generator.getStg().getMathModel(); |
357 | - Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG); |
358 | - if (devStgExporter == null) { |
359 | - throw new RuntimeException("Exporter not available: model class " + devStg.getClass().getName() + " to .g format."); |
360 | - } |
361 | - SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor); |
362 | - monitor.progressUpdate(0.10); |
363 | - |
364 | - // Generating .g for the circuit |
365 | String devStgName = (hasEnvironment ? StgUtils.DEVICE_FILE_NAME : StgUtils.SYSTEM_FILE_NAME) + StgUtils.ASTG_FILE_EXT; |
366 | File devStgFile = new File(directory, devStgName); |
367 | - ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath()); |
368 | - Result<? extends Object> devExportResult = framework.getTaskManager().execute( |
369 | - devExportTask, "Exporting circuit .g", subtaskMonitor); |
370 | - |
371 | + Result<? extends Object> devExportResult = CircuitStgUtils.exportStg(devStg, devStgFile, directory, monitor); |
372 | if (devExportResult.getOutcome() != Outcome.FINISHED) { |
373 | if (devExportResult.getOutcome() == Outcome.CANCELLED) { |
374 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
375 | @@ -104,27 +88,23 @@ |
376 | return new Result<MpsatChainResult>(Outcome.FAILED, |
377 | new MpsatChainResult(devExportResult, null, null, null, toolchainPreparationSettings)); |
378 | } |
379 | - monitor.progressUpdate(0.20); |
380 | + monitor.progressUpdate(0.10); |
381 | |
382 | // Generating .g for the environment |
383 | - STG stg; |
384 | - File stgFile = null; |
385 | + STG sysStg; |
386 | + File sysStgFile = null; |
387 | Result<? extends ExternalProcessResult> pcompResult = null; |
388 | if ( !hasEnvironment ) { |
389 | - stgFile = devStgFile; |
390 | - stg = devStg; |
391 | + sysStgFile = devStgFile; |
392 | + sysStg = devStg; |
393 | } else { |
394 | File envStgFile = null; |
395 | if (envFile.getName().endsWith(StgUtils.ASTG_FILE_EXT)) { |
396 | envStgFile = envFile; |
397 | } else { |
398 | STG envStg = (STG)framework.loadFile(envFile).getMathModel(); |
399 | - Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG); |
400 | envStgFile = new File(directory, StgUtils.ENVIRONMENT_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
401 | - ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath()); |
402 | - Result<? extends Object> envExportResult = framework.getTaskManager().execute( |
403 | - envExportTask, "Exporting environment .g", subtaskMonitor); |
404 | - |
405 | + Result<? extends Object> envExportResult = CircuitStgUtils.exportStg(envStg, envStgFile, directory, monitor); |
406 | if (envExportResult.getOutcome() != Outcome.FINISHED) { |
407 | if (envExportResult.getOutcome() == Outcome.CANCELLED) { |
408 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
409 | @@ -133,14 +113,10 @@ |
410 | new MpsatChainResult(envExportResult, null, null, null, toolchainPreparationSettings)); |
411 | } |
412 | } |
413 | - monitor.progressUpdate(0.25); |
414 | + monitor.progressUpdate(0.20); |
415 | |
416 | // Generating .g for the whole system (circuit and environment) |
417 | - stgFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
418 | - PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, ConversionMode.OUTPUT, true, false, directory); |
419 | - pcompResult = framework.getTaskManager().execute( |
420 | - pcompTask, "Running pcomp", subtaskMonitor); |
421 | - |
422 | + pcompResult = CircuitStgUtils.composeDevWithEnv(devStgFile, envStgFile, directory, monitor); |
423 | if (pcompResult.getOutcome() != Outcome.FINISHED) { |
424 | if (pcompResult.getOutcome() == Outcome.CANCELLED) { |
425 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
426 | @@ -148,18 +124,32 @@ |
427 | return new Result<MpsatChainResult>(Outcome.FAILED, |
428 | new MpsatChainResult(devExportResult, pcompResult, null, null, toolchainPreparationSettings)); |
429 | } |
430 | - FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput())); |
431 | - WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); |
432 | - stg = (STG)stgWorkspaceEntry.getModelEntry().getMathModel(); |
433 | - framework.getWorkspace().close(stgWorkspaceEntry); |
434 | + File compStgFile = new File(directory, StgUtils.COMPOSITION_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
435 | + FileUtils.writeAllText(compStgFile, new String(pcompResult.getReturnValue().getOutput())); |
436 | + monitor.progressUpdate(0.25); |
437 | + |
438 | + // Restore input signals of the composed STG (these can be converted to outputs by PComp) |
439 | + sysStg = CircuitStgUtils.importStg(compStgFile); |
440 | + Set<String> inputSignalNames = devStg.getSignalNames(Type.INPUT, null); |
441 | + CircuitStgUtils.restoreInputSignals(sysStg, inputSignalNames); |
442 | + sysStgFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + StgUtils.ASTG_FILE_EXT); |
443 | + Result<? extends Object> sysExportResult = CircuitStgUtils.exportStg(sysStg, sysStgFile, directory, monitor); |
444 | + if (sysExportResult.getOutcome() != Outcome.FINISHED) { |
445 | + if (sysExportResult.getOutcome() == Outcome.CANCELLED) { |
446 | + return new Result<MpsatChainResult>(Outcome.CANCELLED); |
447 | + } |
448 | + return new Result<MpsatChainResult>(Outcome.FAILED, |
449 | + new MpsatChainResult(sysExportResult, null, null, null, toolchainPreparationSettings)); |
450 | + } |
451 | } |
452 | monitor.progressUpdate(0.30); |
453 | |
454 | // Generate unfolding |
455 | File unfoldingFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + MpsatUtilitySettings.getUnfoldingExtension(true)); |
456 | - PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
457 | + PunfTask punfTask = new PunfTask(sysStgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
458 | + SubtaskMonitor<Object> punfMonitor = new SubtaskMonitor<Object>(monitor); |
459 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
460 | - punfTask, "Unfolding .g", subtaskMonitor); |
461 | + punfTask, "Unfolding .g", punfMonitor); |
462 | |
463 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
464 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
465 | @@ -174,8 +164,7 @@ |
466 | if (hasEnvironment && checkConformation) { |
467 | Set<String> devOutputNames = devStg.getSignalFlatNames(Type.OUTPUT); |
468 | Set<String> devPlaceNames = parsePlaceNames(pcompResult.getReturnValue().getOutputFile("places.list"), 0); |
469 | -// String reachConformation = MpsatSettings.genReachConformation(devOutputNames, devPlaceNames); |
470 | - String reachConformation = MpsatSettings.genReachConformationDetail(stg, devOutputNames, devPlaceNames); |
471 | + String reachConformation = MpsatSettings.genReachConformationDetail(sysStg, devOutputNames, devPlaceNames); |
472 | if (MpsatUtilitySettings.getDebugReach()) { |
473 | System.out.println("\nReach expression for the interface conformation property:"); |
474 | System.out.println(reachConformation); |
475 | @@ -184,10 +173,11 @@ |
476 | MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), |
477 | MpsatUtilitySettings.getSolutionCount(), reachConformation, true); |
478 | |
479 | - MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), |
480 | + MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory), |
481 | unfoldingFile.getCanonicalPath(), directory, true); |
482 | + SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor); |
483 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( |
484 | - mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); |
485 | + mpsatConformationTask, "Running conformation check [MPSat]", mpsatMonitor); |
486 | |
487 | if (mpsatConformationResult.getOutcome() != Outcome.FINISHED) { |
488 | if (mpsatConformationResult.getOutcome() == Outcome.CANCELLED) { |
489 | @@ -209,10 +199,11 @@ |
490 | |
491 | // Check for deadlock |
492 | if (checkDeadlock) { |
493 | - MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(), |
494 | + MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory), |
495 | unfoldingFile.getCanonicalPath(), directory, true); |
496 | + SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor); |
497 | Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute( |
498 | - mpsatDeadlockTask, "Running deadlock check [MPSat]", subtaskMonitor); |
499 | + mpsatDeadlockTask, "Running deadlock check [MPSat]", mpsatMonitor); |
500 | |
501 | if (mpsatDeadlockResult.getOutcome() != Outcome.FINISHED) { |
502 | if (mpsatDeadlockResult.getOutcome() == Outcome.CANCELLED) { |
503 | @@ -234,14 +225,15 @@ |
504 | |
505 | // Check for hazards |
506 | if (checkHazard) { |
507 | - MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(), |
508 | + MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(directory), |
509 | unfoldingFile.getCanonicalPath(), directory, true); |
510 | if (MpsatUtilitySettings.getDebugReach()) { |
511 | System.out.println("\nReach expression for the hazard property:"); |
512 | System.out.println(hazardSettings.getReach()); |
513 | } |
514 | + SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor); |
515 | Result<? extends ExternalProcessResult> mpsatHazardResult = framework.getTaskManager().execute( |
516 | - mpsatHazardTask, "Running hazard check [MPSat]", subtaskMonitor); |
517 | + mpsatHazardTask, "Running hazard check [MPSat]", mpsatMonitor); |
518 | |
519 | if (mpsatHazardResult.getOutcome() != Outcome.FINISHED) { |
520 | if (mpsatHazardResult.getOutcome() == Outcome.CANCELLED) { |
521 | |
522 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java' |
523 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2015-09-25 14:43:34 +0000 |
524 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2015-10-13 11:40:49 +0000 |
525 | @@ -14,6 +14,7 @@ |
526 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; |
527 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; |
528 | import org.workcraft.plugins.mpsat.tasks.PunfTask; |
529 | +import org.workcraft.plugins.shared.CommonDebugSettings; |
530 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
531 | import org.workcraft.plugins.stg.STGModel; |
532 | import org.workcraft.serialisation.Format; |
533 | @@ -23,6 +24,7 @@ |
534 | import org.workcraft.tasks.SubtaskMonitor; |
535 | import org.workcraft.util.Export; |
536 | import org.workcraft.util.Export.ExportTask; |
537 | +import org.workcraft.util.FileUtils; |
538 | import org.workcraft.workspace.WorkspaceEntry; |
539 | |
540 | |
541 | @@ -41,7 +43,11 @@ |
542 | @Override |
543 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
544 | final Framework framework = Framework.getInstance(); |
545 | + File directory = null; |
546 | try { |
547 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
548 | + directory = FileUtils.createTempDirectory(prefix); |
549 | + |
550 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
551 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
552 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
553 | @@ -50,14 +56,13 @@ |
554 | } |
555 | monitor.progressUpdate(0.10); |
556 | |
557 | - File netFile = File.createTempFile("net", exporter.getExtenstion()); |
558 | + File netFile = new File(directory, "net" + exporter.getExtenstion()); |
559 | ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
560 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
561 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
562 | exportTask, "Exporting .g", mon); |
563 | |
564 | if (exportResult.getOutcome() != Outcome.FINISHED) { |
565 | - netFile.delete(); |
566 | if (exportResult.getOutcome() == Outcome.CANCELLED) { |
567 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
568 | } |
569 | @@ -66,14 +71,12 @@ |
570 | } |
571 | monitor.progressUpdate(0.20); |
572 | |
573 | - File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension(true)); |
574 | + File unfoldingFile = new File(directory, "unfolding" + MpsatUtilitySettings.getUnfoldingExtension(true)); |
575 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
576 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
577 | punfTask, "Unfolding .g", mon); |
578 | |
579 | - netFile.delete(); |
580 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
581 | - unfoldingFile.delete(); |
582 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
583 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
584 | } |
585 | @@ -82,7 +85,8 @@ |
586 | } |
587 | monitor.progressUpdate(0.70); |
588 | |
589 | - MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null, true); |
590 | + MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
591 | + unfoldingFile.getCanonicalPath(), directory, true); |
592 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
593 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
594 | |
595 | @@ -98,18 +102,18 @@ |
596 | |
597 | MpsatResultParser mdp = new MpsatResultParser(mpsatResult.getReturnValue()); |
598 | if (!mdp.getSolutions().isEmpty()) { |
599 | - unfoldingFile.delete(); |
600 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
601 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Dataflow has a deadlock")); |
602 | } |
603 | monitor.progressUpdate(1.0); |
604 | |
605 | - unfoldingFile.delete(); |
606 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
607 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Dataflow is deadlock-free")); |
608 | |
609 | } catch (Throwable e) { |
610 | return new Result<MpsatChainResult>(e); |
611 | + } finally { |
612 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
613 | } |
614 | } |
615 | |
616 | |
617 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java' |
618 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2015-09-25 14:43:34 +0000 |
619 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2015-10-13 11:40:49 +0000 |
620 | @@ -14,6 +14,7 @@ |
621 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; |
622 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; |
623 | import org.workcraft.plugins.mpsat.tasks.PunfTask; |
624 | +import org.workcraft.plugins.shared.CommonDebugSettings; |
625 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
626 | import org.workcraft.plugins.stg.STGModel; |
627 | import org.workcraft.serialisation.Format; |
628 | @@ -23,6 +24,7 @@ |
629 | import org.workcraft.tasks.SubtaskMonitor; |
630 | import org.workcraft.util.Export; |
631 | import org.workcraft.util.Export.ExportTask; |
632 | +import org.workcraft.util.FileUtils; |
633 | import org.workcraft.workspace.WorkspaceEntry; |
634 | |
635 | |
636 | @@ -41,7 +43,11 @@ |
637 | @Override |
638 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
639 | final Framework framework = Framework.getInstance(); |
640 | + File directory = null; |
641 | try { |
642 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
643 | + directory = FileUtils.createTempDirectory(prefix); |
644 | + |
645 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
646 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
647 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
648 | @@ -50,14 +56,13 @@ |
649 | } |
650 | monitor.progressUpdate(0.10); |
651 | |
652 | - File netFile = File.createTempFile("net", exporter.getExtenstion()); |
653 | + File netFile = new File(directory, "net" + exporter.getExtenstion()); |
654 | ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
655 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
656 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
657 | exportTask, "Exporting .g", mon); |
658 | |
659 | if (exportResult.getOutcome() != Outcome.FINISHED) { |
660 | - netFile.delete(); |
661 | if (exportResult.getOutcome() == Outcome.CANCELLED) { |
662 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
663 | } |
664 | @@ -66,14 +71,12 @@ |
665 | } |
666 | monitor.progressUpdate(0.20); |
667 | |
668 | - File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension(true)); |
669 | + File unfoldingFile = new File(directory, "unfolding" + MpsatUtilitySettings.getUnfoldingExtension(true)); |
670 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
671 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
672 | punfTask, "Unfolding .g", mon); |
673 | |
674 | - netFile.delete(); |
675 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
676 | - unfoldingFile.delete(); |
677 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
678 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
679 | } |
680 | @@ -82,7 +85,8 @@ |
681 | } |
682 | monitor.progressUpdate(0.40); |
683 | |
684 | - MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null, true); |
685 | + MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
686 | + unfoldingFile.getCanonicalPath(), directory, true); |
687 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
688 | mpsatTask, "Running semimodularity checking [MPSat]", mon); |
689 | |
690 | @@ -97,18 +101,18 @@ |
691 | |
692 | MpsatResultParser mdp = new MpsatResultParser(mpsatResult.getReturnValue()); |
693 | if (!mdp.getSolutions().isEmpty()) { |
694 | - unfoldingFile.delete(); |
695 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
696 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Dataflow has hazard(s)")); |
697 | } |
698 | monitor.progressUpdate(1.0); |
699 | |
700 | - unfoldingFile.delete(); |
701 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
702 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Dataflow is hazard-free")); |
703 | |
704 | } catch (Throwable e) { |
705 | return new Result<MpsatChainResult>(e); |
706 | + } finally { |
707 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
708 | } |
709 | } |
710 | |
711 | |
712 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java' |
713 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2015-09-25 14:43:34 +0000 |
714 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2015-10-13 11:40:49 +0000 |
715 | @@ -14,6 +14,7 @@ |
716 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; |
717 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; |
718 | import org.workcraft.plugins.mpsat.tasks.PunfTask; |
719 | +import org.workcraft.plugins.shared.CommonDebugSettings; |
720 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
721 | import org.workcraft.plugins.stg.STGModel; |
722 | import org.workcraft.serialisation.Format; |
723 | @@ -22,6 +23,7 @@ |
724 | import org.workcraft.tasks.Result.Outcome; |
725 | import org.workcraft.tasks.SubtaskMonitor; |
726 | import org.workcraft.util.Export; |
727 | +import org.workcraft.util.FileUtils; |
728 | import org.workcraft.util.Export.ExportTask; |
729 | import org.workcraft.workspace.WorkspaceEntry; |
730 | |
731 | @@ -46,7 +48,11 @@ |
732 | @Override |
733 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
734 | final Framework framework = Framework.getInstance(); |
735 | + File directory = null; |
736 | try { |
737 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
738 | + directory = FileUtils.createTempDirectory(prefix); |
739 | + |
740 | StgGenerator generator = new StgGenerator((VisualDfs)we.getModelEntry().getVisualModel()); |
741 | STGModel model = (STGModel)generator.getStgModel().getMathModel(); |
742 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
743 | @@ -55,14 +61,13 @@ |
744 | } |
745 | monitor.progressUpdate(0.10); |
746 | |
747 | - File netFile = File.createTempFile("net", exporter.getExtenstion()); |
748 | + File netFile = new File(directory, "net" + exporter.getExtenstion()); |
749 | ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
750 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
751 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
752 | exportTask, "Exporting .g", mon); |
753 | |
754 | if (exportResult.getOutcome() != Outcome.FINISHED) { |
755 | - netFile.delete(); |
756 | if (exportResult.getOutcome() == Outcome.CANCELLED) { |
757 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
758 | } |
759 | @@ -71,14 +76,12 @@ |
760 | } |
761 | monitor.progressUpdate(0.20); |
762 | |
763 | - File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension(true)); |
764 | + File unfoldingFile = new File(directory, "unfolding" + MpsatUtilitySettings.getUnfoldingExtension(true)); |
765 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
766 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
767 | punfTask, "Unfolding .g", mon); |
768 | |
769 | - netFile.delete(); |
770 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
771 | - unfoldingFile.delete(); |
772 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
773 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
774 | } |
775 | @@ -87,7 +90,8 @@ |
776 | } |
777 | monitor.progressUpdate(0.40); |
778 | |
779 | - MpsatTask mpsatTask = new MpsatTask(deadlockSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null, true); |
780 | + MpsatTask mpsatTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory), |
781 | + unfoldingFile.getCanonicalPath(), directory, true); |
782 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
783 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
784 | |
785 | @@ -102,13 +106,13 @@ |
786 | |
787 | MpsatResultParser mdp = new MpsatResultParser(mpsatResult.getReturnValue()); |
788 | if (!mdp.getSolutions().isEmpty()) { |
789 | - unfoldingFile.delete(); |
790 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
791 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, deadlockSettings, "Dataflow has a deadlock")); |
792 | } |
793 | monitor.progressUpdate(0.70); |
794 | |
795 | - mpsatTask = new MpsatTask(hazardSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null, true); |
796 | + mpsatTask = new MpsatTask(hazardSettings.getMpsatArguments(directory), |
797 | + unfoldingFile.getCanonicalPath(), directory, true); |
798 | mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running semimodularity checking [MPSat]", mon); |
799 | if (mpsatResult.getOutcome() != Outcome.FINISHED) { |
800 | if (mpsatResult.getOutcome() == Outcome.CANCELLED) { |
801 | @@ -121,18 +125,18 @@ |
802 | |
803 | mdp = new MpsatResultParser(mpsatResult.getReturnValue()); |
804 | if (!mdp.getSolutions().isEmpty()) { |
805 | - unfoldingFile.delete(); |
806 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
807 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, hazardSettings, "Dataflow has hazard(s)")); |
808 | } |
809 | monitor.progressUpdate(1.0); |
810 | |
811 | - unfoldingFile.delete(); |
812 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
813 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, hazardSettings, "Dataflow is deadlock-free and hazard-free")); |
814 | |
815 | } catch (Throwable e) { |
816 | return new Result<MpsatChainResult>(e); |
817 | + } finally { |
818 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
819 | } |
820 | } |
821 | |
822 | |
823 | === modified file 'FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java' |
824 | --- FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2015-07-22 17:40:16 +0000 |
825 | +++ FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2015-10-13 11:40:49 +0000 |
826 | @@ -27,6 +27,7 @@ |
827 | import org.workcraft.tasks.Task; |
828 | import org.workcraft.util.Export; |
829 | import org.workcraft.util.Export.ExportTask; |
830 | +import org.workcraft.util.FileUtils; |
831 | import org.workcraft.workspace.WorkspaceEntry; |
832 | |
833 | |
834 | @@ -139,9 +140,7 @@ |
835 | } catch (Throwable e) { |
836 | return new Result<WriteSgConversionResult>(e); |
837 | } finally { |
838 | - if ((pnFile != null) && !CommonDebugSettings.getKeepTemporaryFiles() ) { |
839 | - pnFile.delete(); |
840 | - } |
841 | + FileUtils.deleteFile(pnFile, CommonDebugSettings.getKeepTemporaryFiles()); |
842 | } |
843 | } |
844 | |
845 | |
846 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java' |
847 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2015-09-29 15:26:23 +0000 |
848 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2015-10-13 11:40:49 +0000 |
849 | @@ -244,7 +244,7 @@ |
850 | return inversePredicate; |
851 | } |
852 | |
853 | - public String[] getMpsatArguments() { |
854 | + public String[] getMpsatArguments(File workingDirectory) { |
855 | ArrayList<String> args = new ArrayList<String>(); |
856 | for (String option: getMode().getArgument().split("\\s")) { |
857 | args.add(option); |
858 | @@ -252,12 +252,16 @@ |
859 | |
860 | if (getMode().hasReach()) { |
861 | try { |
862 | - File reachFile = File.createTempFile("reach", null); |
863 | - reachFile.deleteOnExit(); |
864 | -// FileUtils.dumpString(reach, getFlatReach()); |
865 | + File reachFile = null; |
866 | + if (workingDirectory == null) { |
867 | + reachFile = File.createTempFile("reach", ".txt"); |
868 | + reachFile.deleteOnExit(); |
869 | + } else { |
870 | + reachFile = new File(workingDirectory, "reach.txt"); |
871 | + } |
872 | FileUtils.dumpString(reachFile, getReach()); |
873 | args.add("-d"); |
874 | - args.add("@"+reachFile.getCanonicalPath()); |
875 | + args.add("@" + reachFile.getCanonicalPath()); |
876 | } catch (IOException e) { |
877 | throw new RuntimeException(e); |
878 | } |
879 | |
880 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java' |
881 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2015-10-08 16:41:22 +0000 |
882 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2015-10-13 11:40:49 +0000 |
883 | @@ -77,7 +77,7 @@ |
884 | monitor.progressUpdate(0.66); |
885 | |
886 | // Run MPSat on the generated unfolding |
887 | - MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), |
888 | + MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
889 | unfoldingFile.getCanonicalPath(), directory, tryPnml); |
890 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
891 | mpsatTask, "Running mpsat model-checking", subtaskMonitor); |
892 | |
893 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java' |
894 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2015-10-08 16:41:22 +0000 |
895 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2015-10-13 11:40:49 +0000 |
896 | @@ -151,7 +151,7 @@ |
897 | MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), |
898 | MpsatUtilitySettings.getSolutionCount(), reachConformation, true); |
899 | |
900 | - MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), |
901 | + MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory), |
902 | unfoldingFile.getCanonicalPath(), directory, true); |
903 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( |
904 | mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); |
905 | |
906 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java' |
907 | --- MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2015-08-03 12:45:13 +0000 |
908 | +++ MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2015-10-13 11:40:49 +0000 |
909 | @@ -67,6 +67,7 @@ |
910 | try { |
911 | if (directory == null) { |
912 | listFile = File.createTempFile("places_", ".list"); |
913 | + listFile.deleteOnExit(); |
914 | } else { |
915 | listFile = new File(directory, "places.list"); |
916 | } |
917 | |
918 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java' |
919 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java 2015-04-17 14:54:25 +0000 |
920 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java 2015-10-13 11:40:49 +0000 |
921 | @@ -14,6 +14,8 @@ |
922 | import org.workcraft.plugins.petrify.tools.PetrifySynthesisGeneralisedCelement; |
923 | import org.workcraft.plugins.petrify.tools.PetrifySynthesisTechnologyMapping; |
924 | import org.workcraft.plugins.petrify.tools.PetrifyUntoggle; |
925 | +import org.workcraft.plugins.petrify.tools.ShowSg; |
926 | +import org.workcraft.plugins.petrify.tools.ShowSgBinary; |
927 | |
928 | public class PetrifyModule implements Module { |
929 | |
930 | @@ -33,7 +35,8 @@ |
931 | pm.registerClass(Tool.class, PetrifyDummyContraction.class); |
932 | pm.registerClass(Tool.class, PetrifyNetSynthesis.class); |
933 | pm.registerClass(Tool.class, PetrifyNetSynthesisWithEr.class); |
934 | -// pm.registerClass(Tool.class, ShowSg.class); |
935 | + pm.registerClass(Tool.class, ShowSg.class); |
936 | + pm.registerClass(Tool.class, ShowSgBinary.class); |
937 | } |
938 | |
939 | @Override |
940 | |
941 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java' |
942 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2015-08-03 12:45:13 +0000 |
943 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2015-10-13 11:40:49 +0000 |
944 | @@ -28,12 +28,15 @@ |
945 | ArrayList<String> command = new ArrayList<String>(); |
946 | command.add(PetrifyUtilitySettings.getDrawAstgCommand()); |
947 | |
948 | - for (String arg : PetrifyUtilitySettings.getDrawAstgArgs().split(" ")) |
949 | - if (!arg.isEmpty()) |
950 | + for (String arg : PetrifyUtilitySettings.getDrawAstgArgs().split(" ")) { |
951 | + if (!arg.isEmpty()) { |
952 | command.add(arg); |
953 | + } |
954 | + } |
955 | |
956 | - for (String arg : options) |
957 | + for (String arg : options) { |
958 | command.add(arg); |
959 | + } |
960 | |
961 | command.add(inputPath); |
962 | command.add("-o"); |
963 | |
964 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawSgTask.java' |
965 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawSgTask.java 2014-12-28 22:42:47 +0000 |
966 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/DrawSgTask.java 2015-10-13 11:40:49 +0000 |
967 | @@ -11,6 +11,8 @@ |
968 | |
969 | import org.workcraft.Framework; |
970 | import org.workcraft.dom.Model; |
971 | +import org.workcraft.plugins.petri.PetriNetModel; |
972 | +import org.workcraft.plugins.shared.CommonDebugSettings; |
973 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
974 | import org.workcraft.serialisation.Format; |
975 | import org.workcraft.tasks.ProgressMonitor; |
976 | @@ -19,6 +21,9 @@ |
977 | import org.workcraft.tasks.Task; |
978 | import org.workcraft.util.Export; |
979 | import org.workcraft.util.Export.ExportTask; |
980 | +import org.workcraft.util.FileUtils; |
981 | +import org.workcraft.util.WorkspaceUtils; |
982 | +import org.workcraft.workspace.WorkspaceEntry; |
983 | |
984 | public class DrawSgTask implements Task<DrawSgResult> { |
985 | |
986 | @@ -46,20 +51,26 @@ |
987 | } |
988 | } |
989 | |
990 | - final Pattern hugeSgPattern = Pattern.compile("with ([0-9]+) states"); |
991 | - private final Model model; |
992 | + final Pattern hugeSgPattern = Pattern.compile("with ([0-9]+) states"); |
993 | + |
994 | + private final WorkspaceEntry we; |
995 | + private boolean binary; |
996 | |
997 | - public DrawSgTask(Model model) { |
998 | - this.model = model; |
999 | + public DrawSgTask(WorkspaceEntry we, boolean binary) { |
1000 | + this.we = we; |
1001 | + this.binary = binary; |
1002 | } |
1003 | |
1004 | @Override |
1005 | public Result<? extends DrawSgResult> run(ProgressMonitor<? super DrawSgResult> monitor) { |
1006 | final Framework framework = Framework.getInstance(); |
1007 | - try { |
1008 | - File dotG = File.createTempFile("workcraft", ".g"); |
1009 | - dotG.deleteOnExit(); |
1010 | + File directory = null; |
1011 | + try { |
1012 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
1013 | + directory = FileUtils.createTempDirectory(prefix); |
1014 | |
1015 | + File dotG = new File(directory, "model.g"); |
1016 | + Model model = WorkspaceUtils.getAs(we, PetriNetModel.class); |
1017 | ExportTask exportTask = Export.createExportTask(model, dotG, Format.STG, framework.getPluginManager()); |
1018 | final Result<? extends Object> dotGResult = framework.getTaskManager().execute(exportTask, "Exporting to .g" ); |
1019 | |
1020 | @@ -74,10 +85,11 @@ |
1021 | return Result.cancelled(); |
1022 | } |
1023 | |
1024 | - File sg = File.createTempFile("workcraft", ".g"); |
1025 | - sg.deleteOnExit(); |
1026 | - |
1027 | + File sg = new File(directory, "model.sg"); |
1028 | List<String> writeSgOptions = new ArrayList<String>(); |
1029 | + if (binary) { |
1030 | + writeSgOptions.add("-bin"); |
1031 | + } |
1032 | while (true) { |
1033 | WriteSgTask writeSgTask = new WriteSgTask(dotG.getAbsolutePath(), sg.getAbsolutePath(), writeSgOptions); |
1034 | Result<? extends ExternalProcessResult> writeSgResult = framework.getTaskManager().execute( |
1035 | @@ -108,10 +120,12 @@ |
1036 | } |
1037 | } |
1038 | } |
1039 | - File ps = File.createTempFile("workcraft", ".ps"); |
1040 | - ps.deleteOnExit(); |
1041 | - |
1042 | - DrawAstgTask drawAstgTask = new DrawAstgTask(sg.getAbsolutePath(), ps.getAbsolutePath(), new ArrayList<String>()); |
1043 | + File ps = new File(directory, "model.ps"); |
1044 | + ArrayList<String> drawAstgOptions = new ArrayList<String>(); |
1045 | + if (binary) { |
1046 | + drawAstgOptions.add("-bin"); |
1047 | + } |
1048 | + DrawAstgTask drawAstgTask = new DrawAstgTask(sg.getAbsolutePath(), ps.getAbsolutePath(), drawAstgOptions); |
1049 | final Result<? extends ExternalProcessResult> drawAstgResult = framework.getTaskManager().execute(drawAstgTask, "Running draw_astg"); |
1050 | |
1051 | if (drawAstgResult.getOutcome() != Outcome.FINISHED) { |
1052 | @@ -125,13 +139,11 @@ |
1053 | } |
1054 | return Result.cancelled(); |
1055 | } |
1056 | - |
1057 | - dotG.delete(); |
1058 | - sg.delete(); |
1059 | return Result.finished(new DrawSgResult(ps, "No errors")); |
1060 | } catch (Throwable e) { |
1061 | - e.printStackTrace(); |
1062 | return Result.exception(e); |
1063 | + } finally { |
1064 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
1065 | } |
1066 | } |
1067 | |
1068 | |
1069 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java' |
1070 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2015-07-22 17:40:16 +0000 |
1071 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2015-10-13 11:40:49 +0000 |
1072 | @@ -20,6 +20,7 @@ |
1073 | import org.workcraft.tasks.Task; |
1074 | import org.workcraft.util.Export; |
1075 | import org.workcraft.util.Export.ExportTask; |
1076 | +import org.workcraft.util.FileUtils; |
1077 | import org.workcraft.workspace.WorkspaceEntry; |
1078 | |
1079 | public class TransformationTask implements Task<TransformationResult>{ |
1080 | @@ -91,9 +92,7 @@ |
1081 | } catch (Throwable e) { |
1082 | return Result.exception(e); |
1083 | } finally { |
1084 | - if ((modelFile != null) && !CommonDebugSettings.getKeepTemporaryFiles() ) { |
1085 | - modelFile.delete(); |
1086 | - } |
1087 | + FileUtils.deleteFile(modelFile, CommonDebugSettings.getKeepTemporaryFiles()); |
1088 | } |
1089 | } |
1090 | |
1091 | |
1092 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSg.java' |
1093 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSg.java 2014-12-27 22:40:44 +0000 |
1094 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSg.java 2015-10-13 11:40:49 +0000 |
1095 | @@ -24,19 +24,24 @@ |
1096 | |
1097 | @Override |
1098 | public String getSection() { |
1099 | - return "State graph"; |
1100 | + return "External visualiser"; |
1101 | } |
1102 | |
1103 | @Override |
1104 | public String getDisplayName() { |
1105 | - return "Show state graph [Petrify]"; |
1106 | + return "Basic state graph [write_sg + draw_astg]"; |
1107 | + } |
1108 | + |
1109 | + public boolean isBinaryEncodded() { |
1110 | + return false; |
1111 | } |
1112 | |
1113 | @Override |
1114 | public void run(WorkspaceEntry we) { |
1115 | - DrawSgTask task = new DrawSgTask(WorkspaceUtils.getAs(we, PetriNetModel.class)); |
1116 | + DrawSgTask task = new DrawSgTask(we, isBinaryEncodded()); |
1117 | final Framework framework = Framework.getInstance(); |
1118 | - framework.getTaskManager().queue(task, "Show state graph", new ProgressMonitor<DrawSgResult>() { |
1119 | + |
1120 | + ProgressMonitor<DrawSgResult> monitor = new ProgressMonitor<DrawSgResult>() { |
1121 | @Override |
1122 | public void progressUpdate(double completion) { |
1123 | } |
1124 | @@ -56,28 +61,28 @@ |
1125 | |
1126 | @Override |
1127 | public void finished(Result<? extends DrawSgResult> result, String description) { |
1128 | - |
1129 | if (result.getOutcome() == Outcome.FINISHED) { |
1130 | SystemOpen.open(result.getReturnValue().getPsFile()); |
1131 | } else if (result.getOutcome() != Outcome.CANCELLED) { |
1132 | - String errorMessage = "Petrify tool chain execution failed :-("; |
1133 | - Throwable cause = result.getCause(); |
1134 | - if (cause != null) { |
1135 | - errorMessage += "\n\nFailure caused by: " + cause.toString() + "\nPlease see the \"Problems\" tab for more details."; |
1136 | - } else { |
1137 | - errorMessage += "\n\nFailure caused by: \n" + result.getReturnValue().getErrorMessages(); |
1138 | + String errorMessage = "Petrify tool chain execution failed :-("; |
1139 | + Throwable cause = result.getCause(); |
1140 | + if (cause != null) { |
1141 | + errorMessage += "\n\nFailure caused by: " + cause.toString() + "\nPlease see the \"Problems\" tab for more details."; |
1142 | + } else { |
1143 | + errorMessage += "\n\nFailure caused by: \n" + result.getReturnValue().getErrorMessages(); |
1144 | + } |
1145 | + final String err = errorMessage; |
1146 | + SwingUtilities.invokeLater(new Runnable() { |
1147 | + @Override |
1148 | + public void run() { |
1149 | + JOptionPane.showMessageDialog(null, err, "Oops..", JOptionPane.ERROR_MESSAGE); |
1150 | } |
1151 | - |
1152 | - final String err = errorMessage; |
1153 | - SwingUtilities.invokeLater(new Runnable() { |
1154 | - @Override |
1155 | - public void run() { |
1156 | - JOptionPane.showMessageDialog(null, err, "Oops..", JOptionPane.ERROR_MESSAGE); |
1157 | - } |
1158 | - }); |
1159 | - } |
1160 | + }); |
1161 | + } |
1162 | } |
1163 | - }); |
1164 | + }; |
1165 | + |
1166 | + framework.getTaskManager().queue(task, "Show state graph", monitor); |
1167 | } |
1168 | |
1169 | } |
1170 | |
1171 | === added file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSgBinary.java' |
1172 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSgBinary.java 1970-01-01 00:00:00 +0000 |
1173 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/ShowSgBinary.java 2015-10-13 11:40:49 +0000 |
1174 | @@ -0,0 +1,23 @@ |
1175 | +package org.workcraft.plugins.petrify.tools; |
1176 | + |
1177 | +import org.workcraft.plugins.stg.STG; |
1178 | +import org.workcraft.util.WorkspaceUtils; |
1179 | +import org.workcraft.workspace.WorkspaceEntry; |
1180 | + |
1181 | +public class ShowSgBinary extends ShowSg { |
1182 | + |
1183 | + @Override |
1184 | + public boolean isApplicableTo(WorkspaceEntry we) { |
1185 | + return WorkspaceUtils.canHas(we, STG.class); |
1186 | + } |
1187 | + |
1188 | + @Override |
1189 | + public String getDisplayName() { |
1190 | + return "Binary-encoded state graph [write_sg + draw_astg]"; |
1191 | + } |
1192 | + |
1193 | + public boolean isBinaryEncodded() { |
1194 | + return true; |
1195 | + } |
1196 | + |
1197 | +} |
1198 | |
1199 | === modified file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java' |
1200 | --- PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2015-04-28 22:14:55 +0000 |
1201 | +++ PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2015-10-13 11:40:49 +0000 |
1202 | @@ -15,6 +15,7 @@ |
1203 | import org.workcraft.plugins.petri.PetriNet; |
1204 | import org.workcraft.plugins.policy.VisualPolicyNet; |
1205 | import org.workcraft.plugins.policy.tools.PetriNetGenerator; |
1206 | +import org.workcraft.plugins.shared.CommonDebugSettings; |
1207 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
1208 | import org.workcraft.serialisation.Format; |
1209 | import org.workcraft.tasks.ProgressMonitor; |
1210 | @@ -22,6 +23,7 @@ |
1211 | import org.workcraft.tasks.Result.Outcome; |
1212 | import org.workcraft.tasks.SubtaskMonitor; |
1213 | import org.workcraft.util.Export; |
1214 | +import org.workcraft.util.FileUtils; |
1215 | import org.workcraft.util.Export.ExportTask; |
1216 | import org.workcraft.workspace.WorkspaceEntry; |
1217 | |
1218 | @@ -40,7 +42,11 @@ |
1219 | @Override |
1220 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
1221 | final Framework framework = Framework.getInstance(); |
1222 | + File directory = null; |
1223 | try { |
1224 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
1225 | + directory = FileUtils.createTempDirectory(prefix); |
1226 | + |
1227 | PetriNetGenerator generator = new PetriNetGenerator((VisualPolicyNet)we.getModelEntry().getVisualModel()); |
1228 | PetriNet model = (PetriNet)generator.getPetriNet().getMathModel(); |
1229 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
1230 | @@ -49,14 +55,13 @@ |
1231 | } |
1232 | monitor.progressUpdate(0.10); |
1233 | |
1234 | - File netFile = File.createTempFile("net", exporter.getExtenstion()); |
1235 | + File netFile = new File(directory, "net" + exporter.getExtenstion()); |
1236 | ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
1237 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
1238 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
1239 | exportTask, "Exporting .g", mon); |
1240 | |
1241 | if (exportResult.getOutcome() != Outcome.FINISHED) { |
1242 | - netFile.delete(); |
1243 | if (exportResult.getOutcome() == Outcome.CANCELLED) { |
1244 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
1245 | } |
1246 | @@ -65,14 +70,12 @@ |
1247 | } |
1248 | monitor.progressUpdate(0.20); |
1249 | |
1250 | - File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension(true)); |
1251 | + File unfoldingFile = new File(directory, "unfolding" + MpsatUtilitySettings.getUnfoldingExtension(true)); |
1252 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath(), true); |
1253 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
1254 | punfTask, "Unfolding .g", mon); |
1255 | |
1256 | - netFile.delete(); |
1257 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
1258 | - unfoldingFile.delete(); |
1259 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
1260 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
1261 | } |
1262 | @@ -81,7 +84,8 @@ |
1263 | } |
1264 | monitor.progressUpdate(0.70); |
1265 | |
1266 | - MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null, true); |
1267 | + MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
1268 | + unfoldingFile.getCanonicalPath(), directory, true); |
1269 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
1270 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
1271 | |
1272 | @@ -97,18 +101,18 @@ |
1273 | |
1274 | MpsatResultParser mdp = new MpsatResultParser(mpsatResult.getReturnValue()); |
1275 | if (!mdp.getSolutions().isEmpty()) { |
1276 | - unfoldingFile.delete(); |
1277 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
1278 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Policy net has a deadlock")); |
1279 | } |
1280 | monitor.progressUpdate(1.0); |
1281 | |
1282 | - unfoldingFile.delete(); |
1283 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
1284 | new MpsatChainResult(exportResult, null, punfResult, mpsatResult, settings, "Policy net is deadlock-free")); |
1285 | |
1286 | } catch (Throwable e) { |
1287 | return new Result<MpsatChainResult>(e); |
1288 | + } finally { |
1289 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
1290 | } |
1291 | } |
1292 | |
1293 | |
1294 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java' |
1295 | --- STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java 2015-09-10 22:34:47 +0000 |
1296 | +++ STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java 2015-10-13 11:40:49 +0000 |
1297 | @@ -10,6 +10,7 @@ |
1298 | public class StgUtils { |
1299 | public static final String DEVICE_FILE_NAME = "device"; |
1300 | public static final String ENVIRONMENT_FILE_NAME = "environment"; |
1301 | + public static final String COMPOSITION_FILE_NAME = "composition"; |
1302 | public static final String SYSTEM_FILE_NAME = "system"; |
1303 | public static final String ASTG_FILE_EXT = ".g"; |
1304 | |
1305 | |
1306 | === modified file 'WorkcraftCore/src/org/workcraft/gui/tasks/TaskControl.java' |
1307 | --- WorkcraftCore/src/org/workcraft/gui/tasks/TaskControl.java 2010-07-19 17:07:08 +0000 |
1308 | +++ WorkcraftCore/src/org/workcraft/gui/tasks/TaskControl.java 2015-10-13 11:40:49 +0000 |
1309 | @@ -40,7 +40,6 @@ |
1310 | JLabel label; |
1311 | JProgressBar progressBar; |
1312 | JButton btnCancel; |
1313 | - JButton btnLog; |
1314 | |
1315 | volatile boolean cancelRequested; |
1316 | |
1317 | @@ -50,7 +49,9 @@ |
1318 | {20, 20, 20} |
1319 | }; |
1320 | |
1321 | - Border lineBorder = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY), BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
1322 | + Border outsideBorder = BorderFactory.createLineBorder(Color.LIGHT_GRAY); |
1323 | + Border insideBorder = BorderFactory.createEmptyBorder(3, 3, 3, 3); |
1324 | + Border lineBorder = BorderFactory.createCompoundBorder(outsideBorder, insideBorder); |
1325 | |
1326 | setBorder(lineBorder); |
1327 | |
1328 | @@ -71,7 +72,6 @@ |
1329 | progressBar.setMinimumSize(new Dimension (100,20)); |
1330 | progressBar.setPreferredSize(new Dimension (300,20)); |
1331 | |
1332 | - btnLog = new JButton("Show log"); |
1333 | btnCancel = new JButton("Cancel"); |
1334 | btnCancel.addActionListener(new ActionListener() { |
1335 | @Override |
1336 | @@ -82,7 +82,6 @@ |
1337 | |
1338 | add(label, "0,0,2,0"); |
1339 | add(progressBar, "0,1,2,1" ); |
1340 | - add(btnLog, "1,2"); |
1341 | add(btnCancel, "2,2"); |
1342 | } |
1343 | |
1344 | |
1345 | === modified file 'WorkcraftCore/src/org/workcraft/gui/tasks/TaskManagerWindow.java' |
1346 | --- WorkcraftCore/src/org/workcraft/gui/tasks/TaskManagerWindow.java 2014-12-12 18:43:40 +0000 |
1347 | +++ WorkcraftCore/src/org/workcraft/gui/tasks/TaskManagerWindow.java 2015-10-13 11:40:49 +0000 |
1348 | @@ -44,9 +44,9 @@ |
1349 | import org.workcraft.tasks.DummyProgressMonitor; |
1350 | import org.workcraft.tasks.ProgressMonitor; |
1351 | import org.workcraft.tasks.Result; |
1352 | +import org.workcraft.tasks.Result.Outcome; |
1353 | import org.workcraft.tasks.Task; |
1354 | import org.workcraft.tasks.TaskMonitor; |
1355 | -import org.workcraft.tasks.Result.Outcome; |
1356 | |
1357 | @SuppressWarnings("serial") |
1358 | public class TaskManagerWindow extends JPanel implements TaskMonitor { |
1359 | @@ -162,15 +162,23 @@ |
1360 | scroll.setViewportView(content); |
1361 | scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
1362 | |
1363 | - Border lineBorder = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY), BorderFactory.createEmptyBorder(2, 2, 2, 2)); |
1364 | + Border outsideBorder = BorderFactory.createLineBorder(Color.LIGHT_GRAY); |
1365 | + Border insideBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2); |
1366 | + Border lineBorder = BorderFactory.createCompoundBorder(outsideBorder, insideBorder); |
1367 | setBorder(lineBorder); |
1368 | |
1369 | final Framework framework = Framework.getInstance(); |
1370 | framework.getTaskManager().addObserver(this); |
1371 | - |
1372 | - JButton comp = new JButton("Queue test task"); |
1373 | - |
1374 | - comp.addActionListener(new ActionListener() { |
1375 | + |
1376 | + // Do we really need this "Queue test task" button? Probably not. |
1377 | + // addQueueTestTasksButton(framework); |
1378 | + |
1379 | + } |
1380 | + |
1381 | + private void addQueueTestTasksButton(final Framework framework) { |
1382 | + JButton testTaskButton = new JButton("Queue test task"); |
1383 | + |
1384 | + testTaskButton.addActionListener(new ActionListener() { |
1385 | @Override |
1386 | public void actionPerformed(ActionEvent e) { |
1387 | framework.getTaskManager().queue(new Task<Object>(){ |
1388 | @@ -192,8 +200,7 @@ |
1389 | |
1390 | @Override |
1391 | public void finished(Result<? extends Object> result, final String description) { |
1392 | - if (result.getOutcome() == Outcome.FINISHED ) |
1393 | - { |
1394 | + if (result.getOutcome() == Outcome.FINISHED ) { |
1395 | SwingUtilities.invokeLater(new Runnable() { |
1396 | @Override |
1397 | public void run() { |
1398 | @@ -206,8 +213,8 @@ |
1399 | }); |
1400 | } |
1401 | }); |
1402 | - |
1403 | - content.add (comp); |
1404 | + |
1405 | + content.add (testTaskButton); |
1406 | } |
1407 | |
1408 | public void removeTaskControl (TaskControl taskControl) { |
1409 | |
1410 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java' |
1411 | --- WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2015-08-03 12:45:13 +0000 |
1412 | +++ WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2015-10-13 11:40:49 +0000 |
1413 | @@ -65,9 +65,9 @@ |
1414 | } |
1415 | } |
1416 | |
1417 | - if (userCancelled) |
1418 | + if (userCancelled) { |
1419 | return Result.cancelled(); |
1420 | - |
1421 | + } |
1422 | ExternalProcessResult result = new ExternalProcessResult(returnCode, stdoutAccum.getData(), stderrAccum.getData(), Collections.<String, byte[]>emptyMap()); |
1423 | |
1424 | return Result.finished(result); |
1425 | @@ -111,4 +111,5 @@ |
1426 | this.returnCode = returnCode; |
1427 | this.finished = true; |
1428 | } |
1429 | + |
1430 | } |