Merge lp:~danilovesky/workcraft/trunk-stg-conformation into lp:workcraft
- trunk-stg-conformation
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 572 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-stg-conformation |
Merge into: | lp:workcraft |
Diff against target: |
1804 lines (+711/-334) 26 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java (+111/-76) CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java (+2/-2) CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java (+1/-1) MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java (+3/-4) MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java (+4/-3) MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java (+132/-107) MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java (+26/-2) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java (+17/-14) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java (+215/-0) MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java (+22/-15) MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java (+7/-3) MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java (+56/-0) MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatCustomPropertyChecker.java (+2/-2) MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java (+0/-7) MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java (+5/-6) MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java (+59/-51) MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java (+1/-1) STGPlugin/src/org/workcraft/plugins/stg/STG.java (+22/-12) STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java (+11/-11) Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java (+1/-1) WorkcraftCore/src/org/workcraft/Info.java (+1/-1) WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java (+9/-9) WorkcraftCore/src/org/workcraft/gui/MainWindow.java (+2/-2) WorkcraftCore/src/org/workcraft/util/FileUtils.java (+0/-2) build_distr_linux.sh (+1/-1) build_distr_windows.sh (+1/-1) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-stg-conformation |
Related bugs: | |
Related blueprints: |
Improve STG usability
(Low)
|
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.
- 575. By Danil Sokolov
-
Polishing the Reach expression for conformation check.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Danil Sokolov (danilovesky) : | # |
review:
Needs Resubmitting
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/tasks/CheckCircuitTask.java' | |||
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2014-11-24 15:37:13 +0000 | |||
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2014-11-30 23:14:46 +0000 | |||
4 | @@ -1,6 +1,13 @@ | |||
5 | 1 | package org.workcraft.plugins.circuit.tasks; | 1 | package org.workcraft.plugins.circuit.tasks; |
6 | 2 | 2 | ||
7 | 3 | import java.io.BufferedReader; | ||
8 | 4 | import java.io.ByteArrayInputStream; | ||
9 | 3 | import java.io.File; | 5 | import java.io.File; |
10 | 6 | import java.io.IOException; | ||
11 | 7 | import java.io.InputStream; | ||
12 | 8 | import java.io.InputStreamReader; | ||
13 | 9 | import java.util.HashSet; | ||
14 | 10 | import java.util.Set; | ||
15 | 4 | 11 | ||
16 | 5 | import org.workcraft.Framework; | 12 | import org.workcraft.Framework; |
17 | 6 | import org.workcraft.interop.Exporter; | 13 | import org.workcraft.interop.Exporter; |
18 | @@ -14,10 +21,11 @@ | |||
19 | 14 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; | 21 | import org.workcraft.plugins.mpsat.tasks.MpsatChainTask; |
20 | 15 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; | 22 | import org.workcraft.plugins.mpsat.tasks.MpsatTask; |
21 | 16 | import org.workcraft.plugins.mpsat.tasks.PunfTask; | 23 | import org.workcraft.plugins.mpsat.tasks.PunfTask; |
22 | 17 | import org.workcraft.plugins.pcomp.PCompOutputMode; | ||
23 | 18 | import org.workcraft.plugins.pcomp.tasks.PcompTask; | 24 | import org.workcraft.plugins.pcomp.tasks.PcompTask; |
24 | 25 | import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode; | ||
25 | 19 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; | 26 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
26 | 20 | import org.workcraft.plugins.stg.STG; | 27 | import org.workcraft.plugins.stg.STG; |
27 | 28 | import org.workcraft.plugins.stg.SignalTransition.Type; | ||
28 | 21 | import org.workcraft.serialisation.Format; | 29 | import org.workcraft.serialisation.Format; |
29 | 22 | import org.workcraft.tasks.ProgressMonitor; | 30 | import org.workcraft.tasks.ProgressMonitor; |
30 | 23 | import org.workcraft.tasks.Result; | 31 | import org.workcraft.tasks.Result; |
31 | @@ -62,6 +70,7 @@ | |||
32 | 62 | 70 | ||
33 | 63 | @Override | 71 | @Override |
34 | 64 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { | 72 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
35 | 73 | File workingDirectory = null; | ||
36 | 65 | try { | 74 | try { |
37 | 66 | // Common variables | 75 | // Common variables |
38 | 67 | monitor.progressUpdate(0.05); | 76 | monitor.progressUpdate(0.05); |
39 | @@ -70,79 +79,76 @@ | |||
40 | 70 | title = title.substring(0, title.length() - 5); | 79 | title = title.substring(0, title.length() - 5); |
41 | 71 | } | 80 | } |
42 | 72 | VisualCircuit visualCircuit = (VisualCircuit)we.getModelEntry().getVisualModel(); | 81 | VisualCircuit visualCircuit = (VisualCircuit)we.getModelEntry().getVisualModel(); |
47 | 73 | STG circuitStg = (STG)STGGenerator.generate(visualCircuit).getMathModel(); | 82 | File envFile = visualCircuit.getEnvironmentFile(); |
48 | 74 | Exporter stgExporter = Export.chooseBestExporter(framework.getPluginManager(), circuitStg, Format.STG); | 83 | boolean hasEnvironment = ((envFile != null) && envFile.exists()); |
49 | 75 | if (stgExporter == null) { | 84 | |
50 | 76 | throw new RuntimeException ("Exporter not available: model class " + circuitStg.getClass().getName() + " to format STG."); | 85 | workingDirectory = FileUtils.createTempDirectory(title + "-"); |
51 | 86 | |||
52 | 87 | STG devStg = (STG)STGGenerator.generate(visualCircuit).getMathModel(); | ||
53 | 88 | Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG); | ||
54 | 89 | if (devStgExporter == null) { | ||
55 | 90 | throw new RuntimeException ("Exporter not available: model class " + devStg.getClass().getName() + " to format STG."); | ||
56 | 77 | } | 91 | } |
57 | 78 | SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor); | 92 | SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor); |
58 | 79 | monitor.progressUpdate(0.10); | 93 | monitor.progressUpdate(0.10); |
59 | 80 | 94 | ||
60 | 81 | // Generating .g for the circuit | 95 | // Generating .g for the circuit |
66 | 82 | String circuitFilePrefix = title + "-circuit-"; | 96 | String devStgName = (hasEnvironment ? "dev.g" : "system.g"); |
67 | 83 | File circuitStgFile = File.createTempFile(circuitFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion()); | 97 | File devStgFile = new File(workingDirectory, devStgName); |
68 | 84 | ExportTask circuitExportTask = new ExportTask(stgExporter, circuitStg, circuitStgFile.getCanonicalPath()); | 98 | ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath()); |
69 | 85 | Result<? extends Object> circuitExportResult = framework.getTaskManager().execute( | 99 | Result<? extends Object> devExportResult = framework.getTaskManager().execute( |
70 | 86 | circuitExportTask, "Exporting circuit .g", subtaskMonitor); | 100 | devExportTask, "Exporting circuit .g", subtaskMonitor); |
71 | 87 | 101 | ||
75 | 88 | if (circuitExportResult.getOutcome() != Outcome.FINISHED) { | 102 | if (devExportResult.getOutcome() != Outcome.FINISHED) { |
76 | 89 | circuitStgFile.delete(); | 103 | if (devExportResult.getOutcome() == Outcome.CANCELLED) { |
74 | 90 | if (circuitExportResult.getOutcome() == Outcome.CANCELLED) { | ||
77 | 91 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 104 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
78 | 92 | } | 105 | } |
79 | 93 | return new Result<MpsatChainResult>(Outcome.FAILED, | 106 | return new Result<MpsatChainResult>(Outcome.FAILED, |
81 | 94 | new MpsatChainResult(circuitExportResult, null, null, null, toolchainPreparationSettings)); | 107 | new MpsatChainResult(devExportResult, null, null, null, toolchainPreparationSettings)); |
82 | 95 | } | 108 | } |
83 | 96 | monitor.progressUpdate(0.20); | 109 | monitor.progressUpdate(0.20); |
84 | 97 | 110 | ||
85 | 98 | // Generating .g for the environment | 111 | // Generating .g for the environment |
86 | 99 | File stgFile; | ||
87 | 100 | STG stg; | 112 | STG stg; |
88 | 113 | File stgFile = null; | ||
89 | 101 | Result<? extends ExternalProcessResult> pcompResult = null; | 114 | Result<? extends ExternalProcessResult> pcompResult = null; |
90 | 102 | File environmentFile = visualCircuit.getEnvironmentFile(); | ||
91 | 103 | boolean hasEnvironment = ((environmentFile != null) && environmentFile.exists()); | ||
92 | 104 | if ( !hasEnvironment ) { | 115 | if ( !hasEnvironment ) { |
96 | 105 | // No environment to compose with | 116 | stgFile = devStgFile; |
97 | 106 | stgFile = circuitStgFile; | 117 | stg = devStg; |
95 | 107 | stg = circuitStg; | ||
98 | 108 | } else { | 118 | } else { |
103 | 109 | // Compose circuit with its environment | 119 | File envStgFile = null; |
104 | 110 | File environmentStgFile; | 120 | if (envFile.getName().endsWith(".g")) { |
105 | 111 | if (environmentFile.getName().endsWith(".g")) { | 121 | envStgFile = envFile; |
102 | 112 | environmentStgFile = environmentFile; | ||
106 | 113 | } else { | 122 | } else { |
113 | 114 | STG environementStg = (STG)framework.loadFile(environmentFile).getMathModel(); | 123 | STG envStg = (STG)framework.loadFile(envFile).getMathModel(); |
114 | 115 | String environmentFilePrefix = title + "-environment-"; | 124 | Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG); |
115 | 116 | environmentStgFile = File.createTempFile(environmentFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion()); | 125 | envStgFile = new File(workingDirectory, "env.g"); |
116 | 117 | ExportTask environmentExportTask = new ExportTask(stgExporter, environementStg, environmentStgFile.getCanonicalPath()); | 126 | ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath()); |
117 | 118 | Result<? extends Object> environmentExportResult = framework.getTaskManager().execute( | 127 | Result<? extends Object> envExportResult = framework.getTaskManager().execute( |
118 | 119 | environmentExportTask, "Exporting environment .g", subtaskMonitor); | 128 | envExportTask, "Exporting environment .g", subtaskMonitor); |
119 | 120 | 129 | ||
123 | 121 | if (environmentExportResult.getOutcome() != Outcome.FINISHED) { | 130 | if (envExportResult.getOutcome() != Outcome.FINISHED) { |
124 | 122 | environmentStgFile.delete(); | 131 | if (envExportResult.getOutcome() == Outcome.CANCELLED) { |
122 | 123 | if (environmentExportResult.getOutcome() == Outcome.CANCELLED) { | ||
125 | 124 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 132 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
126 | 125 | } | 133 | } |
127 | 126 | return new Result<MpsatChainResult>(Outcome.FAILED, | 134 | return new Result<MpsatChainResult>(Outcome.FAILED, |
129 | 127 | new MpsatChainResult(environmentExportResult, null, null, null, toolchainPreparationSettings)); | 135 | new MpsatChainResult(envExportResult, null, null, null, toolchainPreparationSettings)); |
130 | 128 | } | 136 | } |
131 | 129 | } | 137 | } |
132 | 130 | monitor.progressUpdate(0.25); | 138 | monitor.progressUpdate(0.25); |
133 | 131 | 139 | ||
134 | 132 | // Generating .g for the whole system (circuit and environment) | 140 | // Generating .g for the whole system (circuit and environment) |
138 | 133 | String systemFilePrefix = title + "-system-"; | 141 | stgFile = new File(workingDirectory, "system.g"); |
139 | 134 | stgFile = File.createTempFile(systemFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion()); | 142 | PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, ConversionMode.OUTPUT, true, false, workingDirectory); |
137 | 135 | PcompTask pcompTask = new PcompTask(new File[]{circuitStgFile, environmentStgFile}, PCompOutputMode.OUTPUT, true, false); | ||
140 | 136 | pcompResult = framework.getTaskManager().execute( | 143 | pcompResult = framework.getTaskManager().execute( |
141 | 137 | pcompTask, "Running pcomp", subtaskMonitor); | 144 | pcompTask, "Running pcomp", subtaskMonitor); |
142 | 138 | 145 | ||
143 | 139 | if (pcompResult.getOutcome() != Outcome.FINISHED) { | 146 | if (pcompResult.getOutcome() != Outcome.FINISHED) { |
144 | 140 | circuitStgFile.delete(); | ||
145 | 141 | if (pcompResult.getOutcome() == Outcome.CANCELLED) { | 147 | if (pcompResult.getOutcome() == Outcome.CANCELLED) { |
146 | 142 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 148 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
147 | 143 | } | 149 | } |
148 | 144 | return new Result<MpsatChainResult>(Outcome.FAILED, | 150 | return new Result<MpsatChainResult>(Outcome.FAILED, |
150 | 145 | new MpsatChainResult(circuitExportResult, pcompResult, null, null, toolchainPreparationSettings)); | 151 | new MpsatChainResult(devExportResult, pcompResult, null, null, toolchainPreparationSettings)); |
151 | 146 | } | 152 | } |
152 | 147 | FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput())); | 153 | FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput())); |
153 | 148 | WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); | 154 | WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); |
154 | @@ -151,26 +157,26 @@ | |||
155 | 151 | monitor.progressUpdate(0.30); | 157 | monitor.progressUpdate(0.30); |
156 | 152 | 158 | ||
157 | 153 | // Generate unfolding | 159 | // Generate unfolding |
160 | 154 | String unfoldingFilePrefix = title + "-unfolding-"; | 160 | File unfoldingFile = new File(workingDirectory, "system" + MpsatUtilitySettings.getUnfoldingExtension()); |
159 | 155 | File unfoldingFile = File.createTempFile(unfoldingFilePrefix.replaceAll("\\s",""), MpsatUtilitySettings.getUnfoldingExtension()); | ||
161 | 156 | PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); | 161 | PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
162 | 157 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( | 162 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
163 | 158 | punfTask, "Unfolding .g", subtaskMonitor); | 163 | punfTask, "Unfolding .g", subtaskMonitor); |
164 | 159 | 164 | ||
165 | 160 | stgFile.delete(); | ||
166 | 161 | if (punfResult.getOutcome() != Outcome.FINISHED) { | 165 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
167 | 162 | unfoldingFile.delete(); | ||
168 | 163 | if (punfResult.getOutcome() == Outcome.CANCELLED) { | 166 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
169 | 164 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 167 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
170 | 165 | } | 168 | } |
171 | 166 | return new Result<MpsatChainResult>(Outcome.FAILED, | 169 | return new Result<MpsatChainResult>(Outcome.FAILED, |
173 | 167 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, null, toolchainPreparationSettings)); | 170 | new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainPreparationSettings)); |
174 | 168 | } | 171 | } |
175 | 169 | monitor.progressUpdate(0.40); | 172 | monitor.progressUpdate(0.40); |
176 | 170 | 173 | ||
177 | 171 | // Check for interface conformation (only if the environment is specified) | 174 | // Check for interface conformation (only if the environment is specified) |
178 | 172 | if (hasEnvironment && checkConformation) { | 175 | if (hasEnvironment && checkConformation) { |
180 | 173 | String reachConformation = MpsatSettings.genReachConformation(stg, circuitStg); | 176 | Set<String> devOutputNames = devStg.getSignalFlatNames(Type.OUTPUT); |
181 | 177 | Set<String> devPlaceNames = parsePlaceNames(pcompResult.getReturnValue().getOutputFile("places.list"), 0); | ||
182 | 178 | // String reachConformation = MpsatSettings.genReachConformation(devOutputNames, devPlaceNames); | ||
183 | 179 | String reachConformation = MpsatSettings.genReachConformationDetail(stg, devOutputNames, devPlaceNames); | ||
184 | 174 | if (MpsatUtilitySettings.getDebugReach()) { | 180 | if (MpsatUtilitySettings.getDebugReach()) { |
185 | 175 | System.out.println("\nReach expression for the interface conformation property:"); | 181 | System.out.println("\nReach expression for the interface conformation property:"); |
186 | 176 | System.out.println(reachConformation); | 182 | System.out.println(reachConformation); |
187 | @@ -179,7 +185,8 @@ | |||
188 | 179 | MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), | 185 | MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), |
189 | 180 | MpsatUtilitySettings.getSolutionCount(), reachConformation); | 186 | MpsatUtilitySettings.getSolutionCount(), reachConformation); |
190 | 181 | 187 | ||
192 | 182 | MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath()); | 188 | MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), |
193 | 189 | unfoldingFile.getCanonicalPath(), workingDirectory); | ||
194 | 183 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( | 190 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( |
195 | 184 | mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); | 191 | mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); |
196 | 185 | 192 | ||
197 | @@ -188,15 +195,14 @@ | |||
198 | 188 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 195 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
199 | 189 | } | 196 | } |
200 | 190 | return new Result<MpsatChainResult>(Outcome.FAILED, | 197 | return new Result<MpsatChainResult>(Outcome.FAILED, |
202 | 191 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings)); | 198 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings)); |
203 | 192 | } | 199 | } |
204 | 193 | monitor.progressUpdate(0.50); | 200 | monitor.progressUpdate(0.50); |
205 | 194 | 201 | ||
206 | 195 | MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue()); | 202 | MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue()); |
207 | 196 | if (!mpsatConformationParser.getSolutions().isEmpty()) { | 203 | if (!mpsatConformationParser.getSolutions().isEmpty()) { |
208 | 197 | unfoldingFile.delete(); | ||
209 | 198 | return new Result<MpsatChainResult>(Outcome.FINISHED, | 204 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
211 | 199 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings, | 205 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings, |
212 | 200 | "Circuit does not conform to the environment after the following trace:")); | 206 | "Circuit does not conform to the environment after the following trace:")); |
213 | 201 | } | 207 | } |
214 | 202 | } | 208 | } |
215 | @@ -204,7 +210,8 @@ | |||
216 | 204 | 210 | ||
217 | 205 | // Check for deadlock | 211 | // Check for deadlock |
218 | 206 | if (checkDeadlock) { | 212 | if (checkDeadlock) { |
220 | 207 | MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath()); | 213 | MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(), |
221 | 214 | unfoldingFile.getCanonicalPath(), workingDirectory); | ||
222 | 208 | Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute( | 215 | Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute( |
223 | 209 | mpsatDeadlockTask, "Running deadlock check [MPSat]", subtaskMonitor); | 216 | mpsatDeadlockTask, "Running deadlock check [MPSat]", subtaskMonitor); |
224 | 210 | 217 | ||
225 | @@ -213,15 +220,14 @@ | |||
226 | 213 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 220 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
227 | 214 | } | 221 | } |
228 | 215 | return new Result<MpsatChainResult>(Outcome.FAILED, | 222 | return new Result<MpsatChainResult>(Outcome.FAILED, |
230 | 216 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings)); | 223 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings)); |
231 | 217 | } | 224 | } |
232 | 218 | monitor.progressUpdate(0.70); | 225 | monitor.progressUpdate(0.70); |
233 | 219 | 226 | ||
234 | 220 | MpsatResultParser mpsatDeadlockParser = new MpsatResultParser(mpsatDeadlockResult.getReturnValue()); | 227 | MpsatResultParser mpsatDeadlockParser = new MpsatResultParser(mpsatDeadlockResult.getReturnValue()); |
235 | 221 | if (!mpsatDeadlockParser.getSolutions().isEmpty()) { | 228 | if (!mpsatDeadlockParser.getSolutions().isEmpty()) { |
236 | 222 | unfoldingFile.delete(); | ||
237 | 223 | return new Result<MpsatChainResult>(Outcome.FINISHED, | 229 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
239 | 224 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings, | 230 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings, |
240 | 225 | "Circuit has a deadlock after the following trace:")); | 231 | "Circuit has a deadlock after the following trace:")); |
241 | 226 | } | 232 | } |
242 | 227 | } | 233 | } |
243 | @@ -229,7 +235,8 @@ | |||
244 | 229 | 235 | ||
245 | 230 | // Check for hazards | 236 | // Check for hazards |
246 | 231 | if (checkHazard) { | 237 | if (checkHazard) { |
248 | 232 | MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath()); | 238 | MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(), |
249 | 239 | unfoldingFile.getCanonicalPath(), workingDirectory); | ||
250 | 233 | if (MpsatUtilitySettings.getDebugReach()) { | 240 | if (MpsatUtilitySettings.getDebugReach()) { |
251 | 234 | System.out.println("\nReach expression for the hazard property:"); | 241 | System.out.println("\nReach expression for the hazard property:"); |
252 | 235 | System.out.println(hazardSettings.getReach()); | 242 | System.out.println(hazardSettings.getReach()); |
253 | @@ -242,44 +249,72 @@ | |||
254 | 242 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 249 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
255 | 243 | } | 250 | } |
256 | 244 | return new Result<MpsatChainResult>(Outcome.FAILED, | 251 | return new Result<MpsatChainResult>(Outcome.FAILED, |
258 | 245 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings)); | 252 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings)); |
259 | 246 | } | 253 | } |
260 | 247 | monitor.progressUpdate(0.90); | 254 | monitor.progressUpdate(0.90); |
261 | 248 | 255 | ||
262 | 249 | MpsatResultParser mpsatHazardParser = new MpsatResultParser(mpsatHazardResult.getReturnValue()); | 256 | MpsatResultParser mpsatHazardParser = new MpsatResultParser(mpsatHazardResult.getReturnValue()); |
263 | 250 | if (!mpsatHazardParser.getSolutions().isEmpty()) { | 257 | if (!mpsatHazardParser.getSolutions().isEmpty()) { |
264 | 251 | unfoldingFile.delete(); | ||
265 | 252 | return new Result<MpsatChainResult>(Outcome.FINISHED, | 258 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
267 | 253 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings, | 259 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings, |
268 | 254 | "Circuit has a hazard after the following trace:")); | 260 | "Circuit has a hazard after the following trace:")); |
269 | 255 | } | 261 | } |
270 | 256 | } | 262 | } |
271 | 257 | monitor.progressUpdate(1.0); | 263 | monitor.progressUpdate(1.0); |
272 | 258 | 264 | ||
273 | 259 | // Success | 265 | // Success |
291 | 260 | unfoldingFile.delete(); | 266 | String message = getSuccessMessage(envFile); |
275 | 261 | String message = ""; | ||
276 | 262 | if (hasEnvironment) { | ||
277 | 263 | message = "Under the given environment (" + environmentFile.getName() + ")"; | ||
278 | 264 | } else { | ||
279 | 265 | message = "Without environment restrictions"; | ||
280 | 266 | } | ||
281 | 267 | message += " the circuit is:\n"; | ||
282 | 268 | if (checkConformation) { | ||
283 | 269 | message += " * conformant\n"; | ||
284 | 270 | } | ||
285 | 271 | if (checkDeadlock) { | ||
286 | 272 | message += " * deadlock-free\n"; | ||
287 | 273 | } | ||
288 | 274 | if (checkHazard) { | ||
289 | 275 | message += " * hazard-free\n"; | ||
290 | 276 | } | ||
292 | 277 | return new Result<MpsatChainResult>(Outcome.FINISHED, | 267 | return new Result<MpsatChainResult>(Outcome.FINISHED, |
294 | 278 | new MpsatChainResult(circuitExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message)); | 268 | new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message)); |
295 | 279 | 269 | ||
296 | 280 | } catch (Throwable e) { | 270 | } catch (Throwable e) { |
297 | 281 | return new Result<MpsatChainResult>(e); | 271 | return new Result<MpsatChainResult>(e); |
299 | 282 | } | 272 | } finally { |
300 | 273 | if ((workingDirectory != null) && !MpsatUtilitySettings.getDebugTemporaryFiles()) { | ||
301 | 274 | FileUtils.deleteDirectoryTree(workingDirectory); | ||
302 | 275 | } | ||
303 | 276 | } | ||
304 | 277 | } | ||
305 | 278 | |||
306 | 279 | private HashSet<String> parsePlaceNames(byte[] bufferedInput, int lineIndex) { | ||
307 | 280 | HashSet<String> result = new HashSet<String>(); | ||
308 | 281 | InputStream is = new ByteArrayInputStream(bufferedInput); | ||
309 | 282 | BufferedReader br = new BufferedReader(new InputStreamReader(is)); | ||
310 | 283 | try { | ||
311 | 284 | String line = null; | ||
312 | 285 | while ((lineIndex >= 0) && ((line = br.readLine()) != null)) { | ||
313 | 286 | lineIndex--; | ||
314 | 287 | } | ||
315 | 288 | if (line != null) { | ||
316 | 289 | for (String name: line.trim().split("\\s")) { | ||
317 | 290 | result.add(name); | ||
318 | 291 | } | ||
319 | 292 | } | ||
320 | 293 | } catch (IOException e) { | ||
321 | 294 | e.printStackTrace(); | ||
322 | 295 | } | ||
323 | 296 | return result; | ||
324 | 297 | } | ||
325 | 298 | |||
326 | 299 | private String getSuccessMessage(File environmentFile) { | ||
327 | 300 | String message = ""; | ||
328 | 301 | boolean hasEnvironment = ((environmentFile != null) && environmentFile.exists()); | ||
329 | 302 | if (hasEnvironment) { | ||
330 | 303 | message = "Under the given environment (" + environmentFile.getName() + ")"; | ||
331 | 304 | } else { | ||
332 | 305 | message = "Without environment restrictions"; | ||
333 | 306 | } | ||
334 | 307 | message += " the circuit is:\n"; | ||
335 | 308 | if (checkConformation) { | ||
336 | 309 | message += " * conformant\n"; | ||
337 | 310 | } | ||
338 | 311 | if (checkDeadlock) { | ||
339 | 312 | message += " * deadlock-free\n"; | ||
340 | 313 | } | ||
341 | 314 | if (checkHazard) { | ||
342 | 315 | message += " * hazard-free\n"; | ||
343 | 316 | } | ||
344 | 317 | return message; | ||
345 | 283 | } | 318 | } |
346 | 284 | 319 | ||
347 | 285 | } | 320 | } |
348 | 286 | 321 | ||
349 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java' | |||
350 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-11-21 18:25:23 +0000 | |||
351 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-11-30 23:14:46 +0000 | |||
352 | @@ -451,7 +451,7 @@ | |||
353 | 451 | Node parent = contact.getParent(); | 451 | Node parent = contact.getParent(); |
354 | 452 | if (parent instanceof VisualFunctionComponent) { | 452 | if (parent instanceof VisualFunctionComponent) { |
355 | 453 | VisualFunctionComponent component = (VisualFunctionComponent)parent; | 453 | VisualFunctionComponent component = (VisualFunctionComponent)parent; |
357 | 454 | String componentName = NamespaceHelper.getFlatName(circuit.getMathName(component)); | 454 | String componentName = NamespaceHelper.hierarchicalToFlatName(circuit.getMathName(component)); |
358 | 455 | String contactName = circuit.getMathName(contact); | 455 | String contactName = circuit.getMathName(contact); |
359 | 456 | result = componentName + "_" + contactName; | 456 | result = componentName + "_" + contactName; |
360 | 457 | } | 457 | } |
361 | @@ -470,7 +470,7 @@ | |||
362 | 470 | result = circuit.getMathName(outputPort); | 470 | result = circuit.getMathName(outputPort); |
363 | 471 | } else { | 471 | } else { |
364 | 472 | // If the component has a single output, use the component name. Otherwise append the contact. | 472 | // If the component has a single output, use the component name. Otherwise append the contact. |
366 | 473 | result = NamespaceHelper.getFlatName(circuit.getMathName(component)); | 473 | result = NamespaceHelper.hierarchicalToFlatName(circuit.getMathName(component)); |
367 | 474 | int output_cnt = 0; | 474 | int output_cnt = 0; |
368 | 475 | for (Node node: component.getChildren()) { | 475 | for (Node node: component.getChildren()) { |
369 | 476 | if (node instanceof VisualContact) { | 476 | if (node instanceof VisualContact) { |
370 | 477 | 477 | ||
371 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java' | |||
372 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java 2014-07-11 09:35:42 +0000 | |||
373 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java 2014-11-30 23:14:46 +0000 | |||
374 | @@ -61,7 +61,7 @@ | |||
375 | 61 | 61 | ||
376 | 62 | String ref = internalReferences.getReference(node); | 62 | String ref = internalReferences.getReference(node); |
377 | 63 | // use full path to a flattened name | 63 | // use full path to a flattened name |
379 | 64 | String flat = NamespaceHelper.getFlatName(ref); | 64 | String flat = NamespaceHelper.hierarchicalToFlatName(ref); |
380 | 65 | 65 | ||
381 | 66 | // old style naming, if number is used as an ID for a contact | 66 | // old style naming, if number is used as an ID for a contact |
382 | 67 | if (Identifier.isNumber(ref)) { | 67 | if (Identifier.isNumber(ref)) { |
383 | 68 | 68 | ||
384 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java' | |||
385 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java 2013-09-18 16:19:20 +0000 | |||
386 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java 2014-11-30 23:14:46 +0000 | |||
387 | @@ -28,12 +28,11 @@ | |||
388 | 28 | this.result = result; | 28 | this.result = result; |
389 | 29 | } | 29 | } |
390 | 30 | 30 | ||
393 | 31 | public STGModel getResolvedStg() | 31 | public STGModel getResolvedStg() { |
392 | 32 | { | ||
394 | 33 | final byte[] output = result.getReturnValue().getMpsatResult().getReturnValue().getOutputFile("mpsat.g"); | 32 | final byte[] output = result.getReturnValue().getMpsatResult().getReturnValue().getOutputFile("mpsat.g"); |
396 | 34 | if(output == null) | 33 | if(output == null) { |
397 | 35 | return null; | 34 | return null; |
399 | 36 | 35 | } | |
400 | 37 | try { | 36 | try { |
401 | 38 | return new DotGImporter().importSTG(new ByteArrayInputStream(output)); | 37 | return new DotGImporter().importSTG(new ByteArrayInputStream(output)); |
402 | 39 | } catch (DeserialisationException e) { | 38 | } catch (DeserialisationException e) { |
403 | 40 | 39 | ||
404 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java' | |||
405 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java 2014-10-24 16:33:38 +0000 | |||
406 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java 2014-11-30 23:14:46 +0000 | |||
407 | @@ -6,13 +6,13 @@ | |||
408 | 6 | import org.workcraft.Tool; | 6 | import org.workcraft.Tool; |
409 | 7 | import org.workcraft.gui.propertyeditor.Settings; | 7 | import org.workcraft.gui.propertyeditor.Settings; |
410 | 8 | import org.workcraft.plugins.mpsat.tools.CscResolutionTool; | 8 | import org.workcraft.plugins.mpsat.tools.CscResolutionTool; |
412 | 9 | import org.workcraft.plugins.mpsat.tools.CustomPropertyMpsatChecker; | 9 | import org.workcraft.plugins.mpsat.tools.MpsatConformationChecker; |
413 | 10 | import org.workcraft.plugins.mpsat.tools.MpsatConsistencyChecker; | 10 | import org.workcraft.plugins.mpsat.tools.MpsatConsistencyChecker; |
414 | 11 | import org.workcraft.plugins.mpsat.tools.MpsatCscChecker; | 11 | import org.workcraft.plugins.mpsat.tools.MpsatCscChecker; |
415 | 12 | import org.workcraft.plugins.mpsat.tools.MpsatCustomPropertyChecker; | ||
416 | 12 | import org.workcraft.plugins.mpsat.tools.MpsatDeadlockChecker; | 13 | import org.workcraft.plugins.mpsat.tools.MpsatDeadlockChecker; |
417 | 13 | import org.workcraft.plugins.mpsat.tools.MpsatNormalcyChecker; | 14 | import org.workcraft.plugins.mpsat.tools.MpsatNormalcyChecker; |
418 | 14 | import org.workcraft.plugins.mpsat.tools.MpsatPersistencyChecker; | 15 | import org.workcraft.plugins.mpsat.tools.MpsatPersistencyChecker; |
419 | 15 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesis; | ||
420 | 16 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisComplexGate; | 16 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisComplexGate; |
421 | 17 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisGeneralisedCelement; | 17 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisGeneralisedCelement; |
422 | 18 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisStandardCelement; | 18 | import org.workcraft.plugins.mpsat.tools.MpsatSynthesisStandardCelement; |
423 | @@ -38,7 +38,8 @@ | |||
424 | 38 | p.registerClass(Tool.class, MpsatNormalcyChecker.class, framework); | 38 | p.registerClass(Tool.class, MpsatNormalcyChecker.class, framework); |
425 | 39 | p.registerClass(Tool.class, MpsatCscChecker.class, framework); | 39 | p.registerClass(Tool.class, MpsatCscChecker.class, framework); |
426 | 40 | p.registerClass(Tool.class, MpsatUscChecker.class, framework); | 40 | p.registerClass(Tool.class, MpsatUscChecker.class, framework); |
428 | 41 | p.registerClass(Tool.class, CustomPropertyMpsatChecker.class, framework); | 41 | p.registerClass(Tool.class, MpsatConformationChecker.class, framework); |
429 | 42 | p.registerClass(Tool.class, MpsatCustomPropertyChecker.class, framework); | ||
430 | 42 | 43 | ||
431 | 43 | p.registerClass(Settings.class, MpsatUtilitySettings.class); | 44 | p.registerClass(Settings.class, MpsatUtilitySettings.class); |
432 | 44 | p.registerClass(Settings.class, PunfUtilitySettings.class); | 45 | p.registerClass(Settings.class, PunfUtilitySettings.class); |
433 | 45 | 46 | ||
434 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java' | |||
435 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2014-11-13 00:05:09 +0000 | |||
436 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2014-11-30 23:14:46 +0000 | |||
437 | @@ -6,9 +6,10 @@ | |||
438 | 6 | import java.io.File; | 6 | import java.io.File; |
439 | 7 | import java.io.IOException; | 7 | import java.io.IOException; |
440 | 8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
442 | 9 | import java.util.HashSet; | 9 | import java.util.Collection; |
443 | 10 | import java.util.LinkedHashMap; | 10 | import java.util.LinkedHashMap; |
444 | 11 | import java.util.Map; | 11 | import java.util.Map; |
445 | 12 | import java.util.Set; | ||
446 | 12 | import java.util.regex.Matcher; | 13 | import java.util.regex.Matcher; |
447 | 13 | import java.util.regex.Pattern; | 14 | import java.util.regex.Pattern; |
448 | 14 | 15 | ||
449 | @@ -16,7 +17,7 @@ | |||
450 | 16 | import org.workcraft.dom.hierarchy.NamespaceHelper; | 17 | import org.workcraft.dom.hierarchy.NamespaceHelper; |
451 | 17 | import org.workcraft.plugins.stg.STG; | 18 | import org.workcraft.plugins.stg.STG; |
452 | 18 | import org.workcraft.plugins.stg.SignalTransition; | 19 | import org.workcraft.plugins.stg.SignalTransition; |
454 | 19 | import org.workcraft.plugins.stg.SignalTransition.Type; | 20 | import org.workcraft.plugins.stg.SignalTransition.Direction; |
455 | 20 | import org.workcraft.util.FileUtils; | 21 | import org.workcraft.util.FileUtils; |
456 | 21 | 22 | ||
457 | 22 | public class MpsatSettings { | 23 | public class MpsatSettings { |
458 | @@ -53,134 +54,158 @@ | |||
459 | 53 | // Reach expression for checking signal consistency | 54 | // Reach expression for checking signal consistency |
460 | 54 | public static final String reachConsistency = | 55 | public static final String reachConsistency = |
461 | 55 | "exists s in SIGNALS \\ DUMMY {\n" + | 56 | "exists s in SIGNALS \\ DUMMY {\n" + |
467 | 56 | " let Es = ev s {\n" + | 57 | " let Es = ev s {\n" + |
468 | 57 | " $s & exists e in Es s.t. is_plus e { @e }\n" + | 58 | " $s & exists e in Es s.t. is_plus e { @e }\n" + |
469 | 58 | " |\n" + | 59 | " |\n" + |
470 | 59 | " ~$s & exists e in Es s.t. is_minus e { @e }\n" + | 60 | " ~$s & exists e in Es s.t. is_minus e { @e }\n" + |
471 | 60 | " }\n" + | 61 | " }\n" + |
472 | 61 | "}\n"; | 62 | "}\n"; |
473 | 62 | 63 | ||
474 | 63 | // Reach expression for checking semimodularity (output persistency) | 64 | // Reach expression for checking semimodularity (output persistency) |
475 | 64 | public static final String reachSemimodularity = | 65 | public static final String reachSemimodularity = |
476 | 65 | "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n" + | 66 | "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n" + |
486 | 66 | " exists t1 in tran EVENTS s.t. sig t1 in LOCAL {\n" + | 67 | " exists t1 in tran EVENTS s.t. sig t1 in LOCAL {\n" + |
487 | 67 | " @t1 &\n" + | 68 | " @t1 &\n" + |
488 | 68 | " exists t2 in tran EVENTS s.t. sig t2 != sig t1 & card (pre t1 * (pre t2 \\ post t2)) != 0 {\n" + | 69 | " exists t2 in tran EVENTS s.t. sig t2 != sig t1 & card (pre t1 * (pre t2 \\ post t2)) != 0 {\n" + |
489 | 69 | " @t2 &\n" + | 70 | " @t2 &\n" + |
490 | 70 | " forall t3 in tran EVENTS * (tran sig t1 \\ {t1}) s.t. card (pre t3 * (pre t2 \\ post t2)) = 0 {\n" + | 71 | " forall t3 in tran EVENTS * (tran sig t1 \\ {t1}) s.t. card (pre t3 * (pre t2 \\ post t2)) = 0 {\n" + |
491 | 71 | " exists p in pre t3 \\ post t2 { ~$p }\n" + | 72 | " exists p in pre t3 \\ post t2 { ~$p }\n" + |
492 | 72 | " }\n" + | 73 | " }\n" + |
493 | 73 | " }\n" + | 74 | " }\n" + |
494 | 74 | " }\n"; | 75 | " }\n"; |
495 | 75 | 76 | ||
496 | 76 | // Reach expression for checking conformation (this is a template, | 77 | // Reach expression for checking conformation (this is a template, |
497 | 77 | // the list of places needs to be updated for each circuit) | 78 | // the list of places needs to be updated for each circuit) |
498 | 78 | public static final String reachConformation = | 79 | public static final String reachConformation = |
513 | 79 | "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n" + | 80 | // "let devOutputs = gather signalName in { \"out0\" } { S signalName },\n" + |
514 | 80 | " let CPnames = {\"in1_0\", \"in1_1\", \"in0_0\", \"in0_1\", \"out0_0\", \"out0_1\"},\n" + | 81 | // " devPlaces = gather placeName in { \"in1_0\", \"in1_1\", \"in0_1\", \"in0_0\", \"<out0+,out0->\", \"<out0-,out0+>\" } { P placeName } {\n" + |
515 | 81 | " CP=gather n in CPnames { P n } {\n" + | 82 | " card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n" + |
516 | 82 | " exists s in SIGNALS \\ DUMMY {\n" + | 83 | " exists s in devOutputs {\n" + |
517 | 83 | " exists t in tran s {\n" + | 84 | " exists t in tran s {\n" + |
518 | 84 | " forall p in pre t * CP { $p }\n" + | 85 | " is_plus t & forall p in pre t * devPlaces { $ p }\n" + |
519 | 85 | " }\n" + | 86 | " }\n" + |
520 | 86 | " &\n" + | 87 | " &\n" + |
521 | 87 | " forall t in tran s {\n" + | 88 | " forall t in tran s {\n" + |
522 | 88 | " exists p in pre t \\ CP { ~$p }\n" + | 89 | " is_plus t & exists p in pre t \\ devPlaces { ~ $ p }\n" + |
523 | 89 | " }\n" + | 90 | " }\n" + |
524 | 90 | " }\n" + | 91 | " |\n" + |
525 | 91 | " }\n"; | 92 | " exists t in tran s {\n" + |
526 | 92 | 93 | " is_minus t & forall p in pre t * devPlaces { $ p }\n" + | |
527 | 94 | " }\n" + | ||
528 | 95 | " &\n" + | ||
529 | 96 | " forall t in tran s {\n" + | ||
530 | 97 | " is_minus t & exists p in pre t \\ devPlaces { ~ $ p }\n" + | ||
531 | 98 | " }\n" + | ||
532 | 99 | " }\n" + | ||
533 | 100 | "}\n"; | ||
534 | 101 | |||
535 | 93 | // Note: New (PNML-based) version of Punf is required to check conformation property. | 102 | // Note: New (PNML-based) version of Punf is required to check conformation property. |
536 | 94 | // Old version of Punf does not support dead signals, transitions and places well | 103 | // Old version of Punf does not support dead signals, transitions and places well |
537 | 95 | // (e.g. a dead transition may disappear from unfolding), therefore the conformation | 104 | // (e.g. a dead transition may disappear from unfolding), therefore the conformation |
538 | 96 | // property cannot be checked reliably. | 105 | // property cannot be checked reliably. |
558 | 97 | public static String genReachConformation(STG stg, STG circuitStg) { | 106 | public static String genReachConformation(Set<String> devOutputNames, Set<String> devPlaceNames) { |
559 | 98 | // Form a set of system STG places which came from the circuitStg | 107 | String devOutputList = genNameList(devOutputNames); |
560 | 99 | HashSet<Node> circuitPlaces = new HashSet<Node>(); | 108 | String devPlaceList = genNameList(devPlaceNames); |
561 | 100 | for (Type type: Type.values()) { | 109 | return "let devOutputs = gather signalName in { " + devOutputList + " } { S signalName },\n" + |
562 | 101 | for (String s : circuitStg.getSignalReferences(type)) { | 110 | " devPlaces = gather placeName in { " + devPlaceList + " } { P placeName } {\n" + |
563 | 102 | Node p0 = stg.getNodeByReference(s + "_0"); | 111 | reachConformation; |
564 | 103 | if (p0 == null) { | 112 | } |
565 | 104 | p0 = stg.getNodeByReference("<" + s + "-," + s + "+>"); | 113 | |
566 | 105 | } | 114 | private static String genNameList(Collection<String> names) { |
567 | 106 | if (p0 != null) { | 115 | String result = ""; |
568 | 107 | circuitPlaces.add(p0); | 116 | for (String name: names) { |
569 | 108 | } | 117 | if ( !result.isEmpty() ) { |
570 | 109 | Node p1 = stg.getNodeByReference(s + "_1"); | 118 | result += ", "; |
552 | 110 | if (p1 == null) { | ||
553 | 111 | p1 = stg.getNodeByReference("<" + s + "+," + s + "->"); | ||
554 | 112 | } | ||
555 | 113 | if (p1 != null) { | ||
556 | 114 | circuitPlaces.add(p1); | ||
557 | 115 | } | ||
571 | 116 | } | 119 | } |
572 | 120 | result += "\"" + name + "\""; | ||
573 | 117 | } | 121 | } |
575 | 118 | // Generate Reach expression | 122 | return result; |
576 | 123 | } | ||
577 | 124 | |||
578 | 125 | public static String genReachConformationDetail(STG stg, Set<String> devOutputNames, Set<String> devPlaceNames) { | ||
579 | 119 | String result = ""; | 126 | String result = ""; |
587 | 120 | for (String s : circuitStg.getSignalReferences(Type.OUTPUT)) { | 127 | for (String signalFlatName: devOutputNames) { |
588 | 121 | String circuitPredicate = ""; | 128 | String riseDevPredicate = ""; |
589 | 122 | String environmentPredicate = ""; | 129 | String fallDevPredicate = ""; |
590 | 123 | for (SignalTransition t: stg.getSignalTransitions()) { | 130 | String riseEnvPredicate = ""; |
591 | 124 | if (!t.getSignalType().equals(Type.OUTPUT) || !t.getSignalName().equals(s)) continue; | 131 | String fallEnvPredicate = ""; |
592 | 125 | String circuitPreset = ""; | 132 | |
593 | 126 | String environmentPreset = ""; | 133 | String signalRef = NamespaceHelper.flatToHierarchicalName(signalFlatName); |
594 | 134 | for (SignalTransition t: stg.getSignalTransitions(signalRef)) { | ||
595 | 135 | String devPreset = ""; | ||
596 | 136 | String envPreset = ""; | ||
597 | 127 | for (Node p: stg.getPreset(t)) { | 137 | for (Node p: stg.getPreset(t)) { |
606 | 128 | String name = stg.getNodeReference(p); | 138 | String placeRef = stg.getNodeReference(p); |
607 | 129 | if (circuitPlaces.contains(p)) { | 139 | String placeFlatName = NamespaceHelper.hierarchicalToFlatName(placeRef); |
608 | 130 | if (circuitPreset.isEmpty()) { | 140 | if (devPlaceNames.contains(placeFlatName)) { |
609 | 131 | circuitPreset += "{"; | 141 | devPreset += (devPreset.isEmpty() ? "{" : ", "); |
610 | 132 | } else { | 142 | devPreset += "\"" + placeFlatName + "\""; |
611 | 133 | circuitPreset += ", "; | 143 | } |
612 | 134 | } | 144 | envPreset += (envPreset.isEmpty() ? "{" : ", "); |
613 | 135 | circuitPreset += "\"" + name + "\""; | 145 | envPreset += "\"" + placeFlatName + "\""; |
614 | 146 | } | ||
615 | 147 | |||
616 | 148 | if ( !devPreset.isEmpty() && !envPreset.isEmpty() ) { | ||
617 | 149 | devPreset += "}"; | ||
618 | 150 | envPreset += "}"; | ||
619 | 151 | String devPredicate = ""; | ||
620 | 152 | devPredicate += " forall p in " + devPreset + " {\n"; | ||
621 | 153 | devPredicate += " $ P p\n"; | ||
622 | 154 | devPredicate += " }\n"; | ||
623 | 155 | String envPredicate = ""; | ||
624 | 156 | envPredicate += " exists p in " + envPreset + " {\n"; | ||
625 | 157 | envPredicate += " ~$ P p\n"; | ||
626 | 158 | envPredicate += " }\n"; | ||
627 | 159 | if (t.getDirection() == Direction.PLUS) { | ||
628 | 160 | if ( !riseDevPredicate.isEmpty() ) { | ||
629 | 161 | riseDevPredicate += " |\n"; | ||
630 | 162 | } | ||
631 | 163 | riseDevPredicate += devPredicate; | ||
632 | 164 | if ( !riseEnvPredicate.isEmpty() ) { | ||
633 | 165 | riseEnvPredicate += " &\n"; | ||
634 | 166 | } | ||
635 | 167 | riseEnvPredicate += envPredicate; | ||
636 | 136 | } else { | 168 | } else { |
643 | 137 | if (environmentPreset.isEmpty()) { | 169 | if ( !fallDevPredicate.isEmpty() ) { |
644 | 138 | environmentPreset += "{"; | 170 | fallDevPredicate += " |\n"; |
645 | 139 | } else { | 171 | } |
646 | 140 | environmentPreset += ", "; | 172 | fallDevPredicate += devPredicate; |
647 | 141 | } | 173 | if ( !fallEnvPredicate.isEmpty() ) { |
648 | 142 | environmentPreset += "\"" + name + "\""; | 174 | fallEnvPredicate += " &\n"; |
649 | 175 | } | ||
650 | 176 | fallEnvPredicate += envPredicate; | ||
651 | 143 | } | 177 | } |
652 | 144 | } | 178 | } |
687 | 145 | circuitPreset += "}"; | 179 | } |
688 | 146 | environmentPreset += "}"; | 180 | |
689 | 147 | 181 | if ( !riseDevPredicate.isEmpty() || !fallDevPredicate.isEmpty() ) { | |
690 | 148 | if (circuitPredicate.isEmpty()) { | 182 | if (result.isEmpty()) { |
691 | 149 | circuitPredicate += " (\n"; | 183 | result = "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n"; |
692 | 150 | } else { | 184 | } else { |
693 | 151 | circuitPredicate += " |\n"; | 185 | result += "|\n"; |
694 | 152 | } | 186 | } |
695 | 153 | circuitPredicate += " forall p in " + circuitPreset + " {\n"; | 187 | result += "( /* Conformation check for signal \"" + signalFlatName + "\" */\n"; |
696 | 154 | circuitPredicate += " $ P p\n"; | 188 | result += " (\n"; |
697 | 155 | circuitPredicate += " }\n"; | 189 | result += riseDevPredicate; |
698 | 156 | 190 | result += " )\n"; | |
699 | 157 | if (environmentPredicate.isEmpty()) { | 191 | result += " &\n"; |
700 | 158 | environmentPredicate += " (\n"; | 192 | result += " (\n"; |
701 | 159 | } else { | 193 | result += riseEnvPredicate; |
702 | 160 | environmentPredicate += " &\n"; | 194 | result += " )\n"; |
703 | 161 | } | 195 | result += " |\n"; |
704 | 162 | environmentPredicate += " exists p in " + environmentPreset + " {\n"; | 196 | result += " (\n"; |
705 | 163 | environmentPredicate += " ~$ P p\n"; | 197 | result += fallDevPredicate; |
706 | 164 | environmentPredicate += " }\n"; | 198 | result += " )\n"; |
707 | 165 | } | 199 | result += " &\n"; |
708 | 166 | circuitPredicate += " )\n"; | 200 | result += " (\n"; |
709 | 167 | environmentPredicate += " )\n"; | 201 | result += fallEnvPredicate; |
710 | 168 | if (result.isEmpty()) { | 202 | result += " )\n"; |
711 | 169 | result = "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n"; | 203 | result += ")\n"; |
712 | 170 | } else { | 204 | } |
679 | 171 | result += "|\n"; | ||
680 | 172 | } | ||
681 | 173 | result += "/* Conformation check for signal " + s + " */\n"; | ||
682 | 174 | result += "(\n"; | ||
683 | 175 | result += circuitPredicate; | ||
684 | 176 | result += " &\n"; | ||
685 | 177 | result += environmentPredicate; | ||
686 | 178 | result += ")\n"; | ||
713 | 179 | } | 205 | } |
714 | 180 | return result; | 206 | return result; |
715 | 181 | } | 207 | } |
716 | 182 | 208 | ||
717 | 183 | |||
718 | 184 | public MpsatSettings(String name, MpsatMode mode, int verbosity, SolutionMode solutionMode, int solutionNumberLimit, String reach) { | 209 | public MpsatSettings(String name, MpsatMode mode, int verbosity, SolutionMode solutionMode, int solutionNumberLimit, String reach) { |
719 | 185 | super(); | 210 | super(); |
720 | 186 | this.name = name; | 211 | this.name = name; |
721 | @@ -212,7 +237,7 @@ | |||
722 | 212 | Matcher matcher = nodeNamePattern.matcher(reach); | 237 | Matcher matcher = nodeNamePattern.matcher(reach); |
723 | 213 | while (matcher.find()) { | 238 | while (matcher.find()) { |
724 | 214 | String reference = matcher.group(1); | 239 | String reference = matcher.group(1); |
726 | 215 | String flatName = NamespaceHelper.getFlatName(reference); | 240 | String flatName = NamespaceHelper.hierarchicalToFlatName(reference); |
727 | 216 | matcher.appendReplacement(sb, "\"" + flatName + "\""); | 241 | matcher.appendReplacement(sb, "\"" + flatName + "\""); |
728 | 217 | } | 242 | } |
729 | 218 | matcher.appendTail(sb); | 243 | matcher.appendTail(sb); |
730 | 219 | 244 | ||
731 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java' | |||
732 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2014-09-05 16:36:36 +0000 | |||
733 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2014-11-30 23:14:46 +0000 | |||
734 | @@ -38,18 +38,21 @@ | |||
735 | 38 | private static final String keyExtraArgs = prefix + ".args"; | 38 | private static final String keyExtraArgs = prefix + ".args"; |
736 | 39 | private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding"; | 39 | private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding"; |
737 | 40 | private static final String keyDebugReach = prefix + ".debugReach"; | 40 | private static final String keyDebugReach = prefix + ".debugReach"; |
738 | 41 | private static final String keyDebugTemporaryFiles = prefix + ".debugTemporaryFiles"; | ||
739 | 41 | 42 | ||
740 | 42 | private static final String defaultCommand = "mpsat"; | 43 | private static final String defaultCommand = "mpsat"; |
741 | 43 | private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST; | 44 | private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST; |
742 | 44 | private static final String defaultExtraArgs = ""; | 45 | private static final String defaultExtraArgs = ""; |
743 | 45 | private static final Boolean defaultUsePnmlUnfolding = false; | 46 | private static final Boolean defaultUsePnmlUnfolding = false; |
744 | 46 | private static final Boolean defaultDebugReach = false; | 47 | private static final Boolean defaultDebugReach = false; |
745 | 48 | private static final Boolean defaultDebugTemporaryFiles = true; | ||
746 | 47 | 49 | ||
747 | 48 | private static String command = defaultCommand; | 50 | private static String command = defaultCommand; |
748 | 49 | private static SolutionMode solutionMode = defaultSolutionMode; | 51 | private static SolutionMode solutionMode = defaultSolutionMode; |
749 | 50 | private static String extraArgs = defaultExtraArgs; | 52 | private static String extraArgs = defaultExtraArgs; |
750 | 51 | private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding; | 53 | private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding; |
751 | 52 | private static Boolean debugReach = defaultDebugReach; | 54 | private static Boolean debugReach = defaultDebugReach; |
752 | 55 | private static Boolean debigTemporaryFiles = defaultDebugTemporaryFiles; | ||
753 | 53 | 56 | ||
754 | 54 | public MpsatUtilitySettings() { | 57 | public MpsatUtilitySettings() { |
755 | 55 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, String>( | 58 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, String>( |
756 | @@ -93,7 +96,7 @@ | |||
757 | 93 | }); | 96 | }); |
758 | 94 | 97 | ||
759 | 95 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( | 98 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( |
761 | 96 | this, "Debug Reach expressions", Boolean.class) { | 99 | this, "Print out Reach expressions (debug)", Boolean.class) { |
762 | 97 | protected void setter(MpsatUtilitySettings object, Boolean value) { | 100 | protected void setter(MpsatUtilitySettings object, Boolean value) { |
763 | 98 | MpsatUtilitySettings.setDebugReach(value); | 101 | MpsatUtilitySettings.setDebugReach(value); |
764 | 99 | } | 102 | } |
765 | @@ -101,6 +104,16 @@ | |||
766 | 101 | return MpsatUtilitySettings.getDebugReach(); | 104 | return MpsatUtilitySettings.getDebugReach(); |
767 | 102 | } | 105 | } |
768 | 103 | }); | 106 | }); |
769 | 107 | |||
770 | 108 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( | ||
771 | 109 | this, "Keep temporary files (debug)", Boolean.class) { | ||
772 | 110 | protected void setter(MpsatUtilitySettings object, Boolean value) { | ||
773 | 111 | MpsatUtilitySettings.setDebugTemporaryFiles(value); | ||
774 | 112 | } | ||
775 | 113 | protected Boolean getter(MpsatUtilitySettings object) { | ||
776 | 114 | return MpsatUtilitySettings.getDebugTemporaryFiles(); | ||
777 | 115 | } | ||
778 | 116 | }); | ||
779 | 104 | } | 117 | } |
780 | 105 | 118 | ||
781 | 106 | @Override | 119 | @Override |
782 | @@ -115,6 +128,7 @@ | |||
783 | 115 | setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); | 128 | setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
784 | 116 | setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding)); | 129 | setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding)); |
785 | 117 | setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach)); | 130 | setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach)); |
786 | 131 | setDebugTemporaryFiles(config.getBoolean(keyDebugTemporaryFiles, defaultDebugTemporaryFiles)); | ||
787 | 118 | } | 132 | } |
788 | 119 | 133 | ||
789 | 120 | @Override | 134 | @Override |
790 | @@ -124,6 +138,8 @@ | |||
791 | 124 | config.set(keyExtraArgs, getExtraArgs()); | 138 | config.set(keyExtraArgs, getExtraArgs()); |
792 | 125 | config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding()); | 139 | config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding()); |
793 | 126 | config.setBoolean(keyDebugReach, getDebugReach()); | 140 | config.setBoolean(keyDebugReach, getDebugReach()); |
794 | 141 | config.setBoolean(keyDebugTemporaryFiles, getDebugTemporaryFiles()); | ||
795 | 142 | |||
796 | 127 | } | 143 | } |
797 | 128 | 144 | ||
798 | 129 | @Override | 145 | @Override |
799 | @@ -171,7 +187,7 @@ | |||
800 | 171 | public static void setUsePnmlUnfolding(Boolean value) { | 187 | public static void setUsePnmlUnfolding(Boolean value) { |
801 | 172 | usePnmlUnfolding = value; | 188 | usePnmlUnfolding = value; |
802 | 173 | } | 189 | } |
804 | 174 | 190 | ||
805 | 175 | public static Boolean getDebugReach() { | 191 | public static Boolean getDebugReach() { |
806 | 176 | return debugReach; | 192 | return debugReach; |
807 | 177 | } | 193 | } |
808 | @@ -180,6 +196,14 @@ | |||
809 | 180 | debugReach = value; | 196 | debugReach = value; |
810 | 181 | } | 197 | } |
811 | 182 | 198 | ||
812 | 199 | public static Boolean getDebugTemporaryFiles() { | ||
813 | 200 | return debigTemporaryFiles; | ||
814 | 201 | } | ||
815 | 202 | |||
816 | 203 | public static void setDebugTemporaryFiles(Boolean value) { | ||
817 | 204 | debigTemporaryFiles = value; | ||
818 | 205 | } | ||
819 | 206 | |||
820 | 183 | public static String getUnfoldingExtension() { | 207 | public static String getUnfoldingExtension() { |
821 | 184 | return (getUsePnmlUnfolding() ? ".pnml" : ".mci"); | 208 | return (getUsePnmlUnfolding() ? ".pnml" : ".mci"); |
822 | 185 | } | 209 | } |
823 | 186 | 210 | ||
824 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java' | |||
825 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2014-09-05 16:36:36 +0000 | |||
826 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2014-11-30 23:14:46 +0000 | |||
827 | @@ -11,44 +11,41 @@ | |||
828 | 11 | import org.workcraft.serialisation.Format; | 11 | import org.workcraft.serialisation.Format; |
829 | 12 | import org.workcraft.tasks.ProgressMonitor; | 12 | import org.workcraft.tasks.ProgressMonitor; |
830 | 13 | import org.workcraft.tasks.Result; | 13 | import org.workcraft.tasks.Result; |
831 | 14 | import org.workcraft.tasks.Result.Outcome; | ||
832 | 14 | import org.workcraft.tasks.SubtaskMonitor; | 15 | import org.workcraft.tasks.SubtaskMonitor; |
833 | 15 | import org.workcraft.tasks.Task; | 16 | import org.workcraft.tasks.Task; |
834 | 16 | import org.workcraft.tasks.Result.Outcome; | ||
835 | 17 | import org.workcraft.util.Export; | 17 | import org.workcraft.util.Export; |
836 | 18 | import org.workcraft.util.Export.ExportTask; | ||
837 | 18 | import org.workcraft.util.WorkspaceUtils; | 19 | import org.workcraft.util.WorkspaceUtils; |
838 | 19 | import org.workcraft.util.Export.ExportTask; | ||
839 | 20 | import org.workcraft.workspace.WorkspaceEntry; | 20 | import org.workcraft.workspace.WorkspaceEntry; |
840 | 21 | 21 | ||
841 | 22 | public class MpsatChainTask implements Task<MpsatChainResult> { | 22 | public class MpsatChainTask implements Task<MpsatChainResult> { |
842 | 23 | private final WorkspaceEntry we; | 23 | private final WorkspaceEntry we; |
843 | 24 | private final MpsatSettings settings; | 24 | private final MpsatSettings settings; |
844 | 25 | private final Framework framework; | 25 | private final Framework framework; |
845 | 26 | private PetriNetModel model; | ||
846 | 27 | 26 | ||
847 | 28 | public MpsatChainTask(WorkspaceEntry we, MpsatSettings settings, Framework framework) { | 27 | public MpsatChainTask(WorkspaceEntry we, MpsatSettings settings, Framework framework) { |
848 | 29 | this.we = we; | 28 | this.we = we; |
849 | 30 | this.settings = settings; | 29 | this.settings = settings; |
850 | 31 | this.framework = framework; | 30 | this.framework = framework; |
851 | 32 | this.model = null; | ||
852 | 33 | } | 31 | } |
853 | 34 | 32 | ||
854 | 35 | @Override | 33 | @Override |
855 | 36 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { | 34 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { |
856 | 35 | File netFile = null; | ||
857 | 36 | File unfoldingFile = null; | ||
858 | 37 | try { | 37 | try { |
862 | 38 | if(model == null) { | 38 | PetriNetModel model = WorkspaceUtils.getAs(we, PetriNetModel.class); |
860 | 39 | model = WorkspaceUtils.getAs(getWorkspaceEntry(), PetriNetModel.class); | ||
861 | 40 | } | ||
863 | 41 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); | 39 | Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
864 | 42 | if (exporter == null) { | 40 | if (exporter == null) { |
865 | 43 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); | 41 | throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
866 | 44 | } | 42 | } |
868 | 45 | File netFile = File.createTempFile("net", exporter.getExtenstion()); | 43 | netFile = File.createTempFile("net", exporter.getExtenstion()); |
869 | 46 | ExportTask exportTask; | 44 | ExportTask exportTask; |
870 | 47 | exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); | 45 | exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
871 | 48 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); | 46 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
872 | 49 | Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g", mon); | 47 | Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g", mon); |
873 | 50 | if (exportResult.getOutcome() != Outcome.FINISHED) { | 48 | if (exportResult.getOutcome() != Outcome.FINISHED) { |
874 | 51 | netFile.delete(); | ||
875 | 52 | if (exportResult.getOutcome() == Outcome.CANCELLED) { | 49 | if (exportResult.getOutcome() == Outcome.CANCELLED) { |
876 | 53 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 50 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
877 | 54 | } | 51 | } |
878 | @@ -56,13 +53,11 @@ | |||
879 | 56 | } | 53 | } |
880 | 57 | monitor.progressUpdate(0.33); | 54 | monitor.progressUpdate(0.33); |
881 | 58 | 55 | ||
883 | 59 | File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension()); | 56 | unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension()); |
884 | 60 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); | 57 | PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
885 | 61 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", mon); | 58 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", mon); |
886 | 62 | netFile.delete(); | ||
887 | 63 | 59 | ||
888 | 64 | if (punfResult.getOutcome() != Outcome.FINISHED) { | 60 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
889 | 65 | unfoldingFile.delete(); | ||
890 | 66 | if (punfResult.getOutcome() == Outcome.CANCELLED) { | 61 | if (punfResult.getOutcome() == Outcome.CANCELLED) { |
891 | 67 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | 62 | return new Result<MpsatChainResult>(Outcome.CANCELLED); |
892 | 68 | } | 63 | } |
893 | @@ -71,9 +66,8 @@ | |||
894 | 71 | 66 | ||
895 | 72 | monitor.progressUpdate(0.66); | 67 | monitor.progressUpdate(0.66); |
896 | 73 | 68 | ||
898 | 74 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath()); | 69 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null); |
899 | 75 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running mpsat model-checking", mon); | 70 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running mpsat model-checking", mon); |
900 | 76 | unfoldingFile.delete(); | ||
901 | 77 | 71 | ||
902 | 78 | if (mpsatResult.getOutcome() != Outcome.FINISHED) { | 72 | if (mpsatResult.getOutcome() != Outcome.FINISHED) { |
903 | 79 | if (mpsatResult.getOutcome() == Outcome.CANCELLED) { | 73 | if (mpsatResult.getOutcome() == Outcome.CANCELLED) { |
904 | @@ -88,6 +82,15 @@ | |||
905 | 88 | } catch (Throwable e) { | 82 | } catch (Throwable e) { |
906 | 89 | return new Result<MpsatChainResult>(e); | 83 | return new Result<MpsatChainResult>(e); |
907 | 90 | } | 84 | } |
908 | 85 | // Clean up | ||
909 | 86 | finally { | ||
910 | 87 | if ((netFile != null) && !MpsatUtilitySettings.getDebugTemporaryFiles() ) { | ||
911 | 88 | netFile.delete(); | ||
912 | 89 | } | ||
913 | 90 | if ((unfoldingFile != null) && !MpsatUtilitySettings.getDebugTemporaryFiles() ) { | ||
914 | 91 | unfoldingFile.delete(); | ||
915 | 92 | } | ||
916 | 93 | } | ||
917 | 91 | } | 94 | } |
918 | 92 | 95 | ||
919 | 93 | public MpsatSettings getSettings() { | 96 | public MpsatSettings getSettings() { |
920 | 94 | 97 | ||
921 | === added file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java' | |||
922 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 1970-01-01 00:00:00 +0000 | |||
923 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2014-11-30 23:14:46 +0000 | |||
924 | @@ -0,0 +1,215 @@ | |||
925 | 1 | package org.workcraft.plugins.mpsat.tasks; | ||
926 | 2 | |||
927 | 3 | import java.io.BufferedReader; | ||
928 | 4 | import java.io.ByteArrayInputStream; | ||
929 | 5 | import java.io.File; | ||
930 | 6 | import java.io.IOException; | ||
931 | 7 | import java.io.InputStream; | ||
932 | 8 | import java.io.InputStreamReader; | ||
933 | 9 | import java.util.HashSet; | ||
934 | 10 | import java.util.Set; | ||
935 | 11 | |||
936 | 12 | import org.workcraft.Framework; | ||
937 | 13 | import org.workcraft.interop.Exporter; | ||
938 | 14 | import org.workcraft.plugins.mpsat.MpsatMode; | ||
939 | 15 | import org.workcraft.plugins.mpsat.MpsatResultParser; | ||
940 | 16 | import org.workcraft.plugins.mpsat.MpsatSettings; | ||
941 | 17 | import org.workcraft.plugins.mpsat.MpsatUtilitySettings; | ||
942 | 18 | import org.workcraft.plugins.pcomp.tasks.PcompTask; | ||
943 | 19 | import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode; | ||
944 | 20 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; | ||
945 | 21 | import org.workcraft.plugins.stg.STG; | ||
946 | 22 | import org.workcraft.plugins.stg.SignalTransition.Type; | ||
947 | 23 | import org.workcraft.serialisation.Format; | ||
948 | 24 | import org.workcraft.tasks.ProgressMonitor; | ||
949 | 25 | import org.workcraft.tasks.Result; | ||
950 | 26 | import org.workcraft.tasks.Result.Outcome; | ||
951 | 27 | import org.workcraft.tasks.SubtaskMonitor; | ||
952 | 28 | import org.workcraft.util.Export; | ||
953 | 29 | import org.workcraft.util.Export.ExportTask; | ||
954 | 30 | import org.workcraft.util.FileUtils; | ||
955 | 31 | import org.workcraft.workspace.WorkspaceEntry; | ||
956 | 32 | |||
957 | 33 | |||
958 | 34 | public class MpsatConformationTask extends MpsatChainTask { | ||
959 | 35 | private final MpsatSettings toolchainPreparationSettings = new MpsatSettings("Toolchain preparation of data", | ||
960 | 36 | MpsatMode.UNDEFINED, 0, null, 0, null); | ||
961 | 37 | |||
962 | 38 | private final MpsatSettings toolchainCompletionSettings = new MpsatSettings("Toolchain completion", | ||
963 | 39 | MpsatMode.UNDEFINED, 0, null, 0, null); | ||
964 | 40 | |||
965 | 41 | private final WorkspaceEntry we; | ||
966 | 42 | private final Framework framework; | ||
967 | 43 | private File envFile; | ||
968 | 44 | |||
969 | 45 | public MpsatConformationTask(WorkspaceEntry we, Framework framework, File envFile) { | ||
970 | 46 | super (we, null, framework); | ||
971 | 47 | this.we = we; | ||
972 | 48 | this.framework = framework; | ||
973 | 49 | this.envFile = envFile; | ||
974 | 50 | } | ||
975 | 51 | |||
976 | 52 | @Override | ||
977 | 53 | public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) { | ||
978 | 54 | File workingDirectory = null; | ||
979 | 55 | try { | ||
980 | 56 | // Common variables | ||
981 | 57 | monitor.progressUpdate(0.10); | ||
982 | 58 | String title = we.getWorkspacePath().getNode(); | ||
983 | 59 | if (title.endsWith(".work")) { | ||
984 | 60 | title = title.substring(0, title.length() - 5); | ||
985 | 61 | } | ||
986 | 62 | workingDirectory = FileUtils.createTempDirectory(title + "-"); | ||
987 | 63 | |||
988 | 64 | STG devStg = (STG)we.getModelEntry().getVisualModel().getMathModel(); | ||
989 | 65 | Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG); | ||
990 | 66 | if (devStgExporter == null) { | ||
991 | 67 | throw new RuntimeException ("Exporter not available: model class " + devStg.getClass().getName() + " to format STG."); | ||
992 | 68 | } | ||
993 | 69 | SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor); | ||
994 | 70 | monitor.progressUpdate(0.20); | ||
995 | 71 | |||
996 | 72 | // Generating .g for the model | ||
997 | 73 | File devStgFile = new File(workingDirectory, "dev.g"); | ||
998 | 74 | ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath()); | ||
999 | 75 | Result<? extends Object> devExportResult = framework.getTaskManager().execute( | ||
1000 | 76 | devExportTask, "Exporting circuit .g", subtaskMonitor); | ||
1001 | 77 | |||
1002 | 78 | if (devExportResult.getOutcome() != Outcome.FINISHED) { | ||
1003 | 79 | if (devExportResult.getOutcome() == Outcome.CANCELLED) { | ||
1004 | 80 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | ||
1005 | 81 | } | ||
1006 | 82 | return new Result<MpsatChainResult>(Outcome.FAILED, | ||
1007 | 83 | new MpsatChainResult(devExportResult, null, null, null, toolchainPreparationSettings)); | ||
1008 | 84 | } | ||
1009 | 85 | monitor.progressUpdate(0.30); | ||
1010 | 86 | |||
1011 | 87 | // Generating .g for the environment | ||
1012 | 88 | Result<? extends ExternalProcessResult> pcompResult = null; | ||
1013 | 89 | File envStgFile = null; | ||
1014 | 90 | if (envFile.getName().endsWith(".g")) { | ||
1015 | 91 | envStgFile = envFile; | ||
1016 | 92 | } else { | ||
1017 | 93 | STG envStg = (STG)framework.loadFile(envFile).getMathModel(); | ||
1018 | 94 | Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG); | ||
1019 | 95 | envStgFile = new File(workingDirectory, "env.g"); | ||
1020 | 96 | ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath()); | ||
1021 | 97 | Result<? extends Object> envExportResult = framework.getTaskManager().execute( | ||
1022 | 98 | envExportTask, "Exporting environment .g", subtaskMonitor); | ||
1023 | 99 | |||
1024 | 100 | if (envExportResult.getOutcome() != Outcome.FINISHED) { | ||
1025 | 101 | if (envExportResult.getOutcome() == Outcome.CANCELLED) { | ||
1026 | 102 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | ||
1027 | 103 | } | ||
1028 | 104 | return new Result<MpsatChainResult>(Outcome.FAILED, | ||
1029 | 105 | new MpsatChainResult(envExportResult, null, null, null, toolchainPreparationSettings)); | ||
1030 | 106 | } | ||
1031 | 107 | } | ||
1032 | 108 | monitor.progressUpdate(0.40); | ||
1033 | 109 | |||
1034 | 110 | // Generating .g for the whole system (model and environment) | ||
1035 | 111 | File stgFile = new File(workingDirectory, "system.g"); | ||
1036 | 112 | PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, ConversionMode.OUTPUT, true, false, workingDirectory); | ||
1037 | 113 | pcompResult = framework.getTaskManager().execute( | ||
1038 | 114 | pcompTask, "Running pcomp", subtaskMonitor); | ||
1039 | 115 | |||
1040 | 116 | if (pcompResult.getOutcome() != Outcome.FINISHED) { | ||
1041 | 117 | if (pcompResult.getOutcome() == Outcome.CANCELLED) { | ||
1042 | 118 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | ||
1043 | 119 | } | ||
1044 | 120 | return new Result<MpsatChainResult>(Outcome.FAILED, | ||
1045 | 121 | new MpsatChainResult(devExportResult, pcompResult, null, null, toolchainPreparationSettings)); | ||
1046 | 122 | } | ||
1047 | 123 | FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput())); | ||
1048 | 124 | WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true); | ||
1049 | 125 | STG stg = (STG)stgWorkspaceEntry.getModelEntry().getMathModel(); | ||
1050 | 126 | monitor.progressUpdate(0.50); | ||
1051 | 127 | |||
1052 | 128 | // Generate unfolding | ||
1053 | 129 | File unfoldingFile = new File(workingDirectory, "system" + MpsatUtilitySettings.getUnfoldingExtension()); | ||
1054 | 130 | PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); | ||
1055 | 131 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( | ||
1056 | 132 | punfTask, "Unfolding .g", subtaskMonitor); | ||
1057 | 133 | |||
1058 | 134 | if (punfResult.getOutcome() != Outcome.FINISHED) { | ||
1059 | 135 | if (punfResult.getOutcome() == Outcome.CANCELLED) { | ||
1060 | 136 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | ||
1061 | 137 | } | ||
1062 | 138 | return new Result<MpsatChainResult>(Outcome.FAILED, | ||
1063 | 139 | new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainPreparationSettings)); | ||
1064 | 140 | } | ||
1065 | 141 | monitor.progressUpdate(0.60); | ||
1066 | 142 | |||
1067 | 143 | // Check for interface conformation | ||
1068 | 144 | Set<String> devOutputNames = devStg.getSignalFlatNames(Type.OUTPUT); | ||
1069 | 145 | Set<String> devPlaceNames = parsePlaceNames(pcompResult.getReturnValue().getOutputFile("places.list"), 0); | ||
1070 | 146 | // String reachConformation = MpsatSettings.genReachConformation(devOutputNames, devPlaceNames); | ||
1071 | 147 | String reachConformation = MpsatSettings.genReachConformationDetail(stg, devOutputNames, devPlaceNames); | ||
1072 | 148 | if (MpsatUtilitySettings.getDebugReach()) { | ||
1073 | 149 | System.out.println("\nReach expression for the interface conformation property:"); | ||
1074 | 150 | System.out.println(reachConformation); | ||
1075 | 151 | } | ||
1076 | 152 | MpsatSettings conformationSettings = new MpsatSettings("Interface conformation", | ||
1077 | 153 | MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), | ||
1078 | 154 | MpsatUtilitySettings.getSolutionCount(), reachConformation); | ||
1079 | 155 | |||
1080 | 156 | MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), | ||
1081 | 157 | unfoldingFile.getCanonicalPath(), workingDirectory); | ||
1082 | 158 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( | ||
1083 | 159 | mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); | ||
1084 | 160 | |||
1085 | 161 | if (mpsatConformationResult.getOutcome() != Outcome.FINISHED) { | ||
1086 | 162 | if (mpsatConformationResult.getOutcome() == Outcome.CANCELLED) { | ||
1087 | 163 | return new Result<MpsatChainResult>(Outcome.CANCELLED); | ||
1088 | 164 | } | ||
1089 | 165 | return new Result<MpsatChainResult>(Outcome.FAILED, | ||
1090 | 166 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings)); | ||
1091 | 167 | } | ||
1092 | 168 | monitor.progressUpdate(0.80); | ||
1093 | 169 | |||
1094 | 170 | MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue()); | ||
1095 | 171 | if (!mpsatConformationParser.getSolutions().isEmpty()) { | ||
1096 | 172 | return new Result<MpsatChainResult>(Outcome.FINISHED, | ||
1097 | 173 | new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings, | ||
1098 | 174 | "This model does not conform to the environment after the following trace:")); | ||
1099 | 175 | } | ||
1100 | 176 | monitor.progressUpdate(1.0); | ||
1101 | 177 | |||
1102 | 178 | // Success | ||
1103 | 179 | unfoldingFile.delete(); | ||
1104 | 180 | String message = "The model conforms to its environment (" + envFile.getName() + ")."; | ||
1105 | 181 | return new Result<MpsatChainResult>(Outcome.FINISHED, | ||
1106 | 182 | new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message)); | ||
1107 | 183 | |||
1108 | 184 | } catch (Throwable e) { | ||
1109 | 185 | return new Result<MpsatChainResult>(e); | ||
1110 | 186 | } finally { | ||
1111 | 187 | if ((workingDirectory != null) && !MpsatUtilitySettings.getDebugTemporaryFiles()) { | ||
1112 | 188 | FileUtils.deleteDirectoryTree(workingDirectory); | ||
1113 | 189 | } | ||
1114 | 190 | } | ||
1115 | 191 | } | ||
1116 | 192 | |||
1117 | 193 | |||
1118 | 194 | private HashSet<String> parsePlaceNames(byte[] bufferedInput, int lineIndex) { | ||
1119 | 195 | HashSet<String> result = new HashSet<String>(); | ||
1120 | 196 | InputStream is = new ByteArrayInputStream(bufferedInput); | ||
1121 | 197 | BufferedReader br = new BufferedReader(new InputStreamReader(is)); | ||
1122 | 198 | try { | ||
1123 | 199 | String line = null; | ||
1124 | 200 | while ((lineIndex >= 0) && ((line = br.readLine()) != null)) { | ||
1125 | 201 | lineIndex--; | ||
1126 | 202 | } | ||
1127 | 203 | if (line != null) { | ||
1128 | 204 | for (String name: line.trim().split("\\s")) { | ||
1129 | 205 | result.add(name); | ||
1130 | 206 | } | ||
1131 | 207 | } | ||
1132 | 208 | } catch (IOException e) { | ||
1133 | 209 | e.printStackTrace(); | ||
1134 | 210 | } | ||
1135 | 211 | return result; | ||
1136 | 212 | } | ||
1137 | 213 | |||
1138 | 214 | |||
1139 | 215 | } | ||
1140 | 0 | 216 | ||
1141 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java' | |||
1142 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2014-11-13 00:05:09 +0000 | |||
1143 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2014-11-30 23:14:46 +0000 | |||
1144 | @@ -16,12 +16,21 @@ | |||
1145 | 16 | import org.workcraft.util.FileUtils; | 16 | import org.workcraft.util.FileUtils; |
1146 | 17 | 17 | ||
1147 | 18 | public class MpsatTask implements Task<ExternalProcessResult> { | 18 | public class MpsatTask implements Task<ExternalProcessResult> { |
1151 | 19 | private String[] args; | 19 | private final String[] args; |
1152 | 20 | private String inputFileName; | 20 | private final String inputFileName; |
1153 | 21 | 21 | private final File workingDirectory; | |
1154 | 22 | |||
1155 | 22 | public MpsatTask(String[] args, String inputFileName) { | 23 | public MpsatTask(String[] args, String inputFileName) { |
1156 | 24 | this(args, inputFileName, null); | ||
1157 | 25 | } | ||
1158 | 26 | |||
1159 | 27 | public MpsatTask(String[] args, String inputFileName, File workingDirectory) { | ||
1160 | 23 | this.args = args; | 28 | this.args = args; |
1161 | 24 | this.inputFileName = inputFileName; | 29 | this.inputFileName = inputFileName; |
1162 | 30 | if (workingDirectory == null) { | ||
1163 | 31 | workingDirectory = FileUtils.createTempDirectory("mpsat_"); | ||
1164 | 32 | } | ||
1165 | 33 | this.workingDirectory = workingDirectory; | ||
1166 | 25 | } | 34 | } |
1167 | 26 | 35 | ||
1168 | 27 | @Override | 36 | @Override |
1169 | @@ -43,23 +52,20 @@ | |||
1170 | 43 | // Input file argument | 52 | // Input file argument |
1171 | 44 | command.add(inputFileName); | 53 | command.add(inputFileName); |
1172 | 45 | 54 | ||
1176 | 46 | File workingDir = FileUtils.createTempDirectory("mpsat_"); | 55 | ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, workingDirectory); |
1174 | 47 | ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, workingDir); | ||
1175 | 48 | |||
1177 | 49 | Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor); | 56 | Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor); |
1180 | 50 | 57 | if(res.getOutcome() == Outcome.CANCELLED) { | |
1179 | 51 | if(res.getOutcome() == Outcome.CANCELLED) | ||
1181 | 52 | return res; | 58 | return res; |
1182 | 59 | } | ||
1183 | 53 | 60 | ||
1184 | 54 | Map<String, byte[]> outputFiles = new HashMap<String, byte[]>(); | 61 | Map<String, byte[]> outputFiles = new HashMap<String, byte[]>(); |
1185 | 55 | |||
1186 | 56 | try { | 62 | try { |
1187 | 57 | String unfoldingFileName = "mpsat" + MpsatUtilitySettings.getUnfoldingExtension(); | 63 | String unfoldingFileName = "mpsat" + MpsatUtilitySettings.getUnfoldingExtension(); |
1189 | 58 | File unfoldingFile = new File(workingDir, unfoldingFileName); | 64 | File unfoldingFile = new File(workingDirectory, unfoldingFileName); |
1190 | 59 | if(unfoldingFile.exists()) { | 65 | if(unfoldingFile.exists()) { |
1191 | 60 | outputFiles.put(unfoldingFileName, FileUtils.readAllBytes(unfoldingFile)); | 66 | outputFiles.put(unfoldingFileName, FileUtils.readAllBytes(unfoldingFile)); |
1192 | 61 | } | 67 | } |
1194 | 62 | File g = new File(workingDir, "mpsat.g"); | 68 | File g = new File(workingDirectory, "mpsat.g"); |
1195 | 63 | if(g.exists()) { | 69 | if(g.exists()) { |
1196 | 64 | outputFiles.put("mpsat.g", FileUtils.readAllBytes(g)); | 70 | outputFiles.put("mpsat.g", FileUtils.readAllBytes(g)); |
1197 | 65 | } | 71 | } |
1198 | @@ -69,10 +75,11 @@ | |||
1199 | 69 | 75 | ||
1200 | 70 | ExternalProcessResult retVal = res.getReturnValue(); | 76 | ExternalProcessResult retVal = res.getReturnValue(); |
1201 | 71 | ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles); | 77 | ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles); |
1204 | 72 | 78 | if (retVal.getReturnCode() < 2) { | |
1203 | 73 | if (retVal.getReturnCode() < 2) | ||
1205 | 74 | return Result.finished(result); | 79 | return Result.finished(result); |
1207 | 75 | else | 80 | } else { |
1208 | 76 | return Result.failed(result); | 81 | return Result.failed(result); |
1209 | 82 | } | ||
1210 | 77 | } | 83 | } |
1211 | 78 | } | ||
1212 | 79 | \ No newline at end of file | 84 | \ No newline at end of file |
1213 | 85 | |||
1214 | 86 | } | ||
1215 | 80 | 87 | ||
1216 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java' | |||
1217 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java 2014-06-20 21:35:25 +0000 | |||
1218 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java 2014-11-30 23:14:46 +0000 | |||
1219 | @@ -22,15 +22,19 @@ | |||
1220 | 22 | 22 | ||
1221 | 23 | @Override | 23 | @Override |
1222 | 24 | public final void run(WorkspaceEntry we) { | 24 | public final void run(WorkspaceEntry we) { |
1223 | 25 | final MpsatSettings settings = getSettings(); | ||
1224 | 26 | final MpsatChainTask mpsatTask = new MpsatChainTask(we, settings, framework); | ||
1225 | 27 | |||
1226 | 25 | String description = "MPSat tool chain"; | 28 | String description = "MPSat tool chain"; |
1227 | 26 | String title = we.getModelEntry().getModel().getTitle(); | 29 | String title = we.getModelEntry().getModel().getTitle(); |
1228 | 27 | if (!title.isEmpty()) { | 30 | if (!title.isEmpty()) { |
1229 | 28 | description += "(" + title +")"; | 31 | description += "(" + title +")"; |
1230 | 29 | } | 32 | } |
1233 | 30 | final MpsatChainTask mpsatTask = new MpsatChainTask(we, getSettings(), framework); | 33 | MpsatChainResultHandler monitor = new MpsatChainResultHandler(mpsatTask); |
1234 | 31 | framework.getTaskManager().queue(mpsatTask, description, new MpsatChainResultHandler(mpsatTask)); | 34 | |
1235 | 35 | framework.getTaskManager().queue(mpsatTask, description, monitor); | ||
1236 | 32 | } | 36 | } |
1238 | 33 | 37 | ||
1239 | 34 | @Override | 38 | @Override |
1240 | 35 | public abstract String getDisplayName(); | 39 | public abstract String getDisplayName(); |
1241 | 36 | 40 | ||
1242 | 37 | 41 | ||
1243 | === added file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java' | |||
1244 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java 1970-01-01 00:00:00 +0000 | |||
1245 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java 2014-11-30 23:14:46 +0000 | |||
1246 | @@ -0,0 +1,56 @@ | |||
1247 | 1 | package org.workcraft.plugins.mpsat.tools; | ||
1248 | 2 | |||
1249 | 3 | import java.io.File; | ||
1250 | 4 | |||
1251 | 5 | import javax.swing.JFileChooser; | ||
1252 | 6 | |||
1253 | 7 | import org.workcraft.Framework; | ||
1254 | 8 | import org.workcraft.Tool; | ||
1255 | 9 | import org.workcraft.plugins.mpsat.MpsatChainResultHandler; | ||
1256 | 10 | import org.workcraft.plugins.mpsat.tasks.MpsatConformationTask; | ||
1257 | 11 | import org.workcraft.plugins.stg.STGModel; | ||
1258 | 12 | import org.workcraft.util.WorkspaceUtils; | ||
1259 | 13 | import org.workcraft.workspace.WorkspaceEntry; | ||
1260 | 14 | |||
1261 | 15 | public class MpsatConformationChecker implements Tool { | ||
1262 | 16 | private final Framework framework; | ||
1263 | 17 | |||
1264 | 18 | public MpsatConformationChecker(Framework framework) { | ||
1265 | 19 | this.framework = framework; | ||
1266 | 20 | } | ||
1267 | 21 | |||
1268 | 22 | @Override | ||
1269 | 23 | public String getSection() { | ||
1270 | 24 | return "Verification"; | ||
1271 | 25 | } | ||
1272 | 26 | |||
1273 | 27 | @Override | ||
1274 | 28 | public String getDisplayName() { | ||
1275 | 29 | return "Check for conformation (without dummies) [MPSat]..."; | ||
1276 | 30 | } | ||
1277 | 31 | |||
1278 | 32 | @Override | ||
1279 | 33 | public boolean isApplicableTo(WorkspaceEntry we) { | ||
1280 | 34 | return WorkspaceUtils.canHas(we, STGModel.class); | ||
1281 | 35 | } | ||
1282 | 36 | |||
1283 | 37 | @Override | ||
1284 | 38 | public final void run(WorkspaceEntry we) { | ||
1285 | 39 | JFileChooser fc = framework.getMainWindow().createOpenDialog("Open environment file", false, null); | ||
1286 | 40 | if (fc.showDialog(null, "Open") == JFileChooser.APPROVE_OPTION) { | ||
1287 | 41 | File file = fc.getSelectedFile(); | ||
1288 | 42 | if (framework.checkFile(file)) { | ||
1289 | 43 | final MpsatConformationTask mpsatTask = new MpsatConformationTask(we, framework, file); | ||
1290 | 44 | |||
1291 | 45 | String description = "MPSat tool chain"; | ||
1292 | 46 | String title = we.getModelEntry().getModel().getTitle(); | ||
1293 | 47 | if (!title.isEmpty()) { | ||
1294 | 48 | description += "(" + title +")"; | ||
1295 | 49 | } | ||
1296 | 50 | MpsatChainResultHandler monitor = new MpsatChainResultHandler(mpsatTask); | ||
1297 | 51 | |||
1298 | 52 | framework.getTaskManager().queue(mpsatTask, description, monitor); | ||
1299 | 53 | } | ||
1300 | 54 | } | ||
1301 | 55 | } | ||
1302 | 56 | } | ||
1303 | 0 | 57 | ||
1304 | === renamed file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/CustomPropertyMpsatChecker.java' => 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatCustomPropertyChecker.java' | |||
1305 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/CustomPropertyMpsatChecker.java 2014-04-16 21:55:15 +0000 | |||
1306 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatCustomPropertyChecker.java 2014-11-30 23:14:46 +0000 | |||
1307 | @@ -15,9 +15,9 @@ | |||
1308 | 15 | import org.workcraft.util.WorkspaceUtils; | 15 | import org.workcraft.util.WorkspaceUtils; |
1309 | 16 | import org.workcraft.workspace.WorkspaceEntry; | 16 | import org.workcraft.workspace.WorkspaceEntry; |
1310 | 17 | 17 | ||
1312 | 18 | public class CustomPropertyMpsatChecker implements Tool { | 18 | public class MpsatCustomPropertyChecker implements Tool { |
1313 | 19 | 19 | ||
1315 | 20 | public CustomPropertyMpsatChecker(Framework framework) { | 20 | public MpsatCustomPropertyChecker(Framework framework) { |
1316 | 21 | this.framework = framework; | 21 | this.framework = framework; |
1317 | 22 | } | 22 | } |
1318 | 23 | 23 | ||
1319 | 24 | 24 | ||
1320 | === removed file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java' | |||
1321 | --- MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java 2010-10-06 15:51:01 +0000 | |||
1322 | +++ MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java 1970-01-01 00:00:00 +0000 | |||
1323 | @@ -1,7 +0,0 @@ | |||
1324 | 1 | package org.workcraft.plugins.pcomp; | ||
1325 | 2 | |||
1326 | 3 | public enum PCompOutputMode { | ||
1327 | 4 | DUMMY, | ||
1328 | 5 | INTERNAL, | ||
1329 | 6 | OUTPUT | ||
1330 | 7 | } | ||
1331 | 8 | 0 | ||
1332 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java' | |||
1333 | --- MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java 2014-09-05 15:06:01 +0000 | |||
1334 | +++ MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java 2014-11-30 23:14:46 +0000 | |||
1335 | @@ -22,7 +22,7 @@ | |||
1336 | 22 | import org.workcraft.gui.trees.TreeWindow; | 22 | import org.workcraft.gui.trees.TreeWindow; |
1337 | 23 | import org.workcraft.gui.workspace.Path; | 23 | import org.workcraft.gui.workspace.Path; |
1338 | 24 | import org.workcraft.gui.workspace.WorkspaceChooser; | 24 | import org.workcraft.gui.workspace.WorkspaceChooser; |
1340 | 25 | import org.workcraft.plugins.pcomp.PCompOutputMode; | 25 | import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode; |
1341 | 26 | import org.workcraft.plugins.stg.STGWorkspaceFilter; | 26 | import org.workcraft.plugins.stg.STGWorkspaceFilter; |
1342 | 27 | 27 | ||
1343 | 28 | @SuppressWarnings("serial") | 28 | @SuppressWarnings("serial") |
1344 | @@ -62,14 +62,13 @@ | |||
1345 | 62 | return improvedPcomp.isSelected(); | 62 | return improvedPcomp.isSelected(); |
1346 | 63 | } | 63 | } |
1347 | 64 | 64 | ||
1350 | 65 | public PCompOutputMode getMode() | 65 | public ConversionMode getMode() { |
1349 | 66 | { | ||
1351 | 67 | if (leaveOutputs.isSelected()) | 66 | if (leaveOutputs.isSelected()) |
1353 | 68 | return PCompOutputMode.OUTPUT; | 67 | return ConversionMode.OUTPUT; |
1354 | 69 | if (internalize.isSelected()) | 68 | if (internalize.isSelected()) |
1356 | 70 | return PCompOutputMode.INTERNAL; | 69 | return ConversionMode.INTERNAL; |
1357 | 71 | if (dummify.isSelected()) | 70 | if (dummify.isSelected()) |
1359 | 72 | return PCompOutputMode.DUMMY; | 71 | return ConversionMode.DUMMY; |
1360 | 73 | throw new NotSupportedException("No button is selected. Cannot proceed."); | 72 | throw new NotSupportedException("No button is selected. Cannot proceed."); |
1361 | 74 | } | 73 | } |
1362 | 75 | 74 | ||
1363 | 76 | 75 | ||
1364 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java' | |||
1365 | --- MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2014-09-05 15:06:01 +0000 | |||
1366 | +++ MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2014-11-30 23:14:46 +0000 | |||
1367 | @@ -3,28 +3,38 @@ | |||
1368 | 3 | import java.io.File; | 3 | import java.io.File; |
1369 | 4 | import java.io.IOException; | 4 | import java.io.IOException; |
1370 | 5 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
1371 | 6 | import java.util.HashMap; | ||
1372 | 7 | import java.util.Map; | ||
1373 | 6 | 8 | ||
1374 | 7 | import org.workcraft.plugins.pcomp.PCompOutputMode; | ||
1375 | 8 | import org.workcraft.plugins.pcomp.PcompUtilitySettings; | 9 | import org.workcraft.plugins.pcomp.PcompUtilitySettings; |
1376 | 9 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; | 10 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
1377 | 10 | import org.workcraft.plugins.shared.tasks.ExternalProcessTask; | 11 | import org.workcraft.plugins.shared.tasks.ExternalProcessTask; |
1378 | 11 | import org.workcraft.tasks.ProgressMonitor; | 12 | import org.workcraft.tasks.ProgressMonitor; |
1379 | 12 | import org.workcraft.tasks.Result; | 13 | import org.workcraft.tasks.Result; |
1380 | 14 | import org.workcraft.tasks.Result.Outcome; | ||
1381 | 13 | import org.workcraft.tasks.Task; | 15 | import org.workcraft.tasks.Task; |
1382 | 14 | import org.workcraft.tasks.Result.Outcome; | ||
1383 | 15 | import org.workcraft.util.FileUtils; | 16 | import org.workcraft.util.FileUtils; |
1384 | 16 | 17 | ||
1385 | 17 | public class PcompTask implements Task<ExternalProcessResult> { | 18 | public class PcompTask implements Task<ExternalProcessResult> { |
1396 | 18 | private File[] inputs; | 19 | |
1397 | 19 | private final PCompOutputMode mode; | 20 | public enum ConversionMode { |
1398 | 20 | private final boolean sharedOutputs; | 21 | DUMMY, |
1399 | 21 | private final boolean improved; | 22 | INTERNAL, |
1400 | 22 | 23 | OUTPUT | |
1401 | 23 | public PcompTask(File[] inputs, PCompOutputMode mode, boolean sharedOutputs, boolean improved) { | 24 | } |
1402 | 24 | this.inputs = inputs; | 25 | |
1403 | 25 | this.mode = mode; | 26 | private final File[] inputFiles; |
1404 | 26 | this.sharedOutputs = sharedOutputs; | 27 | private final ConversionMode conversionMode; |
1405 | 27 | this.improved = improved; | 28 | private final boolean useSharedOutputs; |
1406 | 29 | private final boolean useImprovedComposition; | ||
1407 | 30 | private final File workingDirectory; | ||
1408 | 31 | |||
1409 | 32 | public PcompTask(File[] inputFiles, ConversionMode conversionMode, boolean useSharedOutputs, boolean useImprovedComposition, File workingDirectory) { | ||
1410 | 33 | this.inputFiles = inputFiles; | ||
1411 | 34 | this.conversionMode = conversionMode; | ||
1412 | 35 | this.useSharedOutputs = useSharedOutputs; | ||
1413 | 36 | this.useImprovedComposition = useImprovedComposition; | ||
1414 | 37 | this.workingDirectory = workingDirectory; | ||
1415 | 28 | } | 38 | } |
1416 | 29 | 39 | ||
1417 | 30 | @Override | 40 | @Override |
1418 | @@ -38,60 +48,58 @@ | |||
1419 | 38 | } | 48 | } |
1420 | 39 | } | 49 | } |
1421 | 40 | 50 | ||
1423 | 41 | if (mode == PCompOutputMode.DUMMY) { | 51 | if (conversionMode == ConversionMode.DUMMY) { |
1424 | 42 | command.add("-d"); | 52 | command.add("-d"); |
1425 | 43 | command.add("-r"); | 53 | command.add("-r"); |
1429 | 44 | } | 54 | } else if (conversionMode == ConversionMode.INTERNAL) { |
1427 | 45 | |||
1428 | 46 | if (mode == PCompOutputMode.INTERNAL) { | ||
1430 | 47 | command.add("-i"); | 55 | command.add("-i"); |
1431 | 48 | } | 56 | } |
1432 | 49 | 57 | ||
1434 | 50 | if (sharedOutputs) { | 58 | if (useSharedOutputs) { |
1435 | 51 | command.add("-o"); | 59 | command.add("-o"); |
1436 | 52 | } | 60 | } |
1437 | 53 | 61 | ||
1439 | 54 | if (improved) { | 62 | if (useImprovedComposition) { |
1440 | 55 | command.add("-p"); | 63 | command.add("-p"); |
1441 | 56 | } | 64 | } |
1442 | 57 | 65 | ||
1445 | 58 | File listFile; | 66 | File listFile = null; |
1444 | 59 | |||
1446 | 60 | try { | 67 | try { |
1448 | 61 | listFile = File.createTempFile("pcomp_", ".list"); | 68 | if (workingDirectory == null) { |
1449 | 69 | listFile = File.createTempFile("places_", ".list"); | ||
1450 | 70 | } else { | ||
1451 | 71 | listFile = new File(workingDirectory, "places.list"); | ||
1452 | 72 | } | ||
1453 | 62 | } catch (IOException e) { | 73 | } catch (IOException e) { |
1454 | 63 | return Result.exception(e); | 74 | return Result.exception(e); |
1455 | 64 | } | 75 | } |
1456 | 76 | command.add("-l" + listFile.getAbsolutePath()); | ||
1457 | 77 | |||
1458 | 78 | for (File inputFile: inputFiles) { | ||
1459 | 79 | command.add(inputFile.getAbsolutePath()); | ||
1460 | 80 | } | ||
1461 | 65 | 81 | ||
1492 | 66 | try | 82 | Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command, new File(".")).run(monitor); |
1493 | 67 | { | 83 | if (res.getOutcome() != Outcome.FINISHED) { |
1494 | 68 | StringBuilder fileList = new StringBuilder(); | 84 | return res; |
1495 | 69 | for (File f : inputs) | 85 | } |
1496 | 70 | { | 86 | |
1497 | 71 | fileList.append(f.getAbsolutePath()); | 87 | Map<String, byte[]> outputFiles = new HashMap<String, byte[]>(); |
1498 | 72 | fileList.append('\n'); | 88 | try { |
1499 | 73 | } | 89 | if(listFile.exists()) { |
1500 | 74 | 90 | outputFiles.put("places.list", FileUtils.readAllBytes(listFile)); | |
1501 | 75 | try { | 91 | } |
1502 | 76 | FileUtils.writeAllText(listFile, fileList.toString()); | 92 | } catch (IOException e) { |
1503 | 77 | } catch (IOException e) { | 93 | return new Result<ExternalProcessResult>(e); |
1504 | 78 | return Result.exception(e); | 94 | } |
1505 | 79 | } | 95 | |
1506 | 80 | 96 | ExternalProcessResult retVal = res.getReturnValue(); | |
1507 | 81 | command.add("@"+listFile.getAbsolutePath()); | 97 | ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles); |
1508 | 82 | 98 | if (retVal.getReturnCode() < 2) { | |
1509 | 83 | Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command, new File(".")).run(monitor); | 99 | return Result.finished(result); |
1510 | 84 | if (res.getOutcome() != Outcome.FINISHED) | 100 | } else { |
1511 | 85 | return res; | 101 | return Result.failed(result); |
1512 | 86 | 102 | } | |
1513 | 87 | ExternalProcessResult retVal = res.getReturnValue(); | 103 | |
1484 | 88 | if (retVal.getReturnCode() < 2) | ||
1485 | 89 | return Result.finished(retVal); | ||
1486 | 90 | else | ||
1487 | 91 | return Result.failed(retVal); | ||
1488 | 92 | } | ||
1489 | 93 | finally { | ||
1490 | 94 | listFile.delete(); | ||
1491 | 95 | } | ||
1514 | 96 | } | 104 | } |
1515 | 97 | } | 105 | } |
1516 | 98 | \ No newline at end of file | 106 | \ No newline at end of file |
1517 | 99 | 107 | ||
1518 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java' | |||
1519 | --- MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java 2014-09-05 15:06:01 +0000 | |||
1520 | +++ MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java 2014-11-30 23:14:46 +0000 | |||
1521 | @@ -46,7 +46,7 @@ | |||
1522 | 46 | } | 46 | } |
1523 | 47 | 47 | ||
1524 | 48 | PcompTask pcompTask = new PcompTask(inputs.toArray(new File[0]), dialog.getMode(), | 48 | PcompTask pcompTask = new PcompTask(inputs.toArray(new File[0]), dialog.getMode(), |
1526 | 49 | dialog.isSharedOutputsChecked(), dialog.isImprovedPcompChecked()); | 49 | dialog.isSharedOutputsChecked(), dialog.isImprovedPcompChecked(), null); |
1527 | 50 | 50 | ||
1528 | 51 | PcompResultHandler pcompResult = new PcompResultHandler(framework, dialog.showInEditor()); | 51 | PcompResultHandler pcompResult = new PcompResultHandler(framework, dialog.showInEditor()); |
1529 | 52 | 52 | ||
1530 | 53 | 53 | ||
1531 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/STG.java' | |||
1532 | --- STGPlugin/src/org/workcraft/plugins/stg/STG.java 2014-11-03 18:11:53 +0000 | |||
1533 | +++ STGPlugin/src/org/workcraft/plugins/stg/STG.java 2014-11-30 23:14:46 +0000 | |||
1534 | @@ -213,6 +213,16 @@ | |||
1535 | 213 | } | 213 | } |
1536 | 214 | }); | 214 | }); |
1537 | 215 | } | 215 | } |
1538 | 216 | |||
1539 | 217 | public Set<String> getSignalFlatNames(Type type) { | ||
1540 | 218 | Set<String> result = new HashSet<String>(); | ||
1541 | 219 | for (SignalTransition st : getSignalTransitions(type)) { | ||
1542 | 220 | String ref = getSignalReference(st); | ||
1543 | 221 | String flatName = NamespaceHelper.hierarchicalToFlatName(ref); | ||
1544 | 222 | result.add(flatName); | ||
1545 | 223 | } | ||
1546 | 224 | return result; | ||
1547 | 225 | } | ||
1548 | 216 | 226 | ||
1549 | 217 | @Override | 227 | @Override |
1550 | 218 | public Set<String> getSignalReferences(Type type) { | 228 | public Set<String> getSignalReferences(Type type) { |
1551 | @@ -359,8 +369,8 @@ | |||
1552 | 359 | throw new RuntimeException("An implicit place cannot have more that one transition in its preset or postset."); | 369 | throw new RuntimeException("An implicit place cannot have more that one transition in its preset or postset."); |
1553 | 360 | } | 370 | } |
1554 | 361 | 371 | ||
1557 | 362 | return "<" + NamespaceHelper.getFlatName(referenceManager.getNodeReference(null, preset.iterator().next())) | 372 | return "<" + NamespaceHelper.hierarchicalToFlatName(referenceManager.getNodeReference(null, preset.iterator().next())) |
1558 | 363 | + "," + NamespaceHelper.getFlatName(referenceManager.getNodeReference(null, postset.iterator().next())) + ">"; | 373 | + "," + NamespaceHelper.hierarchicalToFlatName(referenceManager.getNodeReference(null, postset.iterator().next())) + ">"; |
1559 | 364 | } | 374 | } |
1560 | 365 | } | 375 | } |
1561 | 366 | return super.getNodeReference(provider, node); | 376 | return super.getNodeReference(provider, node); |
1562 | @@ -369,27 +379,27 @@ | |||
1563 | 369 | @Override | 379 | @Override |
1564 | 370 | public Node getNodeByReference(NamespaceProvider provider, String reference) { | 380 | public Node getNodeByReference(NamespaceProvider provider, String reference) { |
1565 | 371 | Pair<String, String> implicitPlaceTransitions = LabelParser.parseImplicitPlaceReference(reference); | 381 | Pair<String, String> implicitPlaceTransitions = LabelParser.parseImplicitPlaceReference(reference); |
1566 | 372 | |||
1567 | 373 | if (implicitPlaceTransitions != null) { | 382 | if (implicitPlaceTransitions != null) { |
1568 | 374 | Node t1 = referenceManager.getNodeByReference(provider, | 383 | Node t1 = referenceManager.getNodeByReference(provider, |
1569 | 375 | NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getFirst()) ); | 384 | NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getFirst()) ); |
1570 | 385 | |||
1571 | 376 | Node t2 = referenceManager.getNodeByReference(provider, | 386 | Node t2 = referenceManager.getNodeByReference(provider, |
1572 | 377 | NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getSecond()) ); | 387 | NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getSecond()) ); |
1579 | 378 | 388 | if ((t1 != null) && (t2 != null)) { | |
1580 | 379 | Set<Node> implicitPlaceCandidates = SetUtils.intersection(getPreset(t2), getPostset(t1)); | 389 | Set<Node> implicitPlaceCandidates = SetUtils.intersection(getPreset(t2), getPostset(t1)); |
1581 | 380 | 390 | ||
1582 | 381 | for (Node node : implicitPlaceCandidates) { | 391 | for (Node node : implicitPlaceCandidates) { |
1583 | 382 | if ((node instanceof STGPlace) && ((STGPlace)node).isImplicit()) { | 392 | if ((node instanceof STGPlace) && ((STGPlace)node).isImplicit()) { |
1584 | 383 | return node; | 393 | return node; |
1585 | 394 | } | ||
1586 | 384 | } | 395 | } |
1587 | 385 | } | 396 | } |
1588 | 386 | |||
1589 | 387 | throw new NotFoundException("Implicit place between " | 397 | throw new NotFoundException("Implicit place between " |
1590 | 388 | + implicitPlaceTransitions.getFirst() + " and " | 398 | + implicitPlaceTransitions.getFirst() + " and " |
1591 | 389 | + implicitPlaceTransitions.getSecond() + " does not exist."); | 399 | + implicitPlaceTransitions.getSecond() + " does not exist."); |
1594 | 390 | } else | 400 | } else { |
1593 | 391 | |||
1595 | 392 | return super.getNodeByReference(provider, reference); | 401 | return super.getNodeByReference(provider, reference); |
1596 | 402 | } | ||
1597 | 393 | } | 403 | } |
1598 | 394 | 404 | ||
1599 | 395 | public void makeExplicit(STGPlace implicitPlace) { | 405 | public void makeExplicit(STGPlace implicitPlace) { |
1600 | 396 | 406 | ||
1601 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java' | |||
1602 | --- STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java 2014-07-28 13:32:42 +0000 | |||
1603 | +++ STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java 2014-11-30 23:14:46 +0000 | |||
1604 | @@ -66,7 +66,7 @@ | |||
1605 | 66 | 66 | ||
1606 | 67 | for (String s : sortedNames) { | 67 | for (String s : sortedNames) { |
1607 | 68 | out.print(" "); | 68 | out.print(" "); |
1609 | 69 | out.print(NamespaceHelper.getFlatName(s)); | 69 | out.print(NamespaceHelper.hierarchicalToFlatName(s)); |
1610 | 70 | } | 70 | } |
1611 | 71 | 71 | ||
1612 | 72 | out.print("\n"); | 72 | out.print("\n"); |
1613 | @@ -90,7 +90,7 @@ | |||
1614 | 90 | return; | 90 | return; |
1615 | 91 | 91 | ||
1616 | 92 | if (model.getPostset(node).size()>0) { | 92 | if (model.getPostset(node).size()>0) { |
1618 | 93 | out.write(NamespaceHelper.getFlatName(model.getNodeReference(node))); | 93 | out.write(NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(node))); |
1619 | 94 | 94 | ||
1620 | 95 | for (Node n : sortNodes (model.getPostset(node), model) ) { | 95 | for (Node n : sortNodes (model.getPostset(node), model) ) { |
1621 | 96 | if (n instanceof STGPlace) { | 96 | if (n instanceof STGPlace) { |
1622 | @@ -98,11 +98,11 @@ | |||
1623 | 98 | Collection<Node> postset = model.getPostset(n); | 98 | Collection<Node> postset = model.getPostset(n); |
1624 | 99 | if (postset.size() > 1) | 99 | if (postset.size() > 1) |
1625 | 100 | throw new FormatException("Implicit place cannot have more than one node in postset"); | 100 | throw new FormatException("Implicit place cannot have more than one node in postset"); |
1627 | 101 | out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(postset.iterator().next()))); | 101 | out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(postset.iterator().next()))); |
1628 | 102 | } else | 102 | } else |
1630 | 103 | out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(n))); | 103 | out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(n))); |
1631 | 104 | } else { | 104 | } else { |
1633 | 105 | out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(n))); | 105 | out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(n))); |
1634 | 106 | } | 106 | } |
1635 | 107 | } | 107 | } |
1636 | 108 | 108 | ||
1637 | @@ -165,12 +165,12 @@ | |||
1638 | 165 | 165 | ||
1639 | 166 | if (p instanceof STGPlace) { | 166 | if (p instanceof STGPlace) { |
1640 | 167 | if ( ((STGPlace)p).isImplicit() ) { | 167 | if ( ((STGPlace)p).isImplicit() ) { |
1643 | 168 | reference = "<" + NamespaceHelper.getFlatName(model.getNodeReference(model.getPreset(p).iterator().next())) + "," + | 168 | reference = "<" + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(model.getPreset(p).iterator().next())) + "," + |
1644 | 169 | NamespaceHelper.getFlatName(model.getNodeReference(model.getPostset(p).iterator().next())) + ">"; | 169 | NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(model.getPostset(p).iterator().next())) + ">"; |
1645 | 170 | } else | 170 | } else |
1647 | 171 | reference = NamespaceHelper.getFlatName(model.getNodeReference(p)); | 171 | reference = NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p)); |
1648 | 172 | } else { | 172 | } else { |
1650 | 173 | reference = NamespaceHelper.getFlatName(model.getNodeReference(p)); | 173 | reference = NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p)); |
1651 | 174 | } | 174 | } |
1652 | 175 | 175 | ||
1653 | 176 | if (tokens == 1) | 176 | if (tokens == 1) |
1654 | @@ -201,7 +201,7 @@ | |||
1655 | 201 | for (Place p : places) { | 201 | for (Place p : places) { |
1656 | 202 | if (p instanceof STGPlace) | 202 | if (p instanceof STGPlace) |
1657 | 203 | if (((STGPlace)p).getCapacity() != 1) | 203 | if (((STGPlace)p).getCapacity() != 1) |
1659 | 204 | capacity.append(" " + NamespaceHelper.getFlatName(model.getNodeReference(p)) + "=" + ((STGPlace)p).getCapacity()); | 204 | capacity.append(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p)) + "=" + ((STGPlace)p).getCapacity()); |
1660 | 205 | } | 205 | } |
1661 | 206 | 206 | ||
1662 | 207 | if (capacity.length() > 0) | 207 | if (capacity.length() > 0) |
1663 | @@ -212,7 +212,7 @@ | |||
1664 | 212 | LinkedList<String> transitions = new LinkedList<String>(); | 212 | LinkedList<String> transitions = new LinkedList<String>(); |
1665 | 213 | 213 | ||
1666 | 214 | for (Transition t : net.getTransitions()) | 214 | for (Transition t : net.getTransitions()) |
1668 | 215 | transitions.add(NamespaceHelper.getFlatName(net.getNodeReference(t))); | 215 | transitions.add(NamespaceHelper.hierarchicalToFlatName(net.getNodeReference(t))); |
1669 | 216 | 216 | ||
1670 | 217 | writeSignalsHeader(out, transitions, ".dummy"); | 217 | writeSignalsHeader(out, transitions, ".dummy"); |
1671 | 218 | 218 | ||
1672 | 219 | 219 | ||
1673 | === modified file 'Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java' | |||
1674 | --- Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java 2014-07-11 09:35:42 +0000 | |||
1675 | +++ Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java 2014-11-30 23:14:46 +0000 | |||
1676 | @@ -68,7 +68,7 @@ | |||
1677 | 68 | String hName = en.getKey(); | 68 | String hName = en.getKey(); |
1678 | 69 | String fName = en.getValue(); | 69 | String fName = en.getValue(); |
1679 | 70 | 70 | ||
1681 | 71 | String answer = NamespaceHelper.getFlatName(hName); | 71 | String answer = NamespaceHelper.hierarchicalToFlatName(hName); |
1682 | 72 | assertTrue(answer.equals(fName)); | 72 | assertTrue(answer.equals(fName)); |
1683 | 73 | 73 | ||
1684 | 74 | hName = hName.replaceAll("'", ""); | 74 | hName = hName.replaceAll("'", ""); |
1685 | 75 | 75 | ||
1686 | === modified file 'WorkcraftCore/src/org/workcraft/Info.java' | |||
1687 | --- WorkcraftCore/src/org/workcraft/Info.java 2014-11-24 15:37:13 +0000 | |||
1688 | +++ WorkcraftCore/src/org/workcraft/Info.java 2014-11-30 23:14:46 +0000 | |||
1689 | @@ -13,7 +13,7 @@ | |||
1690 | 13 | private static final int majorVersion = 3; | 13 | private static final int majorVersion = 3; |
1691 | 14 | private static final int minorVersion = 0; | 14 | private static final int minorVersion = 0; |
1692 | 15 | private static final int revisionVersion = 3; | 15 | private static final int revisionVersion = 3; |
1694 | 16 | private static final String statusVersion = "alpha"; | 16 | private static final String statusVersion = "beta"; |
1695 | 17 | 17 | ||
1696 | 18 | private static final int startYear = 2006; | 18 | private static final int startYear = 2006; |
1697 | 19 | private static final int currentYear = Calendar.getInstance().get(Calendar.YEAR); | 19 | private static final int currentYear = Calendar.getInstance().get(Calendar.YEAR); |
1698 | 20 | 20 | ||
1699 | === modified file 'WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java' | |||
1700 | --- WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java 2014-11-12 18:06:50 +0000 | |||
1701 | +++ WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java 2014-11-30 23:14:46 +0000 | |||
1702 | @@ -23,20 +23,20 @@ | |||
1703 | 23 | // TODO: make it work with the embedded ' characters | 23 | // TODO: make it work with the embedded ' characters |
1704 | 24 | private static Pattern hPattern = Pattern.compile("(/)?(((\\'([^\\']+)\\')|([_A-Za-z][_A-Za-z0-9]*))([\\+\\-\\~])?(/[0-9]+)?)(.*)"); | 24 | private static Pattern hPattern = Pattern.compile("(/)?(((\\'([^\\']+)\\')|([_A-Za-z][_A-Za-z0-9]*))([\\+\\-\\~])?(/[0-9]+)?)(.*)"); |
1705 | 25 | 25 | ||
1708 | 26 | public static String getFlatName(String reference) { | 26 | public static String hierarchicalToFlatName(String reference) { |
1709 | 27 | return getFlatName(reference, flatNameSeparator, true); | 27 | return hierarchicalToFlatName(reference, flatNameSeparator, true); |
1710 | 28 | } | 28 | } |
1711 | 29 | 29 | ||
1713 | 30 | private static String getFlatName(String reference, String flatSeparator, boolean isFirst) { | 30 | private static String hierarchicalToFlatName(String reference, String flatSeparator, boolean suppressLeadingSeparator) { |
1714 | 31 | if (flatSeparator==null) flatSeparator=flatNameSeparator; | 31 | if (flatSeparator==null) flatSeparator=flatNameSeparator; |
1715 | 32 | 32 | ||
1717 | 33 | // do not work with implicit places(?) | 33 | // Do not work with implicit places(?) |
1718 | 34 | if (reference.startsWith("<")) { | 34 | if (reference.startsWith("<")) { |
1719 | 35 | return reference; | 35 | return reference; |
1720 | 36 | } | 36 | } |
1721 | 37 | String ret = ""; | 37 | String ret = ""; |
1724 | 38 | // in this version the first separator is not shown | 38 | // In this version the first separator is suppressed |
1725 | 39 | if (!isFirst && reference.startsWith(hierarchySeparator)) { | 39 | if (!suppressLeadingSeparator && reference.startsWith(hierarchySeparator)) { |
1726 | 40 | ret=flatSeparator; | 40 | ret=flatSeparator; |
1727 | 41 | } | 41 | } |
1728 | 42 | 42 | ||
1729 | @@ -45,11 +45,11 @@ | |||
1730 | 45 | if (tail.equals("")) { | 45 | if (tail.equals("")) { |
1731 | 46 | return ret+head; | 46 | return ret+head; |
1732 | 47 | } | 47 | } |
1734 | 48 | return ret+head+getFlatName(tail, flatSeparator, false); | 48 | return ret + head + hierarchicalToFlatName(tail, flatSeparator, false); |
1735 | 49 | } | 49 | } |
1736 | 50 | 50 | ||
1739 | 51 | public static String flatToHierarchicalName(String reference) { | 51 | public static String flatToHierarchicalName(String flatName) { |
1740 | 52 | return flatToHierarchicalName(reference, flatNameSeparator); | 52 | return flatToHierarchicalName(flatName, flatNameSeparator); |
1741 | 53 | } | 53 | } |
1742 | 54 | 54 | ||
1743 | 55 | private static String flatToHierarchicalName(String reference, String flatSeparator) { | 55 | private static String flatToHierarchicalName(String reference, String flatSeparator) { |
1744 | 56 | 56 | ||
1745 | === modified file 'WorkcraftCore/src/org/workcraft/gui/MainWindow.java' | |||
1746 | --- WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2014-11-24 17:04:15 +0000 | |||
1747 | +++ WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2014-11-30 23:14:46 +0000 | |||
1748 | @@ -833,7 +833,7 @@ | |||
1749 | 833 | } | 833 | } |
1750 | 834 | } | 834 | } |
1751 | 835 | 835 | ||
1753 | 836 | private JFileChooser createOpenDialog(String title, boolean multiSelection, Importer[] importers) { | 836 | public JFileChooser createOpenDialog(String title, boolean multiSelection, Importer[] importers) { |
1754 | 837 | JFileChooser fc = new JFileChooser(); | 837 | JFileChooser fc = new JFileChooser(); |
1755 | 838 | fc.setDialogType(JFileChooser.OPEN_DIALOG); | 838 | fc.setDialogType(JFileChooser.OPEN_DIALOG); |
1756 | 839 | fc.setMultiSelectionEnabled(multiSelection); | 839 | fc.setMultiSelectionEnabled(multiSelection); |
1757 | @@ -856,7 +856,7 @@ | |||
1758 | 856 | return fc; | 856 | return fc; |
1759 | 857 | } | 857 | } |
1760 | 858 | 858 | ||
1762 | 859 | private JFileChooser createSaveDialog(String title, File file, Exporter exporter) { | 859 | public JFileChooser createSaveDialog(String title, File file, Exporter exporter) { |
1763 | 860 | JFileChooser fc = new JFileChooser(); | 860 | JFileChooser fc = new JFileChooser(); |
1764 | 861 | fc.setDialogType(JFileChooser.SAVE_DIALOG); | 861 | fc.setDialogType(JFileChooser.SAVE_DIALOG); |
1765 | 862 | fc.setDialogTitle(title); | 862 | fc.setDialogTitle(title); |
1766 | 863 | 863 | ||
1767 | === modified file 'WorkcraftCore/src/org/workcraft/util/FileUtils.java' | |||
1768 | --- WorkcraftCore/src/org/workcraft/util/FileUtils.java 2014-01-15 17:13:30 +0000 | |||
1769 | +++ WorkcraftCore/src/org/workcraft/util/FileUtils.java 2014-11-30 23:14:46 +0000 | |||
1770 | @@ -31,8 +31,6 @@ | |||
1771 | 31 | import java.io.InputStream; | 31 | import java.io.InputStream; |
1772 | 32 | import java.io.InputStreamReader; | 32 | import java.io.InputStreamReader; |
1773 | 33 | import java.io.OutputStream; | 33 | import java.io.OutputStream; |
1774 | 34 | import java.net.URI; | ||
1775 | 35 | import java.net.URISyntaxException; | ||
1776 | 36 | import java.nio.channels.Channels; | 34 | import java.nio.channels.Channels; |
1777 | 37 | import java.nio.channels.FileChannel; | 35 | import java.nio.channels.FileChannel; |
1778 | 38 | import java.nio.channels.WritableByteChannel; | 36 | import java.nio.channels.WritableByteChannel; |
1779 | 39 | 37 | ||
1780 | === modified file 'build_distr_linux.sh' | |||
1781 | --- build_distr_linux.sh 2014-11-24 15:37:13 +0000 | |||
1782 | +++ build_distr_linux.sh 2014-11-30 23:14:46 +0000 | |||
1783 | @@ -1,7 +1,7 @@ | |||
1784 | 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
1785 | 2 | 2 | ||
1786 | 3 | src_dir="." | 3 | src_dir="." |
1788 | 4 | distr_dir="../../workcraft_3.0.3_alpha" | 4 | distr_dir="../../workcraft_3.0.3_beta" |
1789 | 5 | template_dir="../../distr-template-linux" | 5 | template_dir="../../distr-template-linux" |
1790 | 6 | 6 | ||
1791 | 7 | ./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir | 7 | ./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir |
1792 | 8 | 8 | ||
1793 | === modified file 'build_distr_windows.sh' | |||
1794 | --- build_distr_windows.sh 2014-11-24 15:37:13 +0000 | |||
1795 | +++ build_distr_windows.sh 2014-11-30 23:14:46 +0000 | |||
1796 | @@ -1,7 +1,7 @@ | |||
1797 | 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
1798 | 2 | 2 | ||
1799 | 3 | src_dir="." | 3 | src_dir="." |
1801 | 4 | distr_dir="../../workcraft_3.0.3_alpha" | 4 | distr_dir="../../workcraft_3.0.3_beta" |
1802 | 5 | template_dir="../../distr-template-windows" | 5 | template_dir="../../distr-template-windows" |
1803 | 6 | 6 | ||
1804 | 7 | ./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir | 7 | ./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir |