From 8e264badb791bd67d5f077e6ccf51faf3369622a Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Wed, 14 Aug 2013 13:25:53 +0200 Subject: [PATCH] added new mote type method that returns the by-default used mote interfaces, as opposed to all compatible mote interfaces this allows the user to override default settings in the create-new-mote-type dialogs --- .../cooja/avrmote/MicaZCompileDialog.java | 3 ++ .../se/sics/cooja/mspmote/ESBMoteType.java | 3 ++ .../sics/cooja/mspmote/Exp5438MoteType.java | 18 +++++++++ .../sics/cooja/mspmote/JCreateMoteType.java | 3 ++ .../sics/cooja/mspmote/MspCompileDialog.java | 5 ++- .../se/sics/cooja/mspmote/MspMoteType.java | 1 + .../cooja/mspmote/SentillaUSBMoteType.java | 4 +- .../se/sics/cooja/mspmote/SkyMoteType.java | 3 ++ .../sics/cooja/mspmote/TyndallMoteType.java | 3 ++ .../sics/cooja/mspmote/WismoteMoteType.java | 4 +- .../src/se/sics/cooja/mspmote/Z1MoteType.java | 5 ++- .../cooja/dialogs/AbstractCompileDialog.java | 6 ++- .../dialogs/ContikiMoteCompileDialog.java | 37 ++++++++++--------- 13 files changed, 73 insertions(+), 22 deletions(-) diff --git a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZCompileDialog.java b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZCompileDialog.java index c11ed2862..21a91127f 100644 --- a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZCompileDialog.java +++ b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZCompileDialog.java @@ -64,6 +64,9 @@ public class MicaZCompileDialog extends AbstractCompileDialog { super(parent, simulation, moteType); } + public Class[] getAllMoteInterfaces() { + return ((MicaZMoteType)moteType).getAllMoteInterfaceClasses(); + } public Class[] getDefaultMoteInterfaces() { return ((MicaZMoteType)moteType).getAllMoteInterfaceClasses(); } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java index 934f5f54f..91d256ab8 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java @@ -198,6 +198,9 @@ public class ESBMoteType extends MspMoteType { return true; } + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { return new Class[] { Position.class, diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Exp5438MoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Exp5438MoteType.java index 2cb52bffa..a3ed5090f 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Exp5438MoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Exp5438MoteType.java @@ -179,6 +179,22 @@ public class Exp5438MoteType extends MspMoteType { return null; } + public Class[] getDefaultMoteInterfaceClasses() { + return new Class[] { + Position.class, + RimeAddress.class, + IPAddress.class, + Mote2MoteRelations.class, + MoteAttributes.class, + MspClock.class, + MspMoteID.class, + Msp802154Radio.class, + UsciA1Serial.class, + Exp5438LED.class, + /*Exp5438LCD.class,*/ /* TODO */ + MspDebugOutput.class + }; + } public Class[] getAllMoteInterfaceClasses() { return new Class[] { Position.class, @@ -189,6 +205,8 @@ public class Exp5438MoteType extends MspMoteType { MspClock.class, MspMoteID.class, Msp802154Radio.class, + CC1101Radio.class, + CC1120Radio.class, UsciA1Serial.class, Exp5438LED.class, /*Exp5438LCD.class,*/ /* TODO */ diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/JCreateMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/JCreateMoteType.java index e7a683460..764fbbd37 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/JCreateMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/JCreateMoteType.java @@ -71,6 +71,9 @@ public class JCreateMoteType extends AbstractMspMoteType { } @Override + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { @SuppressWarnings("unchecked") Class[] list = createMoteInterfaceList( diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspCompileDialog.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspCompileDialog.java index 745053ab1..019505f89 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspCompileDialog.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspCompileDialog.java @@ -71,8 +71,11 @@ public class MspCompileDialog extends AbstractCompileDialog { addCompilationTipsTab(tabbedPane); } + public Class[] getAllMoteInterfaces() { + return ((MspMoteType)moteType).getAllMoteInterfaceClasses(); + } public Class[] getDefaultMoteInterfaces() { - return ((MspMoteType)moteType).getAllMoteInterfaceClasses(); + return ((MspMoteType)moteType).getDefaultMoteInterfaceClasses(); } private void addCompilationTipsTab(JTabbedPane parent) { diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java index dea897e2c..d4af5e2f3 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java @@ -320,6 +320,7 @@ public abstract class MspMoteType implements MoteType { } public abstract Class[] getAllMoteInterfaceClasses(); + public abstract Class[] getDefaultMoteInterfaceClasses(); public abstract File getExpectedFirmwareFile(File source); private static ELF loadELF(String filepath) throws IOException { diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SentillaUSBMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SentillaUSBMoteType.java index 5ce424a81..112eee0b3 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SentillaUSBMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SentillaUSBMoteType.java @@ -69,7 +69,9 @@ public class SentillaUSBMoteType extends AbstractMspMoteType { return new SentillaUSBMote(this, simulation); } - @Override + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { @SuppressWarnings("unchecked") Class[] list = createMoteInterfaceList( diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java index ec8453bc6..e5134f0b0 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java @@ -202,6 +202,9 @@ public class SkyMoteType extends MspMoteType { return null; } + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { return new Class[] { Position.class, diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/TyndallMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/TyndallMoteType.java index 7bac0f5ac..ae401a316 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/TyndallMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/TyndallMoteType.java @@ -179,6 +179,9 @@ public class TyndallMoteType extends MspMoteType { return null; } + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { return new Class[] { Position.class, diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/WismoteMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/WismoteMoteType.java index 61659d1f2..80466398d 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/WismoteMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/WismoteMoteType.java @@ -69,7 +69,9 @@ public class WismoteMoteType extends AbstractMspMoteType { return new WismoteMote(this, simulation); } - @Override + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } public Class[] getAllMoteInterfaceClasses() { @SuppressWarnings("unchecked") Class[] list = createMoteInterfaceList( diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Z1MoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Z1MoteType.java index 7e1ab8510..aeeafd99a 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Z1MoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Z1MoteType.java @@ -70,7 +70,10 @@ public class Z1MoteType extends AbstractMspMoteType { return new Z1Mote(this, simulation); } - @Override + public Class[] getDefaultMoteInterfaceClasses() { + return getAllMoteInterfaceClasses(); + } + public Class[] getAllMoteInterfaceClasses() { @SuppressWarnings("unchecked") Class[] list = createMoteInterfaceList( diff --git a/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java index 814cc8d3c..2cf0d1f5b 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java @@ -372,7 +372,7 @@ public abstract class AbstractCompileDialog extends JDialog { ((JCheckBox) c).setSelected(false); } if (moteType.getMoteInterfaceClasses() != null) { - for (Class intfClass: getDefaultMoteInterfaces()) { + for (Class intfClass: getAllMoteInterfaces()) { addMoteInterface(intfClass, false); } for (Class intf: moteType.getMoteInterfaceClasses()) { @@ -380,6 +380,9 @@ public abstract class AbstractCompileDialog extends JDialog { } } else { /* Select default mote interfaces */ + for (Class intfClass: getAllMoteInterfaces()) { + addMoteInterface(intfClass, false); + } for (Class intfClass: getDefaultMoteInterfaces()) { addMoteInterface(intfClass, true); } @@ -714,6 +717,7 @@ public abstract class AbstractCompileDialog extends JDialog { }; public abstract Class[] getDefaultMoteInterfaces(); + public abstract Class[] getAllMoteInterfaces(); /** * @return Currently selected mote interface classes diff --git a/tools/cooja/java/se/sics/cooja/dialogs/ContikiMoteCompileDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/ContikiMoteCompileDialog.java index cdd530924..3be902ce8 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/ContikiMoteCompileDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/ContikiMoteCompileDialog.java @@ -199,24 +199,27 @@ public class ContikiMoteCompileDialog extends AbstractCompileDialog { return ContikiMoteType.getExpectedFirmwareFile(source); } + public Class[] getAllMoteInterfaces() { + ProjectConfig projectConfig = moteType.getConfig(); + String[] intfNames = projectConfig.getStringArrayValue(ContikiMoteType.class, "MOTE_INTERFACES"); + ArrayList> classes = new ArrayList>(); + + /* Load mote interface classes */ + for (String intfName : intfNames) { + Class intfClass = + gui.tryLoadClass(this, MoteInterface.class, intfName); + + if (intfClass == null) { + logger.warn("Failed to load mote interface class: " + intfName); + continue; + } + + classes.add(intfClass); + } + return classes.toArray(new Class[0]); + } public Class[] getDefaultMoteInterfaces() { - ProjectConfig projectConfig = moteType.getConfig(); - String[] intfNames = projectConfig.getStringArrayValue(ContikiMoteType.class, "MOTE_INTERFACES"); - ArrayList> classes = new ArrayList>(); - - /* Load mote interface classes */ - for (String intfName : intfNames) { - Class intfClass = - gui.tryLoadClass(this, MoteInterface.class, intfName); - - if (intfClass == null) { - logger.warn("Failed to load mote interface class: " + intfName); - continue; - } - - classes.add(intfClass); - } - return classes.toArray(new Class[0]); + return getAllMoteInterfaces(); } private void addAdvancedTab(JTabbedPane parent) {