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
11 changed files with 16 additions and 42 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue