moved handling of breakpoint configs from plugin to mote

This commit is contained in:
fros4943 2009-06-15 09:44:42 +00:00
parent 61885eba09
commit 4fecf3fe1e
2 changed files with 34 additions and 14 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: MspMote.java,v 1.30 2009/06/11 10:08:12 fros4943 Exp $
* $Id: MspMote.java,v 1.31 2009/06/15 09:44:42 fros4943 Exp $
*/
package se.sics.cooja.mspmote;
@ -399,6 +399,8 @@ public abstract class MspMote implements Mote, WatchpointMote {
/* Create watchpoint container */
breakpointsContainer = new MspBreakpointContainer(this, getFirmwareDebugInfo(this));
} else if ("breakpoints".equals(element.getName())) {
breakpointsContainer.setConfigXML(element.getChildren(), visAvailable);
} else if (name.equals("interface_config")) {
String intfClass = element.getText().trim();
if (intfClass.equals("se.sics.cooja.mspmote.interfaces.MspIPAddress")) {
@ -430,6 +432,11 @@ public abstract class MspMote implements Mote, WatchpointMote {
element.setText(getType().getIdentifier());
config.add(element);
/* Breakpoints */
element = new Element("breakpoints");
element.addContent(breakpointsContainer.getConfigXML());
config.add(element);
// Mote interfaces
for (MoteInterface moteInterface: getInterfaces().getInterfaces()) {
element = new Element("interface_config");

View file

@ -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.17 2009/06/11 10:12:44 fros4943 Exp $
* $Id: MspCodeWatcher.java,v 1.18 2009/06/15 09:44:42 fros4943 Exp $
*/
package se.sics.cooja.mspmote.plugins;
@ -47,6 +47,7 @@ import org.jdom.Element;
import se.sics.cooja.*;
import se.sics.cooja.mspmote.MspMote;
import se.sics.cooja.mspmote.MspMoteType;
import se.sics.cooja.util.StringUtils;
import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.core.MSP430;
@ -240,11 +241,29 @@ public class MspCodeWatcher extends VisPlugin {
public void closePlugin() {
simulation.deleteObserver(simObserver);
/* Delete breakpoints */
while (breakpoints.getBreakpoints().length > 0) {
breakpoints.removeBreakpoint(breakpoints.getBreakpoints()[0].getExecutableAddress());
}
// if (breakpoints.getBreakpoints().length == 0) {
// return;
// }
//
// if (GUI.isVisualized()) {
// String s1 = "Remove";
// String s2 = "Keep";
// Object[] options = { s1, s2 };
// int n = JOptionPane.showOptionDialog(GUI.getTopParentContainer(),
// "Mote has " + breakpoints.getBreakpoints().length + " breakpoints." +
// "\nShould they be removed?",
// "Remove mote breakpoints?", JOptionPane.YES_NO_OPTION,
// JOptionPane.QUESTION_MESSAGE, null, options, s1);
// if (n != JOptionPane.YES_OPTION) {
// return;
// }
// }
//
// /* Remove all mote breakpoints */
// while (breakpoints.getBreakpoints().length > 0) {
// breakpoints.removeBreakpoint(breakpoints.getBreakpoints()[0].getExecutableAddress());
// }
}
private void updateCurrentSourceCodeFile() {
@ -381,10 +400,6 @@ public class MspCodeWatcher extends VisPlugin {
Vector<Element> config = new Vector<Element>();
Element element;
element = new Element("breakpoints");
element.addContent(breakpoints.getConfigXML());
config.add(element);
element = new Element("split_1");
element.addContent("" + leftSplitPane.getDividerLocation());
config.add(element);
@ -398,9 +413,7 @@ public class MspCodeWatcher extends VisPlugin {
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) {
if (element.getName().equals("breakpoints")) {
breakpoints.setConfigXML(element.getChildren(), visAvailable);
} else if (element.getName().equals("split_1")) {
if (element.getName().equals("split_1")) {
leftSplitPane.setDividerLocation(Integer.parseInt(element.getText()));
} else if (element.getName().equals("split_2")) {
rightSplitPane.setDividerLocation(Integer.parseInt(element.getText()));