updated for new Radio API

This commit is contained in:
nifi 2008-10-15 09:00:52 +00:00
parent adc57729c3
commit 8134af742c

View file

@ -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,7 +65,9 @@ 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 (radioPacket != null) {
byte[] packet = radioPacket.getPacketData();
if (isRouteReply(packet)) { if (isRouteReply(packet)) {
((Graphics2D) g2d).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); ((Graphics2D) g2d).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
} }
@ -81,15 +80,17 @@ public class VisUAODV extends VisTraffic {
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) {
byte[] packet = radioPacket.getPacketData();
if (isRouteRequest(packet)) if (isRouteRequest(packet))
return Color.RED; return Color.RED;
else if (isRouteReply(packet)) else if (isRouteReply(packet))
return Color.GREEN; return Color.GREEN;
else }
return Color.BLACK; return Color.BLACK;
} }
@ -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;
} }