Merge lp:~danilovesky/workcraft/trunk-bug-1351503 into lp:workcraft
- trunk-bug-1351503
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 537 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-bug-1351503 |
Merge into: | lp:workcraft |
Diff against target: |
364 lines (+51/-74) 5 files modified
CpogsPlugin/src/org/workcraft/plugins/cpog/CpogProgrammer.java (+19/-36) CpogsPlugin/src/org/workcraft/plugins/cpog/CpogSettings.java (+24/-1) CpogsPlugin/src/org/workcraft/plugins/cpog/EncoderSettings.java (+6/-6) CpogsPlugin/src/org/workcraft/plugins/cpog/gui/EncoderConfigurationDialog.java (+2/-8) WorkcraftCore/src/org/workcraft/gui/graph/tools/SelectionTool.java (+0/-23) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-bug-1351503 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Approve | ||
Review via email: mp+229468@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Danil Sokolov (danilovesky) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/CpogProgrammer.java' |
2 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/CpogProgrammer.java 2014-07-29 11:59:53 +0000 |
3 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/CpogProgrammer.java 2014-08-04 14:17:33 +0000 |
4 | @@ -32,19 +32,22 @@ |
5 | import org.workcraft.plugins.cpog.optimisation.expressions.Zero; |
6 | import org.workcraft.plugins.cpog.optimisation.javacc.BooleanParser; |
7 | import org.workcraft.plugins.cpog.optimisation.javacc.ParseException; |
8 | +import org.workcraft.util.FileUtils; |
9 | import org.workcraft.util.Func; |
10 | import org.workcraft.util.Geometry; |
11 | import org.workcraft.util.Hierarchy; |
12 | import org.workcraft.workspace.WorkspaceEntry; |
13 | |
14 | public class CpogProgrammer { |
15 | - |
16 | + // FIXME: Relative path to the directory with programmer results. Currently this is hard-coded in programmer. |
17 | + private static final String genEncodingDir = "../tools/results/generated_encoding/"; |
18 | + |
19 | private EncoderSettings settings; |
20 | private File scenarioFile, encodingFile ; |
21 | private Double minArea; |
22 | - |
23 | + |
24 | // SETTING PARAMETERS FOR CALLING PROGRAMMER |
25 | - private String programmerCommand = "programmer"; |
26 | + private String programmerCommand; |
27 | private String espressoCommand; |
28 | private String abcFolder; |
29 | private String gatesLibrary; |
30 | @@ -262,10 +265,6 @@ |
31 | abcFolder = ""; |
32 | gateLibFlag = "-lib"; |
33 | gatesLibrary = ""; |
34 | - JOptionPane.showMessageDialog(null, |
35 | - "You can download it at http://www.eecs.berkeley.edu/~alanmi/abc/ to improve the outcome of the encoding.", |
36 | - "Abc tool disabled", |
37 | - JOptionPane.INFORMATION_MESSAGE); |
38 | } |
39 | |
40 | // FILL IN PARAMETERS FOR CALLING PROGRAMER PROPERLY |
41 | @@ -330,11 +329,10 @@ |
42 | System.out.println("Error"); |
43 | } |
44 | |
45 | - deleteDir(new File("results/")); |
46 | - File d = new File("results/generated_encoding/"); |
47 | - d.mkdirs(); |
48 | - |
49 | - // IF SCENCO MODE IS NOT SELECTED, PROGRAMMER IS CALLED ITERATIVELY |
50 | + FileUtils.deleteDirectoryTree(new File(genEncodingDir)); |
51 | + new File(genEncodingDir).mkdirs(); |
52 | + |
53 | + // IF SCENCO MODE IS NOT SELECTED, PROGRAMMER IS CALLED ITERATIVELY |
54 | // BECAUSE, IF CONTINUOUS OPTION IS SELECTED, TOOL IS CALLED |
55 | // TILL USER PRESSES STOP BUTTON |
56 | if(!SCENCO){ |
57 | @@ -673,22 +671,6 @@ |
58 | } |
59 | } |
60 | |
61 | - // REMOVE DIRECTORY CONTAINS ALL THE CONTROLLER SYNTHESISED |
62 | - // FOR EACH ENCODING SOLUTION |
63 | - private static boolean deleteDir(File dir) { |
64 | - if (dir.isDirectory()) { |
65 | - String[] children = dir.list(); |
66 | - for (int i = 0; i < children.length; i++) { |
67 | - boolean success = deleteDir(new File(dir, children[i])); |
68 | - if (!success) { |
69 | - return false; |
70 | - } |
71 | - } |
72 | - } |
73 | - |
74 | - return dir.delete(); // The directory is empty now and can be deleted. |
75 | - } |
76 | - |
77 | // BUILD CONSTRAINT FOR EACH ELEMENTS LOOPING ON THE SCENARIOS |
78 | private String generateConstraint(char [][][] constraints, int numScenarios, int event1, int event2) |
79 | { |
80 | @@ -856,7 +838,7 @@ |
81 | // THE MICROCONTROLLER SYNTHESISED WITH ABC TOOL |
82 | private void printController(int m){ |
83 | System.out.println(); |
84 | - String fileName = "results/generated_encoding/"; |
85 | + String fileName = genEncodingDir; |
86 | for(int i=0; i<m; i++) fileName = fileName.concat(binaryToInt(opt_enc[i]) + "_"); |
87 | fileName = fileName.concat(".prg"); |
88 | File f = new File(fileName); |
89 | @@ -896,14 +878,14 @@ |
90 | // TO WORKCRAFT TO BUILD THE COMPOSITIONAL GRAPH |
91 | private int callingProgrammer(Double currArea, WorkspaceEntry we, int it, boolean continuous) throws IOException{ |
92 | //Debug Printing: launching executable |
93 | - /*System.out.println(programmerCommand + " " + scenarioFile.getAbsolutePath() + " " + |
94 | - "-m" + " " + effort + " " + genMode + " " + numSol + " " + customFlag + " " + customPath + " " + |
95 | - verbose + " " + cpogSize + " " + disableFunction + " " + oldSynt + " " + |
96 | - espressoFlag + " " + espressoCommand + " " + abcFlag + " " + abcFolder + " " + gateLibFlag + " " + |
97 | - gatesLibrary);*/ |
98 | +// System.out.println(programmerCommand + " " + scenarioFile.getAbsolutePath() + " " + |
99 | +// "-m" + " " + effort + " " + genMode + " " + numSol + " " + customFlag + " " + customPath + " " + |
100 | +// verbose + " " + cpogSize + " " + disableFunction + " " + oldSynt + " " + |
101 | +// espressoFlag + " " + espressoCommand + " " + abcFlag + " " + abcFolder + " " + gateLibFlag + " " + |
102 | +// gatesLibrary); |
103 | process = new ProcessBuilder(programmerCommand, scenarioFile.getAbsolutePath(), |
104 | - "-m",effort,genMode, numSol,customFlag,customPath,verbose,cpogSize,disableFunction,oldSynt, |
105 | - espressoFlag,espressoCommand, abcFlag, abcFolder, gateLibFlag, gatesLibrary).start(); |
106 | + "-m", effort, genMode, numSol, customFlag, customPath, verbose, cpogSize, disableFunction, oldSynt, |
107 | + espressoFlag, espressoCommand, abcFlag, abcFolder, gateLibFlag, gatesLibrary).start(); |
108 | InputStream is = process.getInputStream(); |
109 | InputStreamReader isr = new InputStreamReader(is); |
110 | BufferedReader br = new BufferedReader(isr); |
111 | @@ -1069,6 +1051,7 @@ |
112 | opt_formulaeArcs = new String[elements*elements]; |
113 | truthTableArcs = new String[elements*elements]; |
114 | arcNames = new String[elements*elements]; |
115 | + programmerCommand = CpogSettings.getProgrammerCommand(); |
116 | espressoCommand = CpogSettings.getEspressoCommand(); |
117 | abcFolder = CpogSettings.getAbcFolder(); |
118 | gatesLibrary = CpogSettings.getGatesLibrary(); |
119 | |
120 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/CpogSettings.java' |
121 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/CpogSettings.java 2014-07-25 14:53:23 +0000 |
122 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/CpogSettings.java 2014-08-04 14:17:33 +0000 |
123 | @@ -38,6 +38,7 @@ |
124 | private static final String keyCircuitSize = prefix + ".circuitSize"; |
125 | private static final String keyClaspCommand = prefix + ".claspCommand"; |
126 | private static final String keyMinisatCommand = prefix + ".minisatCommand"; |
127 | + private static final String keyProgrammerCommand = prefix + ".programmerCommand"; |
128 | private static final String keyEspressoCommand = prefix + ".espressoCommand"; |
129 | private static final String keyAbcFolder = prefix + ".abcFolder"; |
130 | private static final String keyGatesLibrary = prefix + ".gatesLibrary"; |
131 | @@ -46,6 +47,7 @@ |
132 | private static final int defaultCircuitSize = 4; |
133 | private static final String defaultClaspCommand = "clasp"; |
134 | private static final String defaultMinisatCommand = "minisat"; |
135 | + private static final String defaultProgrammerCommand = "programmer"; |
136 | private static final String defaultEspressoCommand = "espresso"; |
137 | private static final String defaultAbcFolder = "abc/"; |
138 | private static final String defaultGatesLibrary = "90nm.genlib"; |
139 | @@ -54,6 +56,7 @@ |
140 | private static int circuitSize = defaultCircuitSize; |
141 | private static String claspCommand = defaultClaspCommand; |
142 | private static String minisatCommand = defaultMinisatCommand; |
143 | + private static String programmerCommand = defaultProgrammerCommand; |
144 | private static String espressoCommand = defaultEspressoCommand; |
145 | private static String abcFolder = defaultAbcFolder; |
146 | private static String gatesLibrary = defaultGatesLibrary; |
147 | @@ -100,7 +103,17 @@ |
148 | }); |
149 | |
150 | properties.add(new PropertyDeclaration<CpogSettings, String>( |
151 | - this, "Espresso solver", String.class) { |
152 | + this, "Programmer command", String.class) { |
153 | + protected void setter(CpogSettings object, String value) { |
154 | + CpogSettings.setProgrammerCommand(value); |
155 | + } |
156 | + protected String getter(CpogSettings object) { |
157 | + return CpogSettings.getProgrammerCommand(); |
158 | + } |
159 | + }); |
160 | + |
161 | + properties.add(new PropertyDeclaration<CpogSettings, String>( |
162 | + this, "Espresso command", String.class) { |
163 | protected void setter(CpogSettings object, String value) { |
164 | CpogSettings.setEspressoCommand(value); |
165 | } |
166 | @@ -136,6 +149,7 @@ |
167 | setCircuitSize(config.getInt(keyCircuitSize, defaultCircuitSize)); |
168 | setClaspCommand(config.getString(keyClaspCommand, defaultClaspCommand)); |
169 | setMinisatCommand(config.getString(keyMinisatCommand, defaultMinisatCommand)); |
170 | + setProgrammerCommand(config.getString(keyProgrammerCommand, defaultProgrammerCommand)); |
171 | setEspressoCommand(config.getString(keyEspressoCommand, defaultEspressoCommand)); |
172 | setAbcFolder(config.getString(keyAbcFolder, defaultAbcFolder)); |
173 | setGatesLibrary(config.getString(keyGatesLibrary, defaultGatesLibrary)); |
174 | @@ -147,6 +161,7 @@ |
175 | config.setInt(keyCircuitSize, getCircuitSize()); |
176 | config.set(keyClaspCommand, getClaspCommand()); |
177 | config.set(keyMinisatCommand, getMinisatCommand()); |
178 | + config.set(keyProgrammerCommand, getProgrammerCommand()); |
179 | config.set(keyEspressoCommand, getEspressoCommand()); |
180 | config.set(keyAbcFolder, getAbcFolder()); |
181 | config.set(keyGatesLibrary, getGatesLibrary()); |
182 | @@ -199,6 +214,14 @@ |
183 | minisatCommand = value; |
184 | } |
185 | |
186 | + public static String getProgrammerCommand() { |
187 | + return programmerCommand; |
188 | + } |
189 | + |
190 | + public static void setProgrammerCommand(String value) { |
191 | + programmerCommand = value; |
192 | + } |
193 | + |
194 | public static String getEspressoCommand() { |
195 | return espressoCommand; |
196 | } |
197 | |
198 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/EncoderSettings.java' |
199 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/EncoderSettings.java 2014-07-29 11:59:53 +0000 |
200 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/EncoderSettings.java 2014-08-04 14:17:33 +0000 |
201 | @@ -37,12 +37,6 @@ |
202 | return choice; |
203 | } |
204 | } |
205 | - |
206 | - public EncoderSettings(String espressoPath, String abcPath, String libPath) { |
207 | - this.espressoPath = espressoPath; |
208 | - this.abcPath = abcPath; |
209 | - this.libPath = libPath; |
210 | - } |
211 | |
212 | private int solutionNumber = 10, numPO,bits; |
213 | private GenerationMode genMode = GenerationMode.OPTIMAL_ENCODING; |
214 | @@ -50,6 +44,12 @@ |
215 | private String[] customEnc; |
216 | private String espressoPath,abcPath,libPath; |
217 | |
218 | + public EncoderSettings(String espressoPath, String abcPath, String libPath) { |
219 | + this.espressoPath = espressoPath; |
220 | + this.abcPath = abcPath; |
221 | + this.libPath = libPath; |
222 | + } |
223 | + |
224 | public boolean isCpogSize() { |
225 | return cpogSize; |
226 | } |
227 | |
228 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/gui/EncoderConfigurationDialog.java' |
229 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/gui/EncoderConfigurationDialog.java 2014-07-29 11:59:53 +0000 |
230 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/gui/EncoderConfigurationDialog.java 2014-08-04 14:17:33 +0000 |
231 | @@ -18,7 +18,6 @@ |
232 | import javax.swing.JComboBox; |
233 | import javax.swing.JComponent; |
234 | import javax.swing.JDialog; |
235 | -import javax.swing.JFrame; |
236 | import javax.swing.JLabel; |
237 | import javax.swing.JOptionPane; |
238 | import javax.swing.JPanel; |
239 | @@ -36,6 +35,7 @@ |
240 | import org.workcraft.plugins.shared.presets.PresetManager; |
241 | import org.workcraft.workspace.WorkspaceEntry; |
242 | |
243 | +@SuppressWarnings("serial") |
244 | public class EncoderConfigurationDialog extends JDialog { |
245 | |
246 | private JLabel numberOfSolutionsLabel, contLabel, |
247 | @@ -45,7 +45,6 @@ |
248 | private JCheckBox verboseModeCheck, customEncodings, |
249 | contCheck, abcCheck; |
250 | private JComboBox generationModeBox,OptimiseBox, guidedModeBox; |
251 | - private JFrame frame; |
252 | private JPanel generationPanel, buttonsPanel, content; |
253 | private JButton saveButton, closeButton; |
254 | private JTextField numberOfSolutionsText, bitsText; |
255 | @@ -56,13 +55,11 @@ |
256 | private int m,bits; |
257 | private JRadioButton slow,normal,fast; |
258 | private ButtonGroup group; |
259 | - private JPanel speedPanel, encodingPanel; |
260 | |
261 | // Core variables |
262 | private CpogProgrammer encoder; |
263 | private EncoderSettings settings; |
264 | private WorkspaceEntry we; |
265 | - private static boolean settingsPresent = false; |
266 | |
267 | // sizes |
268 | Dimension dimensionLabel = new Dimension(270, 22); |
269 | @@ -190,7 +187,6 @@ |
270 | } |
271 | |
272 | // Set them on encoder |
273 | - settingsPresent = true; |
274 | encoder = new CpogProgrammer(settings); |
275 | |
276 | // Execute programmer |
277 | @@ -214,13 +210,12 @@ |
278 | private void createGenerationPanel() { |
279 | setMinimumSize(new Dimension(600, 400)); |
280 | generationPanel = new JPanel(new SimpleFlowLayout()); |
281 | - JPanel numberOfSolutionsPanel = new JPanel (new FlowLayout(FlowLayout.LEFT, 3, 0)); |
282 | VisualCPOG cpog = (VisualCPOG)(we.getModelEntry().getVisualModel()); |
283 | ArrayList<VisualScenario> scenarios = new ArrayList<VisualScenario>(cpog.getGroups()); |
284 | m = scenarios.size(); |
285 | |
286 | // ABC TOOL DISABLE FLAG |
287 | - abcCheck = new JCheckBox("",settings.isAbcFlag()); |
288 | + abcCheck = new JCheckBox("", !settings.isAbcFlag()); |
289 | abcLabel = new JLabel("Disable Abc Tool"); |
290 | abcLabel.setPreferredSize(new Dimension(150, 15)); |
291 | abcCheck.addActionListener(new ActionListener() { |
292 | @@ -547,7 +542,6 @@ |
293 | encodingTable.setEnabled(false); |
294 | encodingTable.setBackground(Color.LIGHT_GRAY); |
295 | |
296 | - |
297 | // VERBOSE MODE INSTANTIATION |
298 | verboseModeLabel = new JLabel("Verbose mode"); |
299 | verboseModeLabel.setPreferredSize(dimensionLabel); |
300 | |
301 | === modified file 'WorkcraftCore/src/org/workcraft/gui/graph/tools/SelectionTool.java' |
302 | --- WorkcraftCore/src/org/workcraft/gui/graph/tools/SelectionTool.java 2014-08-01 09:23:25 +0000 |
303 | +++ WorkcraftCore/src/org/workcraft/gui/graph/tools/SelectionTool.java 2014-08-04 14:17:33 +0000 |
304 | @@ -63,7 +63,6 @@ |
305 | import org.workcraft.dom.visual.VisualGroup; |
306 | import org.workcraft.dom.visual.VisualModel; |
307 | import org.workcraft.dom.visual.VisualModelTransformer; |
308 | -import org.workcraft.dom.visual.VisualNode; |
309 | import org.workcraft.dom.visual.VisualPage; |
310 | import org.workcraft.dom.visual.connections.DefaultAnchorGenerator; |
311 | import org.workcraft.exceptions.ArgumentException; |
312 | @@ -81,8 +80,6 @@ |
313 | static private final Color selectionBorderColor = new Color(200, 200, 200); |
314 | static private final Color selectionFillColor = new Color(99, 130, 191, 32); |
315 | static private final Color grayOutColor = Color.LIGHT_GRAY; |
316 | - // node for the MouseOver events |
317 | - private VisualNode mouseOverNode = null; |
318 | |
319 | protected JPanel interfacePanel; |
320 | protected JPanel controlPanel; |
321 | @@ -235,29 +232,15 @@ |
322 | rotatePanel.add(rotateCounterclockwiseButton); |
323 | } |
324 | |
325 | - private void resetState(GraphEditor editor) { |
326 | - mouseOverNode = null; |
327 | - } |
328 | - |
329 | - private void updateState(GraphEditorMouseEvent e) { |
330 | - Point2D mousePosition = e.getPosition(); |
331 | - |
332 | - VisualNode node = (VisualNode) HitMan.hitTestForSelection(mousePosition, e.getModel()); |
333 | - mouseOverNode = node; |
334 | - |
335 | - } |
336 | - |
337 | @Override |
338 | public void activated(final GraphEditor editor) { |
339 | super.activated(editor); |
340 | editor.getWorkspaceEntry().setCanModify(true); |
341 | - resetState(editor); |
342 | } |
343 | |
344 | @Override |
345 | public void deactivated(GraphEditor editor) { |
346 | editor.getModel().selectNone(); |
347 | - resetState(editor); |
348 | } |
349 | |
350 | @Override |
351 | @@ -334,13 +317,7 @@ |
352 | selected.addAll(model.boxHitTest(e.getStartPosition(), e.getPosition())); |
353 | selectionBox = selectionRect(e.getStartPosition(), e.getPosition()); |
354 | e.getEditor().repaint(); |
355 | - } else { |
356 | - // "mouse over" events |
357 | - |
358 | } |
359 | - |
360 | - updateState(e); |
361 | - |
362 | } |
363 | |
364 | @Override |