diff --git a/src/remotesimulation/CommandParser.java b/src/remotesimulation/CommandParser.java index 577a55f21f366238591281b2b9037dabd0d77fd0..22d7ee579c6d001be49d845cddde72be9829ca40 100755 --- a/src/remotesimulation/CommandParser.java +++ b/src/remotesimulation/CommandParser.java @@ -336,8 +336,12 @@ public class CommandParser { commandList.add(sc); // run-exploration - params = new int[0]; - paramNames = new String[0]; + params = new int[2]; + paramNames = new String[2]; + params[0] = 6; + params[1] = 6; + paramNames[0] = "Minimum number of explored commands"; + paramNames[1] = "Minimum number of explored branches"; sc = new SimulationCommand("run-exploration", "re", "1 7", params, paramNames, "Runs the simulation in exploration mode"); commandList.add(sc); diff --git a/src/remotesimulation/SimulationCommand.java b/src/remotesimulation/SimulationCommand.java index bd657ffe3f350dce2449ee6ca95c5d5fa1bd8833..b1e75015930b15627e2d65ad89889868fa19e974 100755 --- a/src/remotesimulation/SimulationCommand.java +++ b/src/remotesimulation/SimulationCommand.java @@ -63,6 +63,7 @@ public class SimulationCommand { // 3: optional int // 4: optional String // 5: String to translate to id + // 6: int: percentage (between 0 and 100) // WARNING: optional parameters must be put at the end of the list public String help; @@ -107,6 +108,10 @@ public class SimulationCommand { return " [string: " + paramNames[i] + "]"; } + if (params[i] == 6) { + return " [int between 0 and 100 (percentage): " + paramNames[i] + "]"; + } + return " <unknow param>"; } @@ -154,6 +159,12 @@ public class SimulationCommand { return false; } } + + if (params[i] == 6) { + if (!checkForInteger(splitCmd[i+1])) { + return false; + } + } } return true; } diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index ce2969a5c8767a07b47a75f887d63c5b3e87fd29..41f0331af1f17e28ce1c0c3a9c4793fefb64bb19 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -47,7 +47,7 @@ package ui.interactivesimulation; //import java.io.*; import javax.swing.*; -//import javax.swing.event.*; +import javax.swing.event.*; import javax.swing.table.*; import java.awt.*; import java.awt.event.*; @@ -55,6 +55,7 @@ import java.io.*; import java.util.*; + import myutil.*; import ui.*; import ui.file.*; @@ -69,7 +70,7 @@ import org.xml.sax.*; import javax.xml.parsers.*; -public class JFrameInteractiveSimulation extends JFrame implements ActionListener, Runnable, MouseListener, ItemListener/*, StoppableGUIElement, SteppedAlgorithm, ExternalCall*/ { +public class JFrameInteractiveSimulation extends JFrame implements ActionListener, Runnable, MouseListener, ItemListener, ChangeListener/*, StoppableGUIElement, SteppedAlgorithm, ExternalCall*/ { protected static final String SIMULATION_HEADER = "siminfo"; protected static final String SIMULATION_GLOBAL = "global"; @@ -149,6 +150,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Formal verification JSlider minimalCommandCoverage, minimalBranchCoverage; + JLabel labelMinimalCommandCoverage, labelMinimalBranchCoverage; // Tasks JPanel taskPanel; @@ -567,39 +569,95 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; - c01.gridwidth = GridBagConstraints.REMAINDER; //end row c01.fill = GridBagConstraints.BOTH; c01.gridheight = 1; + // First empty line + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + jp02.add(new JLabel(" "), c01); + + // Line minimum command: labels + c01.gridwidth = 1; jp02.add(new JLabel("minimum COMMAND coverage"), c01); + labelMinimalCommandCoverage = new JLabel("100%"); + c01.fill = GridBagConstraints.CENTER; + jp02.add(labelMinimalCommandCoverage, c01); + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + c01.fill = GridBagConstraints.BOTH; + jp02.add(new JLabel(" "), c01); + + // Line minimum command: slider + c01.gridwidth = 1; + jp02.add(new JLabel(" "), c01); minimalCommandCoverage = new JSlider(JSlider.HORIZONTAL, 0, 100, 100); + minimalCommandCoverage.setValue(100); minimalCommandCoverage.setMajorTickSpacing(10); minimalCommandCoverage.setMinorTickSpacing(1); minimalCommandCoverage.setPaintTicks(true); minimalCommandCoverage.setPaintLabels(true); minimalCommandCoverage.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); + minimalCommandCoverage.addChangeListener(this); Font font = new Font("Serif", Font.ITALIC, 10); minimalCommandCoverage.setFont(font); - c01.gridwidth = 1; //end row - jp02.add(new JLabel(""), c01); jp02.add(minimalCommandCoverage, c01); c01.gridwidth = GridBagConstraints.REMAINDER; //end row - jp02.add(new JLabel(""), c01); + jp02.add(new JLabel(" "), c01); + + // One empty line + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + jp02.add(new JLabel(" "), c01); + + // Line minimum command: labels + c01.gridwidth = 1; jp02.add(new JLabel("minimum BRANCH coverage"), c01); + labelMinimalBranchCoverage = new JLabel("100%"); + c01.fill = GridBagConstraints.CENTER; + jp02.add(labelMinimalBranchCoverage, c01); c01.gridwidth = GridBagConstraints.REMAINDER; //end row + c01.fill = GridBagConstraints.BOTH; + jp02.add(new JLabel(" "), c01); + + // Line minimum branch: slider + c01.gridwidth = 1; + jp02.add(new JLabel(" "), c01); minimalBranchCoverage = new JSlider(JSlider.HORIZONTAL, 0, 100, 100); + minimalBranchCoverage.setValue(100); + minimalBranchCoverage.setMajorTickSpacing(10); + minimalBranchCoverage.setMinorTickSpacing(1); + minimalBranchCoverage.setPaintTicks(true); + minimalBranchCoverage.setPaintLabels(true); + minimalBranchCoverage.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); + minimalBranchCoverage.addChangeListener(this); + minimalBranchCoverage.setFont(font); + jp02.add(minimalBranchCoverage, c01); + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + jp02.add(new JLabel(" "), c01); + + // Last empty line + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + jp02.add(new JLabel(" "), c01); + + /*c01.gridwidth = 1; + jp02.add(new JLabel("minimum BRANCH coverage"), c01); + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + labelMinimalBranchCoverage = new JLabel("100%"); + c01.fill = GridBagConstraints.EAST; + jp02.add(labelMinimalBranchCoverage, c01); + c01.fill = GridBagConstraints.BOTH; minimalBranchCoverage = new JSlider(JSlider.HORIZONTAL, 0, 100, 100); + minimalBranchCoverage.setValue(100); minimalBranchCoverage.setMajorTickSpacing(10); minimalBranchCoverage.setMinorTickSpacing(1); minimalBranchCoverage.setPaintTicks(true); minimalBranchCoverage.setPaintLabels(true); minimalBranchCoverage.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); + minimalBranchCoverage.addChangeListener(this); minimalBranchCoverage.setFont(font); c01.gridwidth = 1; //end row - jp02.add(new JLabel(""), c01); + jp02.add(new JLabel(" "), c01); jp02.add(minimalBranchCoverage, c01); c01.gridwidth = GridBagConstraints.REMAINDER; //end row - jp02.add(new JLabel(""), c01); + jp02.add(new JLabel(" "), c01);*/ jp01.add(jp02, BorderLayout.CENTER); @@ -1836,7 +1894,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene animateWithInfo.setEnabled(animate.isSelected()); openDiagram.setEnabled(animate.isSelected()); update.setSelected(false); - sendCommand("run-exploration"); + sendCommand("run-exploration " + minimalCommandCoverage.getValue() + " " + minimalBranchCoverage.getValue()); } @@ -2274,6 +2332,18 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + public void stateChanged(ChangeEvent e) { + JSlider source = (JSlider)e.getSource(); + //if (!source.getValueIsAdjusting()) { + int val = (int)source.getValue(); + if (source == minimalCommandCoverage) { + labelMinimalCommandCoverage.setText("" + val+ "%"); + } else { + labelMinimalBranchCoverage.setText("" + val+ "%"); + } + //} +} + public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); //TraceManager.addDev("Command:" + command);