Procházet zdrojové kódy

Adds fixed delay to Links

Andreas T. Meyer-Berg před 5 roky
rodič
revize
37c539d188

+ 19 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/PrecisionLink.java

@@ -48,6 +48,8 @@ public class PrecisionLink implements Link {
 	 */
 	private boolean statusChanged;
 
+	private long fixedDelay=3;
+
 	/**
 	 * Initializes a simple Link with name and an empty devices list.
 	 * 
@@ -181,6 +183,22 @@ public class PrecisionLink implements Link {
 
 	@Override
 	public long getTransmissionDelayFrom(SmartDevice from, SmartDevice to) {
-		return 0;
+		return fixedDelay;
+	}
+	
+	/**
+	 * Set the delay of this Link
+	 * @param delay fixed transmission delay
+	 */
+	public void setFixedDelay(long delay){
+		this.fixedDelay = delay;
+	}
+	
+	/**
+	 * Returns the fixed transmission delay
+	 * @return transmission delay
+	 */
+	public long  getFixedDelay(){
+		return this.fixedDelay;
 	}
 }

+ 22 - 2
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/simpleImplementation/SimpleLink.java

@@ -42,7 +42,11 @@ public class SimpleLink implements Link {
 	 * whether the status changed during the last simulation step
 	 */
 	private boolean statusChanged;
-
+	
+	/**
+	 * Fixed Delay of the Link
+	 */
+	private long fixedDelay = 2;
 	/**
 	 * Initializes a simple Link with name and an empty devices list.
 	 * 
@@ -162,6 +166,22 @@ public class SimpleLink implements Link {
 
 	@Override
 	public long getTransmissionDelayFrom(SmartDevice from, SmartDevice to) {
-		return 0;
+		return fixedDelay;
+	}
+	
+	/**
+	 * Set the delay of this Link
+	 * @param delay fixed transmission delay
+	 */
+	public void setFixedDelay(long delay){
+		this.fixedDelay = delay;
+	}
+	
+	/**
+	 * Returns the fixed transmission delay
+	 * @return transmission delay
+	 */
+	public long  getFixedDelay(){
+		return this.fixedDelay;
 	}
 }