diff --git a/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMote.java b/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMote.java index 5c1e1d3ba..97cca433a 100644 --- a/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMote.java +++ b/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMote.java @@ -221,11 +221,17 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote { if (name.equals("motetype_identifier")) { /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { + /* Backwards compatibility: se.sics -> org.contikios */ + String intfClass = element.getText().trim(); + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + Class moteInterfaceClass = simulation.getCooja().tryLoadClass( - this, MoteInterface.class, element.getText().trim()); + this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { - logger.fatal("Could not load mote interface class: " + element.getText().trim()); + logger.fatal("Could not load mote interface class: " + intfClass); return false; } diff --git a/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMoteType.java b/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMoteType.java index b6a8b2452..c1a33b625 100644 --- a/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMoteType.java +++ b/tools/cooja/apps/avrora/src/org/contikios/cooja/avrmote/MicaZMoteType.java @@ -292,6 +292,11 @@ public class MicaZMoteType implements MoteType { } else if (name.equals("moteinterface")) { String intfClass = element.getText().trim(); + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + Class moteInterfaceClass = simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass); diff --git a/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMote.java index 409be990d..3d66c6b08 100644 --- a/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMote.java @@ -40,7 +40,6 @@ import java.util.Hashtable; import org.apache.log4j.Logger; import org.jdom.Element; - import org.contikios.cooja.ContikiError; import org.contikios.cooja.Cooja; import org.contikios.cooja.Mote; @@ -58,6 +57,7 @@ import org.contikios.cooja.mspmote.interfaces.MspSerial; import org.contikios.cooja.mspmote.plugins.CodeVisualizerSkin; import org.contikios.cooja.mspmote.plugins.MspBreakpoint; import org.contikios.cooja.plugins.Visualizer; + import se.sics.mspsim.cli.CommandContext; import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.LineListener; @@ -409,18 +409,25 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc setWatchpointConfigXML(element.getChildren(), visAvailable); } else if (name.equals("interface_config")) { String intfClass = element.getText().trim(); + + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.MspIPAddress")) { - intfClass = IPAddress.class.getName(); + intfClass = IPAddress.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.ESBLog")) { - intfClass = MspSerial.class.getName(); + intfClass = MspSerial.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.SkyByteRadio")) { - intfClass = Msp802154Radio.class.getName(); + intfClass = Msp802154Radio.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.SkySerial")) { - intfClass = MspSerial.class.getName(); + intfClass = MspSerial.class.getName(); } + Class moteInterfaceClass = simulation.getCooja().tryLoadClass( this, MoteInterface.class, intfClass); diff --git a/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMoteType.java index b5e1c5265..910c6df8c 100644 --- a/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/org/contikios/cooja/mspmote/MspMoteType.java @@ -264,22 +264,27 @@ public abstract class MspMoteType implements MoteType { } else if (name.equals("moteinterface")) { String intfClass = element.getText().trim(); + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + /* Backwards compatibility: MspIPAddress -> IPAddress */ if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.MspIPAddress")) { - logger.warn("Old simulation config detected: IP address interface was moved"); - intfClass = IPAddress.class.getName(); + logger.warn("Old simulation config detected: IP address interface was moved"); + intfClass = IPAddress.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.ESBLog")) { - logger.warn("Old simulation config detected: ESBLog was replaced by MspSerial"); - intfClass = MspSerial.class.getName(); + logger.warn("Old simulation config detected: ESBLog was replaced by MspSerial"); + intfClass = MspSerial.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.SkyByteRadio")) { - logger.warn("Old simulation config detected: SkyByteRadio was replaced by Msp802154Radio"); - intfClass = Msp802154Radio.class.getName(); + logger.warn("Old simulation config detected: SkyByteRadio was replaced by Msp802154Radio"); + intfClass = Msp802154Radio.class.getName(); } if (intfClass.equals("org.contikios.cooja.mspmote.interfaces.SkySerial")) { - logger.warn("Old simulation config detected: SkySerial was replaced by MspSerial"); - intfClass = MspSerial.class.getName(); + logger.warn("Old simulation config detected: SkySerial was replaced by MspSerial"); + intfClass = MspSerial.class.getName(); } Class moteInterfaceClass = diff --git a/tools/cooja/java/org/contikios/cooja/Cooja.java b/tools/cooja/java/org/contikios/cooja/Cooja.java index 89f4332a1..b8c7d57dc 100644 --- a/tools/cooja/java/org/contikios/cooja/Cooja.java +++ b/tools/cooja/java/org/contikios/cooja/Cooja.java @@ -124,7 +124,6 @@ import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; - import org.contikios.cooja.MoteType.MoteTypeCreationException; import org.contikios.cooja.VisPlugin.PluginRequiresVisualizationException; import org.contikios.cooja.contikimote.ContikiMoteType; @@ -3635,14 +3634,19 @@ public class Cooja extends Observable { // Read plugin class String pluginClassName = pluginElement.getText().trim(); + /* Backwards compatibility: se.sics -> org.contikios */ + if (pluginClassName.startsWith("se.sics")) { + pluginClassName = pluginClassName.replaceFirst("se\\.sics", "org.contikios"); + } + /* Backwards compatibility: old visualizers were replaced */ if (pluginClassName.equals("org.contikios.cooja.plugins.VisUDGM") || - pluginClassName.equals("org.contikios.cooja.plugins.VisBattery") || - pluginClassName.equals("org.contikios.cooja.plugins.VisTraffic") || - pluginClassName.equals("org.contikios.cooja.plugins.VisState") || - pluginClassName.equals("org.contikios.cooja.plugins.VisUDGM")) { - logger.warn("Old simulation config detected: visualizers have been remade"); - pluginClassName = "org.contikios.cooja.plugins.Visualizer"; + pluginClassName.equals("org.contikios.cooja.plugins.VisBattery") || + pluginClassName.equals("org.contikios.cooja.plugins.VisTraffic") || + pluginClassName.equals("org.contikios.cooja.plugins.VisState") || + pluginClassName.equals("org.contikios.cooja.plugins.VisUDGM")) { + logger.warn("Old simulation config detected: visualizers have been remade"); + pluginClassName = "org.contikios.cooja.plugins.Visualizer"; } Class pluginClass = diff --git a/tools/cooja/java/org/contikios/cooja/Simulation.java b/tools/cooja/java/org/contikios/cooja/Simulation.java index ab7f487fd..0f9943628 100644 --- a/tools/cooja/java/org/contikios/cooja/Simulation.java +++ b/tools/cooja/java/org/contikios/cooja/Simulation.java @@ -600,6 +600,12 @@ public class Simulation extends Observable implements Runnable { // Radio medium if (element.getName().equals("radiomedium")) { String radioMediumClassName = element.getText().trim(); + + /* Backwards compatibility: se.sics -> org.contikios */ + if (radioMediumClassName.startsWith("se.sics")) { + radioMediumClassName = radioMediumClassName.replaceFirst("se\\.sics", "org.contikios"); + } + Class radioMediumClass = cooja.tryLoadClass( this, RadioMedium.class, radioMediumClassName); @@ -643,6 +649,11 @@ public class Simulation extends Observable implements Runnable { if (element.getName().equals("motetype")) { String moteTypeClassName = element.getText().trim(); + /* Backwards compatibility: se.sics -> org.contikios */ + if (moteTypeClassName.startsWith("se.sics")) { + moteTypeClassName = moteTypeClassName.replaceFirst("se\\.sics", "org.contikios"); + } + /* Try to recreate simulation using a different mote type */ if (visAvailable) { String[] availableMoteTypes = getCooja().getProjectConfig().getStringArrayValue("org.contikios.cooja.Cooja.MOTETYPES"); diff --git a/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMote.java b/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMote.java index cde5db4e1..b2c814b7b 100644 --- a/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMote.java +++ b/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMote.java @@ -35,7 +35,6 @@ import java.util.Collection; import org.apache.log4j.Logger; import org.jdom.Element; - import org.contikios.cooja.Mote; import org.contikios.cooja.MoteInterface; import org.contikios.cooja.MoteInterfaceHandler; @@ -185,11 +184,18 @@ public class ContikiMote extends AbstractWakeupMote implements Mote { if (name.equals("motetype_identifier")) { /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { + String intfClass = element.getText().trim(); + + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + Class moteInterfaceClass = - simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim()); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { - logger.fatal("Could not load mote interface class: " + element.getText().trim()); + logger.fatal("Could not load mote interface class: " + intfClass); return false; } diff --git a/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMoteType.java b/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMoteType.java index 200183d32..78e05abe9 100644 --- a/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMoteType.java +++ b/tools/cooja/java/org/contikios/cooja/contikimote/ContikiMoteType.java @@ -1320,18 +1320,21 @@ public class ContikiMoteType implements MoteType { } else if (name.equals("netstack")) { netStack = NetworkStack.parseConfig(element.getText()); } else if (name.equals("moteinterface")) { - if (element.getText().trim().equals("org.contikios.cooja.contikimote.interfaces.ContikiLog")) { - /* Backwards compatibility: ContikiLog was removed */ - } else { - Class moteInterfaceClass = - simulation.getCooja().tryLoadClass( - this, MoteInterface.class, element.getText().trim()); + String intfClass = element.getText().trim(); - if (moteInterfaceClass == null) { - logger.warn("Can't find mote interface class: " + element.getText()); - } else { - moteInterfacesClasses.add(moteInterfaceClass); - } + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + + Class moteInterfaceClass = + simulation.getCooja().tryLoadClass( + this, MoteInterface.class, intfClass); + + if (moteInterfaceClass == null) { + logger.warn("Can't find mote interface class: " + intfClass); + } else { + moteInterfacesClasses.add(moteInterfaceClass); } } else if ( name.equals("contikibasedir") || diff --git a/tools/cooja/java/org/contikios/cooja/motes/AbstractApplicationMote.java b/tools/cooja/java/org/contikios/cooja/motes/AbstractApplicationMote.java index af6e2682e..ec381e163 100644 --- a/tools/cooja/java/org/contikios/cooja/motes/AbstractApplicationMote.java +++ b/tools/cooja/java/org/contikios/cooja/motes/AbstractApplicationMote.java @@ -37,7 +37,6 @@ import java.util.Properties; import org.apache.log4j.Logger; import org.jdom.Element; - import org.contikios.cooja.Mote; import org.contikios.cooja.MoteInterface; import org.contikios.cooja.MoteInterfaceHandler; @@ -154,11 +153,18 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme if (name.equals("motetype_identifier")) { /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { + String intfClass = element.getText().trim(); + + /* Backwards compatibility: se.sics -> org.contikios */ + if (intfClass.startsWith("se.sics")) { + intfClass = intfClass.replaceFirst("se\\.sics", "org.contikios"); + } + Class moteInterfaceClass = - simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim()); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { - logger.warn("Can't find mote interface class: " + element.getText()); + logger.warn("Can't find mote interface class: " + intfClass); return false; } diff --git a/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java b/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java index 1502a22b6..47387c9f3 100644 --- a/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java +++ b/tools/cooja/java/org/contikios/cooja/plugins/Visualizer.java @@ -1332,6 +1332,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { for (Element element : configXML) { if (element.getName().equals("skin")) { String wanted = element.getText(); + /* Backwards compatibility: se.sics -> org.contikios */ + if (wanted.startsWith("se.sics")) { + wanted = wanted.replaceFirst("se\\.sics", "org.contikios"); + } + for (Class skinClass: visualizerSkins) { if (wanted.equals(skinClass.getName()) /* Backwards compatibility */