Skip to content

Commit bea1b8d

Browse files
committed
Added simulation as argument to moteType.getConfigXML() instead of each MoteType storing a reference to the simulation.
1 parent 3da733a commit bea1b8d

File tree

11 files changed

+16
-42
lines changed

11 files changed

+16
-42
lines changed

tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMoteType.java

+3-11
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,15 @@
3737
import java.io.File;
3838
import java.util.ArrayList;
3939
import java.util.Collection;
40-
import java.util.Vector;
41-
4240
import javax.swing.BorderFactory;
4341
import javax.swing.Box;
4442
import javax.swing.BoxLayout;
4543
import javax.swing.Icon;
4644
import javax.swing.JLabel;
4745
import javax.swing.JPanel;
4846
import javax.swing.JTextArea;
49-
5047
import org.apache.log4j.Logger;
5148
import org.jdom.Element;
52-
5349
import se.sics.cooja.AbstractionLevelDescription;
5450
import se.sics.cooja.ClassDescription;
5551
import se.sics.cooja.GUI;
@@ -83,8 +79,6 @@ public class MicaZMoteType implements MoteType {
8379
private String identifier = null;
8480
private String description = null;
8581

86-
protected Simulation simulation;
87-
8882
/* If source file is defined, the firmware is recompiled when loading simulations */
8983
private File fileFirmware = null;
9084
private File fileSource = null;
@@ -227,8 +221,8 @@ public ProjectConfig getConfig() {
227221
return null;
228222
}
229223

230-
public Collection<Element> getConfigXML() {
231-
Vector<Element> config = new Vector<Element>();
224+
public Collection<Element> getConfigXML(Simulation simulation) {
225+
ArrayList<Element> config = new ArrayList<Element>();
232226

233227
Element element;
234228

@@ -260,7 +254,7 @@ public Collection<Element> getConfigXML() {
260254
config.add(element);
261255

262256
// Mote interfaces
263-
for (Class moteInterface : getMoteInterfaceClasses()) {
257+
for (Class<? extends MoteInterface> moteInterface : getMoteInterfaceClasses()) {
264258
element = new Element("moteinterface");
265259
element.setText(moteInterface.getName());
266260
config.add(element);
@@ -272,7 +266,6 @@ public Collection<Element> getConfigXML() {
272266
public boolean setConfigXML(Simulation simulation,
273267
Collection<Element> configXML, boolean visAvailable)
274268
throws MoteTypeCreationException {
275-
this.simulation = simulation;
276269

277270
ArrayList<Class<? extends MoteInterface>> intfClassList = new ArrayList<Class<? extends MoteInterface>>();
278271
for (Element element : configXML) {
@@ -325,7 +318,6 @@ public boolean setConfigXML(Simulation simulation,
325318

326319
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
327320
throws MoteTypeCreationException {
328-
this.simulation = simulation;
329321

330322
/* If visualized, show compile dialog and let user configure */
331323
if (visAvailable) {

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ protected MspMote createMote(Simulation simulation) {
8282

8383
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
8484
throws MoteTypeCreationException {
85-
this.simulation = simulation;
8685

8786
/* SPECIAL CASE: Cooja started in applet.
8887
* Use preconfigured Contiki firmware */

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Exp5438MoteType.java

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected MspMote createMote(Simulation simulation) {
7373

7474
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
7575
throws MoteTypeCreationException {
76-
this.simulation = simulation;
7776

7877
/* If visualized, show compile dialog and let user configure */
7978
if (visAvailable) {

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,15 @@
3939
import java.util.ArrayList;
4040
import java.util.Collection;
4141
import java.util.Hashtable;
42-
import java.util.Vector;
43-
4442
import javax.swing.BorderFactory;
4543
import javax.swing.Box;
4644
import javax.swing.BoxLayout;
4745
import javax.swing.Icon;
4846
import javax.swing.JLabel;
4947
import javax.swing.JPanel;
5048
import javax.swing.JTextArea;
51-
5249
import org.apache.log4j.Logger;
5350
import org.jdom.Element;
54-
5551
import se.sics.cooja.ClassDescription;
5652
import se.sics.cooja.GUI;
5753
import se.sics.cooja.Mote;
@@ -80,8 +76,6 @@ public abstract class MspMoteType implements MoteType {
8076
private String identifier = null;
8177
private String description = null;
8278

83-
protected Simulation simulation;
84-
8579
/* If source file is defined, the firmware is recompiled when loading simulations */
8680
private File fileSource = null;
8781
private String compileCommands = null;
@@ -223,8 +217,8 @@ public ProjectConfig getConfig() {
223217
return null;
224218
}
225219

226-
public Collection<Element> getConfigXML() {
227-
Vector<Element> config = new Vector<Element>();
220+
public Collection<Element> getConfigXML(Simulation simulation) {
221+
ArrayList<Element> config = new ArrayList<Element>();
228222

229223
Element element;
230224

@@ -259,7 +253,7 @@ public Collection<Element> getConfigXML() {
259253
config.add(element);
260254

261255
// Mote interfaces
262-
for (Class moteInterface : getMoteInterfaceClasses()) {
256+
for (Class<? extends MoteInterface> moteInterface : getMoteInterfaceClasses()) {
263257
element = new Element("moteinterface");
264258
element.setText(moteInterface.getName());
265259
config.add(element);
@@ -271,7 +265,6 @@ public Collection<Element> getConfigXML() {
271265
public boolean setConfigXML(Simulation simulation,
272266
Collection<Element> configXML, boolean visAvailable)
273267
throws MoteTypeCreationException {
274-
this.simulation = simulation;
275268

276269
ArrayList<Class<? extends MoteInterface>> intfClassList = new ArrayList<Class<? extends MoteInterface>>();
277270
for (Element element : configXML) {

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ protected MspMote createMote(Simulation simulation) {
8080

8181
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
8282
throws MoteTypeCreationException {
83-
this.simulation = simulation;
8483

8584
/* SPECIAL CASE: Cooja started in applet.
8685
* Use preconfigured Contiki firmware */

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/TyndallMoteType.java

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected MspMote createMote(Simulation simulation) {
7373

7474
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable)
7575
throws MoteTypeCreationException {
76-
this.simulation = simulation;
7776

7877
/* If visualized, show compile dialog and let user configure */
7978
if (visAvailable) {

tools/cooja/java/se/sics/cooja/MoteType.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2424
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2525
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26-
*
27-
* $Id: MoteType.java,v 1.10 2009/03/10 21:05:00 fros4943 Exp $
2826
*/
2927

3028
package se.sics.cooja;
@@ -191,9 +189,11 @@ public boolean configureAndInit(Container parentContainer, Simulation simulation
191189
* configuration file. For example a Contiki base directory may be saved.
192190
*
193191
* @see #setConfigXML(Simulation, Collection, boolean)
192+
* @param simulation
193+
* Current simulation
194194
* @return XML elements representing the current mote type's config
195195
*/
196-
public Collection<Element> getConfigXML();
196+
public Collection<Element> getConfigXML(Simulation simulation);
197197

198198
/**
199199
* Sets the current mote type config depending on the given XML elements.

tools/cooja/java/se/sics/cooja/Simulation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public Collection<Element> getConfigXML() {
512512
element = new Element("motetype");
513513
element.setText(moteType.getClass().getName());
514514

515-
Collection<Element> moteTypeXML = moteType.getConfigXML();
515+
Collection<Element> moteTypeXML = moteType.getConfigXML(this);
516516
if (moteTypeXML != null) {
517517
element.addContent(moteTypeXML);
518518
}

tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@
5050
import java.util.Vector;
5151
import java.util.regex.Matcher;
5252
import java.util.regex.Pattern;
53-
5453
import javax.swing.Box;
5554
import javax.swing.BoxLayout;
5655
import javax.swing.JLabel;
5756
import javax.swing.JPanel;
58-
5957
import org.apache.log4j.Logger;
6058
import org.jdom.Element;
61-
6259
import se.sics.cooja.AbstractionLevelDescription;
6360
import se.sics.cooja.ClassDescription;
6461
import se.sics.cooja.CoreComm;
@@ -194,8 +191,6 @@ public static NetworkStack parseConfig(String config) {
194191

195192
private NetworkStack netStack = NetworkStack.DEFAULT;
196193

197-
private Simulation simulation = null;
198-
199194
// Type specific class configuration
200195
private ProjectConfig myConfig = null;
201196

@@ -217,7 +212,6 @@ public Mote generateMote(Simulation simulation) {
217212

218213
public boolean configureAndInit(Container parentContainer, Simulation simulation,
219214
boolean visAvailable) throws MoteTypeCreationException {
220-
this.simulation = simulation;
221215
myConfig = simulation.getGUI().getProjectConfig().clone();
222216

223217
if (visAvailable) {
@@ -1270,7 +1264,7 @@ public JPanel getTypeVisualizer() {
12701264
smallPane.add(BorderLayout.WEST, label);
12711265
panel.add(smallPane);
12721266

1273-
for (Class intf : moteInterfacesClasses) {
1267+
for (Class<? extends MoteInterface> intf : moteInterfacesClasses) {
12741268
smallPane = new JPanel(new BorderLayout());
12751269
label = new JLabel(intf.getSimpleName());
12761270
smallPane.add(BorderLayout.EAST, label);
@@ -1294,8 +1288,8 @@ public JPanel getTypeVisualizer() {
12941288
return panel;
12951289
}
12961290

1297-
public Collection<Element> getConfigXML() {
1298-
Vector<Element> config = new Vector<Element>();
1291+
public Collection<Element> getConfigXML(Simulation simulation) {
1292+
ArrayList<Element> config = new ArrayList<Element>();
12991293
Element element;
13001294

13011295
element = new Element("identifier");
@@ -1341,7 +1335,6 @@ public boolean setConfigXML(Simulation simulation,
13411335
File oldVersionSource = null;
13421336

13431337
moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>();
1344-
this.simulation = simulation;
13451338

13461339
for (Element element : configXML) {
13471340
String name = element.getName();

tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMoteType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public ProjectConfig getConfig() {
208208
return myConfig;
209209
}
210210

211-
public Collection<Element> getConfigXML() {
211+
public Collection<Element> getConfigXML(Simulation simulation) {
212212
ArrayList<Element> config = new ArrayList<Element>();
213213
Element element;
214214

tools/cooja/java/se/sics/cooja/motes/ImportAppMoteType.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public ImportAppMoteType(String identifier) {
7272
setDescription("Imported App Mote Type #" + identifier);
7373
}
7474

75-
public Collection<Element> getConfigXML() {
76-
Collection<Element> config = super.getConfigXML();
75+
public Collection<Element> getConfigXML(Simulation simulation) {
76+
Collection<Element> config = super.getConfigXML(simulation);
7777

7878
if (moteClassPath != null) {
7979
Element element = new Element("motepath");

0 commit comments

Comments
 (0)