From 06ed4d3f0a72f6555126bd0a9ec7d070796cc3d6 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 24 Feb 2009 15:07:01 +0000 Subject: [PATCH] added experimental per destination delay --- .../java/se/sics/cooja/RadioConnection.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/RadioConnection.java b/tools/cooja/java/se/sics/cooja/RadioConnection.java index 4a72525a9..f7d578861 100644 --- a/tools/cooja/java/se/sics/cooja/RadioConnection.java +++ b/tools/cooja/java/se/sics/cooja/RadioConnection.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: RadioConnection.java,v 1.5 2008/10/29 18:23:04 fros4943 Exp $ + * $Id: RadioConnection.java,v 1.6 2009/02/24 15:07:01 fros4943 Exp $ */ package se.sics.cooja; @@ -48,6 +48,8 @@ public class RadioConnection { private Vector destinations = new Vector(); + private Vector destinationDelays = new Vector(); + private Vector interfered = new Vector(); /** @@ -78,6 +80,17 @@ public class RadioConnection { */ public void addDestination(Radio radio) { destinations.add(radio); + destinationDelays.add(new Long(0)); + } + + public void addDestination(Radio radio, Long delay) { + destinations.add(radio); + destinationDelays.add(delay); + } + + public Long getDestinationDelay(Radio radio) { + int idx = destinations.indexOf(radio); + return destinationDelays.get(idx); } /** @@ -97,7 +110,10 @@ public class RadioConnection { * Radio */ public void removeDestination(Radio radio) { - destinations.remove(radio); + int idx = destinations.indexOf(radio); + + destinations.remove(idx); + destinationDelays.remove(idx); } /** @@ -121,26 +137,18 @@ public class RadioConnection { * @return All destinations of this connection */ public Radio[] getDestinations() { - Radio[] radioArrayType; - Radio[] radioArray; - - radioArrayType = new Radio[destinations.size()]; - radioArray = destinations.toArray(radioArrayType); - - return radioArray; + Radio[] arr = new Radio[destinations.size()]; + destinations.toArray(arr); + return arr; } /** * @return All radios interfered by this connection */ public Radio[] getInterfered() { - Radio[] radioArrayType; - Radio[] radioArray; - - radioArrayType = new Radio[interfered.size()]; - radioArray = interfered.toArray(radioArrayType); - - return radioArray; + Radio[] arr = new Radio[interfered.size()]; + interfered.toArray(arr); + return arr; } public String toString() {