Merge lp:~danilovesky/workcraft/trunk-stg-conformation into lp:workcraft

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
Reviewer Review Type Date Requested Status
Danil Sokolov Approve
Review via email: mp+243220@code.launchpad.net
To post a comment you must log in.
575. By Danil Sokolov

Polishing the Reach expression for conformation check.

Revision history for this message
Danil Sokolov (danilovesky) :
review: Needs Resubmitting
Revision history for this message
Danil Sokolov (danilovesky) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2014-11-24 15:37:13 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2014-11-30 23:14:46 +0000
@@ -1,6 +1,13 @@
1package org.workcraft.plugins.circuit.tasks;1package org.workcraft.plugins.circuit.tasks;
22
3import java.io.BufferedReader;
4import java.io.ByteArrayInputStream;
3import java.io.File;5import java.io.File;
6import java.io.IOException;
7import java.io.InputStream;
8import java.io.InputStreamReader;
9import java.util.HashSet;
10import java.util.Set;
411
5import org.workcraft.Framework;12import org.workcraft.Framework;
6import org.workcraft.interop.Exporter;13import org.workcraft.interop.Exporter;
@@ -14,10 +21,11 @@
14import org.workcraft.plugins.mpsat.tasks.MpsatChainTask;21import org.workcraft.plugins.mpsat.tasks.MpsatChainTask;
15import org.workcraft.plugins.mpsat.tasks.MpsatTask;22import org.workcraft.plugins.mpsat.tasks.MpsatTask;
16import org.workcraft.plugins.mpsat.tasks.PunfTask;23import org.workcraft.plugins.mpsat.tasks.PunfTask;
17import org.workcraft.plugins.pcomp.PCompOutputMode;
18import org.workcraft.plugins.pcomp.tasks.PcompTask;24import org.workcraft.plugins.pcomp.tasks.PcompTask;
25import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode;
19import org.workcraft.plugins.shared.tasks.ExternalProcessResult;26import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
20import org.workcraft.plugins.stg.STG;27import org.workcraft.plugins.stg.STG;
28import org.workcraft.plugins.stg.SignalTransition.Type;
21import org.workcraft.serialisation.Format;29import org.workcraft.serialisation.Format;
22import org.workcraft.tasks.ProgressMonitor;30import org.workcraft.tasks.ProgressMonitor;
23import org.workcraft.tasks.Result;31import org.workcraft.tasks.Result;
@@ -62,6 +70,7 @@
62 70
63 @Override71 @Override
64 public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) {72 public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) {
73 File workingDirectory = null;
65 try {74 try {
66 // Common variables75 // Common variables
67 monitor.progressUpdate(0.05);76 monitor.progressUpdate(0.05);
@@ -70,79 +79,76 @@
70 title = title.substring(0, title.length() - 5);79 title = title.substring(0, title.length() - 5);
71 }80 }
72 VisualCircuit visualCircuit = (VisualCircuit)we.getModelEntry().getVisualModel();81 VisualCircuit visualCircuit = (VisualCircuit)we.getModelEntry().getVisualModel();
73 STG circuitStg = (STG)STGGenerator.generate(visualCircuit).getMathModel();82 File envFile = visualCircuit.getEnvironmentFile();
74 Exporter stgExporter = Export.chooseBestExporter(framework.getPluginManager(), circuitStg, Format.STG);83 boolean hasEnvironment = ((envFile != null) && envFile.exists());
75 if (stgExporter == null) {84
76 throw new RuntimeException ("Exporter not available: model class " + circuitStg.getClass().getName() + " to format STG.");85 workingDirectory = FileUtils.createTempDirectory(title + "-");
86
87 STG devStg = (STG)STGGenerator.generate(visualCircuit).getMathModel();
88 Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG);
89 if (devStgExporter == null) {
90 throw new RuntimeException ("Exporter not available: model class " + devStg.getClass().getName() + " to format STG.");
77 }91 }
78 SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor);92 SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor);
79 monitor.progressUpdate(0.10);93 monitor.progressUpdate(0.10);
8094
81 // Generating .g for the circuit95 // Generating .g for the circuit
82 String circuitFilePrefix = title + "-circuit-";96 String devStgName = (hasEnvironment ? "dev.g" : "system.g");
83 File circuitStgFile = File.createTempFile(circuitFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion());97 File devStgFile = new File(workingDirectory, devStgName);
84 ExportTask circuitExportTask = new ExportTask(stgExporter, circuitStg, circuitStgFile.getCanonicalPath());98 ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath());
85 Result<? extends Object> circuitExportResult = framework.getTaskManager().execute(99 Result<? extends Object> devExportResult = framework.getTaskManager().execute(
86 circuitExportTask, "Exporting circuit .g", subtaskMonitor);100 devExportTask, "Exporting circuit .g", subtaskMonitor);
87 101
88 if (circuitExportResult.getOutcome() != Outcome.FINISHED) {102 if (devExportResult.getOutcome() != Outcome.FINISHED) {
89 circuitStgFile.delete();103 if (devExportResult.getOutcome() == Outcome.CANCELLED) {
90 if (circuitExportResult.getOutcome() == Outcome.CANCELLED) {
91 return new Result<MpsatChainResult>(Outcome.CANCELLED);104 return new Result<MpsatChainResult>(Outcome.CANCELLED);
92 }105 }
93 return new Result<MpsatChainResult>(Outcome.FAILED, 106 return new Result<MpsatChainResult>(Outcome.FAILED,
94 new MpsatChainResult(circuitExportResult, null, null, null, toolchainPreparationSettings));107 new MpsatChainResult(devExportResult, null, null, null, toolchainPreparationSettings));
95 }108 }
96 monitor.progressUpdate(0.20);109 monitor.progressUpdate(0.20);
97 110
98 // Generating .g for the environment111 // Generating .g for the environment
99 File stgFile;
100 STG stg;112 STG stg;
113 File stgFile = null;
101 Result<? extends ExternalProcessResult> pcompResult = null;114 Result<? extends ExternalProcessResult> pcompResult = null;
102 File environmentFile = visualCircuit.getEnvironmentFile();
103 boolean hasEnvironment = ((environmentFile != null) && environmentFile.exists());
104 if ( !hasEnvironment ) {115 if ( !hasEnvironment ) {
105 // No environment to compose with116 stgFile = devStgFile;
106 stgFile = circuitStgFile;117 stg = devStg;
107 stg = circuitStg;
108 } else {118 } else {
109 // Compose circuit with its environment119 File envStgFile = null;
110 File environmentStgFile;120 if (envFile.getName().endsWith(".g")) {
111 if (environmentFile.getName().endsWith(".g")) {121 envStgFile = envFile;
112 environmentStgFile = environmentFile;
113 } else {122 } else {
114 STG environementStg = (STG)framework.loadFile(environmentFile).getMathModel();123 STG envStg = (STG)framework.loadFile(envFile).getMathModel();
115 String environmentFilePrefix = title + "-environment-";124 Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG);
116 environmentStgFile = File.createTempFile(environmentFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion());125 envStgFile = new File(workingDirectory, "env.g");
117 ExportTask environmentExportTask = new ExportTask(stgExporter, environementStg, environmentStgFile.getCanonicalPath());126 ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath());
118 Result<? extends Object> environmentExportResult = framework.getTaskManager().execute(127 Result<? extends Object> envExportResult = framework.getTaskManager().execute(
119 environmentExportTask, "Exporting environment .g", subtaskMonitor);128 envExportTask, "Exporting environment .g", subtaskMonitor);
120 129
121 if (environmentExportResult.getOutcome() != Outcome.FINISHED) {130 if (envExportResult.getOutcome() != Outcome.FINISHED) {
122 environmentStgFile.delete();131 if (envExportResult.getOutcome() == Outcome.CANCELLED) {
123 if (environmentExportResult.getOutcome() == Outcome.CANCELLED) {
124 return new Result<MpsatChainResult>(Outcome.CANCELLED);132 return new Result<MpsatChainResult>(Outcome.CANCELLED);
125 }133 }
126 return new Result<MpsatChainResult>(Outcome.FAILED, 134 return new Result<MpsatChainResult>(Outcome.FAILED,
127 new MpsatChainResult(environmentExportResult, null, null, null, toolchainPreparationSettings));135 new MpsatChainResult(envExportResult, null, null, null, toolchainPreparationSettings));
128 }136 }
129 }137 }
130 monitor.progressUpdate(0.25);138 monitor.progressUpdate(0.25);
131139
132 // Generating .g for the whole system (circuit and environment)140 // Generating .g for the whole system (circuit and environment)
133 String systemFilePrefix = title + "-system-";141 stgFile = new File(workingDirectory, "system.g");
134 stgFile = File.createTempFile(systemFilePrefix.replaceAll("\\s",""), stgExporter.getExtenstion());142 PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, ConversionMode.OUTPUT, true, false, workingDirectory);
135 PcompTask pcompTask = new PcompTask(new File[]{circuitStgFile, environmentStgFile}, PCompOutputMode.OUTPUT, true, false);
136 pcompResult = framework.getTaskManager().execute(143 pcompResult = framework.getTaskManager().execute(
137 pcompTask, "Running pcomp", subtaskMonitor);144 pcompTask, "Running pcomp", subtaskMonitor);
138 145
139 if (pcompResult.getOutcome() != Outcome.FINISHED) {146 if (pcompResult.getOutcome() != Outcome.FINISHED) {
140 circuitStgFile.delete();
141 if (pcompResult.getOutcome() == Outcome.CANCELLED) {147 if (pcompResult.getOutcome() == Outcome.CANCELLED) {
142 return new Result<MpsatChainResult>(Outcome.CANCELLED);148 return new Result<MpsatChainResult>(Outcome.CANCELLED);
143 }149 }
144 return new Result<MpsatChainResult>(Outcome.FAILED, 150 return new Result<MpsatChainResult>(Outcome.FAILED,
145 new MpsatChainResult(circuitExportResult, pcompResult, null, null, toolchainPreparationSettings));151 new MpsatChainResult(devExportResult, pcompResult, null, null, toolchainPreparationSettings));
146 }152 }
147 FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput()));153 FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput()));
148 WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true);154 WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true);
@@ -151,26 +157,26 @@
151 monitor.progressUpdate(0.30);157 monitor.progressUpdate(0.30);
152158
153 // Generate unfolding159 // Generate unfolding
154 String unfoldingFilePrefix = title + "-unfolding-";160 File unfoldingFile = new File(workingDirectory, "system" + MpsatUtilitySettings.getUnfoldingExtension());
155 File unfoldingFile = File.createTempFile(unfoldingFilePrefix.replaceAll("\\s",""), MpsatUtilitySettings.getUnfoldingExtension());
156 PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());161 PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());
157 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(162 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
158 punfTask, "Unfolding .g", subtaskMonitor);163 punfTask, "Unfolding .g", subtaskMonitor);
159 164
160 stgFile.delete();
161 if (punfResult.getOutcome() != Outcome.FINISHED) {165 if (punfResult.getOutcome() != Outcome.FINISHED) {
162 unfoldingFile.delete();
163 if (punfResult.getOutcome() == Outcome.CANCELLED) {166 if (punfResult.getOutcome() == Outcome.CANCELLED) {
164 return new Result<MpsatChainResult>(Outcome.CANCELLED);167 return new Result<MpsatChainResult>(Outcome.CANCELLED);
165 }168 }
166 return new Result<MpsatChainResult>(Outcome.FAILED, 169 return new Result<MpsatChainResult>(Outcome.FAILED,
167 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, null, toolchainPreparationSettings));170 new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainPreparationSettings));
168 }171 }
169 monitor.progressUpdate(0.40);172 monitor.progressUpdate(0.40);
170 173
171 // Check for interface conformation (only if the environment is specified) 174 // Check for interface conformation (only if the environment is specified)
172 if (hasEnvironment && checkConformation) {175 if (hasEnvironment && checkConformation) {
173 String reachConformation = MpsatSettings.genReachConformation(stg, circuitStg);176 Set<String> devOutputNames = devStg.getSignalFlatNames(Type.OUTPUT);
177 Set<String> devPlaceNames = parsePlaceNames(pcompResult.getReturnValue().getOutputFile("places.list"), 0);
178// String reachConformation = MpsatSettings.genReachConformation(devOutputNames, devPlaceNames);
179 String reachConformation = MpsatSettings.genReachConformationDetail(stg, devOutputNames, devPlaceNames);
174 if (MpsatUtilitySettings.getDebugReach()) {180 if (MpsatUtilitySettings.getDebugReach()) {
175 System.out.println("\nReach expression for the interface conformation property:");181 System.out.println("\nReach expression for the interface conformation property:");
176 System.out.println(reachConformation);182 System.out.println(reachConformation);
@@ -179,7 +185,8 @@
179 MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(), 185 MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(),
180 MpsatUtilitySettings.getSolutionCount(), reachConformation);186 MpsatUtilitySettings.getSolutionCount(), reachConformation);
181 187
182 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath());188 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(),
189 unfoldingFile.getCanonicalPath(), workingDirectory);
183 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(190 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(
184 mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor);191 mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor);
185192
@@ -188,15 +195,14 @@
188 return new Result<MpsatChainResult>(Outcome.CANCELLED);195 return new Result<MpsatChainResult>(Outcome.CANCELLED);
189 }196 }
190 return new Result<MpsatChainResult>(Outcome.FAILED, 197 return new Result<MpsatChainResult>(Outcome.FAILED,
191 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings));198 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings));
192 }199 }
193 monitor.progressUpdate(0.50);200 monitor.progressUpdate(0.50);
194201
195 MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue());202 MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue());
196 if (!mpsatConformationParser.getSolutions().isEmpty()) {203 if (!mpsatConformationParser.getSolutions().isEmpty()) {
197 unfoldingFile.delete();
198 return new Result<MpsatChainResult>(Outcome.FINISHED, 204 return new Result<MpsatChainResult>(Outcome.FINISHED,
199 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings, 205 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings,
200 "Circuit does not conform to the environment after the following trace:"));206 "Circuit does not conform to the environment after the following trace:"));
201 }207 }
202 }208 }
@@ -204,7 +210,8 @@
204 210
205 // Check for deadlock211 // Check for deadlock
206 if (checkDeadlock) {212 if (checkDeadlock) {
207 MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath());213 MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(),
214 unfoldingFile.getCanonicalPath(), workingDirectory);
208 Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute(215 Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute(
209 mpsatDeadlockTask, "Running deadlock check [MPSat]", subtaskMonitor);216 mpsatDeadlockTask, "Running deadlock check [MPSat]", subtaskMonitor);
210 217
@@ -213,15 +220,14 @@
213 return new Result<MpsatChainResult>(Outcome.CANCELLED);220 return new Result<MpsatChainResult>(Outcome.CANCELLED);
214 }221 }
215 return new Result<MpsatChainResult>(Outcome.FAILED, 222 return new Result<MpsatChainResult>(Outcome.FAILED,
216 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings));223 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings));
217 }224 }
218 monitor.progressUpdate(0.70);225 monitor.progressUpdate(0.70);
219 226
220 MpsatResultParser mpsatDeadlockParser = new MpsatResultParser(mpsatDeadlockResult.getReturnValue());227 MpsatResultParser mpsatDeadlockParser = new MpsatResultParser(mpsatDeadlockResult.getReturnValue());
221 if (!mpsatDeadlockParser.getSolutions().isEmpty()) {228 if (!mpsatDeadlockParser.getSolutions().isEmpty()) {
222 unfoldingFile.delete();
223 return new Result<MpsatChainResult>(Outcome.FINISHED, 229 return new Result<MpsatChainResult>(Outcome.FINISHED,
224 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings, 230 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatDeadlockResult, deadlockSettings,
225 "Circuit has a deadlock after the following trace:"));231 "Circuit has a deadlock after the following trace:"));
226 }232 }
227 }233 }
@@ -229,7 +235,8 @@
229 235
230 // Check for hazards236 // Check for hazards
231 if (checkHazard) {237 if (checkHazard) {
232 MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(), unfoldingFile.getCanonicalPath());238 MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(),
239 unfoldingFile.getCanonicalPath(), workingDirectory);
233 if (MpsatUtilitySettings.getDebugReach()) {240 if (MpsatUtilitySettings.getDebugReach()) {
234 System.out.println("\nReach expression for the hazard property:");241 System.out.println("\nReach expression for the hazard property:");
235 System.out.println(hazardSettings.getReach());242 System.out.println(hazardSettings.getReach());
@@ -242,44 +249,72 @@
242 return new Result<MpsatChainResult>(Outcome.CANCELLED);249 return new Result<MpsatChainResult>(Outcome.CANCELLED);
243 }250 }
244 return new Result<MpsatChainResult>(Outcome.FAILED, 251 return new Result<MpsatChainResult>(Outcome.FAILED,
245 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings));252 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings));
246 }253 }
247 monitor.progressUpdate(0.90);254 monitor.progressUpdate(0.90);
248255
249 MpsatResultParser mpsatHazardParser = new MpsatResultParser(mpsatHazardResult.getReturnValue());256 MpsatResultParser mpsatHazardParser = new MpsatResultParser(mpsatHazardResult.getReturnValue());
250 if (!mpsatHazardParser.getSolutions().isEmpty()) {257 if (!mpsatHazardParser.getSolutions().isEmpty()) {
251 unfoldingFile.delete();
252 return new Result<MpsatChainResult>(Outcome.FINISHED, 258 return new Result<MpsatChainResult>(Outcome.FINISHED,
253 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings, 259 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatHazardResult, hazardSettings,
254 "Circuit has a hazard after the following trace:"));260 "Circuit has a hazard after the following trace:"));
255 }261 }
256 }262 }
257 monitor.progressUpdate(1.0);263 monitor.progressUpdate(1.0);
258264
259 // Success265 // Success
260 unfoldingFile.delete();266 String message = getSuccessMessage(envFile);
261 String message = "";
262 if (hasEnvironment) {
263 message = "Under the given environment (" + environmentFile.getName() + ")";
264 } else {
265 message = "Without environment restrictions";
266 }
267 message += " the circuit is:\n";
268 if (checkConformation) {
269 message += " * conformant\n";
270 }
271 if (checkDeadlock) {
272 message += " * deadlock-free\n";
273 }
274 if (checkHazard) {
275 message += " * hazard-free\n";
276 }
277 return new Result<MpsatChainResult>(Outcome.FINISHED, 267 return new Result<MpsatChainResult>(Outcome.FINISHED,
278 new MpsatChainResult(circuitExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message));268 new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message));
279269
280 } catch (Throwable e) {270 } catch (Throwable e) {
281 return new Result<MpsatChainResult>(e);271 return new Result<MpsatChainResult>(e);
282 }272 } finally {
273 if ((workingDirectory != null) && !MpsatUtilitySettings.getDebugTemporaryFiles()) {
274 FileUtils.deleteDirectoryTree(workingDirectory);
275 }
276 }
277 }
278
279 private HashSet<String> parsePlaceNames(byte[] bufferedInput, int lineIndex) {
280 HashSet<String> result = new HashSet<String>();
281 InputStream is = new ByteArrayInputStream(bufferedInput);
282 BufferedReader br = new BufferedReader(new InputStreamReader(is));
283 try {
284 String line = null;
285 while ((lineIndex >= 0) && ((line = br.readLine()) != null)) {
286 lineIndex--;
287 }
288 if (line != null) {
289 for (String name: line.trim().split("\\s")) {
290 result.add(name);
291 }
292 }
293 } catch (IOException e) {
294 e.printStackTrace();
295 }
296 return result;
297 }
298
299 private String getSuccessMessage(File environmentFile) {
300 String message = "";
301 boolean hasEnvironment = ((environmentFile != null) && environmentFile.exists());
302 if (hasEnvironment) {
303 message = "Under the given environment (" + environmentFile.getName() + ")";
304 } else {
305 message = "Without environment restrictions";
306 }
307 message += " the circuit is:\n";
308 if (checkConformation) {
309 message += " * conformant\n";
310 }
311 if (checkDeadlock) {
312 message += " * deadlock-free\n";
313 }
314 if (checkHazard) {
315 message += " * hazard-free\n";
316 }
317 return message;
283 }318 }
284319
285}320}
286321
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-11-21 18:25:23 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-11-30 23:14:46 +0000
@@ -451,7 +451,7 @@
451 Node parent = contact.getParent();451 Node parent = contact.getParent();
452 if (parent instanceof VisualFunctionComponent) {452 if (parent instanceof VisualFunctionComponent) {
453 VisualFunctionComponent component = (VisualFunctionComponent)parent;453 VisualFunctionComponent component = (VisualFunctionComponent)parent;
454 String componentName = NamespaceHelper.getFlatName(circuit.getMathName(component));454 String componentName = NamespaceHelper.hierarchicalToFlatName(circuit.getMathName(component));
455 String contactName = circuit.getMathName(contact);455 String contactName = circuit.getMathName(contact);
456 result = componentName + "_" + contactName;456 result = componentName + "_" + contactName;
457 }457 }
@@ -470,7 +470,7 @@
470 result = circuit.getMathName(outputPort); 470 result = circuit.getMathName(outputPort);
471 } else {471 } else {
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.
473 result = NamespaceHelper.getFlatName(circuit.getMathName(component));473 result = NamespaceHelper.hierarchicalToFlatName(circuit.getMathName(component));
474 int output_cnt = 0;474 int output_cnt = 0;
475 for (Node node: component.getChildren()) {475 for (Node node: component.getChildren()) {
476 if (node instanceof VisualContact) {476 if (node instanceof VisualContact) {
477477
=== modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java'
--- CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java 2014-07-11 09:35:42 +0000
+++ CpogsPlugin/src/org/workcraft/plugins/cpog/serialisation/BooleanFormulaSerialiser.java 2014-11-30 23:14:46 +0000
@@ -61,7 +61,7 @@
61 61
62 String ref = internalReferences.getReference(node);62 String ref = internalReferences.getReference(node);
63 // use full path to a flattened name63 // use full path to a flattened name
64 String flat = NamespaceHelper.getFlatName(ref);64 String flat = NamespaceHelper.hierarchicalToFlatName(ref);
65 65
66 // old style naming, if number is used as an ID for a contact66 // old style naming, if number is used as an ID for a contact
67 if (Identifier.isNumber(ref)) {67 if (Identifier.isNumber(ref)) {
6868
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java 2013-09-18 16:19:20 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatCscResolutionResultHandler.java 2014-11-30 23:14:46 +0000
@@ -28,12 +28,11 @@
28 this.result = result;28 this.result = result;
29 }29 }
30 30
31 public STGModel getResolvedStg()31 public STGModel getResolvedStg() {
32 {
33 final byte[] output = result.getReturnValue().getMpsatResult().getReturnValue().getOutputFile("mpsat.g");32 final byte[] output = result.getReturnValue().getMpsatResult().getReturnValue().getOutputFile("mpsat.g");
34 if(output == null)33 if(output == null) {
35 return null;34 return null;
36 35 }
37 try {36 try {
38 return new DotGImporter().importSTG(new ByteArrayInputStream(output));37 return new DotGImporter().importSTG(new ByteArrayInputStream(output));
39 } catch (DeserialisationException e) {38 } catch (DeserialisationException e) {
4039
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java 2014-10-24 16:33:38 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatModule.java 2014-11-30 23:14:46 +0000
@@ -6,13 +6,13 @@
6import org.workcraft.Tool;6import org.workcraft.Tool;
7import org.workcraft.gui.propertyeditor.Settings;7import org.workcraft.gui.propertyeditor.Settings;
8import org.workcraft.plugins.mpsat.tools.CscResolutionTool;8import org.workcraft.plugins.mpsat.tools.CscResolutionTool;
9import org.workcraft.plugins.mpsat.tools.CustomPropertyMpsatChecker;9import org.workcraft.plugins.mpsat.tools.MpsatConformationChecker;
10import org.workcraft.plugins.mpsat.tools.MpsatConsistencyChecker;10import org.workcraft.plugins.mpsat.tools.MpsatConsistencyChecker;
11import org.workcraft.plugins.mpsat.tools.MpsatCscChecker;11import org.workcraft.plugins.mpsat.tools.MpsatCscChecker;
12import org.workcraft.plugins.mpsat.tools.MpsatCustomPropertyChecker;
12import org.workcraft.plugins.mpsat.tools.MpsatDeadlockChecker;13import org.workcraft.plugins.mpsat.tools.MpsatDeadlockChecker;
13import org.workcraft.plugins.mpsat.tools.MpsatNormalcyChecker;14import org.workcraft.plugins.mpsat.tools.MpsatNormalcyChecker;
14import org.workcraft.plugins.mpsat.tools.MpsatPersistencyChecker;15import org.workcraft.plugins.mpsat.tools.MpsatPersistencyChecker;
15import org.workcraft.plugins.mpsat.tools.MpsatSynthesis;
16import org.workcraft.plugins.mpsat.tools.MpsatSynthesisComplexGate;16import org.workcraft.plugins.mpsat.tools.MpsatSynthesisComplexGate;
17import org.workcraft.plugins.mpsat.tools.MpsatSynthesisGeneralisedCelement;17import org.workcraft.plugins.mpsat.tools.MpsatSynthesisGeneralisedCelement;
18import org.workcraft.plugins.mpsat.tools.MpsatSynthesisStandardCelement;18import org.workcraft.plugins.mpsat.tools.MpsatSynthesisStandardCelement;
@@ -38,7 +38,8 @@
38 p.registerClass(Tool.class, MpsatNormalcyChecker.class, framework);38 p.registerClass(Tool.class, MpsatNormalcyChecker.class, framework);
39 p.registerClass(Tool.class, MpsatCscChecker.class, framework);39 p.registerClass(Tool.class, MpsatCscChecker.class, framework);
40 p.registerClass(Tool.class, MpsatUscChecker.class, framework);40 p.registerClass(Tool.class, MpsatUscChecker.class, framework);
41 p.registerClass(Tool.class, CustomPropertyMpsatChecker.class, framework);41 p.registerClass(Tool.class, MpsatConformationChecker.class, framework);
42 p.registerClass(Tool.class, MpsatCustomPropertyChecker.class, framework);
42 43
43 p.registerClass(Settings.class, MpsatUtilitySettings.class);44 p.registerClass(Settings.class, MpsatUtilitySettings.class);
44 p.registerClass(Settings.class, PunfUtilitySettings.class);45 p.registerClass(Settings.class, PunfUtilitySettings.class);
4546
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2014-11-13 00:05:09 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2014-11-30 23:14:46 +0000
@@ -6,9 +6,10 @@
6import java.io.File;6import java.io.File;
7import java.io.IOException;7import java.io.IOException;
8import java.util.ArrayList;8import java.util.ArrayList;
9import java.util.HashSet;9import java.util.Collection;
10import java.util.LinkedHashMap;10import java.util.LinkedHashMap;
11import java.util.Map;11import java.util.Map;
12import java.util.Set;
12import java.util.regex.Matcher;13import java.util.regex.Matcher;
13import java.util.regex.Pattern;14import java.util.regex.Pattern;
1415
@@ -16,7 +17,7 @@
16import org.workcraft.dom.hierarchy.NamespaceHelper;17import org.workcraft.dom.hierarchy.NamespaceHelper;
17import org.workcraft.plugins.stg.STG;18import org.workcraft.plugins.stg.STG;
18import org.workcraft.plugins.stg.SignalTransition;19import org.workcraft.plugins.stg.SignalTransition;
19import org.workcraft.plugins.stg.SignalTransition.Type;20import org.workcraft.plugins.stg.SignalTransition.Direction;
20import org.workcraft.util.FileUtils;21import org.workcraft.util.FileUtils;
2122
22public class MpsatSettings {23public class MpsatSettings {
@@ -53,134 +54,158 @@
53 // Reach expression for checking signal consistency54 // Reach expression for checking signal consistency
54 public static final String reachConsistency = 55 public static final String reachConsistency =
55 "exists s in SIGNALS \\ DUMMY {\n" +56 "exists s in SIGNALS \\ DUMMY {\n" +
56 " let Es = ev s {\n" +57 " let Es = ev s {\n" +
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" +
58 " |\n" +59 " |\n" +
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" +
60 " }\n" +61 " }\n" +
61 "}\n";62 "}\n";
6263
63 // Reach expression for checking semimodularity (output persistency)64 // Reach expression for checking semimodularity (output persistency)
64 public static final String reachSemimodularity =65 public static final String reachSemimodularity =
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" +
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" +
67 " @t1 &\n" +68 " @t1 &\n" +
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" +
69 " @t2 &\n" +70 " @t2 &\n" +
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" +
71 " exists p in pre t3 \\ post t2 { ~$p }\n" +72 " exists p in pre t3 \\ post t2 { ~$p }\n" +
72 " }\n" +73 " }\n" +
73 " }\n" +74 " }\n" +
74 " }\n";75 " }\n";
75 76
76 // Reach expression for checking conformation (this is a template, 77 // Reach expression for checking conformation (this is a template,
77 // the list of places needs to be updated for each circuit)78 // the list of places needs to be updated for each circuit)
78 public static final String reachConformation =79 public static final String reachConformation =
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" +
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" +
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" +
82 " exists s in SIGNALS \\ DUMMY {\n" +83 " exists s in devOutputs {\n" +
83 " exists t in tran s {\n" +84 " exists t in tran s {\n" +
84 " forall p in pre t * CP { $p }\n" +85 " is_plus t & forall p in pre t * devPlaces { $ p }\n" +
85 " }\n" +86 " }\n" +
86 " &\n" +87 " &\n" +
87 " forall t in tran s {\n" +88 " forall t in tran s {\n" +
88 " exists p in pre t \\ CP { ~$p }\n" +89 " is_plus t & exists p in pre t \\ devPlaces { ~ $ p }\n" +
89 " }\n" +90 " }\n" +
90 " }\n" +91 " |\n" +
91 " }\n";92 " exists t in tran s {\n" +
92 93 " is_minus t & forall p in pre t * devPlaces { $ p }\n" +
94 " }\n" +
95 " &\n" +
96 " forall t in tran s {\n" +
97 " is_minus t & exists p in pre t \\ devPlaces { ~ $ p }\n" +
98 " }\n" +
99 " }\n" +
100 "}\n";
101
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.
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
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
96 // property cannot be checked reliably.105 // property cannot be checked reliably.
97 public static String genReachConformation(STG stg, STG circuitStg) {106 public static String genReachConformation(Set<String> devOutputNames, Set<String> devPlaceNames) {
98 // Form a set of system STG places which came from the circuitStg 107 String devOutputList = genNameList(devOutputNames);
99 HashSet<Node> circuitPlaces = new HashSet<Node>();108 String devPlaceList = genNameList(devPlaceNames);
100 for (Type type: Type.values()) {109 return "let devOutputs = gather signalName in { " + devOutputList + " } { S signalName },\n" +
101 for (String s : circuitStg.getSignalReferences(type)) {110 " devPlaces = gather placeName in { " + devPlaceList + " } { P placeName } {\n" +
102 Node p0 = stg.getNodeByReference(s + "_0");111 reachConformation;
103 if (p0 == null) {112 }
104 p0 = stg.getNodeByReference("<" + s + "-," + s + "+>");113
105 }114 private static String genNameList(Collection<String> names) {
106 if (p0 != null) {115 String result = "";
107 circuitPlaces.add(p0);116 for (String name: names) {
108 }117 if ( !result.isEmpty() ) {
109 Node p1 = stg.getNodeByReference(s + "_1");118 result += ", ";
110 if (p1 == null) {
111 p1 = stg.getNodeByReference("<" + s + "+," + s + "->");
112 }
113 if (p1 != null) {
114 circuitPlaces.add(p1);
115 }
116 }119 }
120 result += "\"" + name + "\"";
117 }121 }
118 // Generate Reach expression122 return result;
123 }
124
125 public static String genReachConformationDetail(STG stg, Set<String> devOutputNames, Set<String> devPlaceNames) {
119 String result = "";126 String result = "";
120 for (String s : circuitStg.getSignalReferences(Type.OUTPUT)) {127 for (String signalFlatName: devOutputNames) {
121 String circuitPredicate = "";128 String riseDevPredicate = "";
122 String environmentPredicate = "";129 String fallDevPredicate = "";
123 for (SignalTransition t: stg.getSignalTransitions()) {130 String riseEnvPredicate = "";
124 if (!t.getSignalType().equals(Type.OUTPUT) || !t.getSignalName().equals(s)) continue;131 String fallEnvPredicate = "";
125 String circuitPreset = "";132
126 String environmentPreset = "";133 String signalRef = NamespaceHelper.flatToHierarchicalName(signalFlatName);
134 for (SignalTransition t: stg.getSignalTransitions(signalRef)) {
135 String devPreset = "";
136 String envPreset = "";
127 for (Node p: stg.getPreset(t)) {137 for (Node p: stg.getPreset(t)) {
128 String name = stg.getNodeReference(p);138 String placeRef = stg.getNodeReference(p);
129 if (circuitPlaces.contains(p)) {139 String placeFlatName = NamespaceHelper.hierarchicalToFlatName(placeRef);
130 if (circuitPreset.isEmpty()) {140 if (devPlaceNames.contains(placeFlatName)) {
131 circuitPreset += "{";141 devPreset += (devPreset.isEmpty() ? "{" : ", ");
132 } else {142 devPreset += "\"" + placeFlatName + "\"";
133 circuitPreset += ", ";143 }
134 }144 envPreset += (envPreset.isEmpty() ? "{" : ", ");
135 circuitPreset += "\"" + name + "\"";145 envPreset += "\"" + placeFlatName + "\"";
146 }
147
148 if ( !devPreset.isEmpty() && !envPreset.isEmpty() ) {
149 devPreset += "}";
150 envPreset += "}";
151 String devPredicate = "";
152 devPredicate += " forall p in " + devPreset + " {\n";
153 devPredicate += " $ P p\n";
154 devPredicate += " }\n";
155 String envPredicate = "";
156 envPredicate += " exists p in " + envPreset + " {\n";
157 envPredicate += " ~$ P p\n";
158 envPredicate += " }\n";
159 if (t.getDirection() == Direction.PLUS) {
160 if ( !riseDevPredicate.isEmpty() ) {
161 riseDevPredicate += " |\n";
162 }
163 riseDevPredicate += devPredicate;
164 if ( !riseEnvPredicate.isEmpty() ) {
165 riseEnvPredicate += " &\n";
166 }
167 riseEnvPredicate += envPredicate;
136 } else {168 } else {
137 if (environmentPreset.isEmpty()) {169 if ( !fallDevPredicate.isEmpty() ) {
138 environmentPreset += "{";170 fallDevPredicate += " |\n";
139 } else {171 }
140 environmentPreset += ", ";172 fallDevPredicate += devPredicate;
141 }173 if ( !fallEnvPredicate.isEmpty() ) {
142 environmentPreset += "\"" + name + "\"";174 fallEnvPredicate += " &\n";
175 }
176 fallEnvPredicate += envPredicate;
143 }177 }
144 }178 }
145 circuitPreset += "}";179 }
146 environmentPreset += "}";180
147181 if ( !riseDevPredicate.isEmpty() || !fallDevPredicate.isEmpty() ) {
148 if (circuitPredicate.isEmpty()) {182 if (result.isEmpty()) {
149 circuitPredicate += " (\n";183 result = "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n";
150 } else {184 } else {
151 circuitPredicate += " |\n";185 result += "|\n";
152 }186 }
153 circuitPredicate += " forall p in " + circuitPreset + " {\n";187 result += "( /* Conformation check for signal \"" + signalFlatName + "\" */\n";
154 circuitPredicate += " $ P p\n";188 result += " (\n";
155 circuitPredicate += " }\n";189 result += riseDevPredicate;
156190 result += " )\n";
157 if (environmentPredicate.isEmpty()) {191 result += " &\n";
158 environmentPredicate += " (\n";192 result += " (\n";
159 } else {193 result += riseEnvPredicate;
160 environmentPredicate += " &\n";194 result += " )\n";
161 }195 result += " |\n";
162 environmentPredicate += " exists p in " + environmentPreset + " {\n";196 result += " (\n";
163 environmentPredicate += " ~$ P p\n";197 result += fallDevPredicate;
164 environmentPredicate += " }\n";198 result += " )\n";
165 }199 result += " &\n";
166 circuitPredicate += " )\n";200 result += " (\n";
167 environmentPredicate += " )\n";201 result += fallEnvPredicate;
168 if (result.isEmpty()) {202 result += " )\n";
169 result = "card DUMMY != 0 ? fail \"This property can be checked only on STGs without dummies\" :\n";203 result += ")\n";
170 } else {204 }
171 result += "|\n";
172 }
173 result += "/* Conformation check for signal " + s + " */\n";
174 result += "(\n";
175 result += circuitPredicate;
176 result += " &\n";
177 result += environmentPredicate;
178 result += ")\n";
179 }205 }
180 return result;206 return result;
181 }207 }
182208
183
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) {
185 super();210 super();
186 this.name = name;211 this.name = name;
@@ -212,7 +237,7 @@
212 Matcher matcher = nodeNamePattern.matcher(reach);237 Matcher matcher = nodeNamePattern.matcher(reach);
213 while (matcher.find()) {238 while (matcher.find()) {
214 String reference = matcher.group(1);239 String reference = matcher.group(1);
215 String flatName = NamespaceHelper.getFlatName(reference);240 String flatName = NamespaceHelper.hierarchicalToFlatName(reference);
216 matcher.appendReplacement(sb, "\"" + flatName + "\"");241 matcher.appendReplacement(sb, "\"" + flatName + "\"");
217 }242 }
218 matcher.appendTail(sb);243 matcher.appendTail(sb);
219244
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2014-09-05 16:36:36 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2014-11-30 23:14:46 +0000
@@ -38,18 +38,21 @@
38 private static final String keyExtraArgs = prefix + ".args";38 private static final String keyExtraArgs = prefix + ".args";
39 private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding";39 private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding";
40 private static final String keyDebugReach = prefix + ".debugReach";40 private static final String keyDebugReach = prefix + ".debugReach";
41 private static final String keyDebugTemporaryFiles = prefix + ".debugTemporaryFiles";
41 42
42 private static final String defaultCommand = "mpsat";43 private static final String defaultCommand = "mpsat";
43 private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST;44 private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST;
44 private static final String defaultExtraArgs = "";45 private static final String defaultExtraArgs = "";
45 private static final Boolean defaultUsePnmlUnfolding = false;46 private static final Boolean defaultUsePnmlUnfolding = false;
46 private static final Boolean defaultDebugReach = false;47 private static final Boolean defaultDebugReach = false;
48 private static final Boolean defaultDebugTemporaryFiles = true;
4749
48 private static String command = defaultCommand;50 private static String command = defaultCommand;
49 private static SolutionMode solutionMode = defaultSolutionMode;51 private static SolutionMode solutionMode = defaultSolutionMode;
50 private static String extraArgs = defaultExtraArgs;52 private static String extraArgs = defaultExtraArgs;
51 private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding;53 private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding;
52 private static Boolean debugReach = defaultDebugReach;54 private static Boolean debugReach = defaultDebugReach;
55 private static Boolean debigTemporaryFiles = defaultDebugTemporaryFiles;
5356
54 public MpsatUtilitySettings() {57 public MpsatUtilitySettings() {
55 properties.add(new PropertyDeclaration<MpsatUtilitySettings, String>(58 properties.add(new PropertyDeclaration<MpsatUtilitySettings, String>(
@@ -93,7 +96,7 @@
93 });96 });
9497
95 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(98 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(
96 this, "Debug Reach expressions", Boolean.class) {99 this, "Print out Reach expressions (debug)", Boolean.class) {
97 protected void setter(MpsatUtilitySettings object, Boolean value) {100 protected void setter(MpsatUtilitySettings object, Boolean value) {
98 MpsatUtilitySettings.setDebugReach(value);101 MpsatUtilitySettings.setDebugReach(value);
99 }102 }
@@ -101,6 +104,16 @@
101 return MpsatUtilitySettings.getDebugReach();104 return MpsatUtilitySettings.getDebugReach();
102 }105 }
103 });106 });
107
108 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(
109 this, "Keep temporary files (debug)", Boolean.class) {
110 protected void setter(MpsatUtilitySettings object, Boolean value) {
111 MpsatUtilitySettings.setDebugTemporaryFiles(value);
112 }
113 protected Boolean getter(MpsatUtilitySettings object) {
114 return MpsatUtilitySettings.getDebugTemporaryFiles();
115 }
116 });
104 }117 }
105 118
106 @Override119 @Override
@@ -115,6 +128,7 @@
115 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));128 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));
116 setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding));129 setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding));
117 setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach));130 setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach));
131 setDebugTemporaryFiles(config.getBoolean(keyDebugTemporaryFiles, defaultDebugTemporaryFiles));
118 }132 }
119133
120 @Override134 @Override
@@ -124,6 +138,8 @@
124 config.set(keyExtraArgs, getExtraArgs());138 config.set(keyExtraArgs, getExtraArgs());
125 config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding());139 config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding());
126 config.setBoolean(keyDebugReach, getDebugReach());140 config.setBoolean(keyDebugReach, getDebugReach());
141 config.setBoolean(keyDebugTemporaryFiles, getDebugTemporaryFiles());
142
127 }143 }
128 144
129 @Override145 @Override
@@ -171,7 +187,7 @@
171 public static void setUsePnmlUnfolding(Boolean value) {187 public static void setUsePnmlUnfolding(Boolean value) {
172 usePnmlUnfolding = value;188 usePnmlUnfolding = value;
173 }189 }
174190
175 public static Boolean getDebugReach() {191 public static Boolean getDebugReach() {
176 return debugReach;192 return debugReach;
177 }193 }
@@ -180,6 +196,14 @@
180 debugReach = value;196 debugReach = value;
181 }197 }
182 198
199 public static Boolean getDebugTemporaryFiles() {
200 return debigTemporaryFiles;
201 }
202
203 public static void setDebugTemporaryFiles(Boolean value) {
204 debigTemporaryFiles = value;
205 }
206
183 public static String getUnfoldingExtension() {207 public static String getUnfoldingExtension() {
184 return (getUsePnmlUnfolding() ? ".pnml" : ".mci");208 return (getUsePnmlUnfolding() ? ".pnml" : ".mci");
185 }209 }
186210
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2014-09-05 16:36:36 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2014-11-30 23:14:46 +0000
@@ -11,44 +11,41 @@
11import org.workcraft.serialisation.Format;11import org.workcraft.serialisation.Format;
12import org.workcraft.tasks.ProgressMonitor;12import org.workcraft.tasks.ProgressMonitor;
13import org.workcraft.tasks.Result;13import org.workcraft.tasks.Result;
14import org.workcraft.tasks.Result.Outcome;
14import org.workcraft.tasks.SubtaskMonitor;15import org.workcraft.tasks.SubtaskMonitor;
15import org.workcraft.tasks.Task;16import org.workcraft.tasks.Task;
16import org.workcraft.tasks.Result.Outcome;
17import org.workcraft.util.Export;17import org.workcraft.util.Export;
18import org.workcraft.util.Export.ExportTask;
18import org.workcraft.util.WorkspaceUtils;19import org.workcraft.util.WorkspaceUtils;
19import org.workcraft.util.Export.ExportTask;
20import org.workcraft.workspace.WorkspaceEntry;20import org.workcraft.workspace.WorkspaceEntry;
2121
22public class MpsatChainTask implements Task<MpsatChainResult> {22public class MpsatChainTask implements Task<MpsatChainResult> {
23 private final WorkspaceEntry we;23 private final WorkspaceEntry we;
24 private final MpsatSettings settings;24 private final MpsatSettings settings;
25 private final Framework framework;25 private final Framework framework;
26 private PetriNetModel model;
2726
28 public MpsatChainTask(WorkspaceEntry we, MpsatSettings settings, Framework framework) {27 public MpsatChainTask(WorkspaceEntry we, MpsatSettings settings, Framework framework) {
29 this.we = we;28 this.we = we;
30 this.settings = settings;29 this.settings = settings;
31 this.framework = framework;30 this.framework = framework;
32 this.model = null;
33 }31 }
34 32
35 @Override33 @Override
36 public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) {34 public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) {
35 File netFile = null;
36 File unfoldingFile = null;
37 try {37 try {
38 if(model == null) {38 PetriNetModel model = WorkspaceUtils.getAs(we, PetriNetModel.class);
39 model = WorkspaceUtils.getAs(getWorkspaceEntry(), PetriNetModel.class);
40 }
41 Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG);39 Exporter exporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG);
42 if (exporter == null) {40 if (exporter == null) {
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.");
44 }42 }
45 File netFile = File.createTempFile("net", exporter.getExtenstion());43 netFile = File.createTempFile("net", exporter.getExtenstion());
46 ExportTask exportTask;44 ExportTask exportTask;
47 exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());45 exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());
48 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);46 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
49 Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g", mon);47 Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g", mon);
50 if (exportResult.getOutcome() != Outcome.FINISHED) {48 if (exportResult.getOutcome() != Outcome.FINISHED) {
51 netFile.delete();
52 if (exportResult.getOutcome() == Outcome.CANCELLED) {49 if (exportResult.getOutcome() == Outcome.CANCELLED) {
53 return new Result<MpsatChainResult>(Outcome.CANCELLED);50 return new Result<MpsatChainResult>(Outcome.CANCELLED);
54 }51 }
@@ -56,13 +53,11 @@
56 }53 }
57 monitor.progressUpdate(0.33);54 monitor.progressUpdate(0.33);
58 55
59 File unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension());56 unfoldingFile = File.createTempFile("unfolding", MpsatUtilitySettings.getUnfoldingExtension());
60 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());57 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());
61 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", mon);58 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", mon);
62 netFile.delete();
63 59
64 if (punfResult.getOutcome() != Outcome.FINISHED) {60 if (punfResult.getOutcome() != Outcome.FINISHED) {
65 unfoldingFile.delete();
66 if (punfResult.getOutcome() == Outcome.CANCELLED) {61 if (punfResult.getOutcome() == Outcome.CANCELLED) {
67 return new Result<MpsatChainResult>(Outcome.CANCELLED);62 return new Result<MpsatChainResult>(Outcome.CANCELLED);
68 }63 }
@@ -71,9 +66,8 @@
7166
72 monitor.progressUpdate(0.66);67 monitor.progressUpdate(0.66);
7368
74 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath());69 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(), unfoldingFile.getCanonicalPath(), null);
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);
76 unfoldingFile.delete();
77 71
78 if (mpsatResult.getOutcome() != Outcome.FINISHED) {72 if (mpsatResult.getOutcome() != Outcome.FINISHED) {
79 if (mpsatResult.getOutcome() == Outcome.CANCELLED) {73 if (mpsatResult.getOutcome() == Outcome.CANCELLED) {
@@ -88,6 +82,15 @@
88 } catch (Throwable e) {82 } catch (Throwable e) {
89 return new Result<MpsatChainResult>(e);83 return new Result<MpsatChainResult>(e);
90 }84 }
85 // Clean up
86 finally {
87 if ((netFile != null) && !MpsatUtilitySettings.getDebugTemporaryFiles() ) {
88 netFile.delete();
89 }
90 if ((unfoldingFile != null) && !MpsatUtilitySettings.getDebugTemporaryFiles() ) {
91 unfoldingFile.delete();
92 }
93 }
91 }94 }
92 95
93 public MpsatSettings getSettings() {96 public MpsatSettings getSettings() {
9497
=== added file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 1970-01-01 00:00:00 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2014-11-30 23:14:46 +0000
@@ -0,0 +1,215 @@
1package org.workcraft.plugins.mpsat.tasks;
2
3import java.io.BufferedReader;
4import java.io.ByteArrayInputStream;
5import java.io.File;
6import java.io.IOException;
7import java.io.InputStream;
8import java.io.InputStreamReader;
9import java.util.HashSet;
10import java.util.Set;
11
12import org.workcraft.Framework;
13import org.workcraft.interop.Exporter;
14import org.workcraft.plugins.mpsat.MpsatMode;
15import org.workcraft.plugins.mpsat.MpsatResultParser;
16import org.workcraft.plugins.mpsat.MpsatSettings;
17import org.workcraft.plugins.mpsat.MpsatUtilitySettings;
18import org.workcraft.plugins.pcomp.tasks.PcompTask;
19import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode;
20import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
21import org.workcraft.plugins.stg.STG;
22import org.workcraft.plugins.stg.SignalTransition.Type;
23import org.workcraft.serialisation.Format;
24import org.workcraft.tasks.ProgressMonitor;
25import org.workcraft.tasks.Result;
26import org.workcraft.tasks.Result.Outcome;
27import org.workcraft.tasks.SubtaskMonitor;
28import org.workcraft.util.Export;
29import org.workcraft.util.Export.ExportTask;
30import org.workcraft.util.FileUtils;
31import org.workcraft.workspace.WorkspaceEntry;
32
33
34public class MpsatConformationTask extends MpsatChainTask {
35 private final MpsatSettings toolchainPreparationSettings = new MpsatSettings("Toolchain preparation of data",
36 MpsatMode.UNDEFINED, 0, null, 0, null);
37
38 private final MpsatSettings toolchainCompletionSettings = new MpsatSettings("Toolchain completion",
39 MpsatMode.UNDEFINED, 0, null, 0, null);
40
41 private final WorkspaceEntry we;
42 private final Framework framework;
43 private File envFile;
44
45 public MpsatConformationTask(WorkspaceEntry we, Framework framework, File envFile) {
46 super (we, null, framework);
47 this.we = we;
48 this.framework = framework;
49 this.envFile = envFile;
50 }
51
52 @Override
53 public Result<? extends MpsatChainResult> run(ProgressMonitor<? super MpsatChainResult> monitor) {
54 File workingDirectory = null;
55 try {
56 // Common variables
57 monitor.progressUpdate(0.10);
58 String title = we.getWorkspacePath().getNode();
59 if (title.endsWith(".work")) {
60 title = title.substring(0, title.length() - 5);
61 }
62 workingDirectory = FileUtils.createTempDirectory(title + "-");
63
64 STG devStg = (STG)we.getModelEntry().getVisualModel().getMathModel();
65 Exporter devStgExporter = Export.chooseBestExporter(framework.getPluginManager(), devStg, Format.STG);
66 if (devStgExporter == null) {
67 throw new RuntimeException ("Exporter not available: model class " + devStg.getClass().getName() + " to format STG.");
68 }
69 SubtaskMonitor<Object> subtaskMonitor = new SubtaskMonitor<Object>(monitor);
70 monitor.progressUpdate(0.20);
71
72 // Generating .g for the model
73 File devStgFile = new File(workingDirectory, "dev.g");
74 ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath());
75 Result<? extends Object> devExportResult = framework.getTaskManager().execute(
76 devExportTask, "Exporting circuit .g", subtaskMonitor);
77
78 if (devExportResult.getOutcome() != Outcome.FINISHED) {
79 if (devExportResult.getOutcome() == Outcome.CANCELLED) {
80 return new Result<MpsatChainResult>(Outcome.CANCELLED);
81 }
82 return new Result<MpsatChainResult>(Outcome.FAILED,
83 new MpsatChainResult(devExportResult, null, null, null, toolchainPreparationSettings));
84 }
85 monitor.progressUpdate(0.30);
86
87 // Generating .g for the environment
88 Result<? extends ExternalProcessResult> pcompResult = null;
89 File envStgFile = null;
90 if (envFile.getName().endsWith(".g")) {
91 envStgFile = envFile;
92 } else {
93 STG envStg = (STG)framework.loadFile(envFile).getMathModel();
94 Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG);
95 envStgFile = new File(workingDirectory, "env.g");
96 ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath());
97 Result<? extends Object> envExportResult = framework.getTaskManager().execute(
98 envExportTask, "Exporting environment .g", subtaskMonitor);
99
100 if (envExportResult.getOutcome() != Outcome.FINISHED) {
101 if (envExportResult.getOutcome() == Outcome.CANCELLED) {
102 return new Result<MpsatChainResult>(Outcome.CANCELLED);
103 }
104 return new Result<MpsatChainResult>(Outcome.FAILED,
105 new MpsatChainResult(envExportResult, null, null, null, toolchainPreparationSettings));
106 }
107 }
108 monitor.progressUpdate(0.40);
109
110 // Generating .g for the whole system (model and environment)
111 File stgFile = new File(workingDirectory, "system.g");
112 PcompTask pcompTask = new PcompTask(new File[]{devStgFile, envStgFile}, ConversionMode.OUTPUT, true, false, workingDirectory);
113 pcompResult = framework.getTaskManager().execute(
114 pcompTask, "Running pcomp", subtaskMonitor);
115
116 if (pcompResult.getOutcome() != Outcome.FINISHED) {
117 if (pcompResult.getOutcome() == Outcome.CANCELLED) {
118 return new Result<MpsatChainResult>(Outcome.CANCELLED);
119 }
120 return new Result<MpsatChainResult>(Outcome.FAILED,
121 new MpsatChainResult(devExportResult, pcompResult, null, null, toolchainPreparationSettings));
122 }
123 FileUtils.writeAllText(stgFile, new String(pcompResult.getReturnValue().getOutput()));
124 WorkspaceEntry stgWorkspaceEntry = framework.getWorkspace().open(stgFile, true);
125 STG stg = (STG)stgWorkspaceEntry.getModelEntry().getMathModel();
126 monitor.progressUpdate(0.50);
127
128 // Generate unfolding
129 File unfoldingFile = new File(workingDirectory, "system" + MpsatUtilitySettings.getUnfoldingExtension());
130 PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());
131 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
132 punfTask, "Unfolding .g", subtaskMonitor);
133
134 if (punfResult.getOutcome() != Outcome.FINISHED) {
135 if (punfResult.getOutcome() == Outcome.CANCELLED) {
136 return new Result<MpsatChainResult>(Outcome.CANCELLED);
137 }
138 return new Result<MpsatChainResult>(Outcome.FAILED,
139 new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainPreparationSettings));
140 }
141 monitor.progressUpdate(0.60);
142
143 // Check for interface conformation
144 Set<String> devOutputNames = devStg.getSignalFlatNames(Type.OUTPUT);
145 Set<String> devPlaceNames = parsePlaceNames(pcompResult.getReturnValue().getOutputFile("places.list"), 0);
146// String reachConformation = MpsatSettings.genReachConformation(devOutputNames, devPlaceNames);
147 String reachConformation = MpsatSettings.genReachConformationDetail(stg, devOutputNames, devPlaceNames);
148 if (MpsatUtilitySettings.getDebugReach()) {
149 System.out.println("\nReach expression for the interface conformation property:");
150 System.out.println(reachConformation);
151 }
152 MpsatSettings conformationSettings = new MpsatSettings("Interface conformation",
153 MpsatMode.STG_REACHABILITY, 0, MpsatUtilitySettings.getSolutionMode(),
154 MpsatUtilitySettings.getSolutionCount(), reachConformation);
155
156 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(),
157 unfoldingFile.getCanonicalPath(), workingDirectory);
158 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(
159 mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor);
160
161 if (mpsatConformationResult.getOutcome() != Outcome.FINISHED) {
162 if (mpsatConformationResult.getOutcome() == Outcome.CANCELLED) {
163 return new Result<MpsatChainResult>(Outcome.CANCELLED);
164 }
165 return new Result<MpsatChainResult>(Outcome.FAILED,
166 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings));
167 }
168 monitor.progressUpdate(0.80);
169
170 MpsatResultParser mpsatConformationParser = new MpsatResultParser(mpsatConformationResult.getReturnValue());
171 if (!mpsatConformationParser.getSolutions().isEmpty()) {
172 return new Result<MpsatChainResult>(Outcome.FINISHED,
173 new MpsatChainResult(devExportResult, pcompResult, punfResult, mpsatConformationResult, conformationSettings,
174 "This model does not conform to the environment after the following trace:"));
175 }
176 monitor.progressUpdate(1.0);
177
178 // Success
179 unfoldingFile.delete();
180 String message = "The model conforms to its environment (" + envFile.getName() + ").";
181 return new Result<MpsatChainResult>(Outcome.FINISHED,
182 new MpsatChainResult(devExportResult, pcompResult, punfResult, null, toolchainCompletionSettings, message));
183
184 } catch (Throwable e) {
185 return new Result<MpsatChainResult>(e);
186 } finally {
187 if ((workingDirectory != null) && !MpsatUtilitySettings.getDebugTemporaryFiles()) {
188 FileUtils.deleteDirectoryTree(workingDirectory);
189 }
190 }
191 }
192
193
194 private HashSet<String> parsePlaceNames(byte[] bufferedInput, int lineIndex) {
195 HashSet<String> result = new HashSet<String>();
196 InputStream is = new ByteArrayInputStream(bufferedInput);
197 BufferedReader br = new BufferedReader(new InputStreamReader(is));
198 try {
199 String line = null;
200 while ((lineIndex >= 0) && ((line = br.readLine()) != null)) {
201 lineIndex--;
202 }
203 if (line != null) {
204 for (String name: line.trim().split("\\s")) {
205 result.add(name);
206 }
207 }
208 } catch (IOException e) {
209 e.printStackTrace();
210 }
211 return result;
212 }
213
214
215}
0216
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2014-11-13 00:05:09 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2014-11-30 23:14:46 +0000
@@ -16,12 +16,21 @@
16import org.workcraft.util.FileUtils;16import org.workcraft.util.FileUtils;
1717
18public class MpsatTask implements Task<ExternalProcessResult> {18public class MpsatTask implements Task<ExternalProcessResult> {
19 private String[] args;19 private final String[] args;
20 private String inputFileName;20 private final String inputFileName;
21 21 private final File workingDirectory;
22
22 public MpsatTask(String[] args, String inputFileName) {23 public MpsatTask(String[] args, String inputFileName) {
24 this(args, inputFileName, null);
25 }
26
27 public MpsatTask(String[] args, String inputFileName, File workingDirectory) {
23 this.args = args;28 this.args = args;
24 this.inputFileName = inputFileName;29 this.inputFileName = inputFileName;
30 if (workingDirectory == null) {
31 workingDirectory = FileUtils.createTempDirectory("mpsat_");
32 }
33 this.workingDirectory = workingDirectory;
25 }34 }
26 35
27 @Override36 @Override
@@ -43,23 +52,20 @@
43 // Input file argument52 // Input file argument
44 command.add(inputFileName);53 command.add(inputFileName);
4554
46 File workingDir = FileUtils.createTempDirectory("mpsat_");55 ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, workingDirectory);
47 ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, workingDir);
48
49 Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor);56 Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor);
50 57 if(res.getOutcome() == Outcome.CANCELLED) {
51 if(res.getOutcome() == Outcome.CANCELLED)
52 return res;58 return res;
59 }
53 60
54 Map<String, byte[]> outputFiles = new HashMap<String, byte[]>();61 Map<String, byte[]> outputFiles = new HashMap<String, byte[]>();
55
56 try {62 try {
57 String unfoldingFileName = "mpsat" + MpsatUtilitySettings.getUnfoldingExtension();63 String unfoldingFileName = "mpsat" + MpsatUtilitySettings.getUnfoldingExtension();
58 File unfoldingFile = new File(workingDir, unfoldingFileName);64 File unfoldingFile = new File(workingDirectory, unfoldingFileName);
59 if(unfoldingFile.exists()) {65 if(unfoldingFile.exists()) {
60 outputFiles.put(unfoldingFileName, FileUtils.readAllBytes(unfoldingFile));66 outputFiles.put(unfoldingFileName, FileUtils.readAllBytes(unfoldingFile));
61 }67 }
62 File g = new File(workingDir, "mpsat.g");68 File g = new File(workingDirectory, "mpsat.g");
63 if(g.exists()) {69 if(g.exists()) {
64 outputFiles.put("mpsat.g", FileUtils.readAllBytes(g));70 outputFiles.put("mpsat.g", FileUtils.readAllBytes(g));
65 }71 }
@@ -69,10 +75,11 @@
69 75
70 ExternalProcessResult retVal = res.getReturnValue();76 ExternalProcessResult retVal = res.getReturnValue();
71 ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles);77 ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles);
72 78 if (retVal.getReturnCode() < 2) {
73 if (retVal.getReturnCode() < 2)
74 return Result.finished(result);79 return Result.finished(result);
75 else80 } else {
76 return Result.failed(result);81 return Result.failed(result);
82 }
77 }83 }
78}
79\ No newline at end of file84\ No newline at end of file
85
86}
8087
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java 2014-06-20 21:35:25 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/AbstractMpsatChecker.java 2014-11-30 23:14:46 +0000
@@ -22,15 +22,19 @@
22 22
23 @Override23 @Override
24 public final void run(WorkspaceEntry we) {24 public final void run(WorkspaceEntry we) {
25 final MpsatSettings settings = getSettings();
26 final MpsatChainTask mpsatTask = new MpsatChainTask(we, settings, framework);
27
25 String description = "MPSat tool chain";28 String description = "MPSat tool chain";
26 String title = we.getModelEntry().getModel().getTitle();29 String title = we.getModelEntry().getModel().getTitle();
27 if (!title.isEmpty()) {30 if (!title.isEmpty()) {
28 description += "(" + title +")";31 description += "(" + title +")";
29 }32 }
30 final MpsatChainTask mpsatTask = new MpsatChainTask(we, getSettings(), framework);33 MpsatChainResultHandler monitor = new MpsatChainResultHandler(mpsatTask);
31 framework.getTaskManager().queue(mpsatTask, description, new MpsatChainResultHandler(mpsatTask));34
35 framework.getTaskManager().queue(mpsatTask, description, monitor);
32 }36 }
3337
34 @Override38 @Override
35 public abstract String getDisplayName();39 public abstract String getDisplayName();
3640
3741
=== added file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java 1970-01-01 00:00:00 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatConformationChecker.java 2014-11-30 23:14:46 +0000
@@ -0,0 +1,56 @@
1package org.workcraft.plugins.mpsat.tools;
2
3import java.io.File;
4
5import javax.swing.JFileChooser;
6
7import org.workcraft.Framework;
8import org.workcraft.Tool;
9import org.workcraft.plugins.mpsat.MpsatChainResultHandler;
10import org.workcraft.plugins.mpsat.tasks.MpsatConformationTask;
11import org.workcraft.plugins.stg.STGModel;
12import org.workcraft.util.WorkspaceUtils;
13import org.workcraft.workspace.WorkspaceEntry;
14
15public class MpsatConformationChecker implements Tool {
16 private final Framework framework;
17
18 public MpsatConformationChecker(Framework framework) {
19 this.framework = framework;
20 }
21
22 @Override
23 public String getSection() {
24 return "Verification";
25 }
26
27 @Override
28 public String getDisplayName() {
29 return "Check for conformation (without dummies) [MPSat]...";
30 }
31
32 @Override
33 public boolean isApplicableTo(WorkspaceEntry we) {
34 return WorkspaceUtils.canHas(we, STGModel.class);
35 }
36
37 @Override
38 public final void run(WorkspaceEntry we) {
39 JFileChooser fc = framework.getMainWindow().createOpenDialog("Open environment file", false, null);
40 if (fc.showDialog(null, "Open") == JFileChooser.APPROVE_OPTION) {
41 File file = fc.getSelectedFile();
42 if (framework.checkFile(file)) {
43 final MpsatConformationTask mpsatTask = new MpsatConformationTask(we, framework, file);
44
45 String description = "MPSat tool chain";
46 String title = we.getModelEntry().getModel().getTitle();
47 if (!title.isEmpty()) {
48 description += "(" + title +")";
49 }
50 MpsatChainResultHandler monitor = new MpsatChainResultHandler(mpsatTask);
51
52 framework.getTaskManager().queue(mpsatTask, description, monitor);
53 }
54 }
55 }
56}
057
=== renamed file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/CustomPropertyMpsatChecker.java' => 'MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatCustomPropertyChecker.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/CustomPropertyMpsatChecker.java 2014-04-16 21:55:15 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/tools/MpsatCustomPropertyChecker.java 2014-11-30 23:14:46 +0000
@@ -15,9 +15,9 @@
15import org.workcraft.util.WorkspaceUtils;15import org.workcraft.util.WorkspaceUtils;
16import org.workcraft.workspace.WorkspaceEntry;16import org.workcraft.workspace.WorkspaceEntry;
1717
18public class CustomPropertyMpsatChecker implements Tool {18public class MpsatCustomPropertyChecker implements Tool {
1919
20 public CustomPropertyMpsatChecker(Framework framework) {20 public MpsatCustomPropertyChecker(Framework framework) {
21 this.framework = framework;21 this.framework = framework;
22 }22 }
23 23
2424
=== removed file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java'
--- MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java 2010-10-06 15:51:01 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/pcomp/PCompOutputMode.java 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1package org.workcraft.plugins.pcomp;
2
3public enum PCompOutputMode {
4 DUMMY,
5 INTERNAL,
6 OUTPUT
7}
80
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java'
--- MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java 2014-09-05 15:06:01 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/pcomp/gui/PcompDialog.java 2014-11-30 23:14:46 +0000
@@ -22,7 +22,7 @@
22import org.workcraft.gui.trees.TreeWindow;22import org.workcraft.gui.trees.TreeWindow;
23import org.workcraft.gui.workspace.Path;23import org.workcraft.gui.workspace.Path;
24import org.workcraft.gui.workspace.WorkspaceChooser;24import org.workcraft.gui.workspace.WorkspaceChooser;
25import org.workcraft.plugins.pcomp.PCompOutputMode;25import org.workcraft.plugins.pcomp.tasks.PcompTask.ConversionMode;
26import org.workcraft.plugins.stg.STGWorkspaceFilter;26import org.workcraft.plugins.stg.STGWorkspaceFilter;
2727
28@SuppressWarnings("serial")28@SuppressWarnings("serial")
@@ -62,14 +62,13 @@
62 return improvedPcomp.isSelected();62 return improvedPcomp.isSelected();
63 }63 }
64 64
65 public PCompOutputMode getMode()65 public ConversionMode getMode() {
66 {
67 if (leaveOutputs.isSelected())66 if (leaveOutputs.isSelected())
68 return PCompOutputMode.OUTPUT;67 return ConversionMode.OUTPUT;
69 if (internalize.isSelected())68 if (internalize.isSelected())
70 return PCompOutputMode.INTERNAL;69 return ConversionMode.INTERNAL;
71 if (dummify.isSelected())70 if (dummify.isSelected())
72 return PCompOutputMode.DUMMY;71 return ConversionMode.DUMMY;
73 throw new NotSupportedException("No button is selected. Cannot proceed.");72 throw new NotSupportedException("No button is selected. Cannot proceed.");
74 }73 }
75 74
7675
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java'
--- MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2014-09-05 15:06:01 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2014-11-30 23:14:46 +0000
@@ -3,28 +3,38 @@
3import java.io.File;3import java.io.File;
4import java.io.IOException;4import java.io.IOException;
5import java.util.ArrayList;5import java.util.ArrayList;
6import java.util.HashMap;
7import java.util.Map;
68
7import org.workcraft.plugins.pcomp.PCompOutputMode;
8import org.workcraft.plugins.pcomp.PcompUtilitySettings;9import org.workcraft.plugins.pcomp.PcompUtilitySettings;
9import org.workcraft.plugins.shared.tasks.ExternalProcessResult;10import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
10import org.workcraft.plugins.shared.tasks.ExternalProcessTask;11import org.workcraft.plugins.shared.tasks.ExternalProcessTask;
11import org.workcraft.tasks.ProgressMonitor;12import org.workcraft.tasks.ProgressMonitor;
12import org.workcraft.tasks.Result;13import org.workcraft.tasks.Result;
14import org.workcraft.tasks.Result.Outcome;
13import org.workcraft.tasks.Task;15import org.workcraft.tasks.Task;
14import org.workcraft.tasks.Result.Outcome;
15import org.workcraft.util.FileUtils;16import org.workcraft.util.FileUtils;
1617
17public class PcompTask implements Task<ExternalProcessResult> {18public class PcompTask implements Task<ExternalProcessResult> {
18 private File[] inputs;19
19 private final PCompOutputMode mode;20 public enum ConversionMode {
20 private final boolean sharedOutputs;21 DUMMY,
21 private final boolean improved;22 INTERNAL,
22 23 OUTPUT
23 public PcompTask(File[] inputs, PCompOutputMode mode, boolean sharedOutputs, boolean improved) {24 }
24 this.inputs = inputs;25
25 this.mode = mode;26 private final File[] inputFiles;
26 this.sharedOutputs = sharedOutputs;27 private final ConversionMode conversionMode;
27 this.improved = improved;28 private final boolean useSharedOutputs;
29 private final boolean useImprovedComposition;
30 private final File workingDirectory;
31
32 public PcompTask(File[] inputFiles, ConversionMode conversionMode, boolean useSharedOutputs, boolean useImprovedComposition, File workingDirectory) {
33 this.inputFiles = inputFiles;
34 this.conversionMode = conversionMode;
35 this.useSharedOutputs = useSharedOutputs;
36 this.useImprovedComposition = useImprovedComposition;
37 this.workingDirectory = workingDirectory;
28 }38 }
29 39
30 @Override40 @Override
@@ -38,60 +48,58 @@
38 }48 }
39 }49 }
40 50
41 if (mode == PCompOutputMode.DUMMY) {51 if (conversionMode == ConversionMode.DUMMY) {
42 command.add("-d");52 command.add("-d");
43 command.add("-r");53 command.add("-r");
44 }54 } else if (conversionMode == ConversionMode.INTERNAL) {
45
46 if (mode == PCompOutputMode.INTERNAL) {
47 command.add("-i");55 command.add("-i");
48 }56 }
49 57
50 if (sharedOutputs) {58 if (useSharedOutputs) {
51 command.add("-o");59 command.add("-o");
52 }60 }
5361
54 if (improved) {62 if (useImprovedComposition) {
55 command.add("-p");63 command.add("-p");
56 }64 }
57 65
58 File listFile;66 File listFile = null;
59
60 try {67 try {
61 listFile = File.createTempFile("pcomp_", ".list");68 if (workingDirectory == null) {
69 listFile = File.createTempFile("places_", ".list");
70 } else {
71 listFile = new File(workingDirectory, "places.list");
72 }
62 } catch (IOException e) {73 } catch (IOException e) {
63 return Result.exception(e);74 return Result.exception(e);
64 }75 }
76 command.add("-l" + listFile.getAbsolutePath());
77
78 for (File inputFile: inputFiles) {
79 command.add(inputFile.getAbsolutePath());
80 }
65 81
66 try82 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command, new File(".")).run(monitor);
67 {83 if (res.getOutcome() != Outcome.FINISHED) {
68 StringBuilder fileList = new StringBuilder();84 return res;
69 for (File f : inputs)85 }
70 {86
71 fileList.append(f.getAbsolutePath());87 Map<String, byte[]> outputFiles = new HashMap<String, byte[]>();
72 fileList.append('\n');88 try {
73 }89 if(listFile.exists()) {
74 90 outputFiles.put("places.list", FileUtils.readAllBytes(listFile));
75 try {91 }
76 FileUtils.writeAllText(listFile, fileList.toString());92 } catch (IOException e) {
77 } catch (IOException e) {93 return new Result<ExternalProcessResult>(e);
78 return Result.exception(e);94 }
79 }95
8096 ExternalProcessResult retVal = res.getReturnValue();
81 command.add("@"+listFile.getAbsolutePath());97 ExternalProcessResult result = new ExternalProcessResult(retVal.getReturnCode(), retVal.getOutput(), retVal.getErrors(), outputFiles);
82 98 if (retVal.getReturnCode() < 2) {
83 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command, new File(".")).run(monitor);99 return Result.finished(result);
84 if (res.getOutcome() != Outcome.FINISHED)100 } else {
85 return res;101 return Result.failed(result);
86 102 }
87 ExternalProcessResult retVal = res.getReturnValue();103
88 if (retVal.getReturnCode() < 2)
89 return Result.finished(retVal);
90 else
91 return Result.failed(retVal);
92 }
93 finally {
94 listFile.delete();
95 }
96 }104 }
97}105}
98\ No newline at end of file106\ No newline at end of file
99107
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java'
--- MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java 2014-09-05 15:06:01 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/pcomp/tools/PcompTool.java 2014-11-30 23:14:46 +0000
@@ -46,7 +46,7 @@
46 }46 }
47 47
48 PcompTask pcompTask = new PcompTask(inputs.toArray(new File[0]), dialog.getMode(), 48 PcompTask pcompTask = new PcompTask(inputs.toArray(new File[0]), dialog.getMode(),
49 dialog.isSharedOutputsChecked(), dialog.isImprovedPcompChecked());49 dialog.isSharedOutputsChecked(), dialog.isImprovedPcompChecked(), null);
50 50
51 PcompResultHandler pcompResult = new PcompResultHandler(framework, dialog.showInEditor());51 PcompResultHandler pcompResult = new PcompResultHandler(framework, dialog.showInEditor());
52 52
5353
=== modified file 'STGPlugin/src/org/workcraft/plugins/stg/STG.java'
--- STGPlugin/src/org/workcraft/plugins/stg/STG.java 2014-11-03 18:11:53 +0000
+++ STGPlugin/src/org/workcraft/plugins/stg/STG.java 2014-11-30 23:14:46 +0000
@@ -213,6 +213,16 @@
213 }213 }
214 });214 });
215 }215 }
216
217 public Set<String> getSignalFlatNames(Type type) {
218 Set<String> result = new HashSet<String>();
219 for (SignalTransition st : getSignalTransitions(type)) {
220 String ref = getSignalReference(st);
221 String flatName = NamespaceHelper.hierarchicalToFlatName(ref);
222 result.add(flatName);
223 }
224 return result;
225 }
216226
217 @Override227 @Override
218 public Set<String> getSignalReferences(Type type) {228 public Set<String> getSignalReferences(Type type) {
@@ -359,8 +369,8 @@
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.");
360 }370 }
361 371
362 return "<" + NamespaceHelper.getFlatName(referenceManager.getNodeReference(null, preset.iterator().next())) 372 return "<" + NamespaceHelper.hierarchicalToFlatName(referenceManager.getNodeReference(null, preset.iterator().next()))
363 + "," + NamespaceHelper.getFlatName(referenceManager.getNodeReference(null, postset.iterator().next())) + ">";373 + "," + NamespaceHelper.hierarchicalToFlatName(referenceManager.getNodeReference(null, postset.iterator().next())) + ">";
364 }374 }
365 }375 }
366 return super.getNodeReference(provider, node);376 return super.getNodeReference(provider, node);
@@ -369,27 +379,27 @@
369 @Override379 @Override
370 public Node getNodeByReference(NamespaceProvider provider, String reference) {380 public Node getNodeByReference(NamespaceProvider provider, String reference) {
371 Pair<String, String> implicitPlaceTransitions = LabelParser.parseImplicitPlaceReference(reference);381 Pair<String, String> implicitPlaceTransitions = LabelParser.parseImplicitPlaceReference(reference);
372
373 if (implicitPlaceTransitions != null) {382 if (implicitPlaceTransitions != null) {
374 Node t1 = referenceManager.getNodeByReference(provider, 383 Node t1 = referenceManager.getNodeByReference(provider,
375 NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getFirst()) );384 NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getFirst()) );
385
376 Node t2 = referenceManager.getNodeByReference(provider, 386 Node t2 = referenceManager.getNodeByReference(provider,
377 NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getSecond()) );387 NamespaceHelper.flatToHierarchicalName(implicitPlaceTransitions.getSecond()) );
378388 if ((t1 != null) && (t2 != null)) {
379 Set<Node> implicitPlaceCandidates = SetUtils.intersection(getPreset(t2), getPostset(t1));389 Set<Node> implicitPlaceCandidates = SetUtils.intersection(getPreset(t2), getPostset(t1));
380390
381 for (Node node : implicitPlaceCandidates) {391 for (Node node : implicitPlaceCandidates) {
382 if ((node instanceof STGPlace) && ((STGPlace)node).isImplicit()) {392 if ((node instanceof STGPlace) && ((STGPlace)node).isImplicit()) {
383 return node;393 return node;
394 }
384 }395 }
385 }396 }
386
387 throw new NotFoundException("Implicit place between "397 throw new NotFoundException("Implicit place between "
388 + implicitPlaceTransitions.getFirst() + " and "398 + implicitPlaceTransitions.getFirst() + " and "
389 + implicitPlaceTransitions.getSecond() + " does not exist.");399 + implicitPlaceTransitions.getSecond() + " does not exist.");
390 } else400 } else {
391
392 return super.getNodeByReference(provider, reference); 401 return super.getNodeByReference(provider, reference);
402 }
393 }403 }
394404
395 public void makeExplicit(STGPlace implicitPlace) {405 public void makeExplicit(STGPlace implicitPlace) {
396406
=== modified file 'STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java'
--- STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java 2014-07-28 13:32:42 +0000
+++ STGPlugin/src/org/workcraft/plugins/stg/serialisation/DotGSerialiser.java 2014-11-30 23:14:46 +0000
@@ -66,7 +66,7 @@
66 66
67 for (String s : sortedNames) {67 for (String s : sortedNames) {
68 out.print(" ");68 out.print(" ");
69 out.print(NamespaceHelper.getFlatName(s));69 out.print(NamespaceHelper.hierarchicalToFlatName(s));
70 }70 }
71 71
72 out.print("\n");72 out.print("\n");
@@ -90,7 +90,7 @@
90 return;90 return;
91 91
92 if (model.getPostset(node).size()>0) {92 if (model.getPostset(node).size()>0) {
93 out.write(NamespaceHelper.getFlatName(model.getNodeReference(node)));93 out.write(NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(node)));
9494
95 for (Node n : sortNodes (model.getPostset(node), model) ) {95 for (Node n : sortNodes (model.getPostset(node), model) ) {
96 if (n instanceof STGPlace) {96 if (n instanceof STGPlace) {
@@ -98,11 +98,11 @@
98 Collection<Node> postset = model.getPostset(n);98 Collection<Node> postset = model.getPostset(n);
99 if (postset.size() > 1)99 if (postset.size() > 1)
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");
101 out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(postset.iterator().next()))); 101 out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(postset.iterator().next())));
102 } else102 } else
103 out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(n))); 103 out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(n)));
104 } else {104 } else {
105 out.write(" " + NamespaceHelper.getFlatName(model.getNodeReference(n)));105 out.write(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(n)));
106 }106 }
107 }107 }
108 108
@@ -165,12 +165,12 @@
165 165
166 if (p instanceof STGPlace) {166 if (p instanceof STGPlace) {
167 if ( ((STGPlace)p).isImplicit() ) {167 if ( ((STGPlace)p).isImplicit() ) {
168 reference = "<" + NamespaceHelper.getFlatName(model.getNodeReference(model.getPreset(p).iterator().next())) + "," +168 reference = "<" + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(model.getPreset(p).iterator().next())) + "," +
169 NamespaceHelper.getFlatName(model.getNodeReference(model.getPostset(p).iterator().next())) + ">";169 NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(model.getPostset(p).iterator().next())) + ">";
170 } else170 } else
171 reference = NamespaceHelper.getFlatName(model.getNodeReference(p));171 reference = NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p));
172 } else {172 } else {
173 reference = NamespaceHelper.getFlatName(model.getNodeReference(p));173 reference = NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p));
174 }174 }
175 175
176 if (tokens == 1)176 if (tokens == 1)
@@ -201,7 +201,7 @@
201 for (Place p : places) {201 for (Place p : places) {
202 if (p instanceof STGPlace)202 if (p instanceof STGPlace)
203 if (((STGPlace)p).getCapacity() != 1)203 if (((STGPlace)p).getCapacity() != 1)
204 capacity.append(" " + NamespaceHelper.getFlatName(model.getNodeReference(p)) + "=" + ((STGPlace)p).getCapacity());204 capacity.append(" " + NamespaceHelper.hierarchicalToFlatName(model.getNodeReference(p)) + "=" + ((STGPlace)p).getCapacity());
205 }205 }
206 206
207 if (capacity.length() > 0)207 if (capacity.length() > 0)
@@ -212,7 +212,7 @@
212 LinkedList<String> transitions = new LinkedList<String>(); 212 LinkedList<String> transitions = new LinkedList<String>();
213 213
214 for (Transition t : net.getTransitions())214 for (Transition t : net.getTransitions())
215 transitions.add(NamespaceHelper.getFlatName(net.getNodeReference(t)));215 transitions.add(NamespaceHelper.hierarchicalToFlatName(net.getNodeReference(t)));
216 216
217 writeSignalsHeader(out, transitions, ".dummy");217 writeSignalsHeader(out, transitions, ".dummy");
218 218
219219
=== modified file 'Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java'
--- Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java 2014-07-11 09:35:42 +0000
+++ Tests/src/org/workcraft/testing/dom/hierarchy/HierarchicalUniqueNameReferenceManagerTest.java 2014-11-30 23:14:46 +0000
@@ -68,7 +68,7 @@
68 String hName = en.getKey();68 String hName = en.getKey();
69 String fName = en.getValue();69 String fName = en.getValue();
70 70
71 String answer = NamespaceHelper.getFlatName(hName); 71 String answer = NamespaceHelper.hierarchicalToFlatName(hName);
72 assertTrue(answer.equals(fName));72 assertTrue(answer.equals(fName));
73 73
74 hName = hName.replaceAll("'", "");74 hName = hName.replaceAll("'", "");
7575
=== modified file 'WorkcraftCore/src/org/workcraft/Info.java'
--- WorkcraftCore/src/org/workcraft/Info.java 2014-11-24 15:37:13 +0000
+++ WorkcraftCore/src/org/workcraft/Info.java 2014-11-30 23:14:46 +0000
@@ -13,7 +13,7 @@
13 private static final int majorVersion = 3;13 private static final int majorVersion = 3;
14 private static final int minorVersion = 0;14 private static final int minorVersion = 0;
15 private static final int revisionVersion = 3;15 private static final int revisionVersion = 3;
16 private static final String statusVersion = "alpha";16 private static final String statusVersion = "beta";
1717
18 private static final int startYear = 2006;18 private static final int startYear = 2006;
19 private static final int currentYear = Calendar.getInstance().get(Calendar.YEAR);19 private static final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
2020
=== modified file 'WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java'
--- WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java 2014-11-12 18:06:50 +0000
+++ WorkcraftCore/src/org/workcraft/dom/hierarchy/NamespaceHelper.java 2014-11-30 23:14:46 +0000
@@ -23,20 +23,20 @@
23 // TODO: make it work with the embedded ' characters23 // TODO: make it work with the embedded ' characters
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]+)?)(.*)");
25 25
26 public static String getFlatName(String reference) {26 public static String hierarchicalToFlatName(String reference) {
27 return getFlatName(reference, flatNameSeparator, true);27 return hierarchicalToFlatName(reference, flatNameSeparator, true);
28 }28 }
29 29
30 private static String getFlatName(String reference, String flatSeparator, boolean isFirst) {30 private static String hierarchicalToFlatName(String reference, String flatSeparator, boolean suppressLeadingSeparator) {
31 if (flatSeparator==null) flatSeparator=flatNameSeparator;31 if (flatSeparator==null) flatSeparator=flatNameSeparator;
32 32
33 // do not work with implicit places(?)33 // Do not work with implicit places(?)
34 if (reference.startsWith("<")) { 34 if (reference.startsWith("<")) {
35 return reference;35 return reference;
36 }36 }
37 String ret = "";37 String ret = "";
38 // in this version the first separator is not shown38 // In this version the first separator is suppressed
39 if (!isFirst && reference.startsWith(hierarchySeparator)) {39 if (!suppressLeadingSeparator && reference.startsWith(hierarchySeparator)) {
40 ret=flatSeparator;40 ret=flatSeparator;
41 }41 }
42 42
@@ -45,11 +45,11 @@
45 if (tail.equals("")) { 45 if (tail.equals("")) {
46 return ret+head;46 return ret+head;
47 }47 }
48 return ret+head+getFlatName(tail, flatSeparator, false);48 return ret + head + hierarchicalToFlatName(tail, flatSeparator, false);
49 }49 }
50 50
51 public static String flatToHierarchicalName(String reference) {51 public static String flatToHierarchicalName(String flatName) {
52 return flatToHierarchicalName(reference, flatNameSeparator);52 return flatToHierarchicalName(flatName, flatNameSeparator);
53 }53 }
54 54
55 private static String flatToHierarchicalName(String reference, String flatSeparator) {55 private static String flatToHierarchicalName(String reference, String flatSeparator) {
5656
=== modified file 'WorkcraftCore/src/org/workcraft/gui/MainWindow.java'
--- WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2014-11-24 17:04:15 +0000
+++ WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2014-11-30 23:14:46 +0000
@@ -833,7 +833,7 @@
833 }833 }
834 }834 }
835835
836 private JFileChooser createOpenDialog(String title, boolean multiSelection, Importer[] importers) {836 public JFileChooser createOpenDialog(String title, boolean multiSelection, Importer[] importers) {
837 JFileChooser fc = new JFileChooser();837 JFileChooser fc = new JFileChooser();
838 fc.setDialogType(JFileChooser.OPEN_DIALOG);838 fc.setDialogType(JFileChooser.OPEN_DIALOG);
839 fc.setMultiSelectionEnabled(multiSelection);839 fc.setMultiSelectionEnabled(multiSelection);
@@ -856,7 +856,7 @@
856 return fc;856 return fc;
857 }857 }
858 858
859 private JFileChooser createSaveDialog(String title, File file, Exporter exporter) {859 public JFileChooser createSaveDialog(String title, File file, Exporter exporter) {
860 JFileChooser fc = new JFileChooser();860 JFileChooser fc = new JFileChooser();
861 fc.setDialogType(JFileChooser.SAVE_DIALOG);861 fc.setDialogType(JFileChooser.SAVE_DIALOG);
862 fc.setDialogTitle(title);862 fc.setDialogTitle(title);
863863
=== modified file 'WorkcraftCore/src/org/workcraft/util/FileUtils.java'
--- WorkcraftCore/src/org/workcraft/util/FileUtils.java 2014-01-15 17:13:30 +0000
+++ WorkcraftCore/src/org/workcraft/util/FileUtils.java 2014-11-30 23:14:46 +0000
@@ -31,8 +31,6 @@
31import java.io.InputStream;31import java.io.InputStream;
32import java.io.InputStreamReader;32import java.io.InputStreamReader;
33import java.io.OutputStream;33import java.io.OutputStream;
34import java.net.URI;
35import java.net.URISyntaxException;
36import java.nio.channels.Channels;34import java.nio.channels.Channels;
37import java.nio.channels.FileChannel;35import java.nio.channels.FileChannel;
38import java.nio.channels.WritableByteChannel;36import java.nio.channels.WritableByteChannel;
3937
=== modified file 'build_distr_linux.sh'
--- build_distr_linux.sh 2014-11-24 15:37:13 +0000
+++ build_distr_linux.sh 2014-11-30 23:14:46 +0000
@@ -1,7 +1,7 @@
1#!/usr/bin/env bash1#!/usr/bin/env bash
22
3src_dir="."3src_dir="."
4distr_dir="../../workcraft_3.0.3_alpha"4distr_dir="../../workcraft_3.0.3_beta"
5template_dir="../../distr-template-linux"5template_dir="../../distr-template-linux"
66
7./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir7./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir
88
=== modified file 'build_distr_windows.sh'
--- build_distr_windows.sh 2014-11-24 15:37:13 +0000
+++ build_distr_windows.sh 2014-11-30 23:14:46 +0000
@@ -1,7 +1,7 @@
1#!/usr/bin/env bash1#!/usr/bin/env bash
22
3src_dir="."3src_dir="."
4distr_dir="../../workcraft_3.0.3_alpha"4distr_dir="../../workcraft_3.0.3_beta"
5template_dir="../../distr-template-windows"5template_dir="../../distr-template-windows"
66
7./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir7./build_distr.sh -s $src_dir -d $distr_dir -t $template_dir

Subscribers

People subscribed via source and target branches