added simulation config backwards compatibility for contiki mote types: may not work for configurations with several compiled sources

This commit is contained in:
fros4943 2009-03-11 18:42:53 +00:00
parent 3a2718279b
commit 47da035f38

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiMoteType.java,v 1.31 2009/03/11 11:54:19 fros4943 Exp $ * $Id: ContikiMoteType.java,v 1.32 2009/03/11 18:42:53 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
@ -1274,6 +1274,9 @@ public class ContikiMoteType implements MoteType {
public boolean setConfigXML(Simulation simulation, public boolean setConfigXML(Simulation simulation,
Collection<Element> configXML, boolean visAvailable) Collection<Element> configXML, boolean visAvailable)
throws MoteTypeCreationException { throws MoteTypeCreationException {
boolean warnedOldVersion = false;
File oldVersionSource = null;
moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>(); moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>();
this.simulation = simulation; this.simulation = simulation;
@ -1309,6 +1312,29 @@ public class ContikiMoteType implements MoteType {
} else { } else {
moteInterfacesClasses.add(moteInterfaceClass); moteInterfacesClasses.add(moteInterfaceClass);
} }
} else if (
name.equals("contikibasedir") ||
name.equals("contikicoredir") ||
name.equals("projectdir") ||
name.equals("compilefile") ||
name.equals("process") ||
name.equals("sensor") ||
name.equals("coreinterface")) {
/* Backwards compatibility: old contiki mote type is being loaded */
if (!warnedOldVersion) {
warnedOldVersion = true;
logger.warn("Old simulation config detected: contiki mote types may not load correctly");
}
if (name.equals("compilefile")) {
if (element.getText().endsWith(".c")) {
File potentialFile = new File(element.getText());
if (potentialFile.exists()) {
oldVersionSource = potentialFile;
}
}
}
} else { } else {
logger.fatal("Unrecognized entry in loaded configuration: " + name); logger.fatal("Unrecognized entry in loaded configuration: " + name);
} }
@ -1320,6 +1346,25 @@ public class ContikiMoteType implements MoteType {
moteInterfacesClasses.toArray(arr); moteInterfacesClasses.toArray(arr);
setCoreInterfaces(ContikiMoteType.getRequiredCoreInterfaces(arr)); setCoreInterfaces(ContikiMoteType.getRequiredCoreInterfaces(arr));
/* Backwards compatibility: old contiki mote type is being loaded */
if (getContikiSourceFile() == null &&
warnedOldVersion &&
oldVersionSource != null)
{
/* Guess Contiki source */
setContikiSourceFile(oldVersionSource);
logger.info("Guessing Contiki source: " + oldVersionSource.getAbsolutePath());
setContikiFirmwareFile(getExpectedFirmwareFile(oldVersionSource));
logger.info("Guessing Contiki firmware: " + getContikiFirmwareFile().getAbsolutePath());
/* Guess compile commands */
String compileCommands =
"make " + getExpectedFirmwareFile(oldVersionSource).getName() + " TARGET=cooja";
logger.info("Guessing compile commands: " + compileCommands);
setCompileCommands(compileCommands);
}
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable); boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
return createdOK; return createdOK;
} }