removed use of temporary (simulation-specific) plugins, instead plugins should be unregistered when no longer needed + added method called when radio medium is removed from simulation
This commit is contained in:
parent
30885ba4ce
commit
9a3c7ae650
4 changed files with 40 additions and 11 deletions
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MRM.java,v 1.11 2009/11/25 15:43:03 fros4943 Exp $
|
||||
* $Id: MRM.java,v 1.12 2010/12/02 15:25:50 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.mrm;
|
||||
|
@ -72,6 +72,7 @@ public class MRM extends AbstractRadioMedium {
|
|||
|
||||
private Random random = null;
|
||||
|
||||
private Simulation sim;
|
||||
/**
|
||||
* Notifies observers when this radio medium has changed settings.
|
||||
*/
|
||||
|
@ -82,16 +83,26 @@ public class MRM extends AbstractRadioMedium {
|
|||
*/
|
||||
public MRM(Simulation simulation) {
|
||||
super(simulation);
|
||||
sim = simulation;
|
||||
|
||||
random = simulation.getRandomGenerator();
|
||||
|
||||
// Create the channel model
|
||||
currentChannelModel = new ChannelModel();
|
||||
|
||||
// Register temporary plugins
|
||||
simulation.getGUI().registerTemporaryPlugin(AreaViewer.class);
|
||||
simulation.getGUI().registerTemporaryPlugin(FormulaViewer.class);
|
||||
/* Register plugins */
|
||||
sim.getGUI().registerPlugin(AreaViewer.class);
|
||||
sim.getGUI().registerPlugin(FormulaViewer.class);
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
super.removed();
|
||||
|
||||
/* Unregister plugins */
|
||||
sim.getGUI().unregisterPlugin(AreaViewer.class);
|
||||
sim.getGUI().unregisterPlugin(FormulaViewer.class);
|
||||
}
|
||||
|
||||
public MRMRadioConnection createConnections(Radio sendingRadio) {
|
||||
Position sendingPosition = sendingRadio.getPosition();
|
||||
MRMRadioConnection newConnection = new MRMRadioConnection(sendingRadio);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: RadioMedium.java,v 1.9 2010/02/03 15:49:25 fros4943 Exp $
|
||||
* $Id: RadioMedium.java,v 1.10 2010/12/02 15:25:50 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -165,4 +165,10 @@ public abstract class RadioMedium {
|
|||
.getConstructor(new Class[] { Simulation.class });
|
||||
return (RadioMedium) constr.newInstance(new Object[] { simulation });
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when radio medium is removed.
|
||||
*/
|
||||
public void removed() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* (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.67 2010/10/12 10:58:31 fros4943 Exp $
|
||||
* $Id: Simulation.java,v 1.68 2010/12/02 15:25:49 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -732,6 +732,11 @@ public class Simulation extends Observable implements Runnable {
|
|||
* This method is called just before the simulation is removed.
|
||||
*/
|
||||
public void removed() {
|
||||
/* Remove radio medium */
|
||||
if (currentRadioMedium != null) {
|
||||
currentRadioMedium.removed();
|
||||
}
|
||||
|
||||
/* Remove all motes */
|
||||
Mote[] motes = getMotes();
|
||||
for (Mote m: motes) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: DirectedGraphMedium.java,v 1.7 2010/11/10 13:09:01 fros4943 Exp $
|
||||
* $Id: DirectedGraphMedium.java,v 1.8 2010/12/02 15:25:50 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.radiomediums;
|
||||
|
@ -88,12 +88,19 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
|||
|
||||
requestEdgeAnalysis();
|
||||
|
||||
/* Register plugin.
|
||||
* TODO Should be unregistered when radio medium is removed */
|
||||
simulation.getGUI().registerTemporaryPlugin(DGRMConfigurator.class);
|
||||
/* Register plugin and visualizer skin */
|
||||
simulation.getGUI().registerPlugin(DGRMConfigurator.class);
|
||||
Visualizer.registerVisualizerSkin(DGRMVisualizerSkin.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
super.removed();
|
||||
|
||||
/* Unregister plugin and visualizer skin */
|
||||
simulation.getGUI().unregisterPlugin(DGRMConfigurator.class);
|
||||
Visualizer.unregisterVisualizerSkin(DGRMVisualizerSkin.class);
|
||||
}
|
||||
|
||||
public void addEdge(Edge e) {
|
||||
edges.add(e);
|
||||
requestEdgeAnalysis();
|
||||
|
|
Loading…
Add table
Reference in a new issue