new radio medium api

This commit is contained in:
fros4943 2009-10-27 10:14:09 +00:00
parent 2d7e188c77
commit 29f618836f
2 changed files with 28 additions and 21 deletions

View file

@ -26,33 +26,41 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MRM.java,v 1.9 2009/02/24 15:05:36 fros4943 Exp $ * $Id: MRM.java,v 1.10 2009/10/27 10:14:09 fros4943 Exp $
*/ */
package se.sics.mrm; package se.sics.mrm;
import java.util.*; import java.util.Collection;
import java.util.Hashtable;
import java.util.Observable;
import java.util.Observer;
import java.util.Random;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.*; import se.sics.cooja.ClassDescription;
import se.sics.cooja.interfaces.*; import se.sics.cooja.RadioConnection;
import se.sics.cooja.Simulation;
import se.sics.cooja.interfaces.Position;
import se.sics.cooja.interfaces.Radio;
import se.sics.cooja.radiomediums.AbstractRadioMedium; import se.sics.cooja.radiomediums.AbstractRadioMedium;
/** /**
* This is the main class of the COOJA Multi-path Ray-tracing Medium (MRM) * This is the main class of the COOJA Multi-path Ray-tracing Medium (MRM)
* package. * package.
* *
* MRM is meant to be an alternative to the simpler radio mediums available in * MRM is an alternative to the simpler radio mediums available in
* COOJA. It is packet based and uses a 2D ray-tracing approach to approximate * COOJA. It is packet based and uses a 2D ray-tracing approach to approximate
* signal strength attenuations between simulated radios. Currently the * signal strength attenuation between simulated radios. Currently the
* ray-tracing only supports reflections and refractions through homogeneous * ray-tracing only supports reflections and refractions through homogeneous
* obstacles. * obstacles.
* *
* MRM provides a number of plugins for example a plugin for visualizing radio * MRM registers two plugins: a plugin for visualizing the radio
* environments, and a plugin for configuring the radio medium. * environments, and a plugin for configuring the radio medium parameters.
* *
* Future work includes adding diffractions and scattering support. * Future work includes adding support for diffraction and scattering.
* *
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ -61,7 +69,6 @@ public class MRM extends AbstractRadioMedium {
private static Logger logger = Logger.getLogger(MRM.class); private static Logger logger = Logger.getLogger(MRM.class);
private ChannelModel currentChannelModel = null; private ChannelModel currentChannelModel = null;
private Simulation mySimulation = null;
private Random random = null; private Random random = null;
@ -101,6 +108,9 @@ public class MRM extends AbstractRadioMedium {
continue; continue;
} }
/* TODO Use DGRM to cache link information.
* (No need to loop over all receivers) */
double listeningPositionX = listeningRadio.getPosition().getXCoordinate(); double listeningPositionX = listeningRadio.getPosition().getXCoordinate();
double listeningPositionY = listeningRadio.getPosition().getYCoordinate(); double listeningPositionY = listeningRadio.getPosition().getYCoordinate();
@ -229,13 +239,11 @@ public class MRM extends AbstractRadioMedium {
} }
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
// Forwarding to current channel model
return currentChannelModel.getConfigXML(); return currentChannelModel.getConfigXML();
} }
public boolean setConfigXML(Collection<Element> configXML, public boolean setConfigXML(Collection<Element> configXML,
boolean visAvailable) { boolean visAvailable) {
// Forwarding to current channel model
return currentChannelModel.setConfigXML(configXML); return currentChannelModel.setConfigXML(configXML);
} }
@ -255,8 +263,7 @@ public class MRM extends AbstractRadioMedium {
/** /**
* Deletes an earlier registered setting observer. * Deletes an earlier registered setting observer.
* *
* @param osb * @param obs Earlier registered observer
* Earlier registered observer
*/ */
public void deleteSettingsObserver(Observer obs) { public void deleteSettingsObserver(Observer obs) {
settingsObservable.deleteObserver(obs); settingsObservable.deleteObserver(obs);
@ -276,7 +283,7 @@ public class MRM extends AbstractRadioMedium {
* @return Number of registered radios. * @return Number of registered radios.
*/ */
public int getRegisteredRadioCount() { public int getRegisteredRadioCount() {
return getRegisteredRadios().size(); return getRegisteredRadios().length;
} }
/** /**
@ -286,7 +293,7 @@ public class MRM extends AbstractRadioMedium {
* @return Radio at given index * @return Radio at given index
*/ */
public Radio getRegisteredRadio(int index) { public Radio getRegisteredRadio(int index) {
return getRegisteredRadios().get(index); return getRegisteredRadios()[index];
} }
/** /**

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: UDGMVisualizerSkin.java,v 1.8 2009/09/17 12:10:28 fros4943 Exp $ * $Id: UDGMVisualizerSkin.java,v 1.9 2009/10/27 10:14:58 fros4943 Exp $
*/ */
package se.sics.cooja.plugins.skins; package se.sics.cooja.plugins.skins;
@ -162,16 +162,16 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
txRangeSpinner.addChangeListener(new ChangeListener() { txRangeSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
radioMedium.TRANSMITTING_RANGE = ((SpinnerNumberModel) radioMedium.setTxRange(((SpinnerNumberModel)
txRangeSpinner.getModel()).getNumber().doubleValue(); txRangeSpinner.getModel()).getNumber().doubleValue());
visualizer.repaint(); visualizer.repaint();
} }
}); });
interferenceRangeSpinner.addChangeListener(new ChangeListener() { interferenceRangeSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
radioMedium.INTERFERENCE_RANGE = ((SpinnerNumberModel) radioMedium.setInterferenceRange(((SpinnerNumberModel)
interferenceRangeSpinner.getModel()).getNumber().doubleValue(); interferenceRangeSpinner.getModel()).getNumber().doubleValue());
visualizer.repaint(); visualizer.repaint();
} }
}); });