+ support for config file relative paths when saving simulations
This commit is contained in:
parent
a17e7d109a
commit
7099572282
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MicaZMoteType.java,v 1.2 2009/03/11 14:12:18 fros4943 Exp $
|
||||
* $Id: MicaZMoteType.java,v 1.3 2009/03/12 15:11:03 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.avrmote;
|
||||
|
@ -51,6 +51,8 @@ import se.sics.cooja.dialogs.MessageList.MessageContainer;
|
|||
public class MicaZMoteType implements MoteType {
|
||||
private static Logger logger = Logger.getLogger(MicaZMoteType.class);
|
||||
|
||||
private Simulation simulation;
|
||||
|
||||
public static final String target = "micaz";
|
||||
public static final String targetNice = "MicaZ";
|
||||
|
||||
|
@ -150,6 +152,8 @@ public class MicaZMoteType implements MoteType {
|
|||
protected boolean configureAndInitMicaZType(Container parentContainer, Simulation simulation,
|
||||
boolean visAvailable, final String target, final String targetNice)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
boolean compileFromSource = false;
|
||||
|
||||
if (getIdentifier() == null && !visAvailable) {
|
||||
|
@ -1060,8 +1064,8 @@ public class MicaZMoteType implements MoteType {
|
|||
// Source file
|
||||
if (fileSource != null) {
|
||||
element = new Element("source");
|
||||
fileSource = GUI.stripAbsoluteContikiPath(fileSource);
|
||||
element.setText(fileSource.getPath().replaceAll("\\\\", "/"));
|
||||
File file = simulation.getGUI().createPortablePath(fileSource);
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
element = new Element("command");
|
||||
element.setText(compileCommand);
|
||||
|
@ -1069,9 +1073,7 @@ public class MicaZMoteType implements MoteType {
|
|||
} else {
|
||||
// ELF file
|
||||
element = new Element("elf");
|
||||
File file = fileFirmware;
|
||||
file = GUI.stripAbsoluteContikiPath(file);
|
||||
fileFirmware = file;
|
||||
File file = simulation.getGUI().createPortablePath(fileFirmware);
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
}
|
||||
|
@ -1091,10 +1093,16 @@ public class MicaZMoteType implements MoteType {
|
|||
description = element.getText();
|
||||
} else if (name.equals("source")) {
|
||||
fileSource = new File(element.getText());
|
||||
if (!fileSource.exists()) {
|
||||
fileSource = simulation.getGUI().restorePortablePath(fileSource);
|
||||
}
|
||||
} else if (name.equals("command")) {
|
||||
compileCommand = element.getText();
|
||||
} else if (name.equals("elf")) {
|
||||
fileFirmware = new File(element.getText());
|
||||
if (!fileFirmware.exists()) {
|
||||
fileFirmware = simulation.getGUI().restorePortablePath(fileSource);
|
||||
}
|
||||
} else {
|
||||
logger.fatal("Unrecognized entry in loaded configuration: " + name);
|
||||
throw new MoteTypeCreationException(
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ESBMoteType.java,v 1.8 2009/03/11 17:46:59 fros4943 Exp $
|
||||
* $Id: ESBMoteType.java,v 1.9 2009/03/12 15:12:10 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote;
|
||||
|
@ -56,14 +56,6 @@ import se.sics.cooja.mspmote.interfaces.TR1001Radio;
|
|||
public class ESBMoteType extends MspMoteType {
|
||||
private static Logger logger = Logger.getLogger(ESBMoteType.class);
|
||||
|
||||
public ESBMoteType() {
|
||||
}
|
||||
|
||||
public ESBMoteType(String identifier) {
|
||||
setIdentifier(identifier);
|
||||
setDescription("ESB Mote Type #" + identifier);
|
||||
}
|
||||
|
||||
public Icon getMoteTypeIcon() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
URL imageURL = this.getClass().getClassLoader().getResource("images/esb.jpg");
|
||||
|
@ -88,6 +80,7 @@ public class ESBMoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* SPECIAL CASE: Cooja started in applet.
|
||||
* Use preconfigured Contiki firmware */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MspMoteType.java,v 1.28 2009/03/11 17:46:59 fros4943 Exp $
|
||||
* $Id: MspMoteType.java,v 1.29 2009/03/12 15:12:10 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote;
|
||||
|
@ -56,6 +56,8 @@ public abstract class MspMoteType implements MoteType {
|
|||
private String identifier = null;
|
||||
private String description = null;
|
||||
|
||||
protected Simulation simulation;
|
||||
|
||||
/* If source file is defined, the firmware is recompiled when loading simulations */
|
||||
private File fileSource = null;
|
||||
private String compileCommands = null;
|
||||
|
@ -214,7 +216,7 @@ public abstract class MspMoteType implements MoteType {
|
|||
// Source file
|
||||
if (fileSource != null) {
|
||||
element = new Element("source");
|
||||
File file = GUI.stripAbsoluteContikiPath(fileSource);
|
||||
File file = simulation.getGUI().createPortablePath(fileSource);
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
element = new Element("commands");
|
||||
|
@ -224,7 +226,7 @@ public abstract class MspMoteType implements MoteType {
|
|||
|
||||
// Firmware file
|
||||
element = new Element("firmware");
|
||||
File file = GUI.stripAbsoluteContikiPath(fileFirmware);
|
||||
File file = simulation.getGUI().createPortablePath(fileFirmware);
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
|
||||
|
@ -241,6 +243,8 @@ public abstract class MspMoteType implements MoteType {
|
|||
public boolean setConfigXML(Simulation simulation,
|
||||
Collection<Element> configXML, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
ArrayList<Class<? extends MoteInterface>> intfClassList = new ArrayList<Class<? extends MoteInterface>>();
|
||||
for (Element element : configXML) {
|
||||
String name = element.getName();
|
||||
|
@ -250,7 +254,11 @@ public abstract class MspMoteType implements MoteType {
|
|||
} else if (name.equals("description")) {
|
||||
description = element.getText();
|
||||
} else if (name.equals("source")) {
|
||||
fileSource = new File(element.getText());
|
||||
File file = new File(element.getText());
|
||||
if (!file.exists()) {
|
||||
file = simulation.getGUI().restorePortablePath(file);
|
||||
}
|
||||
fileSource = file;
|
||||
} else if (name.equals("command")) {
|
||||
/* Backwards compatibility: command is now commands */
|
||||
logger.warn("Old simulation config detected: old version only supports a single compile command");
|
||||
|
@ -258,7 +266,11 @@ public abstract class MspMoteType implements MoteType {
|
|||
} else if (name.equals("commands")) {
|
||||
compileCommands = element.getText();
|
||||
} else if (name.equals("firmware")) {
|
||||
fileFirmware = new File(element.getText());
|
||||
File file = new File(element.getText());
|
||||
if (!file.exists()) {
|
||||
file = simulation.getGUI().restorePortablePath(file);
|
||||
}
|
||||
fileFirmware = file;
|
||||
} else if (name.equals("elf")) {
|
||||
/* Backwards compatibility: elf is now firmware */
|
||||
logger.warn("Old simulation config detected: firmware specified as elf");
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: SkyMoteType.java,v 1.7 2009/03/11 17:46:59 fros4943 Exp $
|
||||
* $Id: SkyMoteType.java,v 1.8 2009/03/12 15:12:10 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote;
|
||||
|
@ -57,14 +57,6 @@ import se.sics.cooja.mspmote.interfaces.SkySerial;
|
|||
public class SkyMoteType extends MspMoteType {
|
||||
private static Logger logger = Logger.getLogger(SkyMoteType.class);
|
||||
|
||||
public SkyMoteType() {
|
||||
}
|
||||
|
||||
public SkyMoteType(String identifier) {
|
||||
setIdentifier(identifier);
|
||||
setDescription("Sky Mote Type #" + identifier);
|
||||
}
|
||||
|
||||
public Icon getMoteTypeIcon() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
URL imageURL = this.getClass().getClassLoader().getResource("images/sky.jpg");
|
||||
|
@ -89,6 +81,7 @@ public class SkyMoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* SPECIAL CASE: Cooja started in applet.
|
||||
* Use preconfigured Contiki firmware */
|
||||
|
|
|
@ -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.14 2008/11/03 18:11:44 fros4943 Exp $
|
||||
* $Id: MspCodeWatcher.java,v 1.15 2009/03/12 15:12:23 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote.plugins;
|
||||
|
@ -309,7 +309,7 @@ public class MspCodeWatcher extends VisPlugin {
|
|||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
static class Breakpoints {
|
||||
class Breakpoints {
|
||||
private Hashtable<File, Hashtable<Integer, Integer>> debuggingInfo = null;
|
||||
private Vector<Breakpoint> breakpoints = new Vector<Breakpoint>();
|
||||
private Vector<ActionListener> listeners = new Vector<ActionListener>();
|
||||
|
@ -541,8 +541,8 @@ public class MspCodeWatcher extends VisPlugin {
|
|||
|
||||
if (codeFile != null) {
|
||||
element = new Element("codefile");
|
||||
codeFile = GUI.stripAbsoluteContikiPath(codeFile);
|
||||
element.setText(codeFile.getPath().replaceAll("\\\\", "/"));
|
||||
File file = mySimulation.getGUI().createPortablePath(codeFile);
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,11 @@ public class MspCodeWatcher extends VisPlugin {
|
|||
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||
for (Element element : configXML) {
|
||||
if (element.getName().equals("codefile")) {
|
||||
codeFile = new File(element.getText());
|
||||
File file = new File(element.getText());
|
||||
if (!file.exists()) {
|
||||
file = mySimulation.getGUI().restorePortablePath(file);
|
||||
}
|
||||
codeFile = file;
|
||||
if (!codeFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ContikiMoteType.java,v 1.32 2009/03/11 18:42:53 fros4943 Exp $
|
||||
* $Id: ContikiMoteType.java,v 1.33 2009/03/12 15:08:29 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.contikimote;
|
||||
|
@ -1246,8 +1246,8 @@ public class ContikiMoteType implements MoteType {
|
|||
config.add(element);
|
||||
|
||||
element = new Element("contikiapp");
|
||||
File tmp = GUI.stripAbsoluteContikiPath(getContikiSourceFile());
|
||||
element.setText(tmp.getPath().replaceAll("\\\\", "/")); /* TODO Fix Contiki-relative path */
|
||||
File file = simulation.getGUI().createPortablePath(getContikiSourceFile());
|
||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||
config.add(element);
|
||||
|
||||
element = new Element("commands");
|
||||
|
@ -1288,7 +1288,12 @@ public class ContikiMoteType implements MoteType {
|
|||
} else if (name.equals("description")) {
|
||||
description = element.getText();
|
||||
} else if (name.equals("contikiapp")) {
|
||||
setContikiSourceFile(new File(element.getText())); /* TODO Fix Contiki-relative paths */
|
||||
File file = new File(element.getText());
|
||||
if (!file.exists()) {
|
||||
file = simulation.getGUI().restorePortablePath(file);
|
||||
}
|
||||
|
||||
setContikiSourceFile(file);
|
||||
|
||||
/* XXX Do not load the generated firmware. Instead, load the unique library file directly */
|
||||
File contikiFirmware = new File(
|
||||
|
|
Loading…
Reference in a new issue