updated for new Radio API
This commit is contained in:
parent
adc57729c3
commit
8134af742c
|
@ -26,12 +26,10 @@
|
||||||
* 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: VisUAODV.java,v 1.1 2007/03/23 23:33:54 fros4943 Exp $
|
* $Id: VisUAODV.java,v 1.2 2008/10/15 09:00:52 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
import se.sics.cooja.interfaces.*;
|
import se.sics.cooja.interfaces.*;
|
||||||
import se.sics.cooja.plugins.*;
|
import se.sics.cooja.plugins.*;
|
||||||
|
@ -50,7 +48,6 @@ import se.sics.cooja.plugins.*;
|
||||||
@PluginType(PluginType.SIM_PLUGIN)
|
@PluginType(PluginType.SIM_PLUGIN)
|
||||||
public class VisUAODV extends VisTraffic {
|
public class VisUAODV extends VisTraffic {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static Logger logger = Logger.getLogger(VisUAODV.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new VisUAODV visualizer.
|
* Creates a new VisUAODV visualizer.
|
||||||
|
@ -68,29 +65,33 @@ public class VisUAODV extends VisTraffic {
|
||||||
Point destPixelPosition = transformPositionToPixel(destPosition);
|
Point destPixelPosition = transformPositionToPixel(destPosition);
|
||||||
g2d.setColor(getColorOf(connection));
|
g2d.setColor(getColorOf(connection));
|
||||||
|
|
||||||
byte[] packet = ((PacketRadio)destRadio).getLastPacketReceived();
|
RadioPacket radioPacket = destRadio.getLastPacketReceived();
|
||||||
if (isRouteReply(packet)) {
|
if (radioPacket != null) {
|
||||||
((Graphics2D) g2d).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
|
byte[] packet = radioPacket.getPacketData();
|
||||||
}
|
if (isRouteReply(packet)) {
|
||||||
|
((Graphics2D) g2d).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
g2d.drawLine(sourcePixelPosition.x, sourcePixelPosition.y,
|
g2d.drawLine(sourcePixelPosition.x, sourcePixelPosition.y,
|
||||||
destPixelPosition.x, destPixelPosition.y);
|
destPixelPosition.x, destPixelPosition.y);
|
||||||
|
|
||||||
int hopCount = getHopCount(packet);
|
int hopCount = getHopCount(packet);
|
||||||
if (hopCount >= 0)
|
if (hopCount >= 0)
|
||||||
g2d.drawString("" + hopCount, sourcePixelPosition.x, sourcePixelPosition.y);
|
g2d.drawString("" + hopCount, sourcePixelPosition.x, sourcePixelPosition.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Color getColorOf(RadioConnection conn) {
|
protected Color getColorOf(RadioConnection conn) {
|
||||||
byte[] packet = ((PacketRadio)conn.getSource()).getLastPacketReceived();
|
RadioPacket radioPacket = conn.getSource().getLastPacketReceived();
|
||||||
|
if (radioPacket != null) {
|
||||||
if (isRouteRequest(packet))
|
byte[] packet = radioPacket.getPacketData();
|
||||||
return Color.RED;
|
if (isRouteRequest(packet))
|
||||||
else if (isRouteReply(packet))
|
return Color.RED;
|
||||||
return Color.GREEN;
|
else if (isRouteReply(packet))
|
||||||
else
|
return Color.GREEN;
|
||||||
return Color.BLACK;
|
}
|
||||||
|
return Color.BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRouteRequest(byte[] data) {
|
private boolean isRouteRequest(byte[] data) {
|
||||||
|
@ -105,7 +106,7 @@ public class VisUAODV extends VisTraffic {
|
||||||
}
|
}
|
||||||
private int getHopCount(byte[] data) {
|
private int getHopCount(byte[] data) {
|
||||||
if (data.length > 31)
|
if (data.length > 31)
|
||||||
return (int) data[31];
|
return data[31];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue