reload simulation bug fix (lost edges) + removed some debugging output
This commit is contained in:
parent
6e26f08c15
commit
24f00bce76
|
@ -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: DirectedGraphMedium.java,v 1.1 2009/02/24 15:29:52 fros4943 Exp $
|
* $Id: DirectedGraphMedium.java,v 1.2 2009/06/08 12:42:10 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.radiomediums;
|
package se.sics.cooja.radiomediums;
|
||||||
|
@ -114,12 +114,13 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
super.registerMote(mote, sim);
|
super.registerMote(mote, sim);
|
||||||
|
|
||||||
for (Edge edge: edges) {
|
for (Edge edge: edges) {
|
||||||
if (edge.delayedLoadConfig != null) {
|
if (edge.delayedLoadConfig == null) {
|
||||||
boolean ok = edge.setConfigXML(edge.delayedLoadConfig, sim);
|
continue;
|
||||||
if (ok) {
|
}
|
||||||
edge.delayedLoadConfig = null;
|
|
||||||
}
|
/* Try to configure edge now */
|
||||||
return;
|
if (edge.setConfigXML(edge.delayedLoadConfig, sim)) {
|
||||||
|
edge.delayedLoadConfig = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
private class DestinationRadio {
|
private class DestinationRadio {
|
||||||
Radio radio;
|
Radio radio;
|
||||||
double ratio;
|
double ratio;
|
||||||
long delay;
|
long delay; /* us */
|
||||||
|
|
||||||
public DestinationRadio(Radio dest, double ratio, long delay) {
|
public DestinationRadio(Radio dest, double ratio, long delay) {
|
||||||
this.radio = dest;
|
this.radio = dest;
|
||||||
|
@ -221,23 +222,23 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
return new RadioConnection(source);
|
return new RadioConnection(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(source + ": " + destinations.length + " potential destinations");
|
/*logger.info(source + ": " + destinations.length + " potential destinations");*/
|
||||||
RadioConnection newConn = new RadioConnection(source);
|
RadioConnection newConn = new RadioConnection(source);
|
||||||
for (DestinationRadio dest: destinations) {
|
for (DestinationRadio dest: destinations) {
|
||||||
if (dest.radio == source) {
|
if (dest.radio == source) {
|
||||||
/* Fail: cannot receive our own transmission */
|
/* Fail: cannot receive our own transmission */
|
||||||
logger.info(source + ": Fail, receiver is sender");
|
/*logger.info(source + ": Fail, receiver is sender");*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.ratio < 1.0 && random.nextDouble() > dest.ratio) {
|
if (dest.ratio < 1.0 && random.nextDouble() > dest.ratio) {
|
||||||
logger.info(source + ": Fail, randomly");
|
/*logger.info(source + ": Fail, randomly");*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.radio.isReceiving()) {
|
if (dest.radio.isReceiving()) {
|
||||||
/* Fail: radio is already actively receiving */
|
/* Fail: radio is already actively receiving */
|
||||||
logger.info(source + ": Fail, receiving");
|
/*logger.info(source + ": Fail, receiving");*/
|
||||||
newConn.addInterfered(dest.radio);
|
newConn.addInterfered(dest.radio);
|
||||||
|
|
||||||
/* We will also interfere with the other connection */
|
/* We will also interfere with the other connection */
|
||||||
|
@ -260,13 +261,13 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
|
|
||||||
if (dest.radio.isInterfered()) {
|
if (dest.radio.isInterfered()) {
|
||||||
/* Fail: radio is interfered in another connection */
|
/* Fail: radio is interfered in another connection */
|
||||||
logger.info(source + ": Fail, interfered");
|
/*logger.info(source + ": Fail, interfered");*/
|
||||||
newConn.addInterfered(dest.radio);
|
newConn.addInterfered(dest.radio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success: radio starts receiving */
|
/* Success: radio starts receiving */
|
||||||
logger.info(source + ": OK: " + dest.radio);
|
/*logger.info(source + ": OK: " + dest.radio);*/
|
||||||
newConn.addDestination(dest.radio, dest.delay);
|
newConn.addDestination(dest.radio, dest.delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +333,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
public Mote source = null;
|
public Mote source = null;
|
||||||
public Mote dest = null; /* null: all motes*/
|
public Mote dest = null; /* null: all motes*/
|
||||||
public double successRatio = 1.0; /* Link success ratio (per packet). */
|
public double successRatio = 1.0; /* Link success ratio (per packet). */
|
||||||
public long delay = 0; /* Propagation delay (milliseconds). */
|
public long delay = 0; /* Propagation delay (us). */
|
||||||
|
|
||||||
public Edge(Mote source, double ratio, long delay) {
|
public Edge(Mote source, double ratio, long delay) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
@ -383,10 +384,10 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
String moteDescription = element.getText();
|
String moteDescription = element.getText();
|
||||||
|
|
||||||
boolean foundMote = false;
|
boolean foundMote = false;
|
||||||
for (int i=0; i < simulation.getMotesCount(); i++) {
|
for (Mote m: simulation.getMotes()) {
|
||||||
if (moteDescription.equals(simulation.getMote(i).toString())) {
|
if (moteDescription.equals(m.toString())) {
|
||||||
foundMote = true;
|
foundMote = true;
|
||||||
source = simulation.getMote(i);
|
source = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,10 +404,10 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
dest = null; /* ALL */
|
dest = null; /* ALL */
|
||||||
} else {
|
} else {
|
||||||
boolean foundMote = false;
|
boolean foundMote = false;
|
||||||
for (int i=0; i < simulation.getMotesCount(); i++) {
|
for (Mote m: simulation.getMotes()) {
|
||||||
if (moteDescription.equals(simulation.getMote(i).toString())) {
|
if (moteDescription.equals(m.toString())) {
|
||||||
foundMote = true;
|
foundMote = true;
|
||||||
dest = simulation.getMote(i);
|
dest = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue