From bbf88f37232c2b12019dcd28f167f15fcc821b1e Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 28 Oct 2008 13:38:55 +0000 Subject: [PATCH] removed passive/active interfaces notion. --- .../cooja/motes/AbstractApplicationMote.java | 30 ++++++------------- .../se/sics/cooja/motes/DisturberMote.java | 26 +++++----------- .../se/sics/cooja/motes/DisturberRadio.java | 4 +-- .../java/se/sics/cooja/motes/DummyMote.java | 6 ++-- 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java index 173525c5b..e74ae0750 100644 --- a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: AbstractApplicationMote.java,v 1.2 2008/03/18 13:05:23 fros4943 Exp $ + * $Id: AbstractApplicationMote.java,v 1.3 2008/10/28 13:38:55 fros4943 Exp $ */ package se.sics.cooja.motes; @@ -93,12 +93,12 @@ public abstract class AbstractApplicationMote implements Mote { // Create position myInterfaceHandler = new MoteInterfaceHandler(); Position myPosition = new Position(this); - myInterfaceHandler.addPassiveInterface(myPosition); + myInterfaceHandler.addInterface(myPosition); // Create radio myApplicationRadio = new ApplicationRadio(this); myApplicationRadio.addObserver(radioDataObserver); - myInterfaceHandler.addActiveInterface(myApplicationRadio); + myInterfaceHandler.addInterface(myApplicationRadio); } public void setState(State newState) { @@ -161,20 +161,8 @@ public abstract class AbstractApplicationMote implements Mote { element = new Element("interface_config"); element.setText(myInterfaceHandler.getPosition().getClass().getName()); - // Active interface configs (if any) - for (MoteInterface moteInterface: getInterfaces().getAllActiveInterfaces()) { - element = new Element("interface_config"); - element.setText(moteInterface.getClass().getName()); - - Collection interfaceXML = moteInterface.getConfigXML(); - if (interfaceXML != null) { - element.addContent(interfaceXML); - config.add(element); - } - } - - // Passive interface configs (if any) - for (MoteInterface moteInterface: getInterfaces().getAllPassiveInterfaces()) { + // Interfaces + for (MoteInterface moteInterface: getInterfaces().getInterfaces()) { element = new Element("interface_config"); element.setText(moteInterface.getClass().getName()); @@ -196,10 +184,10 @@ public abstract class AbstractApplicationMote implements Mote { myMemory = new SectionMoteMemory(new Properties()); myInterfaceHandler = new MoteInterfaceHandler(); Position myPosition = new Position(this); - myInterfaceHandler.addPassiveInterface(myPosition); + myInterfaceHandler.addInterface(myPosition); myApplicationRadio = new ApplicationRadio(this); myApplicationRadio.addObserver(radioDataObserver); - myInterfaceHandler.addActiveInterface(myApplicationRadio); + myInterfaceHandler.addInterface(myApplicationRadio); for (Element element : configXML) { String name = element.getName(); @@ -207,8 +195,8 @@ public abstract class AbstractApplicationMote implements Mote { if (name.equals("motetype_identifier")) { myType = simulation.getMoteType(element.getText()); } else if (name.equals("interface_config")) { - Class moteInterfaceClass = simulation.getGUI() - .tryLoadClass(this, MoteInterface.class, element.getText().trim()); + Class moteInterfaceClass = + simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim()); if (moteInterfaceClass == null) { logger.warn("Can't find mote interface class: " + element.getText()); diff --git a/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java b/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java index dd1442c6a..60a4c9a7d 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: DisturberMote.java,v 1.3 2008/03/31 15:22:42 fros4943 Exp $ + * $Id: DisturberMote.java,v 1.4 2008/10/28 13:39:24 fros4943 Exp $ */ package se.sics.cooja.motes; @@ -88,11 +88,11 @@ public class DisturberMote implements Mote { Position myPosition = new Position(this); myPosition.setCoordinates(myRandom.nextDouble() * 100, myRandom .nextDouble() * 100, myRandom.nextDouble() * 100); - myInterfaceHandler.addPassiveInterface(myPosition); + myInterfaceHandler.addInterface(myPosition); // create interface handler for radio myDisturberRadio = new DisturberRadio(this); - myInterfaceHandler.addActiveInterface(myDisturberRadio); + myInterfaceHandler.addInterface(myDisturberRadio); } public void setState(State newState) { @@ -163,20 +163,8 @@ public class DisturberMote implements Mote { element = new Element("interface_config"); element.setText(myInterfaceHandler.getPosition().getClass().getName()); - // Active interface configs (if any) - for (MoteInterface moteInterface: getInterfaces().getAllActiveInterfaces()) { - element = new Element("interface_config"); - element.setText(moteInterface.getClass().getName()); - - Collection interfaceXML = moteInterface.getConfigXML(); - if (interfaceXML != null) { - element.addContent(interfaceXML); - config.add(element); - } - } - - // Passive interface configs (if any) - for (MoteInterface moteInterface: getInterfaces().getAllPassiveInterfaces()) { + // Interfaces + for (MoteInterface moteInterface: getInterfaces().getInterfaces()) { element = new Element("interface_config"); element.setText(moteInterface.getClass().getName()); @@ -198,9 +186,9 @@ public class DisturberMote implements Mote { myMemory = new SectionMoteMemory(new Properties()); myInterfaceHandler = new MoteInterfaceHandler(); Position myPosition = new Position(this); - myInterfaceHandler.addPassiveInterface(myPosition); + myInterfaceHandler.addInterface(myPosition); myDisturberRadio = new DisturberRadio(this); - myInterfaceHandler.addActiveInterface(myDisturberRadio); + myInterfaceHandler.addInterface(myDisturberRadio); for (Element element : configXML) { diff --git a/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java b/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java index b63c3fc2a..66c72b439 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java +++ b/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: DisturberRadio.java,v 1.7 2008/03/18 13:55:46 fros4943 Exp $ + * $Id: DisturberRadio.java,v 1.8 2008/10/28 13:39:24 fros4943 Exp $ */ package se.sics.cooja.motes; @@ -236,7 +236,7 @@ public class DisturberRadio extends Radio { this.deleteObserver(observer); } - public double energyConsumptionPerTick() { + public double energyConsumption() { return 0; } diff --git a/tools/cooja/java/se/sics/cooja/motes/DummyMote.java b/tools/cooja/java/se/sics/cooja/motes/DummyMote.java index 5653102c0..45072e9df 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DummyMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/DummyMote.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: DummyMote.java,v 1.4 2008/03/31 15:22:41 fros4943 Exp $ + * $Id: DummyMote.java,v 1.5 2008/10/28 13:39:24 fros4943 Exp $ */ package se.sics.cooja.motes; @@ -97,7 +97,7 @@ public class DummyMote implements Mote { Position myPosition = new Position(this); myPosition.setCoordinates(myRandom.nextDouble() * 100, myRandom .nextDouble() * 100, myRandom.nextDouble() * 100); - myInterfaceHandler.addPassiveInterface(myPosition); + myInterfaceHandler.addInterface(myPosition); } public void setState(State newState) { @@ -188,7 +188,7 @@ public class DummyMote implements Mote { mySim = simulation; myMemory = new SectionMoteMemory(new Properties()); myInterfaceHandler = new MoteInterfaceHandler(); - myInterfaceHandler.addPassiveInterface(new Position(this)); + myInterfaceHandler.addInterface(new Position(this)); for (Element element : configXML) { String name = element.getName();