From 07834f08de40ddc0e9d8155855dcbabab8b14ede Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 11 Feb 2008 11:50:44 +0000 Subject: [PATCH] new step method takes maximum cycle count argument --- .../cooja/mspmote/plugins/MspCodeWatcher.java | 43 +++++++++++-------- .../mspmote/plugins/MspCycleWatcher.java | 4 +- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCodeWatcher.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCodeWatcher.java index 2ccaffdf5..afd2a1b67 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCodeWatcher.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCodeWatcher.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspCodeWatcher.java,v 1.1 2008/02/07 14:55:18 fros4943 Exp $ + * $Id: MspCodeWatcher.java,v 1.2 2008/02/11 11:50:44 fros4943 Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -50,7 +50,7 @@ import se.sics.cooja.mspmote.MspMote; import se.sics.cooja.mspmote.MspMoteType; import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.util.DebugUI; +import se.sics.mspsim.ui.DebugUI; import se.sics.mspsim.util.Utils; @ClassDescription("Msp Code Watcher") @@ -74,6 +74,9 @@ public class MspCodeWatcher extends VisPlugin { private JLabel filenameLabel; + private Vector files; + private JComboBox fileComboBox; + /** * Mini-debugger for MSP Motes. * Visualizes instructions, source code and allows a user to manipulate breakpoints. @@ -106,7 +109,7 @@ public class MspCodeWatcher extends VisPlugin { JPanel controlPanel = new JPanel(); // Extract files found in debugging info - final Vector files = new Vector(); + files = new Vector(); Enumeration fileEnum = debuggingInfo.keys(); while (fileEnum.hasMoreElements()) { File file = (File) fileEnum.nextElement(); @@ -121,26 +124,18 @@ public class MspCodeWatcher extends VisPlugin { files.add(index, file); } String[] fileNames = new String[files.size() + 1]; - fileNames[0] = "[select file]"; + fileNames[0] = "[view sourcefile]"; for (int i=0; i < files.size(); i++) { fileNames[i+1] = files.get(i).getName(); } - JComboBox fileComboBox = new JComboBox(fileNames); + fileComboBox = new JComboBox(fileNames); fileComboBox.setSelectedIndex(0); fileComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - JComboBox source = (JComboBox)e.getSource(); - int index = source.getSelectedIndex(); - if (index == 0) { - return; - } - - File selectedFile = files.get(index-1); - Vector codeData = readTextFile(selectedFile); - codeUI.displayNewCode(selectedFile, codeData, -1); - codeFile = null; + sourceFileSelectionChanged(); } }); + fileComboBox.setRenderer(new BasicComboBoxRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -172,7 +167,7 @@ public class MspCodeWatcher extends VisPlugin { stepButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Perform single step here - mspMote.getCPU().step(); + mspMote.getCPU().step(mspMote.getCPU().cycles+1); updateInfo(); } }); @@ -209,6 +204,18 @@ public class MspCodeWatcher extends VisPlugin { } } + private void sourceFileSelectionChanged() { + int index = fileComboBox.getSelectedIndex(); + if (index == 0) { + return; + } + + File selectedFile = files.get(index-1); + Vector codeData = readTextFile(selectedFile); + codeUI.displayNewCode(selectedFile, codeData, -1); + codeFile = null; + } + /** * Contains currently active breakpoints. * @@ -580,7 +587,9 @@ public class MspCodeWatcher extends VisPlugin { } else { filenameLabel.setText(""); } -} + + fileComboBox.setSelectedIndex(0); + } public void closePlugin() { mySimulation.deleteObserver(simObserver); diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCycleWatcher.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCycleWatcher.java index baed3ddac..193f355ce 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCycleWatcher.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCycleWatcher.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspCycleWatcher.java,v 1.1 2008/02/07 14:55:18 fros4943 Exp $ + * $Id: MspCycleWatcher.java,v 1.2 2008/02/11 11:50:44 fros4943 Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -84,7 +84,7 @@ public class MspCycleWatcher extends VisPlugin { JPanel controlPanel = new JPanel(new GridLayout(2,3,5,5)); controlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - controlPanel.add(new JLabel("Total cycles:")); + controlPanel.add(new JLabel("Cycle counter:")); controlPanel.add(cycleTextField); controlPanel.add(updateButton); controlPanel.add(new JLabel("Since reset:"));