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.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ConnectionLogger.java,v 1.3 2006/12/15 12:03:32 fros4943 Exp $
|
||||
* $Id: ConnectionLogger.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
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
|
||||
* 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]
|
||||
* [dest_z] DEST_DATA [received data bytes] [newline]
|
||||
*
|
||||
* @see RadioConnection
|
||||
* @see RadioMedium
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public class ConnectionLogger {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static Logger logger = Logger.getLogger(ConnectionLogger.class);
|
||||
|
||||
private static int LOG_TO_FILE = 1;
|
||||
|
||||
private static int LOG_TO_LOG4J = 2;
|
||||
|
||||
private static int LOG_TO_FILE_AND_LOG4J = 3;
|
||||
|
||||
private int myType;
|
||||
|
||||
private File myFile;
|
||||
|
||||
/**
|
||||
|
@ -123,7 +124,8 @@ public class ConnectionLogger {
|
|||
out.write("SRC_DATA\t".getBytes());
|
||||
for (byte b : conn.getSourceData()) {
|
||||
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("\t".getBytes());
|
||||
|
@ -142,9 +144,11 @@ public class ConnectionLogger {
|
|||
out.write("DEST_DATA\t".getBytes());
|
||||
for (byte b : conn.getDestinationData()[i]) {
|
||||
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("\t".getBytes());
|
||||
}
|
||||
out.write("\t".getBytes());
|
||||
|
||||
out.write("\n".getBytes());
|
||||
}
|
||||
|
@ -164,7 +168,8 @@ public class ConnectionLogger {
|
|||
out.write("SRC_DATA\t".getBytes());
|
||||
for (byte b : conn.getSourceData()) {
|
||||
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("\n".getBytes());
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: CoreComm.java,v 1.2 2006/08/23 17:11:09 fros4943 Exp $
|
||||
* $Id: CoreComm.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -35,19 +33,19 @@ import java.io.File;
|
|||
import se.sics.cooja.corecomm.*;
|
||||
|
||||
/**
|
||||
* The package corecomm's purpose is communicating with the simulation core
|
||||
* using Java Native Interface (JNI). Each implementing class (named
|
||||
* Lib[1-MAX]), loads a shared library which belongs to one mote type. The
|
||||
* reason for this somewhat strange design is that once loaded, a native library
|
||||
* cannot be unloaded in Java (yet). Therefore if we wish to load several
|
||||
* libraries, the names and associated native functions must have unique names.
|
||||
* And those names are defined via the calling class in JNI. For example, the
|
||||
* native tick function in class Lib1 is named
|
||||
* contiki_javasim_corecomm_Lib1_tick. When creating a new mote type, the main
|
||||
* contiki source file is generated with function names compatible with the next
|
||||
* available corecomm. This also implies that even if a mote type is deleted, a
|
||||
* new one cannot be created without restarting the JVM and thus the entire
|
||||
* simulation.
|
||||
* The purpose of corecomm's is communicating with a compiled Contiki system
|
||||
* using Java Native Interface (JNI). Each implemented class (named Lib[1-MAX]),
|
||||
* loads a shared library which belongs to one mote type. The reason for this
|
||||
* somewhat strange design is that once loaded, a native library cannot be
|
||||
* unloaded in Java (in the current versions available). Therefore if we wish to
|
||||
* load several libraries, the names and associated native functions must have
|
||||
* unique names. And those names are defined via the calling class in JNI. For
|
||||
* example, the corresponding function for a native tick method in class Lib1
|
||||
* will be named Java_se_sics_cooja_corecomm_Lib1_tick. When creating a new mote
|
||||
* type, the main Contiki source file is generated with function names
|
||||
* compatible with the next available corecomm class. This also implies that
|
||||
* even if a mote type is deleted, a new one cannot be created using the same
|
||||
* corecomm class without restarting the JVM and thus the entire simulation.
|
||||
*
|
||||
* Each implemented CoreComm class needs read access to the following core
|
||||
* variables:
|
||||
|
@ -56,23 +54,23 @@ import se.sics.cooja.corecomm.*;
|
|||
* </ul>
|
||||
* and the following native functions:
|
||||
* <ul>
|
||||
* <li>init()
|
||||
* <li>tick()
|
||||
* <li>init()
|
||||
* <li>getReferenceAbsAddr()
|
||||
* <li>getMemory(int start, int length)
|
||||
* <li>getMemory(int start, int length, byte[] mem)
|
||||
* <li>setMemory(int start, int length, byte[] mem)
|
||||
* </ul>
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
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;
|
||||
|
||||
// Static pointers to current libraries
|
||||
private final static CoreComm[] coreComms = new CoreComm[MAX_LIBRARIES];
|
||||
|
||||
private final static File[] coreCommFiles = new File[MAX_LIBRARIES];
|
||||
|
||||
/**
|
||||
|
@ -195,7 +193,7 @@ public abstract class CoreComm {
|
|||
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)
|
||||
*/
|
||||
protected abstract void init();
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: GUI.java,v 1.14 2007/01/10 09:03:02 fros4943 Exp $
|
||||
* $Id: GUI.java,v 1.15 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -39,7 +37,6 @@ import java.net.URL;
|
|||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MenuEvent;
|
||||
import javax.swing.event.MenuListener;
|
||||
|
@ -58,7 +55,13 @@ import se.sics.cooja.dialogs.*;
|
|||
import se.sics.cooja.plugins.*;
|
||||
|
||||
/**
|
||||
* Main file of COOJA Simulator.
|
||||
* Main file of COOJA Simulator. Typically contains a visualizer for the
|
||||
* simulator, but can also be started without visualizer.
|
||||
*
|
||||
* This class loads external Java classes (in user platforms), and handles the
|
||||
* COOJA plugins as well as the configuration system. If provides a number of
|
||||
* help methods for the rest of the COOJA system, and is the starting point for
|
||||
* loading and saving simulation configs.
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
|
@ -118,36 +121,44 @@ public class GUI {
|
|||
};
|
||||
|
||||
/**
|
||||
* Main frame for current GUI.
|
||||
* Null when COOJA is run without GUI!
|
||||
* Main frame for current GUI. Null when COOJA is run without visualizer!
|
||||
*/
|
||||
public static JFrame frame;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static Logger logger = Logger.getLogger(GUI.class);
|
||||
|
||||
// External tools setting names
|
||||
private static Properties currentExternalToolsSettings;
|
||||
|
||||
private static final String externalToolsSettingNames[] = new String[] {
|
||||
"PATH_CONTIKI", "PATH_COOJA_CORE_RELATIVE", "PATH_MAKE", "PATH_SHELL",
|
||||
"PATH_C_COMPILER", "COMPILER_ARGS", "PATH_LINKER", "PATH_NM", "NM_ARGS",
|
||||
"PATH_OBJDUMP", "OBJDUMP_ARGS", "LINKER_ARGS_1",
|
||||
"LINKER_ARGS_2", "CONTIKI_STANDARD_PROCESSES", "CMD_GREP_PROCESSES",
|
||||
"PATH_OBJDUMP", "OBJDUMP_ARGS", "LINKER_ARGS_1", "LINKER_ARGS_2",
|
||||
"CONTIKI_STANDARD_PROCESSES", "CMD_GREP_PROCESSES",
|
||||
"REGEXP_PARSE_PROCESSES", "CMD_GREP_INTERFACES",
|
||||
"REGEXP_PARSE_INTERFACES", "CMD_GREP_SENSORS", "REGEXP_PARSE_SENSORS",
|
||||
"CONTIKI_MAIN_TEMPLATE_FILENAME", "DEFAULT_USERPLATFORMS" };
|
||||
|
||||
private static final int FRAME_NEW_OFFSET = 30;
|
||||
|
||||
private static final int FRAME_STANDARD_WIDTH = 150;
|
||||
|
||||
private static final int FRAME_STANDARD_HEIGHT = 300;
|
||||
|
||||
private GUI myGUI;
|
||||
|
||||
private Simulation mySimulation;
|
||||
|
||||
protected Mote selectedMote = null;
|
||||
|
||||
protected GUIEventHandler guiEventHandler = new GUIEventHandler();
|
||||
|
||||
private JMenu menuPlugins, menuMoteTypeClasses, menuMoteTypes;
|
||||
|
||||
private JPopupMenu menuMotePlugins;
|
||||
|
||||
private JDesktopPane myDesktopPane;
|
||||
|
||||
private Vector<Plugin> startedPlugins = new Vector<Plugin>();
|
||||
|
@ -155,14 +166,21 @@ public class GUI {
|
|||
// Platform configuration variables
|
||||
// Maintained via method reparsePlatformConfig()
|
||||
private PlatformConfig platformConfig;
|
||||
|
||||
private Vector<File> currentUserPlatforms = new Vector<File>();
|
||||
|
||||
private ClassLoader userPlatformClassLoader;
|
||||
|
||||
private Vector<Class<? extends MoteType>> moteTypeClasses = new Vector<Class<? extends MoteType>>();
|
||||
|
||||
private Vector<Class<? extends Plugin>> pluginClasses = new Vector<Class<? extends Plugin>>();
|
||||
|
||||
private Vector<Class<? extends Plugin>> pluginClassesTemporary = new Vector<Class<? extends Plugin>>();
|
||||
|
||||
private Vector<Class<? extends RadioMedium>> radioMediumClasses = new Vector<Class<? extends RadioMedium>>();
|
||||
|
||||
private Vector<Class<? extends IPDistributor>> ipDistributorClasses = new Vector<Class<? extends IPDistributor>>();
|
||||
|
||||
private Vector<Class<? extends Positioner>> positionerClasses = new Vector<Class<? extends Positioner>>();
|
||||
|
||||
/**
|
||||
|
@ -178,13 +196,13 @@ public class GUI {
|
|||
frame.setJMenuBar(createMenuBar());
|
||||
}
|
||||
|
||||
|
||||
// Load default and overwrite with user settings (if any)
|
||||
loadExternalToolsDefaultSettings();
|
||||
loadExternalToolsUserSettings();
|
||||
|
||||
// Register default user platforms
|
||||
String defaultUserPlatforms = getExternalToolsSetting("DEFAULT_USERPLATFORMS", null);
|
||||
String defaultUserPlatforms = getExternalToolsSetting(
|
||||
"DEFAULT_USERPLATFORMS", null);
|
||||
if (defaultUserPlatforms != null) {
|
||||
String[] defaultUserPlatformsArr = defaultUserPlatforms.split(";");
|
||||
if (defaultUserPlatformsArr.length > 0) {
|
||||
|
@ -200,10 +218,9 @@ public class GUI {
|
|||
// Load extendable parts (using current platform config)
|
||||
reparsePlatformConfig();
|
||||
|
||||
// EXPERIMENTAL: Start all standard GUI plugins
|
||||
// Start all standard GUI plugins
|
||||
for (Class<? extends Plugin> visPluginClass : pluginClasses) {
|
||||
int pluginType = visPluginClass.getAnnotation(PluginType.class)
|
||||
.value();
|
||||
int pluginType = visPluginClass.getAnnotation(PluginType.class).value();
|
||||
if (pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||
startPlugin(visPluginClass, this, null, null);
|
||||
}
|
||||
|
@ -321,8 +338,10 @@ public class GUI {
|
|||
menuMoteTypeClasses.add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void menuDeselected(MenuEvent e) {
|
||||
}
|
||||
|
||||
public void menuCanceled(MenuEvent e) {
|
||||
}
|
||||
});
|
||||
|
@ -364,8 +383,10 @@ public class GUI {
|
|||
menuMoteTypes.add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void menuDeselected(MenuEvent e) {
|
||||
}
|
||||
|
||||
public void menuCanceled(MenuEvent e) {
|
||||
}
|
||||
});
|
||||
|
@ -421,7 +442,6 @@ public class GUI {
|
|||
frame.setSize(700, 700);
|
||||
frame.addWindowListener(gui.guiEventHandler);
|
||||
|
||||
|
||||
// Display the window.
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
@ -521,12 +541,12 @@ public class GUI {
|
|||
File contikiBaseDir = new File(getExternalToolsSetting("PATH_CONTIKI"));
|
||||
File contikiCoreDir = new File(contikiBaseDir,
|
||||
getExternalToolsSetting("PATH_COOJA_CORE_RELATIVE"));
|
||||
File libFile = new File(ContikiMoteType.tempOutputDirectory,
|
||||
moteTypeID + ContikiMoteType.librarySuffix);
|
||||
File mapFile = new File(ContikiMoteType.tempOutputDirectory,
|
||||
moteTypeID + ContikiMoteType.mapSuffix);
|
||||
File depFile = new File(ContikiMoteType.tempOutputDirectory,
|
||||
moteTypeID + ContikiMoteType.dependSuffix);
|
||||
File libFile = new File(ContikiMoteType.tempOutputDirectory, moteTypeID
|
||||
+ ContikiMoteType.librarySuffix);
|
||||
File mapFile = new File(ContikiMoteType.tempOutputDirectory, moteTypeID
|
||||
+ ContikiMoteType.mapSuffix);
|
||||
File depFile = new File(ContikiMoteType.tempOutputDirectory, moteTypeID
|
||||
+ ContikiMoteType.dependSuffix);
|
||||
if (libFile.exists())
|
||||
libFile.delete();
|
||||
if (depFile.exists())
|
||||
|
@ -773,7 +793,8 @@ public class GUI {
|
|||
Class<? extends RadioMedium> radioMediumClass = gui.tryLoadClass(gui,
|
||||
RadioMedium.class, radioMediumClassName);
|
||||
|
||||
RadioMedium radioMedium = RadioMedium.generateRadioMedium(radioMediumClass, simulation);
|
||||
RadioMedium radioMedium = RadioMedium.generateRadioMedium(
|
||||
radioMediumClass, simulation);
|
||||
simulation.setRadioMedium(radioMedium);
|
||||
} catch (Exception e) {
|
||||
logger.fatal(">> Failed to load radio medium, aborting: "
|
||||
|
@ -943,8 +964,7 @@ public class GUI {
|
|||
Class<? extends RadioMedium> radioMediumClass) {
|
||||
// Check that simulation constructor exists
|
||||
try {
|
||||
radioMediumClass
|
||||
.getConstructor(new Class[]{Simulation.class});
|
||||
radioMediumClass.getConstructor(new Class[] { Simulation.class });
|
||||
} catch (Exception e) {
|
||||
logger.fatal("No simulation constructor found of radio medium: "
|
||||
+ radioMediumClass);
|
||||
|
@ -1012,15 +1032,15 @@ public class GUI {
|
|||
|
||||
try {
|
||||
// Append config to general config
|
||||
// logger.info("Appending user platform configuration: " + userPlatform);
|
||||
// logger.info("Appending user platform configuration: " +
|
||||
// userPlatform);
|
||||
platformConfig.appendUserPlatform(userPlatform);
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.fatal("Could not find platform config file: "
|
||||
+ userPlatform);
|
||||
logger.fatal("Could not find platform config file: " + userPlatform);
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
logger.fatal("Error when reading platform config file: "
|
||||
+ userPlatform);
|
||||
logger
|
||||
.fatal("Error when reading platform config file: " + userPlatform);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1053,8 +1073,8 @@ public class GUI {
|
|||
"PLUGINS");
|
||||
if (pluginClassNames != null) {
|
||||
for (String pluginClassName : pluginClassNames) {
|
||||
Class<? extends Plugin> pluginClass = tryLoadClass(this,
|
||||
Plugin.class, pluginClassName);
|
||||
Class<? extends Plugin> pluginClass = tryLoadClass(this, Plugin.class,
|
||||
pluginClassName);
|
||||
|
||||
if (pluginClass != null) {
|
||||
registerPlugin(pluginClass);
|
||||
|
@ -1237,11 +1257,8 @@ public class GUI {
|
|||
* Mote passed as argument to mote plugins
|
||||
* @return Start plugin if any
|
||||
*/
|
||||
public Plugin startPlugin(Class<? extends Plugin> pluginClass,
|
||||
GUI gui,
|
||||
Simulation simulation,
|
||||
Mote mote
|
||||
) {
|
||||
public Plugin startPlugin(Class<? extends Plugin> pluginClass, GUI gui,
|
||||
Simulation simulation, Mote mote) {
|
||||
|
||||
// Check that plugin class is registered
|
||||
if (!pluginClasses.contains(pluginClass)) {
|
||||
|
@ -1278,17 +1295,18 @@ public class GUI {
|
|||
|
||||
// Tag plugin with mote
|
||||
newPlugin.tagWithObject(mote);
|
||||
} else if (pluginType == PluginType.SIM_PLUGIN ||
|
||||
pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||
} else if (pluginType == PluginType.SIM_PLUGIN
|
||||
|| pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||
if (simulation == null) {
|
||||
logger.fatal("Can't start simulation plugin (no simulation)");
|
||||
return null;
|
||||
}
|
||||
|
||||
newPlugin = pluginClass.getConstructor(new Class[]{Simulation.class, GUI.class})
|
||||
.newInstance(simulation, gui);
|
||||
} else if (pluginType == PluginType.COOJA_PLUGIN ||
|
||||
pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||
newPlugin = pluginClass.getConstructor(
|
||||
new Class[] { Simulation.class, GUI.class }).newInstance(
|
||||
simulation, gui);
|
||||
} else if (pluginType == PluginType.COOJA_PLUGIN
|
||||
|| pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||
if (gui == null) {
|
||||
logger.fatal("Can't start COOJA plugin (no GUI)");
|
||||
return null;
|
||||
|
@ -1338,8 +1356,7 @@ public class GUI {
|
|||
* New plugin to register
|
||||
* @return True if this plugin was registered ok, false otherwise
|
||||
*/
|
||||
public boolean registerTemporaryPlugin(
|
||||
Class<? extends Plugin> newPluginClass) {
|
||||
public boolean registerTemporaryPlugin(Class<? extends Plugin> newPluginClass) {
|
||||
if (pluginClasses.contains(newPluginClass))
|
||||
return false;
|
||||
|
||||
|
@ -1408,12 +1425,14 @@ public class GUI {
|
|||
// Check that plugin type is valid and constructor exists
|
||||
try {
|
||||
if (pluginType == PluginType.MOTE_PLUGIN) {
|
||||
newPluginClass.getConstructor(new Class[]{Mote.class, Simulation.class, GUI.class});
|
||||
} else if (pluginType == PluginType.SIM_PLUGIN ||
|
||||
pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||
newPluginClass.getConstructor(new Class[]{Simulation.class, GUI.class});
|
||||
} else if (pluginType == PluginType.COOJA_PLUGIN ||
|
||||
pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||
newPluginClass.getConstructor(new Class[] { Mote.class,
|
||||
Simulation.class, GUI.class });
|
||||
} else if (pluginType == PluginType.SIM_PLUGIN
|
||||
|| pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||
newPluginClass
|
||||
.getConstructor(new Class[] { Simulation.class, GUI.class });
|
||||
} else if (pluginType == PluginType.COOJA_PLUGIN
|
||||
|| pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||
newPluginClass.getConstructor(new Class[] { GUI.class });
|
||||
} else {
|
||||
logger.fatal("Could not find valid plugin type annotation in class "
|
||||
|
@ -1531,7 +1550,8 @@ public class GUI {
|
|||
boolean moteTypeOK = false;
|
||||
try {
|
||||
newMoteType = moteTypeClass.newInstance();
|
||||
moteTypeOK = newMoteType.configureAndInit(frame, mySimulation, isVisualized());
|
||||
moteTypeOK = newMoteType.configureAndInit(frame, mySimulation,
|
||||
isVisualized());
|
||||
} catch (Exception e) {
|
||||
logger.fatal("Exception when creating mote type: " + e);
|
||||
return;
|
||||
|
@ -1567,9 +1587,10 @@ public class GUI {
|
|||
|
||||
// Close all started non-GUI plugins
|
||||
for (Object startedPlugin : startedPlugins.toArray()) {
|
||||
int pluginType = startedPlugin.getClass().getAnnotation(PluginType.class).value();
|
||||
if (pluginType != PluginType.COOJA_PLUGIN &&
|
||||
pluginType != PluginType.COOJA_STANDARD_PLUGIN)
|
||||
int pluginType = startedPlugin.getClass().getAnnotation(
|
||||
PluginType.class).value();
|
||||
if (pluginType != PluginType.COOJA_PLUGIN
|
||||
&& pluginType != PluginType.COOJA_STANDARD_PLUGIN)
|
||||
removePlugin((Plugin) startedPlugin, false);
|
||||
}
|
||||
|
||||
|
@ -1713,7 +1734,8 @@ public class GUI {
|
|||
if (mySimulation != null) {
|
||||
mySimulation.stopSimulation();
|
||||
|
||||
Vector<Mote> newMotes = AddMoteDialog.showDialog(frame, mySimulation, moteType);
|
||||
Vector<Mote> newMotes = AddMoteDialog.showDialog(frame, mySimulation,
|
||||
moteType);
|
||||
if (newMotes != null) {
|
||||
for (Mote newMote : newMotes)
|
||||
mySimulation.addMote(newMote);
|
||||
|
@ -1888,15 +1910,16 @@ public class GUI {
|
|||
* Save external tools user settings to file.
|
||||
*/
|
||||
public static void saveExternalToolsUserSettings() {
|
||||
File configFile = new File(System.getProperty("user.home"), GUI.EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
|
||||
File configFile = new File(System.getProperty("user.home"),
|
||||
GUI.EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(configFile);
|
||||
currentExternalToolsSettings.store(out, "COOJA User Settings");
|
||||
out.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
// Could not open settings file for writing, aborting
|
||||
logger.warn("Could not save external tools user settings to " + configFile
|
||||
+ ", aborting");
|
||||
logger.warn("Could not save external tools user settings to "
|
||||
+ configFile + ", aborting");
|
||||
} catch (IOException ex) {
|
||||
// Could not open settings file for writing, aborting
|
||||
logger.warn("Error while saving external tools user settings to "
|
||||
|
@ -1909,14 +1932,19 @@ public class GUI {
|
|||
private class GUIEventHandler implements ActionListener, WindowListener {
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
|
@ -2013,7 +2041,8 @@ public class GUI {
|
|||
}
|
||||
|
||||
private ClassLoader createClassLoader(Vector<File> currentUserPlatforms) {
|
||||
return createClassLoader(ClassLoader.getSystemClassLoader(), currentUserPlatforms);
|
||||
return createClassLoader(ClassLoader.getSystemClassLoader(),
|
||||
currentUserPlatforms);
|
||||
}
|
||||
|
||||
private File findJarFile(File platformPath, String jarfile) {
|
||||
|
@ -2068,7 +2097,8 @@ public class GUI {
|
|||
}
|
||||
}
|
||||
|
||||
return new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]), parent);
|
||||
return new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]),
|
||||
parent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2235,7 +2265,8 @@ public class GUI {
|
|||
* @throws UnsatisfiedLinkError
|
||||
* If associated libraries could not be loaded
|
||||
*/
|
||||
public Simulation loadSimulationConfig(File file, boolean quick) throws UnsatisfiedLinkError {
|
||||
public Simulation loadSimulationConfig(File file, boolean quick)
|
||||
throws UnsatisfiedLinkError {
|
||||
|
||||
Simulation newSim = null;
|
||||
|
||||
|
@ -2286,8 +2317,7 @@ public class GUI {
|
|||
* Saves current simulation configuration to given file and notifies
|
||||
* observers.
|
||||
*
|
||||
* @see #loadSimulationConfig(File file)
|
||||
* @see #getConfigXML()
|
||||
* @see #loadSimulationConfig(File, boolean)
|
||||
* @param file
|
||||
* File to write
|
||||
*/
|
||||
|
@ -2322,6 +2352,7 @@ public class GUI {
|
|||
|
||||
/**
|
||||
* Returns started plugins config.
|
||||
*
|
||||
* @return Config or null
|
||||
*/
|
||||
public Collection<Element> getPluginsConfigXML() {
|
||||
|
@ -2331,18 +2362,20 @@ public class GUI {
|
|||
// (Only return config of non-GUI plugins)
|
||||
Element pluginElement, pluginSubElement;
|
||||
for (Plugin startedPlugin : startedPlugins) {
|
||||
int pluginType = startedPlugin.getClass().getAnnotation(PluginType.class).value();
|
||||
int pluginType = startedPlugin.getClass().getAnnotation(PluginType.class)
|
||||
.value();
|
||||
|
||||
// Ignore GUI plugins
|
||||
if (pluginType == PluginType.COOJA_PLUGIN ||
|
||||
pluginType == PluginType.COOJA_STANDARD_PLUGIN)
|
||||
if (pluginType == PluginType.COOJA_PLUGIN
|
||||
|| pluginType == PluginType.COOJA_STANDARD_PLUGIN)
|
||||
continue;
|
||||
|
||||
pluginElement = new Element("plugin");
|
||||
pluginElement.setText(startedPlugin.getClass().getName());
|
||||
|
||||
// Create mote argument config (if mote plugin)
|
||||
if (pluginType == PluginType.MOTE_PLUGIN && startedPlugin.getTag() != null) {
|
||||
if (pluginType == PluginType.MOTE_PLUGIN
|
||||
&& startedPlugin.getTag() != null) {
|
||||
pluginSubElement = new Element("mote_arg");
|
||||
Mote taggedMote = (Mote) startedPlugin.getTag();
|
||||
for (int moteNr = 0; moteNr < mySimulation.getMotesCount(); moteNr++) {
|
||||
|
@ -2371,7 +2404,8 @@ public class GUI {
|
|||
pluginElement.addContent(pluginSubElement);
|
||||
|
||||
pluginSubElement = new Element("z");
|
||||
pluginSubElement.setText("" + getDesktopPane().getComponentZOrder(startedVisPlugin));
|
||||
pluginSubElement.setText(""
|
||||
+ getDesktopPane().getComponentZOrder(startedVisPlugin));
|
||||
pluginElement.addContent(pluginSubElement);
|
||||
|
||||
pluginSubElement = new Element("height");
|
||||
|
@ -2387,7 +2421,8 @@ public class GUI {
|
|||
pluginElement.addContent(pluginSubElement);
|
||||
|
||||
pluginSubElement = new Element("minimized");
|
||||
pluginSubElement.setText(new Boolean(startedVisPlugin.isIcon()).toString());
|
||||
pluginSubElement.setText(new Boolean(startedVisPlugin.isIcon())
|
||||
.toString());
|
||||
pluginElement.addContent(pluginSubElement);
|
||||
}
|
||||
|
||||
|
@ -2433,14 +2468,15 @@ public class GUI {
|
|||
}
|
||||
|
||||
// Start plugin (before applying rest of config)
|
||||
Plugin startedPlugin = startPlugin(visPluginClass, this,
|
||||
simulation, mote);
|
||||
Plugin startedPlugin = startPlugin(visPluginClass, this, simulation,
|
||||
mote);
|
||||
|
||||
// Apply plugin specific configuration
|
||||
for (Element pluginSubElement : (List<Element>) pluginElement
|
||||
.getChildren()) {
|
||||
if (pluginSubElement.getName().equals("plugin_config")) {
|
||||
startedPlugin.setConfigXML(pluginSubElement.getChildren(), visAvailable);
|
||||
startedPlugin.setConfigXML(pluginSubElement.getChildren(),
|
||||
visAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2477,7 +2513,8 @@ public class GUI {
|
|||
// Ignoring
|
||||
}
|
||||
} else if (pluginSubElement.getName().equals("plugin_config")) {
|
||||
startedVisPlugin.setConfigXML(pluginSubElement.getChildren(), visAvailable);
|
||||
startedVisPlugin.setConfigXML(pluginSubElement.getChildren(),
|
||||
visAvailable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: IPDistributor.java,v 1.1 2006/08/21 12:12:56 fros4943 Exp $
|
||||
* $Id: IPDistributor.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
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.
|
||||
*
|
||||
* @see se.sics.cooja.Positioner
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public abstract class IPDistributor {
|
||||
|
@ -48,11 +47,13 @@ public abstract class IPDistributor {
|
|||
* constructor argument. Instead of calling the constructors directly this
|
||||
* method may be used.
|
||||
*
|
||||
* @param ipDistClass Class
|
||||
* @param newMotes All motes that later should be assigned IP numbers
|
||||
* @param ipDistClass
|
||||
* Class
|
||||
* @param newMotes
|
||||
* All motes that later should be assigned IP numbers
|
||||
* @return IP distributor instance
|
||||
*/
|
||||
public static final IPDistributor generateInterface(
|
||||
public static final IPDistributor generateIPDistributor(
|
||||
Class<? extends IPDistributor> ipDistClass, Vector<Mote> newMotes) {
|
||||
try {
|
||||
// Generating IP distributor
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: Mote.java,v 1.3 2007/01/09 10:16:26 fros4943 Exp $
|
||||
* $Id: Mote.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -36,10 +34,11 @@ import java.util.Observer;
|
|||
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.
|
||||
* Motes in different states may be handled differently by the for example simulation loops and plugins.
|
||||
* A mote is always in some state, describing the status of the CPU etc. Motes
|
||||
* 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.
|
||||
*
|
||||
|
@ -55,16 +54,20 @@ public interface Mote {
|
|||
* Possible mote states
|
||||
*/
|
||||
public static enum State {
|
||||
ACTIVE, // Active state
|
||||
LPM, // Low power mode (sleeping)
|
||||
DEAD // Dead (for example out of batteries)
|
||||
/* Active state */
|
||||
ACTIVE,
|
||||
/* Low power mode (sleeping) */
|
||||
LPM,
|
||||
/* Dead (for example out of batteries) */
|
||||
DEAD
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to change state to given argument.
|
||||
* A dead mote can typically not change state, while a sleeping or active mote can.
|
||||
* Tries to change state to given argument. A dead mote can typically not
|
||||
* 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);
|
||||
|
||||
|
@ -74,11 +77,11 @@ public interface Mote {
|
|||
public State getState();
|
||||
|
||||
/**
|
||||
* Adds new state observer.
|
||||
* This observer is notified if mote changes state.
|
||||
* Adds new state observer. This observer is notified if mote changes state.
|
||||
*
|
||||
* @see #deleteStateObserver(Observer)
|
||||
* @param newObserver New observer
|
||||
* @param newObserver
|
||||
* New observer
|
||||
*/
|
||||
public void addStateObserver(Observer newObserver);
|
||||
|
||||
|
@ -86,11 +89,11 @@ public interface Mote {
|
|||
* Delete existing state observer.
|
||||
*
|
||||
* @see #addStateObserver(Observer)
|
||||
* @param newObserver Registered state observer
|
||||
* @param newObserver
|
||||
* Registered state observer
|
||||
*/
|
||||
public void deleteStateObserver(Observer newObserver);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the interface handler of this mote.
|
||||
*
|
||||
|
@ -102,12 +105,12 @@ public interface Mote {
|
|||
/**
|
||||
* Sets the interface handler of this mote.
|
||||
*
|
||||
* @param moteInterfaceHandler New interface handler
|
||||
* @param moteInterfaceHandler
|
||||
* New interface handler
|
||||
* @see #getInterfaces()
|
||||
*/
|
||||
public void setInterfaces(MoteInterfaceHandler moteInterfaceHandler);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the memory of this mote.
|
||||
*
|
||||
|
@ -120,11 +123,11 @@ public interface Mote {
|
|||
* Sets the memory of this mote.
|
||||
*
|
||||
* @see #getMemory()
|
||||
* @param memory Mote memory
|
||||
* @param memory
|
||||
* Mote memory
|
||||
*/
|
||||
public void setMemory(MoteMemory memory);
|
||||
|
||||
|
||||
/**
|
||||
* Returns mote type.
|
||||
*
|
||||
|
@ -137,11 +140,11 @@ public interface Mote {
|
|||
* Sets mote type to given argument.
|
||||
*
|
||||
* @see #getType()
|
||||
* @param type New type
|
||||
* @param type
|
||||
* New type
|
||||
*/
|
||||
public void setType(MoteType type);
|
||||
|
||||
|
||||
/**
|
||||
* Returns simulation which holds this mote.
|
||||
*
|
||||
|
@ -154,37 +157,37 @@ public interface Mote {
|
|||
* Sets the simulation which holds this mote.
|
||||
*
|
||||
* @see #getSimulation()
|
||||
* @param simulation Simulation
|
||||
* @param simulation
|
||||
* Simulation
|
||||
*/
|
||||
public void setSimulation(Simulation simulation);
|
||||
|
||||
/**
|
||||
* Ticks this mote and increases any internal time to given argument.
|
||||
*
|
||||
* Each mote implementation may handle calls to this method differently,
|
||||
* but, if existing, the simulated mote should at least handle one event.
|
||||
* Each mote implementation may handle calls to this method differently, but
|
||||
* 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
|
||||
* polls all interfaces,
|
||||
* activates the memory,
|
||||
* lets the underlying mote software handle one event,
|
||||
* fetches the updated memory and
|
||||
* finally polls all interfaces again.
|
||||
* A call to this method typically polls all interfaces, activates the memory,
|
||||
* lets the underlying mote software handle one event, fetches the updated
|
||||
* memory and finally polls all interfaces again.
|
||||
*
|
||||
* @param simTime New simulation time
|
||||
* @param simTime
|
||||
* New simulation time
|
||||
*/
|
||||
public void tick(int simTime);
|
||||
|
||||
/**
|
||||
* Returns XML elements representing the current config of this mote.
|
||||
* This is fetched by the simulator for example when saving a simulation configuration file.
|
||||
* For example a mote may return the configs of all its interfaces.
|
||||
* This method should however not return state specific information such as the mote state.
|
||||
* (All nodes are restarted when loading a simulation.)
|
||||
* Returns XML elements representing the current config of this mote. This is
|
||||
* fetched by the simulator for example when saving a simulation configuration
|
||||
* file. For example a mote may return the configs of all its interfaces. This
|
||||
* method should however not return state specific information such as the
|
||||
* 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
|
||||
*/
|
||||
public abstract Collection<Element> getConfigXML();
|
||||
|
@ -192,11 +195,14 @@ public interface Mote {
|
|||
/**
|
||||
* Sets the current mote config depending on the given XML elements.
|
||||
*
|
||||
* @param simulation Simulation holding this mote
|
||||
* @param configXML Config XML elements
|
||||
* @param simulation
|
||||
* Simulation holding this mote
|
||||
* @param configXML
|
||||
* Config XML elements
|
||||
*
|
||||
* @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.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MoteInterface.java,v 1.2 2007/01/09 10:16:42 fros4943 Exp $
|
||||
* $Id: MoteInterface.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -38,16 +36,19 @@ import org.apache.log4j.Logger;
|
|||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* A mote interface represents a mote property.
|
||||
* Often this is a simulated hardware peripheral such as a button or a led.
|
||||
* This can also be a property the mote software itself is unaware of,
|
||||
* for example the current position of the mote.
|
||||
* A mote interface represents a mote property. Often this is a simulated
|
||||
* hardware peripheral such as a button or a led. This can also be a property
|
||||
* the mote software itself is unaware of, for example the current position of
|
||||
* 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.
|
||||
* In order to create a passive interfaces, the class should also implement the dummy Java interface PassiveMoteInterface.
|
||||
* For an explanation of the differences of active and passive interfaces see class PassiveMoteInterface.
|
||||
* Interfaces are divided into active and passive interfaces, which are handled
|
||||
* differently. In order to create a passive interface, the class should also
|
||||
* implement the dummy Java interface PassiveMoteInterface. For an explanation
|
||||
* of the differences of active and passive interfaces see class
|
||||
* PassiveMoteInterface.
|
||||
*
|
||||
* @see PassiveMoteInterface
|
||||
* @author Fredrik Osterlind
|
||||
|
@ -56,14 +57,18 @@ public abstract class MoteInterface extends Observable {
|
|||
private static Logger logger = Logger.getLogger(MoteInterface.class);
|
||||
|
||||
/**
|
||||
* This method creates an instance of the given class with the given mote as constructor
|
||||
* argument. Instead of calling the interface constructors directly this method may be used.
|
||||
* This method creates an instance of the given class with the given mote as
|
||||
* 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
|
||||
*/
|
||||
public static final MoteInterface generateInterface(Class<? extends MoteInterface> interfaceClass, Mote mote) {
|
||||
public static final MoteInterface generateInterface(
|
||||
Class<? extends MoteInterface> interfaceClass, Mote mote) {
|
||||
try {
|
||||
// Generating interface
|
||||
MoteInterface instance = (MoteInterface) interfaceClass.getConstructor(
|
||||
|
@ -87,12 +92,12 @@ public abstract class MoteInterface extends Observable {
|
|||
public abstract void doActionsAfterTick();
|
||||
|
||||
/**
|
||||
* Returns a panel with interesting data for this interface.
|
||||
* This could for example show last messages sent/received for
|
||||
* a radio interface, or logged message for a log interface.
|
||||
* Returns a panel with interesting data for this interface. This could for
|
||||
* example show last messages sent/received for a radio interface, or logged
|
||||
* message for a log interface.
|
||||
*
|
||||
* All panels returned from this method must later be released
|
||||
* for memory reasons.
|
||||
* All panels returned from this method must later be released for memory
|
||||
* reasons.
|
||||
*
|
||||
* If returned panel is null, this interface will not be visualized.
|
||||
*
|
||||
|
@ -103,32 +108,40 @@ public abstract class MoteInterface extends Observable {
|
|||
|
||||
/**
|
||||
* 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()
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Returns approximated energy consumed (mQ) during the current tick.
|
||||
* If the interface is active, this information must be available after the doActionsAfterTick method.
|
||||
* If the interface is passive, this information must be available after the doActionsBeforeTick method.
|
||||
* Returns approximated energy consumed (mQ) during the current tick. If the
|
||||
* interface is active, this information must be available after the
|
||||
* 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,
|
||||
* and calculate whatever energy it needs in that state and during one tick.
|
||||
* The interface is responsible to gather information about the current
|
||||
* 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
|
||||
* called.
|
||||
*
|
||||
* For example, a radio transmitter or a PIR sensor often has a much higher energy
|
||||
* 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.
|
||||
* 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.
|
||||
* For example, a radio transmitter or a PIR sensor often has a much higher
|
||||
* energy 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. 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
|
||||
* @return Energy consumption of this device during the current tick
|
||||
|
@ -136,13 +149,14 @@ public abstract class MoteInterface extends Observable {
|
|||
public abstract double energyConsumptionPerTick();
|
||||
|
||||
/**
|
||||
* Returns XML elements representing the current config of this mote interface.
|
||||
* This is fetched by the simulator for example when saving a simulation configuration file.
|
||||
* For example an IP interface may return one element with the mote IP address.
|
||||
* This method should however not return state specific information such as a log history.
|
||||
* (All nodes are restarted when loading a simulation.)
|
||||
* Returns XML elements representing the current config of this mote
|
||||
* interface. This is fetched by the simulator for example when saving a
|
||||
* simulation configuration file. For example an IP interface may return one
|
||||
* element with the mote IP address. This method should however not return
|
||||
* 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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MoteInterfaceHandler.java,v 1.1 2006/08/21 12:12:56 fros4943 Exp $
|
||||
* $Id: MoteInterfaceHandler.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
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
|
||||
* 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, for example when visualizing nodes.)
|
||||
* position, for example a typical visualizer.)
|
||||
*
|
||||
* Interfaces are divided into active and passive interfaces. Active interfaces
|
||||
* 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 Battery myBattery;
|
||||
|
||||
private Beeper myBeeper;
|
||||
|
||||
private Button myButton;
|
||||
|
||||
private Clock myClock;
|
||||
|
||||
private IPAddress myIPAddress;
|
||||
|
||||
private LED myLED;
|
||||
|
||||
private Log myLog;
|
||||
|
||||
private MoteID myMoteID;
|
||||
|
||||
private PIR myPIR;
|
||||
|
||||
private Position myPosition;
|
||||
|
||||
private Radio myRadio;
|
||||
|
||||
private Vector<MoteInterface> myActiveInterfaces = 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) {
|
||||
|
||||
Enumeration<? extends MoteInterface> allActive = myActiveInterfaces.elements();
|
||||
Enumeration<? extends MoteInterface> allActive = myActiveInterfaces
|
||||
.elements();
|
||||
while (allActive.hasMoreElements()) {
|
||||
N nextInterface = (N) allActive.nextElement();
|
||||
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
||||
return nextInterface;
|
||||
}
|
||||
Enumeration<? extends MoteInterface> allPassive = myPassiveInterfaces.elements();
|
||||
Enumeration<? extends MoteInterface> allPassive = myPassiveInterfaces
|
||||
.elements();
|
||||
while (allPassive.hasMoreElements()) {
|
||||
N nextInterface = (N) allPassive.nextElement();
|
||||
if (interfaceType.isAssignableFrom(nextInterface.getClass()))
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -41,6 +41,7 @@ package se.sics.cooja;
|
|||
* different memory sections, not covering the entire range
|
||||
* between the start address and the end address of this memory.
|
||||
*
|
||||
* @see se.sics.cooja.SectionMoteMemory
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public interface MoteMemory {
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MoteType.java,v 1.2 2007/01/09 10:16:26 fros4943 Exp $
|
||||
* $Id: MoteType.java,v 1.3 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -37,15 +35,14 @@ import javax.swing.JPanel;
|
|||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Every simulated motes belongs to a mote type.
|
||||
*
|
||||
* The mote type defines properties common for several motes. These properties
|
||||
* may differ between different implementations, but typically includes how a
|
||||
* mote of that type is initialized, which hardware peripherals each mote has
|
||||
* etc.
|
||||
* Every simulated motes must belong to a mote type.
|
||||
*
|
||||
* A mote type may also hold the connection to an underlying simulation
|
||||
* framework.
|
||||
* framework, such as a compiled Contiki system.
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
|
@ -99,7 +96,7 @@ public interface MoteType {
|
|||
* Generates a mote of this mote type.
|
||||
*
|
||||
* @param simulation
|
||||
* Newly created mote's simulation
|
||||
* Simulation that will contain mote
|
||||
* @return New mote
|
||||
*/
|
||||
public Mote generateMote(Simulation simulation);
|
||||
|
@ -116,16 +113,19 @@ public interface MoteType {
|
|||
* Parent frame or null
|
||||
* @param simulation
|
||||
* 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
|
||||
*/
|
||||
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.
|
||||
* This is fetched by the simulator for example when saving a simulation
|
||||
* 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
|
||||
*/
|
||||
public Collection<Element> getConfigXML();
|
||||
|
@ -141,6 +141,8 @@ public interface MoteType {
|
|||
* Simulation that will hold the mote type
|
||||
* @param configXML
|
||||
* Config XML elements
|
||||
* @param visAvailable
|
||||
* True if this method is allowed to show a visualizer
|
||||
* @return True if config was set successfully, false otherwise
|
||||
*/
|
||||
public boolean setConfigXML(Simulation simulation,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -34,19 +34,18 @@ package se.sics.cooja;
|
|||
/**
|
||||
* Mote interfaces are divided into active and passive interfaces.
|
||||
*
|
||||
* A passive mote interface is treated different than an ordinary (active)
|
||||
* mote interface;
|
||||
* Passive interfaces are allowed to act even when the mote is sleeping,
|
||||
* while active interface only acts when the mote is in active state.
|
||||
* A passive mote interface is treated different than an ordinary (active) mote
|
||||
* interface; Passive interfaces are allowed to act even when the mote is
|
||||
* sleeping, while active interface only acts when the mote is in active state.
|
||||
*
|
||||
* A typical active interface is the radio interface, since radio
|
||||
* messages only can be received when the mote is active.
|
||||
* A typical active interface is the radio interface, since radio messages only
|
||||
* can be received when the mote is active.
|
||||
*
|
||||
* A typical passive interface is the battery interface, since a mote
|
||||
* consumes energy even though it is sleeping.
|
||||
* A typical passive interface is the battery interface, since a mote consumes
|
||||
* energy even though it is sleeping.
|
||||
*
|
||||
* All passive interface should implement this interface.
|
||||
* All interfaces not implemented this interface will be handled as active interfaces.
|
||||
* All passive interface should implement this interface. All interfaces not
|
||||
* implemented this interface will be handled as active interfaces.
|
||||
*
|
||||
* Any energy required by this interface must be available after the
|
||||
* doActionsBeforeTick method.
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -149,12 +149,12 @@ public class PlatformConfig {
|
|||
* instead.
|
||||
*
|
||||
* @param callingClass
|
||||
* Class which value belongs to
|
||||
* Class which value belong to
|
||||
* @param key
|
||||
* Key
|
||||
* @param value
|
||||
* Element of array
|
||||
* @return User platform
|
||||
* @param arrayElement
|
||||
* Value or array element
|
||||
* @return User platform defining arguments or null
|
||||
*/
|
||||
public File getUserPlatformDefining(Class callingClass, String key, String arrayElement) {
|
||||
|
||||
|
|
|
@ -26,19 +26,19 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
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.
|
||||
*
|
||||
* @see se.sics.cooja.VisPlugin
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public interface Plugin {
|
||||
|
@ -67,7 +67,6 @@ public interface Plugin {
|
|||
*/
|
||||
public Object getTag();
|
||||
|
||||
|
||||
/**
|
||||
* Returns XML elements representing the current config of this plugin. This
|
||||
* is fetched by the simulator for example when saving a simulation
|
||||
|
@ -76,7 +75,7 @@ public interface Plugin {
|
|||
* such as the value of a mote LED, or total number of motes. (All nodes are
|
||||
* restarted when loading a simulation.)
|
||||
*
|
||||
* @see #setConfigXML(Collection)
|
||||
* @see #setConfigXML(Collection, boolean)
|
||||
* @return XML elements representing the current radio medium config
|
||||
*/
|
||||
public Collection<Element> getConfigXML();
|
||||
|
@ -89,6 +88,7 @@ public interface Plugin {
|
|||
* Config XML elements
|
||||
* @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.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: PluginType.java,v 1.1 2007/01/09 10:15:26 fros4943 Exp $
|
||||
* $Id: PluginType.java,v 1.2 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -35,7 +33,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Annotation type to describe a plugin type.
|
||||
* Annotation type to identify a plugin type.
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
|
@ -48,18 +46,17 @@ public @interface PluginType {
|
|||
*
|
||||
* A mote plugin concerns one specific mote.
|
||||
*
|
||||
* An example of such a plugin may be to display
|
||||
* some mote information in a frame.
|
||||
* An example of such a plugin may be to display some mote information in a
|
||||
* frame.
|
||||
*
|
||||
* Mote plugins can not be instantiated from the
|
||||
* regular menu bar, but are instead started from
|
||||
* other plugins, for example a visualizer that let's
|
||||
* a user select a mote.
|
||||
* Mote plugins can not be instantiated from the regular menu bar, but are
|
||||
* instead started from other plugins, for example a visualizer that let's a
|
||||
* user select a mote.
|
||||
*
|
||||
* When constructed, a mote plugin is given a Mote.
|
||||
* When constructed, a mote plugin is given a mote, the current active
|
||||
* simulation and the GUI object.
|
||||
*
|
||||
* If the current simulation is removed, so are
|
||||
* all instances of this plugin.
|
||||
* If the current simulation is removed, so are all instances of this plugin.
|
||||
*/
|
||||
public static final int MOTE_PLUGIN = 1;
|
||||
|
||||
|
@ -68,26 +65,25 @@ public @interface PluginType {
|
|||
*
|
||||
* A simulation plugin concerns one specific simulation.
|
||||
*
|
||||
* An example of such a plugin may be to display
|
||||
* number of motes and current simulation time in a window.
|
||||
* An example of such a plugin may be to display number of motes and current
|
||||
* simulation time in a window.
|
||||
*
|
||||
* Simulation plugins are available via the plugins menubar.
|
||||
*
|
||||
* When constructed, a simulation plugin is given the current
|
||||
* active simulation.
|
||||
* When constructed, a simulation plugin is given the current active
|
||||
* simulation and the GUI object.
|
||||
*
|
||||
* If the current simulation is removed, so are
|
||||
* all instances of this plugin.
|
||||
* If the current simulation is removed, so are all instances of this plugin.
|
||||
*/
|
||||
public static final int SIM_PLUGIN = 2;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* where a user can control the current simulation.
|
||||
* An example of such a plugin may be a control panel where a user can save
|
||||
* and load different simulations.
|
||||
*
|
||||
* COOJA plugins are available via the plugins menubar.
|
||||
*
|
||||
|
@ -98,22 +94,22 @@ public @interface PluginType {
|
|||
/**
|
||||
* Simulation Standard Plugin
|
||||
*
|
||||
* This is treated exactly like a Simulation Plugin, with the
|
||||
* only difference that this will automatically be opened
|
||||
* when a new simulation is created.
|
||||
* This is treated exactly like a Simulation Plugin, with the only difference
|
||||
* that this will automatically be opened when a new simulation is created.
|
||||
*
|
||||
* @see #SIM_PLUGIN
|
||||
*/
|
||||
public static final int SIM_STANDARD_PLUGIN = 4;
|
||||
|
||||
|
||||
/**
|
||||
* COOJA Standard Plugin
|
||||
*
|
||||
* This is treated exactly like a COOJA Plugin, with the
|
||||
* only difference that this will automatically be opened
|
||||
* when the simulator is started.
|
||||
* This is treated exactly like a COOJA Plugin, with the only difference that
|
||||
* this will automatically be opened when the simulator is started.
|
||||
*
|
||||
* @see #COOJA_PLUGIN
|
||||
*/
|
||||
public static final int COOJA_STANDARD_PLUGIN = 5;
|
||||
|
||||
int value();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
|
|
@ -26,25 +26,24 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collection;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import org.apache.log4j.Logger;
|
||||
import java.util.*;
|
||||
import org.jdom.Element;
|
||||
|
||||
import se.sics.cooja.interfaces.Position;
|
||||
import se.sics.cooja.interfaces.Radio;
|
||||
|
||||
/**
|
||||
* This interface represents a radio medium. Radios registered to this medium
|
||||
* can both send and receive radio data. Depending on the implementation of this
|
||||
* interface, more or less accurate radio behaviour imitation is aquired.
|
||||
* The abstract class RadioMedium should be implemented by all COOJA radio
|
||||
* mediums. Radios registered in this medium can both send and receive radio
|
||||
* 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
|
||||
* plugins. These plugins shows the user some radio medium specific details,
|
||||
|
@ -53,7 +52,6 @@ import se.sics.cooja.interfaces.Radio;
|
|||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public abstract class RadioMedium {
|
||||
private static Logger logger = Logger.getLogger(RadioMedium.class);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* loading a simulation.)
|
||||
*
|
||||
* @see #setConfigXML(Collection)
|
||||
* @see #setConfigXML(Collection, boolean)
|
||||
* @return XML elements representing the current radio medium config
|
||||
*/
|
||||
public abstract Collection<Element> getConfigXML();
|
||||
|
@ -182,7 +180,6 @@ public abstract class RadioMedium {
|
|||
*/
|
||||
public abstract boolean setConfigXML(Collection<Element> configXML, boolean visAvailable);
|
||||
|
||||
|
||||
/**
|
||||
* This method creates an instance of the given class with the given
|
||||
* simulation constructor argument. Instead of calling the constructors
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: SectionMoteMemory.java,v 1.3 2006/12/15 11:47:40 fros4943 Exp $
|
||||
* $Id: SectionMoteMemory.java,v 1.4 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -39,8 +37,8 @@ import org.apache.log4j.Logger;
|
|||
import se.sics.cooja.MoteMemory;
|
||||
|
||||
/**
|
||||
* Represents a mote memory consisting of non-overlapping memory sections. This
|
||||
* memory also contains information about variable starts addresses.
|
||||
* Represents a mote memory consisting of non-overlapping memory sections with
|
||||
* variables' memory addresses.
|
||||
* <p>
|
||||
* When an unhandled memory segment is set a new section is automatically
|
||||
* created for this segment.
|
||||
|
@ -52,6 +50,7 @@ public class SectionMoteMemory implements MoteMemory {
|
|||
private static Logger logger = Logger.getLogger(SectionMoteMemory.class);
|
||||
|
||||
private Vector<MoteMemorySection> sections = new Vector<MoteMemorySection>();
|
||||
|
||||
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
|
||||
*/
|
||||
public int getVariableAddress(String varName) {
|
||||
|
@ -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
|
||||
*/
|
||||
private class MoteMemorySection {
|
||||
private byte[] data = null;
|
||||
|
||||
private int startAddr;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,37 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: Simulation.java,v 1.8 2007/01/10 09:02:38 fros4943 Exp $
|
||||
* $Id: Simulation.java,v 1.9 2007/01/10 14:57:42 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.*;
|
||||
|
@ -39,13 +36,15 @@ import org.jdom.*;
|
|||
import se.sics.cooja.dialogs.*;
|
||||
|
||||
/**
|
||||
* A simulation contains motes and ticks them one by one. When all motes has
|
||||
* been ticked once, the simulation sleeps for some specified time, and the
|
||||
* current simulation time is updated. Some observers (tick observers) are also
|
||||
* notified.
|
||||
* A simulation consists of a number of motes and mote types.
|
||||
*
|
||||
* The motes in the simulation are ticked one by one in a simulation loop. When
|
||||
* 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
|
||||
* 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
|
||||
* interfaces.
|
||||
*
|
||||
|
@ -54,20 +53,25 @@ import se.sics.cooja.dialogs.*;
|
|||
public class Simulation extends Observable implements Runnable {
|
||||
|
||||
private Vector<Mote> motes = new Vector<Mote>();
|
||||
|
||||
private Vector<MoteType> moteTypes = new Vector<MoteType>();
|
||||
|
||||
private int delayTime = 100;
|
||||
|
||||
private int currentSimulationTime = 0;
|
||||
|
||||
private int tickTime = 1;
|
||||
|
||||
private String title = null;
|
||||
|
||||
// Radio Medium
|
||||
private RadioMedium currentRadioMedium = null;
|
||||
|
||||
private static Logger logger = Logger.getLogger(Simulation.class);
|
||||
|
||||
private boolean isRunning = false;
|
||||
|
||||
private boolean stopSimulation = false;
|
||||
|
||||
private Thread thread = null;
|
||||
|
||||
private GUI myGUI = null;
|
||||
|
@ -79,6 +83,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
notifyObservers();
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
// New simulation instance
|
||||
myGUI = gui;
|
||||
}
|
||||
|
||||
|
@ -202,12 +206,11 @@ public class Simulation extends Observable implements Runnable {
|
|||
} 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.
|
||||
*/
|
||||
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
|
||||
* config also includes the current radio medium, all mote types and motes.
|
||||
*
|
||||
* @see #saveSimulationConfig(File file)
|
||||
* @return Current simulation config
|
||||
*/
|
||||
public Collection<Element> getConfigXML() {
|
||||
|
@ -294,21 +303,21 @@ public class Simulation extends Observable implements Runnable {
|
|||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GUI holding this simulation
|
||||
*/
|
||||
public GUI getGUI() {
|
||||
return myGUI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current simulation config depending on the given XML elements.
|
||||
*
|
||||
* @see #getConfigXML()
|
||||
* @param configXML
|
||||
* 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
|
||||
for (Element element : configXML) {
|
||||
|
@ -336,13 +345,14 @@ public class Simulation extends Observable implements Runnable {
|
|||
// Radio medium
|
||||
if (element.getName().equals("radiomedium")) {
|
||||
String radioMediumClassName = element.getText().trim();
|
||||
Class<? extends RadioMedium> radioMediumClass = myGUI
|
||||
.tryLoadClass(this, RadioMedium.class, radioMediumClassName);
|
||||
Class<? extends RadioMedium> radioMediumClass = myGUI.tryLoadClass(
|
||||
this, RadioMedium.class, radioMediumClassName);
|
||||
|
||||
if (radioMediumClass != null) {
|
||||
// Create radio medium specified in config
|
||||
try {
|
||||
currentRadioMedium = RadioMedium.generateRadioMedium(radioMediumClass, this);
|
||||
currentRadioMedium = RadioMedium.generateRadioMedium(
|
||||
radioMediumClass, this);
|
||||
} catch (Exception e) {
|
||||
currentRadioMedium = null;
|
||||
logger.warn("Could not load radio medium class: "
|
||||
|
@ -377,8 +387,8 @@ public class Simulation extends Observable implements Runnable {
|
|||
if (element.getName().equals("motetype")) {
|
||||
String moteTypeClassName = element.getText().trim();
|
||||
|
||||
Class<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(
|
||||
this, MoteType.class, moteTypeClassName);
|
||||
Class<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(this,
|
||||
MoteType.class, moteTypeClassName);
|
||||
|
||||
if (moteTypeClass == null) {
|
||||
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)
|
||||
.newInstance();
|
||||
|
||||
boolean createdOK = moteType.setConfigXML(this, element.getChildren(), visAvailable);
|
||||
boolean createdOK = moteType.setConfigXML(this, element.getChildren(),
|
||||
visAvailable);
|
||||
if (createdOK) {
|
||||
addMoteType(moteType);
|
||||
} else {
|
||||
|
@ -400,8 +411,8 @@ public class Simulation extends Observable implements Runnable {
|
|||
|
||||
// Mote
|
||||
if (element.getName().equals("mote")) {
|
||||
Class<? extends Mote> moteClass = myGUI.tryLoadClass(this,
|
||||
Mote.class, element.getText().trim());
|
||||
Class<? extends Mote> moteClass = myGUI.tryLoadClass(this, Mote.class,
|
||||
element.getText().trim());
|
||||
|
||||
Mote mote = moteClass.getConstructor((Class[]) null).newInstance();
|
||||
if (mote.setConfigXML(this, element.getChildren(), visAvailable)) {
|
||||
|
@ -460,7 +471,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
* Get a mote from this simulation.
|
||||
*
|
||||
* @param pos
|
||||
* Position of mote
|
||||
* Internal list position of mote
|
||||
* @return Mote
|
||||
*/
|
||||
public Mote getMote(int pos) {
|
||||
|
@ -503,7 +514,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
/**
|
||||
* Adds given mote type to simulation.
|
||||
*
|
||||
* @param newMoteType
|
||||
* @param newMoteType Mote type
|
||||
*/
|
||||
public void addMoteType(MoteType newMoteType) {
|
||||
moteTypes.add(newMoteType);
|
||||
|
@ -593,7 +604,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
}
|
||||
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++)
|
||||
currentRadioMedium.registerMote(motes.get(i), this);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* 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;
|
||||
|
@ -38,13 +38,14 @@ import javax.swing.event.InternalFrameListener;
|
|||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* Abstract class VisPlugin should be implemented by plugins for COOJA Simulator.
|
||||
* By extending JInternalFrame, the visual apperence is decided by the plugin itself.
|
||||
* Abstract class VisPlugin should be implemented by all plugins with
|
||||
* 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
|
||||
*/
|
||||
|
@ -104,5 +105,4 @@ public abstract class VisPlugin extends JInternalFrame implements Plugin {
|
|||
return tag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue