Added simulation as argument to moteType.getConfigXML() instead of each MoteType storing a reference to the simulation.
This commit is contained in:
parent
3da733ac55
commit
bea1b8d3a1
|
@ -37,8 +37,6 @@ import java.awt.Dimension;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
|
@ -46,10 +44,8 @@ import javax.swing.Icon;
|
|||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
||||
import se.sics.cooja.AbstractionLevelDescription;
|
||||
import se.sics.cooja.ClassDescription;
|
||||
import se.sics.cooja.GUI;
|
||||
|
@ -83,8 +79,6 @@ public class MicaZMoteType implements MoteType {
|
|||
private String identifier = null;
|
||||
private String description = null;
|
||||
|
||||
protected Simulation simulation;
|
||||
|
||||
/* If source file is defined, the firmware is recompiled when loading simulations */
|
||||
private File fileFirmware = null;
|
||||
private File fileSource = null;
|
||||
|
@ -227,8 +221,8 @@ public class MicaZMoteType implements MoteType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
Vector<Element> config = new Vector<Element>();
|
||||
public Collection<Element> getConfigXML(Simulation simulation) {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
|
||||
Element element;
|
||||
|
||||
|
@ -260,7 +254,7 @@ public class MicaZMoteType implements MoteType {
|
|||
config.add(element);
|
||||
|
||||
// Mote interfaces
|
||||
for (Class moteInterface : getMoteInterfaceClasses()) {
|
||||
for (Class<? extends MoteInterface> moteInterface : getMoteInterfaceClasses()) {
|
||||
element = new Element("moteinterface");
|
||||
element.setText(moteInterface.getName());
|
||||
config.add(element);
|
||||
|
@ -272,7 +266,6 @@ public class MicaZMoteType implements MoteType {
|
|||
public boolean setConfigXML(Simulation simulation,
|
||||
Collection<Element> configXML, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
ArrayList<Class<? extends MoteInterface>> intfClassList = new ArrayList<Class<? extends MoteInterface>>();
|
||||
for (Element element : configXML) {
|
||||
|
@ -325,7 +318,6 @@ public class MicaZMoteType implements MoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* If visualized, show compile dialog and let user configure */
|
||||
if (visAvailable) {
|
||||
|
|
|
@ -82,7 +82,6 @@ public class ESBMoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* SPECIAL CASE: Cooja started in applet.
|
||||
* Use preconfigured Contiki firmware */
|
||||
|
|
|
@ -73,7 +73,6 @@ public class Exp5438MoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* If visualized, show compile dialog and let user configure */
|
||||
if (visAvailable) {
|
||||
|
|
|
@ -39,8 +39,6 @@ import java.net.URL;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
|
@ -48,10 +46,8 @@ import javax.swing.Icon;
|
|||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
||||
import se.sics.cooja.ClassDescription;
|
||||
import se.sics.cooja.GUI;
|
||||
import se.sics.cooja.Mote;
|
||||
|
@ -80,8 +76,6 @@ public abstract class MspMoteType implements MoteType {
|
|||
private String identifier = null;
|
||||
private String description = null;
|
||||
|
||||
protected Simulation simulation;
|
||||
|
||||
/* If source file is defined, the firmware is recompiled when loading simulations */
|
||||
private File fileSource = null;
|
||||
private String compileCommands = null;
|
||||
|
@ -223,8 +217,8 @@ public abstract class MspMoteType implements MoteType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
Vector<Element> config = new Vector<Element>();
|
||||
public Collection<Element> getConfigXML(Simulation simulation) {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
|
||||
Element element;
|
||||
|
||||
|
@ -259,7 +253,7 @@ public abstract class MspMoteType implements MoteType {
|
|||
config.add(element);
|
||||
|
||||
// Mote interfaces
|
||||
for (Class moteInterface : getMoteInterfaceClasses()) {
|
||||
for (Class<? extends MoteInterface> moteInterface : getMoteInterfaceClasses()) {
|
||||
element = new Element("moteinterface");
|
||||
element.setText(moteInterface.getName());
|
||||
config.add(element);
|
||||
|
@ -271,7 +265,6 @@ public abstract class MspMoteType implements MoteType {
|
|||
public boolean setConfigXML(Simulation simulation,
|
||||
Collection<Element> configXML, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
ArrayList<Class<? extends MoteInterface>> intfClassList = new ArrayList<Class<? extends MoteInterface>>();
|
||||
for (Element element : configXML) {
|
||||
|
|
|
@ -80,7 +80,6 @@ public class SkyMoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* SPECIAL CASE: Cooja started in applet.
|
||||
* Use preconfigured Contiki firmware */
|
||||
|
|
|
@ -73,7 +73,6 @@ public class TyndallMoteType extends MspMoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
|
||||
throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
|
||||
/* If visualized, show compile dialog and let user configure */
|
||||
if (visAvailable) {
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
* 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.10 2009/03/10 21:05:00 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -191,9 +189,11 @@ public interface MoteType {
|
|||
* configuration file. For example a Contiki base directory may be saved.
|
||||
*
|
||||
* @see #setConfigXML(Simulation, Collection, boolean)
|
||||
* @param simulation
|
||||
* Current simulation
|
||||
* @return XML elements representing the current mote type's config
|
||||
*/
|
||||
public Collection<Element> getConfigXML();
|
||||
public Collection<Element> getConfigXML(Simulation simulation);
|
||||
|
||||
/**
|
||||
* Sets the current mote type config depending on the given XML elements.
|
||||
|
|
|
@ -512,7 +512,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
element = new Element("motetype");
|
||||
element.setText(moteType.getClass().getName());
|
||||
|
||||
Collection<Element> moteTypeXML = moteType.getConfigXML();
|
||||
Collection<Element> moteTypeXML = moteType.getConfigXML(this);
|
||||
if (moteTypeXML != null) {
|
||||
element.addContent(moteTypeXML);
|
||||
}
|
||||
|
|
|
@ -50,15 +50,12 @@ import java.util.Random;
|
|||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
||||
import se.sics.cooja.AbstractionLevelDescription;
|
||||
import se.sics.cooja.ClassDescription;
|
||||
import se.sics.cooja.CoreComm;
|
||||
|
@ -194,8 +191,6 @@ public class ContikiMoteType implements MoteType {
|
|||
|
||||
private NetworkStack netStack = NetworkStack.DEFAULT;
|
||||
|
||||
private Simulation simulation = null;
|
||||
|
||||
// Type specific class configuration
|
||||
private ProjectConfig myConfig = null;
|
||||
|
||||
|
@ -217,7 +212,6 @@ public class ContikiMoteType implements MoteType {
|
|||
|
||||
public boolean configureAndInit(Container parentContainer, Simulation simulation,
|
||||
boolean visAvailable) throws MoteTypeCreationException {
|
||||
this.simulation = simulation;
|
||||
myConfig = simulation.getGUI().getProjectConfig().clone();
|
||||
|
||||
if (visAvailable) {
|
||||
|
@ -1270,7 +1264,7 @@ public class ContikiMoteType implements MoteType {
|
|||
smallPane.add(BorderLayout.WEST, label);
|
||||
panel.add(smallPane);
|
||||
|
||||
for (Class intf : moteInterfacesClasses) {
|
||||
for (Class<? extends MoteInterface> intf : moteInterfacesClasses) {
|
||||
smallPane = new JPanel(new BorderLayout());
|
||||
label = new JLabel(intf.getSimpleName());
|
||||
smallPane.add(BorderLayout.EAST, label);
|
||||
|
@ -1294,8 +1288,8 @@ public class ContikiMoteType implements MoteType {
|
|||
return panel;
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
Vector<Element> config = new Vector<Element>();
|
||||
public Collection<Element> getConfigXML(Simulation simulation) {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
Element element;
|
||||
|
||||
element = new Element("identifier");
|
||||
|
@ -1341,7 +1335,6 @@ public class ContikiMoteType implements MoteType {
|
|||
File oldVersionSource = null;
|
||||
|
||||
moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>();
|
||||
this.simulation = simulation;
|
||||
|
||||
for (Element element : configXML) {
|
||||
String name = element.getName();
|
||||
|
|
|
@ -208,7 +208,7 @@ public abstract class AbstractApplicationMoteType implements MoteType {
|
|||
return myConfig;
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
public Collection<Element> getConfigXML(Simulation simulation) {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
Element element;
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ public class ImportAppMoteType extends AbstractApplicationMoteType {
|
|||
setDescription("Imported App Mote Type #" + identifier);
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
Collection<Element> config = super.getConfigXML();
|
||||
public Collection<Element> getConfigXML(Simulation simulation) {
|
||||
Collection<Element> config = super.getConfigXML(simulation);
|
||||
|
||||
if (moteClassPath != null) {
|
||||
Element element = new Element("motepath");
|
||||
|
|
Loading…
Reference in a new issue