documentation (including javadoc) update
This commit is contained in:
parent
b2516a09ef
commit
0c98ce0651
18 changed files with 807 additions and 724 deletions
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: ConnectionLogger.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: ConnectionLogger.java,v 1.3 2006/12/15 12:03:32 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -42,24 +40,27 @@ import se.sics.cooja.interfaces.Position;
|
||||||
* connections given via the method logConnection will be written to either
|
* connections given via the method logConnection will be written to either
|
||||||
* default Log4J info stream, a log file or both.
|
* default Log4J info stream, a log file or both.
|
||||||
*
|
*
|
||||||
* Log files have the following structure (spaces are tabs): SRC_POS [src_x]
|
* Log files have the following structure (seprated by tabs): SRC_POS [src_x]
|
||||||
* [src_y] [src_z] SRC_DATA [sent data bytes] DEST_POS [dest_x] [dest_y]
|
* [src_y] [src_z] SRC_DATA [sent data bytes] DEST_POS [dest_x] [dest_y]
|
||||||
* [dest_z] DEST_DATA [received data bytes] [newline]
|
* [dest_z] DEST_DATA [received data bytes] [newline]
|
||||||
*
|
*
|
||||||
* @see RadioConnection
|
* @see RadioConnection
|
||||||
* @see RadioMedium
|
* @see RadioMedium
|
||||||
*
|
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public class ConnectionLogger {
|
public class ConnectionLogger {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(ConnectionLogger.class);
|
private static Logger logger = Logger.getLogger(ConnectionLogger.class);
|
||||||
|
|
||||||
private static int LOG_TO_FILE = 1;
|
private static int LOG_TO_FILE = 1;
|
||||||
|
|
||||||
private static int LOG_TO_LOG4J = 2;
|
private static int LOG_TO_LOG4J = 2;
|
||||||
|
|
||||||
private static int LOG_TO_FILE_AND_LOG4J = 3;
|
private static int LOG_TO_FILE_AND_LOG4J = 3;
|
||||||
|
|
||||||
private int myType;
|
private int myType;
|
||||||
|
|
||||||
private File myFile;
|
private File myFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +124,8 @@ public class ConnectionLogger {
|
||||||
out.write("SRC_DATA\t".getBytes());
|
out.write("SRC_DATA\t".getBytes());
|
||||||
for (byte b : conn.getSourceData()) {
|
for (byte b : conn.getSourceData()) {
|
||||||
String hexString = Integer.toHexString((int) b);
|
String hexString = Integer.toHexString((int) b);
|
||||||
if (hexString.length() == 1) hexString = "0" + hexString;
|
if (hexString.length() == 1)
|
||||||
|
hexString = "0" + hexString;
|
||||||
out.write(hexString.getBytes());
|
out.write(hexString.getBytes());
|
||||||
}
|
}
|
||||||
out.write("\t".getBytes());
|
out.write("\t".getBytes());
|
||||||
|
@ -142,9 +144,11 @@ public class ConnectionLogger {
|
||||||
out.write("DEST_DATA\t".getBytes());
|
out.write("DEST_DATA\t".getBytes());
|
||||||
for (byte b : conn.getDestinationData()[i]) {
|
for (byte b : conn.getDestinationData()[i]) {
|
||||||
String hexString = Integer.toHexString((int) b);
|
String hexString = Integer.toHexString((int) b);
|
||||||
if (hexString.length() == 1) hexString = "0" + hexString;
|
if (hexString.length() == 1)
|
||||||
|
hexString = "0" + hexString;
|
||||||
out.write(hexString.getBytes());
|
out.write(hexString.getBytes());
|
||||||
} out.write("\t".getBytes());
|
}
|
||||||
|
out.write("\t".getBytes());
|
||||||
|
|
||||||
out.write("\n".getBytes());
|
out.write("\n".getBytes());
|
||||||
}
|
}
|
||||||
|
@ -164,7 +168,8 @@ public class ConnectionLogger {
|
||||||
out.write("SRC_DATA\t".getBytes());
|
out.write("SRC_DATA\t".getBytes());
|
||||||
for (byte b : conn.getSourceData()) {
|
for (byte b : conn.getSourceData()) {
|
||||||
String hexString = Integer.toHexString((int) b);
|
String hexString = Integer.toHexString((int) b);
|
||||||
if (hexString.length() == 1) hexString = "0" + hexString;
|
if (hexString.length() == 1)
|
||||||
|
hexString = "0" + hexString;
|
||||||
out.write(hexString.getBytes());
|
out.write(hexString.getBytes());
|
||||||
}
|
}
|
||||||
out.write("\n".getBytes());
|
out.write("\n".getBytes());
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: CoreComm.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: CoreComm.java,v 1.2 2006/08/23 17:11:09 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -35,19 +33,19 @@ import java.io.File;
|
||||||
import se.sics.cooja.corecomm.*;
|
import se.sics.cooja.corecomm.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The package corecomm's purpose is communicating with the simulation core
|
* The purpose of corecomm's is communicating with a compiled Contiki system
|
||||||
* using Java Native Interface (JNI). Each implementing class (named
|
* using Java Native Interface (JNI). Each implemented class (named Lib[1-MAX]),
|
||||||
* Lib[1-MAX]), loads a shared library which belongs to one mote type. The
|
* loads a shared library which belongs to one mote type. The reason for this
|
||||||
* reason for this somewhat strange design is that once loaded, a native library
|
* somewhat strange design is that once loaded, a native library cannot be
|
||||||
* cannot be unloaded in Java (yet). Therefore if we wish to load several
|
* unloaded in Java (in the current versions available). Therefore if we wish to
|
||||||
* libraries, the names and associated native functions must have unique names.
|
* load several libraries, the names and associated native functions must have
|
||||||
* And those names are defined via the calling class in JNI. For example, the
|
* unique names. And those names are defined via the calling class in JNI. For
|
||||||
* native tick function in class Lib1 is named
|
* example, the corresponding function for a native tick method in class Lib1
|
||||||
* contiki_javasim_corecomm_Lib1_tick. When creating a new mote type, the main
|
* will be named Java_se_sics_cooja_corecomm_Lib1_tick. When creating a new mote
|
||||||
* contiki source file is generated with function names compatible with the next
|
* type, the main Contiki source file is generated with function names
|
||||||
* available corecomm. This also implies that even if a mote type is deleted, a
|
* compatible with the next available corecomm class. This also implies that
|
||||||
* new one cannot be created without restarting the JVM and thus the entire
|
* even if a mote type is deleted, a new one cannot be created using the same
|
||||||
* simulation.
|
* corecomm class without restarting the JVM and thus the entire simulation.
|
||||||
*
|
*
|
||||||
* Each implemented CoreComm class needs read access to the following core
|
* Each implemented CoreComm class needs read access to the following core
|
||||||
* variables:
|
* variables:
|
||||||
|
@ -56,23 +54,23 @@ import se.sics.cooja.corecomm.*;
|
||||||
* </ul>
|
* </ul>
|
||||||
* and the following native functions:
|
* and the following native functions:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>init()
|
|
||||||
* <li>tick()
|
* <li>tick()
|
||||||
|
* <li>init()
|
||||||
* <li>getReferenceAbsAddr()
|
* <li>getReferenceAbsAddr()
|
||||||
* <li>getMemory(int start, int length)
|
* <li>getMemory(int start, int length, byte[] mem)
|
||||||
* <li>setMemory(int start, int length, byte[] mem)
|
* <li>setMemory(int start, int length, byte[] mem)
|
||||||
* </ul>
|
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public abstract class CoreComm {
|
public abstract class CoreComm {
|
||||||
/**
|
/**
|
||||||
* Maximum supported core communicators in a simulation.
|
* Maximum supported core communicators in a simulator.
|
||||||
*/
|
*/
|
||||||
private final static int MAX_LIBRARIES = 8;
|
private final static int MAX_LIBRARIES = 8;
|
||||||
|
|
||||||
// Static pointers to current libraries
|
// Static pointers to current libraries
|
||||||
private final static CoreComm[] coreComms = new CoreComm[MAX_LIBRARIES];
|
private final static CoreComm[] coreComms = new CoreComm[MAX_LIBRARIES];
|
||||||
|
|
||||||
private final static File[] coreCommFiles = new File[MAX_LIBRARIES];
|
private final static File[] coreCommFiles = new File[MAX_LIBRARIES];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,7 +193,7 @@ public abstract class CoreComm {
|
||||||
public abstract void tick();
|
public abstract void tick();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a mote by running a startup script in the core. (Should only by
|
* Initializes a mote by running a startup script in the core. (Should only be
|
||||||
* run once, at the same time as the library is loaded)
|
* run once, at the same time as the library is loaded)
|
||||||
*/
|
*/
|
||||||
protected abstract void init();
|
protected abstract void init();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: IPDistributor.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: IPDistributor.java,v 1.1 2006/08/21 12:12:56 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -38,6 +36,7 @@ import org.apache.log4j.Logger;
|
||||||
/**
|
/**
|
||||||
* A IP distributor is used for determining IP addresses of newly created motes.
|
* A IP distributor is used for determining IP addresses of newly created motes.
|
||||||
*
|
*
|
||||||
|
* @see se.sics.cooja.Positioner
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public abstract class IPDistributor {
|
public abstract class IPDistributor {
|
||||||
|
@ -48,17 +47,19 @@ public abstract class IPDistributor {
|
||||||
* constructor argument. Instead of calling the constructors directly this
|
* constructor argument. Instead of calling the constructors directly this
|
||||||
* method may be used.
|
* method may be used.
|
||||||
*
|
*
|
||||||
* @param ipDistClass Class
|
* @param ipDistClass
|
||||||
* @param newMotes All motes that later should be assigned IP numbers
|
* Class
|
||||||
|
* @param newMotes
|
||||||
|
* All motes that later should be assigned IP numbers
|
||||||
* @return IP distributor instance
|
* @return IP distributor instance
|
||||||
*/
|
*/
|
||||||
public static final IPDistributor generateInterface(
|
public static final IPDistributor generateIPDistributor(
|
||||||
Class<? extends IPDistributor> ipDistClass, Vector<Mote> newMotes) {
|
Class<? extends IPDistributor> ipDistClass, Vector<Mote> newMotes) {
|
||||||
try {
|
try {
|
||||||
// Generating IP distributor
|
// Generating IP distributor
|
||||||
Constructor constr = ipDistClass
|
Constructor constr = ipDistClass
|
||||||
.getConstructor(new Class[]{Vector.class});
|
.getConstructor(new Class[] { Vector.class });
|
||||||
return (IPDistributor) constr.newInstance(new Object[]{newMotes});
|
return (IPDistributor) constr.newInstance(new Object[] { newMotes });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Exception when creating " + ipDistClass + ": " + e);
|
logger.fatal("Exception when creating " + ipDistClass + ": " + e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -66,9 +67,9 @@ public abstract class IPDistributor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next mote position.
|
* Returns the next mote IP address.
|
||||||
*
|
*
|
||||||
* @return Position
|
* @return IP Address
|
||||||
*/
|
*/
|
||||||
public abstract String getNextIPAddress();
|
public abstract String getNextIPAddress();
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: Mote.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: Mote.java,v 1.3 2007/01/09 10:16:26 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -36,10 +34,11 @@ import java.util.Observer;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a simulated mote.
|
* A simulated mote.
|
||||||
*
|
*
|
||||||
* A mote is always in some state, describing the status of the CPU etc.
|
* A mote is always in some state, describing the status of the CPU etc. Motes
|
||||||
* Motes in different states may be handled differently by the for example simulation loops and plugins.
|
* in different states may be handled differently by for example the simulation
|
||||||
|
* loop and plugins.
|
||||||
*
|
*
|
||||||
* All motes must also have an interface handler, a mote type and a mote memory.
|
* All motes must also have an interface handler, a mote type and a mote memory.
|
||||||
*
|
*
|
||||||
|
@ -55,16 +54,20 @@ public interface Mote {
|
||||||
* Possible mote states
|
* Possible mote states
|
||||||
*/
|
*/
|
||||||
public static enum State {
|
public static enum State {
|
||||||
ACTIVE, // Active state
|
/* Active state */
|
||||||
LPM, // Low power mode (sleeping)
|
ACTIVE,
|
||||||
DEAD // Dead (for example out of batteries)
|
/* Low power mode (sleeping) */
|
||||||
|
LPM,
|
||||||
|
/* Dead (for example out of batteries) */
|
||||||
|
DEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to change state to given argument.
|
* Tries to change state to given argument. A dead mote can typically not
|
||||||
* A dead mote can typically not change state, while a sleeping or active mote can.
|
* change state, while a sleeping or active mote can.
|
||||||
*
|
*
|
||||||
* @param newState New state of mote.
|
* @param newState
|
||||||
|
* New state of mote.
|
||||||
*/
|
*/
|
||||||
public void setState(State newState);
|
public void setState(State newState);
|
||||||
|
|
||||||
|
@ -74,11 +77,11 @@ public interface Mote {
|
||||||
public State getState();
|
public State getState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new state observer.
|
* Adds new state observer. This observer is notified if mote changes state.
|
||||||
* This observer is notified if mote changes state.
|
*
|
||||||
*
|
|
||||||
* @see #deleteStateObserver(Observer)
|
* @see #deleteStateObserver(Observer)
|
||||||
* @param newObserver New observer
|
* @param newObserver
|
||||||
|
* New observer
|
||||||
*/
|
*/
|
||||||
public void addStateObserver(Observer newObserver);
|
public void addStateObserver(Observer newObserver);
|
||||||
|
|
||||||
|
@ -86,11 +89,11 @@ public interface Mote {
|
||||||
* Delete existing state observer.
|
* Delete existing state observer.
|
||||||
*
|
*
|
||||||
* @see #addStateObserver(Observer)
|
* @see #addStateObserver(Observer)
|
||||||
* @param newObserver Registered state observer
|
* @param newObserver
|
||||||
|
* Registered state observer
|
||||||
*/
|
*/
|
||||||
public void deleteStateObserver(Observer newObserver);
|
public void deleteStateObserver(Observer newObserver);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the interface handler of this mote.
|
* Returns the interface handler of this mote.
|
||||||
*
|
*
|
||||||
|
@ -102,12 +105,12 @@ public interface Mote {
|
||||||
/**
|
/**
|
||||||
* Sets the interface handler of this mote.
|
* Sets the interface handler of this mote.
|
||||||
*
|
*
|
||||||
* @param moteInterfaceHandler New interface handler
|
* @param moteInterfaceHandler
|
||||||
|
* New interface handler
|
||||||
* @see #getInterfaces()
|
* @see #getInterfaces()
|
||||||
*/
|
*/
|
||||||
public void setInterfaces(MoteInterfaceHandler moteInterfaceHandler);
|
public void setInterfaces(MoteInterfaceHandler moteInterfaceHandler);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the memory of this mote.
|
* Returns the memory of this mote.
|
||||||
*
|
*
|
||||||
|
@ -120,11 +123,11 @@ public interface Mote {
|
||||||
* Sets the memory of this mote.
|
* Sets the memory of this mote.
|
||||||
*
|
*
|
||||||
* @see #getMemory()
|
* @see #getMemory()
|
||||||
* @param memory Mote memory
|
* @param memory
|
||||||
|
* Mote memory
|
||||||
*/
|
*/
|
||||||
public void setMemory(MoteMemory memory);
|
public void setMemory(MoteMemory memory);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns mote type.
|
* Returns mote type.
|
||||||
*
|
*
|
||||||
|
@ -137,11 +140,11 @@ public interface Mote {
|
||||||
* Sets mote type to given argument.
|
* Sets mote type to given argument.
|
||||||
*
|
*
|
||||||
* @see #getType()
|
* @see #getType()
|
||||||
* @param type New type
|
* @param type
|
||||||
|
* New type
|
||||||
*/
|
*/
|
||||||
public void setType(MoteType type);
|
public void setType(MoteType type);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns simulation which holds this mote.
|
* Returns simulation which holds this mote.
|
||||||
*
|
*
|
||||||
|
@ -149,42 +152,42 @@ public interface Mote {
|
||||||
* @return Simulation
|
* @return Simulation
|
||||||
*/
|
*/
|
||||||
public Simulation getSimulation();
|
public Simulation getSimulation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the simulation which holds this mote.
|
* Sets the simulation which holds this mote.
|
||||||
*
|
*
|
||||||
* @see #getSimulation()
|
* @see #getSimulation()
|
||||||
* @param simulation Simulation
|
* @param simulation
|
||||||
|
* Simulation
|
||||||
*/
|
*/
|
||||||
public void setSimulation(Simulation simulation);
|
public void setSimulation(Simulation simulation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ticks this mote and increases any internal time to given argument.
|
* Ticks this mote and increases any internal time to given argument.
|
||||||
*
|
*
|
||||||
* Each mote implementation may handle calls to this method differently,
|
* Each mote implementation may handle calls to this method differently, but
|
||||||
* but, if existing, the simulated mote should at least handle one event.
|
* typically the simulated mote should at least handle one event.
|
||||||
*
|
*
|
||||||
* This method is responsible for updating the mote interfaces, the memory and the mote state.
|
* This method is responsible for updating the mote interfaces, the memory and
|
||||||
|
* the mote state.
|
||||||
*
|
*
|
||||||
* A call to this method typically
|
* A call to this method typically polls all interfaces, activates the memory,
|
||||||
* polls all interfaces,
|
* lets the underlying mote software handle one event, fetches the updated
|
||||||
* activates the memory,
|
* memory and finally polls all interfaces again.
|
||||||
* lets the underlying mote software handle one event,
|
*
|
||||||
* fetches the updated memory and
|
* @param simTime
|
||||||
* finally polls all interfaces again.
|
* New simulation time
|
||||||
*
|
|
||||||
* @param simTime New simulation time
|
|
||||||
*/
|
*/
|
||||||
public void tick(int simTime);
|
public void tick(int simTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns XML elements representing the current config of this mote.
|
* Returns XML elements representing the current config of this mote. This is
|
||||||
* This is fetched by the simulator for example when saving a simulation configuration file.
|
* fetched by the simulator for example when saving a simulation configuration
|
||||||
* For example a mote may return the configs of all its interfaces.
|
* file. For example a mote may return the configs of all its interfaces. This
|
||||||
* This method should however not return state specific information such as the mote state.
|
* method should however not return state specific information such as the
|
||||||
* (All nodes are restarted when loading a simulation.)
|
* mote state. (All nodes are restarted when loading a simulation.)
|
||||||
*
|
*
|
||||||
* @see #setConfigXML(Simulation, Collection)
|
* @see #setConfigXML(Simulation, Collection, boolean)
|
||||||
* @return XML elements representing the current mote config
|
* @return XML elements representing the current mote config
|
||||||
*/
|
*/
|
||||||
public abstract Collection<Element> getConfigXML();
|
public abstract Collection<Element> getConfigXML();
|
||||||
|
@ -192,11 +195,14 @@ public interface Mote {
|
||||||
/**
|
/**
|
||||||
* Sets the current mote config depending on the given XML elements.
|
* Sets the current mote config depending on the given XML elements.
|
||||||
*
|
*
|
||||||
* @param simulation Simulation holding this mote
|
* @param simulation
|
||||||
* @param configXML Config XML elements
|
* Simulation holding this mote
|
||||||
|
* @param configXML
|
||||||
|
* Config XML elements
|
||||||
*
|
*
|
||||||
* @see #getConfigXML()
|
* @see #getConfigXML()
|
||||||
*/
|
*/
|
||||||
public abstract boolean setConfigXML(Simulation simulation, Collection<Element> configXML, boolean visAvailable);
|
public abstract boolean setConfigXML(Simulation simulation,
|
||||||
|
Collection<Element> configXML, boolean visAvailable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: MoteInterface.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: MoteInterface.java,v 1.2 2007/01/09 10:16:42 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -38,16 +36,19 @@ import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mote interface represents a mote property.
|
* A mote interface represents a mote property. Often this is a simulated
|
||||||
* Often this is a simulated hardware peripheral such as a button or a led.
|
* hardware peripheral such as a button or a led. This can also be a property
|
||||||
* This can also be a property the mote software itself is unaware of,
|
* the mote software itself is unaware of, for example the current position of
|
||||||
* for example the current position of the mote.
|
* the mote.
|
||||||
*
|
*
|
||||||
* Interfaces are the main way for the simulator to interact with a simulated mote.
|
* Interfaces are the main way for the simulator to interact with a simulated
|
||||||
|
* mote.
|
||||||
*
|
*
|
||||||
* Interfaces are divided into active and passive interfaces, and are handled differently.
|
* Interfaces are divided into active and passive interfaces, which are handled
|
||||||
* In order to create a passive interfaces, the class should also implement the dummy Java interface PassiveMoteInterface.
|
* differently. In order to create a passive interface, the class should also
|
||||||
* For an explanation of the differences of active and passive interfaces see class PassiveMoteInterface.
|
* implement the dummy Java interface PassiveMoteInterface. For an explanation
|
||||||
|
* of the differences of active and passive interfaces see class
|
||||||
|
* PassiveMoteInterface.
|
||||||
*
|
*
|
||||||
* @see PassiveMoteInterface
|
* @see PassiveMoteInterface
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
|
@ -56,19 +57,23 @@ public abstract class MoteInterface extends Observable {
|
||||||
private static Logger logger = Logger.getLogger(MoteInterface.class);
|
private static Logger logger = Logger.getLogger(MoteInterface.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates an instance of the given class with the given mote as constructor
|
* This method creates an instance of the given class with the given mote as
|
||||||
* argument. Instead of calling the interface constructors directly this method may be used.
|
* constructor argument. Instead of calling the interface constructors
|
||||||
*
|
* directly this method may be used.
|
||||||
* @param interfaceClass Mote interface class
|
*
|
||||||
* @param mote Mote that will hold the interface
|
* @param interfaceClass
|
||||||
|
* Mote interface class
|
||||||
|
* @param mote
|
||||||
|
* Mote that will hold the interface
|
||||||
* @return Mote interface instance
|
* @return Mote interface instance
|
||||||
*/
|
*/
|
||||||
public static final MoteInterface generateInterface(Class<? extends MoteInterface> interfaceClass, Mote mote) {
|
public static final MoteInterface generateInterface(
|
||||||
|
Class<? extends MoteInterface> interfaceClass, Mote mote) {
|
||||||
try {
|
try {
|
||||||
// Generating interface
|
// Generating interface
|
||||||
MoteInterface instance = (MoteInterface) interfaceClass.getConstructor(
|
MoteInterface instance = (MoteInterface) interfaceClass.getConstructor(
|
||||||
new Class[] { Mote.class }).newInstance(new Object[] { mote });
|
new Class[] { Mote.class }).newInstance(new Object[] { mote });
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Exception when creating " + interfaceClass + ": " + e);
|
logger.fatal("Exception when creating " + interfaceClass + ": " + e);
|
||||||
|
@ -87,12 +92,12 @@ public abstract class MoteInterface extends Observable {
|
||||||
public abstract void doActionsAfterTick();
|
public abstract void doActionsAfterTick();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a panel with interesting data for this interface.
|
* Returns a panel with interesting data for this interface. This could for
|
||||||
* This could for example show last messages sent/received for
|
* example show last messages sent/received for a radio interface, or logged
|
||||||
* a radio interface, or logged message for a log interface.
|
* message for a log interface.
|
||||||
*
|
*
|
||||||
* All panels returned from this method must later be released
|
* All panels returned from this method must later be released for memory
|
||||||
* for memory reasons.
|
* reasons.
|
||||||
*
|
*
|
||||||
* If returned panel is null, this interface will not be visualized.
|
* If returned panel is null, this interface will not be visualized.
|
||||||
*
|
*
|
||||||
|
@ -103,46 +108,55 @@ public abstract class MoteInterface extends Observable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be called when a visualizer panel is no longer in use.
|
* This method should be called when a visualizer panel is no longer in use.
|
||||||
* Any resources of that panel, for example registered observers, will be released.
|
* Any resources of that panel, for example registered observers, will be
|
||||||
|
* released.
|
||||||
*
|
*
|
||||||
* @see #getInterfaceVisualizer()
|
* @see #getInterfaceVisualizer()
|
||||||
* @param panel A interface visualizer panel fetched earlier for this mote interface.
|
* @param panel
|
||||||
|
* A interface visualizer panel fetched earlier for this mote
|
||||||
|
* interface.
|
||||||
*/
|
*/
|
||||||
public abstract void releaseInterfaceVisualizer(JPanel panel);
|
public abstract void releaseInterfaceVisualizer(JPanel panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns approximated energy consumed (mQ) during the current tick.
|
* Returns approximated energy consumed (mQ) during the current tick. If the
|
||||||
* If the interface is active, this information must be available after the doActionsAfterTick method.
|
* interface is active, this information must be available after the
|
||||||
* If the interface is passive, this information must be available after the doActionsBeforeTick method.
|
* doActionsAfterTick method. If the interface is passive, this information
|
||||||
|
* must be available after the doActionsBeforeTick method.
|
||||||
*
|
*
|
||||||
* The interface is responsible to gather information about the current internal state,
|
* The interface is responsible to gather information about the current
|
||||||
* and calculate whatever energy it needs in that state and during one tick.
|
* internal state, and calculate whatever energy it needs in that state and
|
||||||
*
|
* during one tick.
|
||||||
* If the holding mote is dead, this method will not be called.
|
*
|
||||||
* If the holding mote is sleeping and this interface is active, this method will not be called.
|
* If the holding mote is dead, this method will not be called. If the holding
|
||||||
*
|
* mote is sleeping and this interface is active, this method will not be
|
||||||
* For example, a radio transmitter or a PIR sensor often has a much higher energy
|
* called.
|
||||||
* usage than a button sensor which virtually needs no energy at all.
|
*
|
||||||
* If the radio is turned off in hardware, it should return a zero energy consumption.
|
* For example, a radio transmitter or a PIR sensor often has a much higher
|
||||||
* If the radio is sending something which would take longer than one tick, it may either return
|
* energy usage than a button sensor which virtually needs no energy at all.
|
||||||
* the total energy used directly, or a smaller amount during several ticks.
|
* If the radio is turned off in hardware, it should return a zero energy
|
||||||
|
* consumption. If the radio is sending something which would take longer than
|
||||||
|
* one tick, it may either return the total energy used directly, or a smaller
|
||||||
|
* amount during several ticks.
|
||||||
|
*
|
||||||
|
* This method may typically be used by the passive interface battery, which
|
||||||
|
* sums up all energy used during one tick and decreases the battery energy
|
||||||
|
* left.
|
||||||
*
|
*
|
||||||
* This method may typically be used by the passive interface battery, which sums up
|
|
||||||
* all energy used during one tick and decreases the battery energy left.
|
|
||||||
*
|
|
||||||
* @see se.sics.cooja.interfaces.Battery
|
* @see se.sics.cooja.interfaces.Battery
|
||||||
* @return Energy consumption of this device during the current tick
|
* @return Energy consumption of this device during the current tick
|
||||||
*/
|
*/
|
||||||
public abstract double energyConsumptionPerTick();
|
public abstract double energyConsumptionPerTick();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns XML elements representing the current config of this mote interface.
|
* Returns XML elements representing the current config of this mote
|
||||||
* This is fetched by the simulator for example when saving a simulation configuration file.
|
* interface. This is fetched by the simulator for example when saving a
|
||||||
* For example an IP interface may return one element with the mote IP address.
|
* simulation configuration file. For example an IP interface may return one
|
||||||
* This method should however not return state specific information such as a log history.
|
* element with the mote IP address. This method should however not return
|
||||||
* (All nodes are restarted when loading a simulation.)
|
* state specific information such as a log history. (All nodes are restarted
|
||||||
|
* when loading a simulation.)
|
||||||
*
|
*
|
||||||
* @see #setConfigXML(Collection)
|
* @see #setConfigXML(Collection, boolean)
|
||||||
* @return XML elements representing the current interface config
|
* @return XML elements representing the current interface config
|
||||||
*/
|
*/
|
||||||
public abstract Collection<Element> getConfigXML();
|
public abstract Collection<Element> getConfigXML();
|
||||||
|
@ -151,8 +165,12 @@ public abstract class MoteInterface extends Observable {
|
||||||
* Sets the current mote interface config depending on the given XML elements.
|
* Sets the current mote interface config depending on the given XML elements.
|
||||||
*
|
*
|
||||||
* @see #getConfigXML()
|
* @see #getConfigXML()
|
||||||
* @param configXML Config XML elements
|
* @param configXML
|
||||||
|
* Config XML elements
|
||||||
|
* @param visAvailable
|
||||||
|
* Is this object allowed to show a visualizer?
|
||||||
*/
|
*/
|
||||||
public abstract void setConfigXML(Collection<Element> configXML, boolean visAvailable);
|
public abstract void setConfigXML(Collection<Element> configXML,
|
||||||
|
boolean visAvailable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: MoteInterfaceHandler.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: MoteInterfaceHandler.java,v 1.1 2006/08/21 12:12:56 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -40,7 +38,7 @@ import se.sics.cooja.interfaces.*;
|
||||||
* A mote interface handler holds all interfaces for a specific mote. Even
|
* A mote interface handler holds all interfaces for a specific mote. Even
|
||||||
* though an interface handler strictly does not need any interfaces at all, a
|
* though an interface handler strictly does not need any interfaces at all, a
|
||||||
* position interface is highly recommended. (A lot of plugins depend on a mote
|
* position interface is highly recommended. (A lot of plugins depend on a mote
|
||||||
* position, for example when visualizing nodes.)
|
* position, for example a typical visualizer.)
|
||||||
*
|
*
|
||||||
* Interfaces are divided into active and passive interfaces. Active interfaces
|
* Interfaces are divided into active and passive interfaces. Active interfaces
|
||||||
* are only polled if the mote is active, while passive interfaces are polled in
|
* are only polled if the mote is active, while passive interfaces are polled in
|
||||||
|
@ -54,18 +52,29 @@ public class MoteInterfaceHandler {
|
||||||
private static Logger logger = Logger.getLogger(MoteInterfaceHandler.class);
|
private static Logger logger = Logger.getLogger(MoteInterfaceHandler.class);
|
||||||
|
|
||||||
private Battery myBattery;
|
private Battery myBattery;
|
||||||
|
|
||||||
private Beeper myBeeper;
|
private Beeper myBeeper;
|
||||||
|
|
||||||
private Button myButton;
|
private Button myButton;
|
||||||
|
|
||||||
private Clock myClock;
|
private Clock myClock;
|
||||||
|
|
||||||
private IPAddress myIPAddress;
|
private IPAddress myIPAddress;
|
||||||
|
|
||||||
private LED myLED;
|
private LED myLED;
|
||||||
|
|
||||||
private Log myLog;
|
private Log myLog;
|
||||||
|
|
||||||
private MoteID myMoteID;
|
private MoteID myMoteID;
|
||||||
|
|
||||||
private PIR myPIR;
|
private PIR myPIR;
|
||||||
|
|
||||||
private Position myPosition;
|
private Position myPosition;
|
||||||
|
|
||||||
private Radio myRadio;
|
private Radio myRadio;
|
||||||
|
|
||||||
private Vector<MoteInterface> myActiveInterfaces = new Vector<MoteInterface>();
|
private Vector<MoteInterface> myActiveInterfaces = new Vector<MoteInterface>();
|
||||||
|
|
||||||
private Vector<MoteInterface> myPassiveInterfaces = new Vector<MoteInterface>();
|
private Vector<MoteInterface> myPassiveInterfaces = new Vector<MoteInterface>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,13 +129,15 @@ public class MoteInterfaceHandler {
|
||||||
*/
|
*/
|
||||||
public <N extends MoteInterface> N getInterfaceOfType(Class<N> interfaceType) {
|
public <N extends MoteInterface> N getInterfaceOfType(Class<N> interfaceType) {
|
||||||
|
|
||||||
Enumeration<? extends MoteInterface> allActive = myActiveInterfaces.elements();
|
Enumeration<? extends MoteInterface> allActive = myActiveInterfaces
|
||||||
|
.elements();
|
||||||
while (allActive.hasMoreElements()) {
|
while (allActive.hasMoreElements()) {
|
||||||
N nextInterface = (N) allActive.nextElement();
|
N nextInterface = (N) allActive.nextElement();
|
||||||
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
||||||
return nextInterface;
|
return nextInterface;
|
||||||
}
|
}
|
||||||
Enumeration<? extends MoteInterface> allPassive = myPassiveInterfaces.elements();
|
Enumeration<? extends MoteInterface> allPassive = myPassiveInterfaces
|
||||||
|
.elements();
|
||||||
while (allPassive.hasMoreElements()) {
|
while (allPassive.hasMoreElements()) {
|
||||||
N nextInterface = (N) allPassive.nextElement();
|
N nextInterface = (N) allPassive.nextElement();
|
||||||
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
||||||
|
@ -266,7 +277,7 @@ public class MoteInterfaceHandler {
|
||||||
}
|
}
|
||||||
return myRadio;
|
return myRadio;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Polls all active interfaces. This method should be called during a mote
|
* Polls all active interfaces. This method should be called during a mote
|
||||||
* tick before the mote software is executed.
|
* tick before the mote software is executed.
|
||||||
|
|
|
@ -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: MoteMemory.java,v 1.1 2006/08/21 12:12:55 fros4943 Exp $
|
* $Id: MoteMemory.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -41,6 +41,7 @@ package se.sics.cooja;
|
||||||
* different memory sections, not covering the entire range
|
* different memory sections, not covering the entire range
|
||||||
* between the start address and the end address of this memory.
|
* between the start address and the end address of this memory.
|
||||||
*
|
*
|
||||||
|
* @see se.sics.cooja.SectionMoteMemory
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public interface MoteMemory {
|
public interface MoteMemory {
|
||||||
|
@ -49,7 +50,7 @@ public interface MoteMemory {
|
||||||
* Clears the entire memory.
|
* Clears the entire memory.
|
||||||
*/
|
*/
|
||||||
public void clearMemory();
|
public void clearMemory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a memory segment.
|
* Returns a memory segment.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: MoteType.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: MoteType.java,v 1.2 2007/01/09 10:16:26 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -37,15 +35,14 @@ import javax.swing.JPanel;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every simulated motes belongs to a mote type.
|
|
||||||
*
|
|
||||||
* The mote type defines properties common for several motes. These properties
|
* The mote type defines properties common for several motes. These properties
|
||||||
* may differ between different implementations, but typically includes how a
|
* may differ between different implementations, but typically includes how a
|
||||||
* mote of that type is initialized, which hardware peripherals each mote has
|
* mote of that type is initialized, which hardware peripherals each mote has
|
||||||
* etc.
|
* etc.
|
||||||
|
* Every simulated motes must belong to a mote type.
|
||||||
*
|
*
|
||||||
* A mote type may also hold the connection to an underlying simulation
|
* A mote type may also hold the connection to an underlying simulation
|
||||||
* framework.
|
* framework, such as a compiled Contiki system.
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
|
@ -99,7 +96,7 @@ public interface MoteType {
|
||||||
* Generates a mote of this mote type.
|
* Generates a mote of this mote type.
|
||||||
*
|
*
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* Newly created mote's simulation
|
* Simulation that will contain mote
|
||||||
* @return New mote
|
* @return New mote
|
||||||
*/
|
*/
|
||||||
public Mote generateMote(Simulation simulation);
|
public Mote generateMote(Simulation simulation);
|
||||||
|
@ -116,16 +113,19 @@ public interface MoteType {
|
||||||
* Parent frame or null
|
* Parent frame or null
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* Simulation holding (or that should hold) mote type
|
* Simulation holding (or that should hold) mote type
|
||||||
|
* @param visAvailable
|
||||||
|
* True if this method is allowed to show a visualizer
|
||||||
* @return True if mote type has valid settings and is ready to be used
|
* @return True if mote type has valid settings and is ready to be used
|
||||||
*/
|
*/
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation, boolean visAvailable);
|
public boolean configureAndInit(JFrame parentFrame, Simulation simulation,
|
||||||
|
boolean visAvailable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns XML elements representing the current config of this mote type.
|
* Returns XML elements representing the current config of this mote type.
|
||||||
* This is fetched by the simulator for example when saving a simulation
|
* This is fetched by the simulator for example when saving a simulation
|
||||||
* configuration file. For example a Contiki base directory may be saved.
|
* configuration file. For example a Contiki base directory may be saved.
|
||||||
*
|
*
|
||||||
* @see #setConfigXML(Simulation, Collection)
|
* @see #setConfigXML(Simulation, Collection, boolean)
|
||||||
* @return XML elements representing the current mote type's config
|
* @return XML elements representing the current mote type's config
|
||||||
*/
|
*/
|
||||||
public Collection<Element> getConfigXML();
|
public Collection<Element> getConfigXML();
|
||||||
|
@ -141,6 +141,8 @@ public interface MoteType {
|
||||||
* Simulation that will hold the mote type
|
* Simulation that will hold the mote type
|
||||||
* @param configXML
|
* @param configXML
|
||||||
* Config XML elements
|
* Config XML elements
|
||||||
|
* @param visAvailable
|
||||||
|
* True if this method is allowed to show a visualizer
|
||||||
* @return True if config was set successfully, false otherwise
|
* @return True if config was set successfully, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean setConfigXML(Simulation simulation,
|
public boolean setConfigXML(Simulation simulation,
|
||||||
|
|
|
@ -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: PassiveMoteInterface.java,v 1.1 2006/08/21 12:12:57 fros4943 Exp $
|
* $Id: PassiveMoteInterface.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -34,19 +34,18 @@ package se.sics.cooja;
|
||||||
/**
|
/**
|
||||||
* Mote interfaces are divided into active and passive interfaces.
|
* Mote interfaces are divided into active and passive interfaces.
|
||||||
*
|
*
|
||||||
* A passive mote interface is treated different than an ordinary (active)
|
* A passive mote interface is treated different than an ordinary (active) mote
|
||||||
* mote interface;
|
* interface; Passive interfaces are allowed to act even when the mote is
|
||||||
* Passive interfaces are allowed to act even when the mote is sleeping,
|
* sleeping, while active interface only acts when the mote is in active state.
|
||||||
* while active interface only acts when the mote is in active state.
|
|
||||||
*
|
*
|
||||||
* A typical active interface is the radio interface, since radio
|
* A typical active interface is the radio interface, since radio messages only
|
||||||
* messages only can be received when the mote is active.
|
* can be received when the mote is active.
|
||||||
*
|
*
|
||||||
* A typical passive interface is the battery interface, since a mote
|
* A typical passive interface is the battery interface, since a mote consumes
|
||||||
* consumes energy even though it is sleeping.
|
* energy even though it is sleeping.
|
||||||
*
|
*
|
||||||
* All passive interface should implement this interface.
|
* All passive interface should implement this interface. All interfaces not
|
||||||
* All interfaces not implemented this interface will be handled as active interfaces.
|
* implemented this interface will be handled as active interfaces.
|
||||||
*
|
*
|
||||||
* Any energy required by this interface must be available after the
|
* Any energy required by this interface must be available after the
|
||||||
* doActionsBeforeTick method.
|
* doActionsBeforeTick method.
|
||||||
|
|
|
@ -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: PlatformConfig.java,v 1.3 2006/09/06 12:26:33 fros4943 Exp $
|
* $Id: PlatformConfig.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -149,12 +149,12 @@ public class PlatformConfig {
|
||||||
* instead.
|
* instead.
|
||||||
*
|
*
|
||||||
* @param callingClass
|
* @param callingClass
|
||||||
* Class which value belongs to
|
* Class which value belong to
|
||||||
* @param key
|
* @param key
|
||||||
* Key
|
* Key
|
||||||
* @param value
|
* @param arrayElement
|
||||||
* Element of array
|
* Value or array element
|
||||||
* @return User platform
|
* @return User platform defining arguments or null
|
||||||
*/
|
*/
|
||||||
public File getUserPlatformDefining(Class callingClass, String key, String arrayElement) {
|
public File getUserPlatformDefining(Class callingClass, String key, String arrayElement) {
|
||||||
|
|
||||||
|
|
|
@ -26,30 +26,30 @@
|
||||||
* 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: Plugin.java,v 1.1 2007/01/09 10:15:42 fros4943 Exp $
|
* $Id: Plugin.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for a COOJA interaction plugin. The typical interaction plugin
|
* Main interface for a COOJA interaction plugin. The typical interaction plugin
|
||||||
* is a visualization plugin, see abstract VisPlugin for more information.
|
* is a visualization plugin, see abstract VisPlugin for more information.
|
||||||
*
|
*
|
||||||
|
* @see se.sics.cooja.VisPlugin
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public interface Plugin {
|
public interface Plugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when an opened plugin is about to close.
|
* This method is called when an opened plugin is about to close.
|
||||||
* It should release any resources such as registered observers or
|
* It should release any resources such as registered observers or
|
||||||
* opened interface visualizers.
|
* opened interface visualizers.
|
||||||
*/
|
*/
|
||||||
public void closePlugin();
|
public void closePlugin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used by the simulator for book-keeping purposes, and should
|
* This method is used by the simulator for book-keeping purposes, and should
|
||||||
* normally not be called by the plugin itself.
|
* normally not be called by the plugin itself.
|
||||||
|
@ -66,8 +66,7 @@ public interface Plugin {
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
public Object getTag();
|
public Object getTag();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns XML elements representing the current config of this plugin. This
|
* Returns XML elements representing the current config of this plugin. This
|
||||||
* is fetched by the simulator for example when saving a simulation
|
* is fetched by the simulator for example when saving a simulation
|
||||||
|
@ -76,11 +75,11 @@ public interface Plugin {
|
||||||
* such as the value of a mote LED, or total number of motes. (All nodes are
|
* such as the value of a mote LED, or total number of motes. (All nodes are
|
||||||
* restarted when loading a simulation.)
|
* restarted when loading a simulation.)
|
||||||
*
|
*
|
||||||
* @see #setConfigXML(Collection)
|
* @see #setConfigXML(Collection, boolean)
|
||||||
* @return XML elements representing the current radio medium config
|
* @return XML elements representing the current radio medium config
|
||||||
*/
|
*/
|
||||||
public Collection<Element> getConfigXML();
|
public Collection<Element> getConfigXML();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current plugin config depending on the given XML elements.
|
* Sets the current plugin config depending on the given XML elements.
|
||||||
*
|
*
|
||||||
|
@ -89,6 +88,7 @@ public interface Plugin {
|
||||||
* Config XML elements
|
* Config XML elements
|
||||||
* @return True if config was set successfully, false otherwise
|
* @return True if config was set successfully, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable);
|
public boolean setConfigXML(Collection<Element> configXML,
|
||||||
|
boolean visAvailable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: PluginType.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: PluginType.java,v 1.1 2007/01/09 10:15:26 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -35,8 +33,8 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation type to describe a plugin type.
|
* Annotation type to identify a plugin type.
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@ -45,75 +43,73 @@ public @interface PluginType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mote Plugin
|
* Mote Plugin
|
||||||
*
|
*
|
||||||
* A mote plugin concerns one specific mote.
|
* A mote plugin concerns one specific mote.
|
||||||
*
|
*
|
||||||
* An example of such a plugin may be to display
|
* An example of such a plugin may be to display some mote information in a
|
||||||
* some mote information in a frame.
|
* frame.
|
||||||
*
|
*
|
||||||
* Mote plugins can not be instantiated from the
|
* Mote plugins can not be instantiated from the regular menu bar, but are
|
||||||
* regular menu bar, but are instead started from
|
* instead started from other plugins, for example a visualizer that let's a
|
||||||
* other plugins, for example a visualizer that let's
|
* user select a mote.
|
||||||
* a user select a mote.
|
*
|
||||||
*
|
* When constructed, a mote plugin is given a mote, the current active
|
||||||
* When constructed, a mote plugin is given a Mote.
|
* simulation and the GUI object.
|
||||||
*
|
*
|
||||||
* If the current simulation is removed, so are
|
* If the current simulation is removed, so are all instances of this plugin.
|
||||||
* all instances of this plugin.
|
|
||||||
*/
|
*/
|
||||||
public static final int MOTE_PLUGIN = 1;
|
public static final int MOTE_PLUGIN = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulation Plugin
|
* Simulation Plugin
|
||||||
*
|
*
|
||||||
* A simulation plugin concerns one specific simulation.
|
* A simulation plugin concerns one specific simulation.
|
||||||
*
|
*
|
||||||
* An example of such a plugin may be to display
|
* An example of such a plugin may be to display number of motes and current
|
||||||
* number of motes and current simulation time in a window.
|
* simulation time in a window.
|
||||||
*
|
*
|
||||||
* Simulation plugins are available via the plugins menubar.
|
* Simulation plugins are available via the plugins menubar.
|
||||||
*
|
*
|
||||||
* When constructed, a simulation plugin is given the current
|
* When constructed, a simulation plugin is given the current active
|
||||||
* active simulation.
|
* simulation and the GUI object.
|
||||||
*
|
*
|
||||||
* If the current simulation is removed, so are
|
* If the current simulation is removed, so are all instances of this plugin.
|
||||||
* all instances of this plugin.
|
|
||||||
*/
|
*/
|
||||||
public static final int SIM_PLUGIN = 2;
|
public static final int SIM_PLUGIN = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COOJA Plugin
|
* COOJA Plugin
|
||||||
*
|
*
|
||||||
* A COOJA plugin does not depend on the current simulation to function.
|
* A COOJA plugin does not depend on the current simulation (if any).
|
||||||
*
|
*
|
||||||
* An example of such a plugin may be a control panel
|
* An example of such a plugin may be a control panel where a user can save
|
||||||
* where a user can control the current simulation.
|
* and load different simulations.
|
||||||
*
|
*
|
||||||
* COOJA plugins are available via the plugins menubar.
|
* COOJA plugins are available via the plugins menubar.
|
||||||
*
|
*
|
||||||
* When constructed, a COOJA plugin is given the current GUI.
|
* When constructed, a COOJA plugin is given the current GUI.
|
||||||
*/
|
*/
|
||||||
public static final int COOJA_PLUGIN = 3;
|
public static final int COOJA_PLUGIN = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulation Standard Plugin
|
* Simulation Standard Plugin
|
||||||
*
|
*
|
||||||
* This is treated exactly like a Simulation Plugin, with the
|
* This is treated exactly like a Simulation Plugin, with the only difference
|
||||||
* only difference that this will automatically be opened
|
* that this will automatically be opened when a new simulation is created.
|
||||||
* when a new simulation is created.
|
*
|
||||||
|
* @see #SIM_PLUGIN
|
||||||
*/
|
*/
|
||||||
public static final int SIM_STANDARD_PLUGIN = 4;
|
public static final int SIM_STANDARD_PLUGIN = 4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COOJA Standard Plugin
|
* COOJA Standard Plugin
|
||||||
*
|
*
|
||||||
* This is treated exactly like a COOJA Plugin, with the
|
* This is treated exactly like a COOJA Plugin, with the only difference that
|
||||||
* only difference that this will automatically be opened
|
* this will automatically be opened when the simulator is started.
|
||||||
* when the simulator is started.
|
*
|
||||||
|
* @see #COOJA_PLUGIN
|
||||||
*/
|
*/
|
||||||
public static final int COOJA_STANDARD_PLUGIN = 5;
|
public static final int COOJA_STANDARD_PLUGIN = 5;
|
||||||
|
|
||||||
int value();
|
int value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: Positioner.java,v 1.1 2006/08/21 12:12:51 fros4943 Exp $
|
* $Id: Positioner.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -72,11 +72,11 @@ public abstract class Positioner {
|
||||||
double endZ) {
|
double endZ) {
|
||||||
try {
|
try {
|
||||||
// Generating positioner
|
// Generating positioner
|
||||||
Constructor constr = positionerClass.getConstructor(new Class[]{
|
Constructor constr = positionerClass.getConstructor(new Class[] {
|
||||||
int.class, double.class, double.class, double.class, double.class,
|
int.class, double.class, double.class, double.class, double.class,
|
||||||
double.class, double.class});
|
double.class, double.class });
|
||||||
return (Positioner) constr.newInstance(new Object[]{totalNumberOfMotes,
|
return (Positioner) constr.newInstance(new Object[] { totalNumberOfMotes,
|
||||||
startX, endX, startY, endY, startZ, endZ});
|
startX, endX, startY, endY, startZ, endZ });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.fatal("Exception when creating " + positionerClass + ": " + e);
|
logger.fatal("Exception when creating " + positionerClass + ": " + e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -26,25 +26,24 @@
|
||||||
* 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: RadioMedium.java,v 1.3 2007/01/10 09:02:17 fros4943 Exp $
|
* $Id: RadioMedium.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Observable;
|
|
||||||
import java.util.Observer;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.interfaces.Position;
|
import se.sics.cooja.interfaces.Position;
|
||||||
import se.sics.cooja.interfaces.Radio;
|
import se.sics.cooja.interfaces.Radio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a radio medium. Radios registered to this medium
|
* The abstract class RadioMedium should be implemented by all COOJA radio
|
||||||
* can both send and receive radio data. Depending on the implementation of this
|
* mediums. Radios registered in this medium can both send and receive radio
|
||||||
* interface, more or less accurate radio behaviour imitation is aquired.
|
* data. Depending on the implementation of this interface, more or less
|
||||||
|
* accurate radio behaviour imitation is aquired.
|
||||||
*
|
*
|
||||||
* Often a radio medium, at initialization, registers one or several dynamic
|
* Often a radio medium, at initialization, registers one or several dynamic
|
||||||
* plugins. These plugins shows the user some radio medium specific details,
|
* plugins. These plugins shows the user some radio medium specific details,
|
||||||
|
@ -53,7 +52,6 @@ import se.sics.cooja.interfaces.Radio;
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public abstract class RadioMedium {
|
public abstract class RadioMedium {
|
||||||
private static Logger logger = Logger.getLogger(RadioMedium.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a mote to this medium.
|
* Registers a mote to this medium.
|
||||||
|
@ -167,7 +165,7 @@ public abstract class RadioMedium {
|
||||||
* information such as a current radio status. (All nodes are restarted when
|
* information such as a current radio status. (All nodes are restarted when
|
||||||
* loading a simulation.)
|
* loading a simulation.)
|
||||||
*
|
*
|
||||||
* @see #setConfigXML(Collection)
|
* @see #setConfigXML(Collection, boolean)
|
||||||
* @return XML elements representing the current radio medium config
|
* @return XML elements representing the current radio medium config
|
||||||
*/
|
*/
|
||||||
public abstract Collection<Element> getConfigXML();
|
public abstract Collection<Element> getConfigXML();
|
||||||
|
@ -182,7 +180,6 @@ public abstract class RadioMedium {
|
||||||
*/
|
*/
|
||||||
public abstract boolean setConfigXML(Collection<Element> configXML, boolean visAvailable);
|
public abstract boolean setConfigXML(Collection<Element> configXML, boolean visAvailable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates an instance of the given class with the given
|
* This method creates an instance of the given class with the given
|
||||||
* simulation constructor argument. Instead of calling the constructors
|
* simulation constructor argument. Instead of calling the constructors
|
||||||
|
|
|
@ -1,32 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: SectionMoteMemory.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: SectionMoteMemory.java,v 1.3 2006/12/15 11:47:40 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -39,8 +37,8 @@ import org.apache.log4j.Logger;
|
||||||
import se.sics.cooja.MoteMemory;
|
import se.sics.cooja.MoteMemory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mote memory consisting of non-overlapping memory sections. This
|
* Represents a mote memory consisting of non-overlapping memory sections with
|
||||||
* memory also contains information about variable starts addresses.
|
* variables' memory addresses.
|
||||||
* <p>
|
* <p>
|
||||||
* When an unhandled memory segment is set a new section is automatically
|
* When an unhandled memory segment is set a new section is automatically
|
||||||
* created for this segment.
|
* created for this segment.
|
||||||
|
@ -52,6 +50,7 @@ public class SectionMoteMemory implements MoteMemory {
|
||||||
private static Logger logger = Logger.getLogger(SectionMoteMemory.class);
|
private static Logger logger = Logger.getLogger(SectionMoteMemory.class);
|
||||||
|
|
||||||
private Vector<MoteMemorySection> sections = new Vector<MoteMemorySection>();
|
private Vector<MoteMemorySection> sections = new Vector<MoteMemorySection>();
|
||||||
|
|
||||||
private final Properties variableAddresses;
|
private final Properties variableAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +77,8 @@ public class SectionMoteMemory implements MoteMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param varName Variable name
|
* @param varName
|
||||||
|
* Variable name
|
||||||
* @return Address of given variable, or -1
|
* @return Address of given variable, or -1
|
||||||
*/
|
*/
|
||||||
public int getVariableAddress(String varName) {
|
public int getVariableAddress(String varName) {
|
||||||
|
@ -86,7 +86,7 @@ public class SectionMoteMemory implements MoteMemory {
|
||||||
return -1;
|
return -1;
|
||||||
return ((Integer) variableAddresses.get(varName)).intValue();
|
return ((Integer) variableAddresses.get(varName)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMemory() {
|
public void clearMemory() {
|
||||||
sections.clear();
|
sections.clear();
|
||||||
}
|
}
|
||||||
|
@ -341,12 +341,13 @@ public class SectionMoteMemory implements MoteMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A memory section represented of a byte array and a start address.
|
* A memory section contains a byte array and a start address.
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
private class MoteMemorySection {
|
private class MoteMemorySection {
|
||||||
private byte[] data = null;
|
private byte[] data = null;
|
||||||
|
|
||||||
private int startAddr;
|
private int startAddr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,37 +1,34 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||||
* All rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* are met:
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* materials provided with the distribution. 3. Neither the name of the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Institute nor the names of its contributors may be used to endorse or promote
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* products derived from this software without specific prior written
|
||||||
* may be used to endorse or promote products derived from this software
|
* permission.
|
||||||
* without specific prior written permission.
|
*
|
||||||
*
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
*
|
||||||
* SUCH DAMAGE.
|
* $Id: Simulation.java,v 1.9 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*
|
|
||||||
* $Id: Simulation.java,v 1.8 2007/01/10 09:02:38 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.*;
|
import org.jdom.*;
|
||||||
|
@ -39,13 +36,15 @@ import org.jdom.*;
|
||||||
import se.sics.cooja.dialogs.*;
|
import se.sics.cooja.dialogs.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simulation contains motes and ticks them one by one. When all motes has
|
* A simulation consists of a number of motes and mote types.
|
||||||
* been ticked once, the simulation sleeps for some specified time, and the
|
*
|
||||||
* current simulation time is updated. Some observers (tick observers) are also
|
* The motes in the simulation are ticked one by one in a simulation loop. When
|
||||||
* notified.
|
* all motes have been ticked once, the simulation time is updated and then the
|
||||||
|
* simulation sleeps for some specified delay time. Any tick observers are also
|
||||||
|
* notified at this time.
|
||||||
*
|
*
|
||||||
* When observing the simulation itself, the simulation state, added or deleted
|
* When observing the simulation itself, the simulation state, added or deleted
|
||||||
* motes etc are observed, as opposed to individual mote changes. Changes of
|
* motes etc. are observed, as opposed to individual mote changes. Changes of
|
||||||
* individual motes should instead be observed via corresponding mote
|
* individual motes should instead be observed via corresponding mote
|
||||||
* interfaces.
|
* interfaces.
|
||||||
*
|
*
|
||||||
|
@ -54,24 +53,29 @@ import se.sics.cooja.dialogs.*;
|
||||||
public class Simulation extends Observable implements Runnable {
|
public class Simulation extends Observable implements Runnable {
|
||||||
|
|
||||||
private Vector<Mote> motes = new Vector<Mote>();
|
private Vector<Mote> motes = new Vector<Mote>();
|
||||||
|
|
||||||
private Vector<MoteType> moteTypes = new Vector<MoteType>();
|
private Vector<MoteType> moteTypes = new Vector<MoteType>();
|
||||||
|
|
||||||
private int delayTime = 100;
|
private int delayTime = 100;
|
||||||
|
|
||||||
private int currentSimulationTime = 0;
|
private int currentSimulationTime = 0;
|
||||||
|
|
||||||
private int tickTime = 1;
|
private int tickTime = 1;
|
||||||
|
|
||||||
private String title = null;
|
private String title = null;
|
||||||
|
|
||||||
// Radio Medium
|
|
||||||
private RadioMedium currentRadioMedium = null;
|
private RadioMedium currentRadioMedium = null;
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(Simulation.class);
|
private static Logger logger = Logger.getLogger(Simulation.class);
|
||||||
|
|
||||||
private boolean isRunning = false;
|
private boolean isRunning = false;
|
||||||
|
|
||||||
private boolean stopSimulation = false;
|
private boolean stopSimulation = false;
|
||||||
|
|
||||||
private Thread thread = null;
|
private Thread thread = null;
|
||||||
|
|
||||||
private GUI myGUI = null;
|
private GUI myGUI = null;
|
||||||
|
|
||||||
// Tick observable
|
// Tick observable
|
||||||
private class TickObservable extends Observable {
|
private class TickObservable extends Observable {
|
||||||
private void allTicksPerformed() {
|
private void allTicksPerformed() {
|
||||||
|
@ -79,6 +83,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TickObservable tickObservable = new TickObservable();
|
private TickObservable tickObservable = new TickObservable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,10 +173,9 @@ public class Simulation extends Observable implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new simulation with a delay time of 1 second.
|
* Creates a new simulation with a delay time of 100 ms.
|
||||||
*/
|
*/
|
||||||
public Simulation(GUI gui) {
|
public Simulation(GUI gui) {
|
||||||
// New simulation instance
|
|
||||||
myGUI = gui;
|
myGUI = gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,12 +206,11 @@ public class Simulation extends Observable implements Runnable {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // else logger.fatal("Could not stop simulation: isRunning=" + isRunning +
|
}
|
||||||
// ", thread=" + thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts simulation if stopped, ticks all motes once, and finally stop
|
* Starts simulation if stopped, ticks all motes once, and finally stops
|
||||||
* simulation again.
|
* simulation again.
|
||||||
*/
|
*/
|
||||||
public void tickSimulation() {
|
public void tickSimulation() {
|
||||||
|
@ -228,11 +231,17 @@ public class Simulation extends Observable implements Runnable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return GUI holding this simulation
|
||||||
|
*/
|
||||||
|
public GUI getGUI() {
|
||||||
|
return myGUI;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current simulation config represented by XML elements. This
|
* Returns the current simulation config represented by XML elements. This
|
||||||
* config also includes the current radio medium, all mote types and motes.
|
* config also includes the current radio medium, all mote types and motes.
|
||||||
*
|
*
|
||||||
* @see #saveSimulationConfig(File file)
|
|
||||||
* @return Current simulation config
|
* @return Current simulation config
|
||||||
*/
|
*/
|
||||||
public Collection<Element> getConfigXML() {
|
public Collection<Element> getConfigXML() {
|
||||||
|
@ -294,21 +303,21 @@ public class Simulation extends Observable implements Runnable {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return GUI holding this simulation
|
|
||||||
*/
|
|
||||||
public GUI getGUI() {
|
|
||||||
return myGUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current simulation config depending on the given XML elements.
|
* Sets the current simulation config depending on the given XML elements.
|
||||||
*
|
*
|
||||||
* @see #getConfigXML()
|
* @see #getConfigXML()
|
||||||
* @param configXML
|
* @param configXML
|
||||||
* Config XML elements
|
* Config XML elements
|
||||||
|
* @param visAvailable
|
||||||
|
* True if simulation is allowed to show visualizers while loading
|
||||||
|
* the given config
|
||||||
|
* @return True if simulation config set successfully
|
||||||
|
* @throws Exception
|
||||||
|
* If configuration could not be loaded
|
||||||
*/
|
*/
|
||||||
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) throws Exception {
|
public boolean setConfigXML(Collection<Element> configXML,
|
||||||
|
boolean visAvailable) throws Exception {
|
||||||
|
|
||||||
// Parse elements
|
// Parse elements
|
||||||
for (Element element : configXML) {
|
for (Element element : configXML) {
|
||||||
|
@ -336,20 +345,21 @@ public class Simulation extends Observable implements Runnable {
|
||||||
// Radio medium
|
// Radio medium
|
||||||
if (element.getName().equals("radiomedium")) {
|
if (element.getName().equals("radiomedium")) {
|
||||||
String radioMediumClassName = element.getText().trim();
|
String radioMediumClassName = element.getText().trim();
|
||||||
Class<? extends RadioMedium> radioMediumClass = myGUI
|
Class<? extends RadioMedium> radioMediumClass = myGUI.tryLoadClass(
|
||||||
.tryLoadClass(this, RadioMedium.class, radioMediumClassName);
|
this, RadioMedium.class, radioMediumClassName);
|
||||||
|
|
||||||
if (radioMediumClass != null) {
|
if (radioMediumClass != null) {
|
||||||
// Create radio medium specified in config
|
// Create radio medium specified in config
|
||||||
try {
|
try {
|
||||||
currentRadioMedium = RadioMedium.generateRadioMedium(radioMediumClass, this);
|
currentRadioMedium = RadioMedium.generateRadioMedium(
|
||||||
|
radioMediumClass, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
currentRadioMedium = null;
|
currentRadioMedium = null;
|
||||||
logger.warn("Could not load radio medium class: "
|
logger.warn("Could not load radio medium class: "
|
||||||
+ radioMediumClassName);
|
+ radioMediumClassName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show configure simulation dialog
|
// Show configure simulation dialog
|
||||||
boolean createdOK = false;
|
boolean createdOK = false;
|
||||||
if (visAvailable) {
|
if (visAvailable) {
|
||||||
|
@ -377,8 +387,8 @@ public class Simulation extends Observable implements Runnable {
|
||||||
if (element.getName().equals("motetype")) {
|
if (element.getName().equals("motetype")) {
|
||||||
String moteTypeClassName = element.getText().trim();
|
String moteTypeClassName = element.getText().trim();
|
||||||
|
|
||||||
Class<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(
|
Class<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(this,
|
||||||
this, MoteType.class, moteTypeClassName);
|
MoteType.class, moteTypeClassName);
|
||||||
|
|
||||||
if (moteTypeClass == null) {
|
if (moteTypeClass == null) {
|
||||||
logger.fatal("Could not load mote type class: " + moteTypeClassName);
|
logger.fatal("Could not load mote type class: " + moteTypeClassName);
|
||||||
|
@ -388,7 +398,8 @@ public class Simulation extends Observable implements Runnable {
|
||||||
MoteType moteType = moteTypeClass.getConstructor((Class[]) null)
|
MoteType moteType = moteTypeClass.getConstructor((Class[]) null)
|
||||||
.newInstance();
|
.newInstance();
|
||||||
|
|
||||||
boolean createdOK = moteType.setConfigXML(this, element.getChildren(), visAvailable);
|
boolean createdOK = moteType.setConfigXML(this, element.getChildren(),
|
||||||
|
visAvailable);
|
||||||
if (createdOK) {
|
if (createdOK) {
|
||||||
addMoteType(moteType);
|
addMoteType(moteType);
|
||||||
} else {
|
} else {
|
||||||
|
@ -400,8 +411,8 @@ public class Simulation extends Observable implements Runnable {
|
||||||
|
|
||||||
// Mote
|
// Mote
|
||||||
if (element.getName().equals("mote")) {
|
if (element.getName().equals("mote")) {
|
||||||
Class<? extends Mote> moteClass = myGUI.tryLoadClass(this,
|
Class<? extends Mote> moteClass = myGUI.tryLoadClass(this, Mote.class,
|
||||||
Mote.class, element.getText().trim());
|
element.getText().trim());
|
||||||
|
|
||||||
Mote mote = moteClass.getConstructor((Class[]) null).newInstance();
|
Mote mote = moteClass.getConstructor((Class[]) null).newInstance();
|
||||||
if (mote.setConfigXML(this, element.getChildren(), visAvailable)) {
|
if (mote.setConfigXML(this, element.getChildren(), visAvailable)) {
|
||||||
|
@ -460,7 +471,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
* Get a mote from this simulation.
|
* Get a mote from this simulation.
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
* Position of mote
|
* Internal list position of mote
|
||||||
* @return Mote
|
* @return Mote
|
||||||
*/
|
*/
|
||||||
public Mote getMote(int pos) {
|
public Mote getMote(int pos) {
|
||||||
|
@ -503,7 +514,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
/**
|
/**
|
||||||
* Adds given mote type to simulation.
|
* Adds given mote type to simulation.
|
||||||
*
|
*
|
||||||
* @param newMoteType
|
* @param newMoteType Mote type
|
||||||
*/
|
*/
|
||||||
public void addMoteType(MoteType newMoteType) {
|
public void addMoteType(MoteType newMoteType) {
|
||||||
moteTypes.add(newMoteType);
|
moteTypes.add(newMoteType);
|
||||||
|
@ -593,7 +604,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
}
|
}
|
||||||
this.currentRadioMedium = radioMedium;
|
this.currentRadioMedium = radioMedium;
|
||||||
|
|
||||||
// Add all current motes to be observered by new radio medium
|
// Add all current motes to the new radio medium
|
||||||
for (int i = 0; i < motes.size(); i++)
|
for (int i = 0; i < motes.size(); i++)
|
||||||
currentRadioMedium.registerMote(motes.get(i), this);
|
currentRadioMedium.registerMote(motes.get(i), this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: VisPlugin.java,v 1.3 2007/01/09 10:14:21 fros4943 Exp $
|
* $Id: VisPlugin.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -38,14 +38,15 @@ import javax.swing.event.InternalFrameListener;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class VisPlugin should be implemented by plugins for COOJA Simulator.
|
* Abstract class VisPlugin should be implemented by all plugins with
|
||||||
* By extending JInternalFrame, the visual apperence is decided by the plugin itself.
|
* visualizers. By extending JInternalFrame, the visual apperence is decided by
|
||||||
*
|
* the plugin itself.
|
||||||
* An implemented plugin should be registered at runtime using the following method:
|
*
|
||||||
* GUI.registerPlugin(Class<? extends VisPlugin>, String)
|
* To add a new plugin to the simulator environment either add it via a user
|
||||||
*
|
* platform or by altering the standard configuration files.
|
||||||
* For example how to implement a plugin see classes SimControl or Vis2D.
|
*
|
||||||
*
|
* For example how to implement a plugin see plugins SimControl or Visualizer2D.
|
||||||
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public abstract class VisPlugin extends JInternalFrame implements Plugin {
|
public abstract class VisPlugin extends JInternalFrame implements Plugin {
|
||||||
|
@ -104,5 +105,4 @@ public abstract class VisPlugin extends JInternalFrame implements Plugin {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue