Cooja: Add LQI to DGRM
This commit is contained in:
parent
f5c8cff5b2
commit
bed3877984
3 changed files with 46 additions and 4 deletions
|
@ -92,9 +92,11 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
private final static int IDX_DST = 1;
|
private final static int IDX_DST = 1;
|
||||||
private final static int IDX_RATIO = 2;
|
private final static int IDX_RATIO = 2;
|
||||||
private final static int IDX_SIGNAL = 3;
|
private final static int IDX_SIGNAL = 3;
|
||||||
private final static int IDX_DELAY = 4;
|
private final static int IDX_LQI = 4;
|
||||||
|
private final static int IDX_DELAY = 5;
|
||||||
|
|
||||||
private final static String[] COLUMN_NAMES = new String[] {
|
private final static String[] COLUMN_NAMES = new String[] {
|
||||||
"Source", "Destination", "RX Ratio", "RSSI", "Delay"
|
"Source", "Destination", "RX Ratio", "RSSI","LQI", "Delay"
|
||||||
};
|
};
|
||||||
|
|
||||||
private GUI gui = null;
|
private GUI gui = null;
|
||||||
|
@ -129,6 +131,10 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
for (double d=AbstractRadioMedium.SS_STRONG; d >= AbstractRadioMedium.SS_WEAK; d -= 1) {
|
for (double d=AbstractRadioMedium.SS_STRONG; d >= AbstractRadioMedium.SS_WEAK; d -= 1) {
|
||||||
combo.addItem((int) d);
|
combo.addItem((int) d);
|
||||||
}
|
}
|
||||||
|
} else if (column == IDX_LQI) {
|
||||||
|
for (int d = 110; d > 50; d -= 5) {
|
||||||
|
combo.addItem((int) d);
|
||||||
|
}
|
||||||
} else if (column == IDX_DELAY) {
|
} else if (column == IDX_DELAY) {
|
||||||
for (double d=0; d <= 5; d++) {
|
for (double d=0; d <= 5; d++) {
|
||||||
combo.addItem(d);
|
combo.addItem(d);
|
||||||
|
@ -162,6 +168,17 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
setText(String.format("%1.1f dBm", v));
|
setText(String.format("%1.1f dBm", v));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
graphTable.getColumnModel().getColumn(IDX_LQI).setCellRenderer(new DefaultTableCellRenderer() {
|
||||||
|
private static final long serialVersionUID = -4669897764928372246L;
|
||||||
|
public void setValue(Object value) {
|
||||||
|
if (!(value instanceof Long)) {
|
||||||
|
setText(value.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long v = ((Long) value).longValue();
|
||||||
|
setText(String.valueOf(v));
|
||||||
|
}
|
||||||
|
});
|
||||||
graphTable.getColumnModel().getColumn(IDX_DELAY).setCellRenderer(new DefaultTableCellRenderer() {
|
graphTable.getColumnModel().getColumn(IDX_DELAY).setCellRenderer(new DefaultTableCellRenderer() {
|
||||||
private static final long serialVersionUID = -4669897764928372246L;
|
private static final long serialVersionUID = -4669897764928372246L;
|
||||||
public void setValue(Object value) {
|
public void setValue(Object value) {
|
||||||
|
@ -175,6 +192,7 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
});
|
});
|
||||||
graphTable.getColumnModel().getColumn(IDX_RATIO).setCellEditor(new DefaultCellEditor(combo));
|
graphTable.getColumnModel().getColumn(IDX_RATIO).setCellEditor(new DefaultCellEditor(combo));
|
||||||
graphTable.getColumnModel().getColumn(IDX_SIGNAL).setCellEditor(new DefaultCellEditor(combo));
|
graphTable.getColumnModel().getColumn(IDX_SIGNAL).setCellEditor(new DefaultCellEditor(combo));
|
||||||
|
graphTable.getColumnModel().getColumn(IDX_LQI).setCellEditor(new DefaultCellEditor(combo));
|
||||||
graphTable.getColumnModel().getColumn(IDX_DELAY).setCellEditor(new DefaultCellEditor(combo));
|
graphTable.getColumnModel().getColumn(IDX_DELAY).setCellEditor(new DefaultCellEditor(combo));
|
||||||
|
|
||||||
graphTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
|
graphTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
|
||||||
|
@ -412,6 +430,9 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
if (column == IDX_SIGNAL) {
|
if (column == IDX_SIGNAL) {
|
||||||
return ((DGRMDestinationRadio)edge.superDest).signal;
|
return ((DGRMDestinationRadio)edge.superDest).signal;
|
||||||
}
|
}
|
||||||
|
if (column == IDX_LQI) {
|
||||||
|
return ((DGRMDestinationRadio)edge.superDest).lqi;
|
||||||
|
}
|
||||||
if (column == IDX_DELAY) {
|
if (column == IDX_DELAY) {
|
||||||
return ((DGRMDestinationRadio)edge.superDest).delay / Simulation.MILLISECOND;
|
return ((DGRMDestinationRadio)edge.superDest).delay / Simulation.MILLISECOND;
|
||||||
}
|
}
|
||||||
|
@ -434,7 +455,10 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
} else if (column == IDX_DELAY) {
|
} else if (column == IDX_DELAY) {
|
||||||
((DGRMDestinationRadio)edge.superDest).delay =
|
((DGRMDestinationRadio)edge.superDest).delay =
|
||||||
((Number)value).longValue() * Simulation.MILLISECOND;
|
((Number)value).longValue() * Simulation.MILLISECOND;
|
||||||
} else {
|
} else if (column == IDX_LQI) {
|
||||||
|
((DGRMDestinationRadio)edge.superDest).lqi = ((Number)value).intValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
super.setValueAt(value, row, column);
|
super.setValueAt(value, row, column);
|
||||||
}
|
}
|
||||||
radioMedium.requestEdgeAnalysis();
|
radioMedium.requestEdgeAnalysis();
|
||||||
|
@ -462,6 +486,9 @@ public class DGRMConfigurator extends VisPlugin {
|
||||||
if (column == IDX_SIGNAL) {
|
if (column == IDX_SIGNAL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (column == IDX_LQI) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (column == IDX_DELAY) {
|
if (column == IDX_DELAY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,11 @@ public class DGRMVisualizerSkin implements VisualizerSkin {
|
||||||
g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
|
g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
|
||||||
for (DestinationRadio r: dests) {
|
for (DestinationRadio r: dests) {
|
||||||
double prob = ((DGRMDestinationRadio)r).ratio;
|
double prob = ((DGRMDestinationRadio)r).ratio;
|
||||||
|
double rssi = ((DGRMDestinationRadio)r).signal;
|
||||||
|
double pos_rssi = rssi + 100;
|
||||||
|
int lqi = ((DGRMDestinationRadio)r).lqi;
|
||||||
|
float red = (float)(1 - prob*pos_rssi/90*lqi/100);
|
||||||
|
float green = (float)(prob*pos_rssi/90*lqi/100);
|
||||||
if (prob == 0.0d) {
|
if (prob == 0.0d) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +130,8 @@ public class DGRMVisualizerSkin implements VisualizerSkin {
|
||||||
Position pos = r.radio.getPosition();
|
Position pos = r.radio.getPosition();
|
||||||
Point pixel = visualizer.transformPositionToPixel(pos);
|
Point pixel = visualizer.transformPositionToPixel(pos);
|
||||||
msgWidth = fm.stringWidth(msg);
|
msgWidth = fm.stringWidth(msg);
|
||||||
g.setColor(new Color(1-(float)prob, (float)prob, 0.0f));
|
g.setColor(new Color(red, green, 0.0f));
|
||||||
|
g.drawString("LQI: " + lqi + " RSSI: " + rssi,(x + pixel.x)/2,(y + pixel.y)/2);
|
||||||
g.drawLine(x, y, pixel.x, pixel.y);
|
g.drawLine(x, y, pixel.x, pixel.y);
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
|
g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class DGRMDestinationRadio extends DestinationRadio {
|
||||||
public double ratio = 1.0; /* Link success ratio (per packet). */
|
public double ratio = 1.0; /* Link success ratio (per packet). */
|
||||||
public double signal = AbstractRadioMedium.SS_STRONG; /* RSSI */
|
public double signal = AbstractRadioMedium.SS_STRONG; /* RSSI */
|
||||||
public long delay = 0; /* EXPERIMENTAL: Propagation delay (us). */
|
public long delay = 0; /* EXPERIMENTAL: Propagation delay (us). */
|
||||||
|
public int lqi = 105;
|
||||||
|
|
||||||
public DGRMDestinationRadio() {
|
public DGRMDestinationRadio() {
|
||||||
super();
|
super();
|
||||||
|
@ -55,6 +56,7 @@ public class DGRMDestinationRadio extends DestinationRadio {
|
||||||
clone.ratio = this.ratio;
|
clone.ratio = this.ratio;
|
||||||
clone.delay = this.delay;
|
clone.delay = this.delay;
|
||||||
clone.signal = this.signal;
|
clone.signal = this.signal;
|
||||||
|
clone.lqi = this.lqi;
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +72,11 @@ public class DGRMDestinationRadio extends DestinationRadio {
|
||||||
element.setText("" + signal);
|
element.setText("" + signal);
|
||||||
config.add(element);
|
config.add(element);
|
||||||
|
|
||||||
|
element = new Element("lqi");
|
||||||
|
element.setText("" + lqi);
|
||||||
|
config.add(element);
|
||||||
|
|
||||||
|
|
||||||
element = new Element("delay");
|
element = new Element("delay");
|
||||||
element.setText("" + delay);
|
element.setText("" + delay);
|
||||||
config.add(element);
|
config.add(element);
|
||||||
|
@ -86,6 +93,8 @@ public class DGRMDestinationRadio extends DestinationRadio {
|
||||||
ratio = Double.parseDouble(element.getText());
|
ratio = Double.parseDouble(element.getText());
|
||||||
} else if (element.getName().equals("signal")) {
|
} else if (element.getName().equals("signal")) {
|
||||||
signal = Double.parseDouble(element.getText());
|
signal = Double.parseDouble(element.getText());
|
||||||
|
} else if (element.getName().equals("lqi")) {
|
||||||
|
lqi = Integer.parseInt(element.getText());
|
||||||
} else if (element.getName().equals("delay")) {
|
} else if (element.getName().equals("delay")) {
|
||||||
delay = Long.parseLong(element.getText());
|
delay = Long.parseLong(element.getText());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue