|
@@ -5,7 +5,6 @@ import java.util.Random;
|
|
|
|
|
|
import org.apache.commons.math3.distribution.AbstractRealDistribution;
|
|
|
import org.apache.commons.math3.distribution.LaplaceDistribution;
|
|
|
-import org.apache.commons.math3.distribution.NormalDistribution;
|
|
|
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.distributionHandler.ConstantValueDistributionHandler;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.scheduler.Schedulable;
|
|
@@ -95,7 +94,7 @@ public class Port implements Schedulable {
|
|
|
owner = device;
|
|
|
connection = null;
|
|
|
triggerIntervalStat = new ConstantValueDistributionHandler(new Random().nextInt(1000)+1);
|
|
|
- triggerInterval = triggerIntervalStat.sampleNextValue();
|
|
|
+ triggerInterval = Math.max(1, triggerIntervalStat.sampleNextValue());
|
|
|
|
|
|
lastTrigger = 0;
|
|
|
jitter = (short)(new Random().nextInt(5)+1);
|
|
@@ -115,7 +114,7 @@ public class Port implements Schedulable {
|
|
|
owner = device;
|
|
|
connection = null;
|
|
|
triggerIntervalStat = new ConstantValueDistributionHandler(triggerInterval);
|
|
|
- this.triggerInterval = triggerIntervalStat.sampleNextValue();
|
|
|
+ this.triggerInterval = Math.max(1, triggerIntervalStat.sampleNextValue());
|
|
|
lastTrigger = 0;
|
|
|
jitter = 0;
|
|
|
currentJitter = (short)Math.round(Math.random()*jitter);
|
|
@@ -137,7 +136,7 @@ public class Port implements Schedulable {
|
|
|
owner = device;
|
|
|
connection = null;
|
|
|
triggerIntervalStat = new ConstantValueDistributionHandler(triggerInterval);
|
|
|
- this.triggerInterval = triggerIntervalStat.sampleNextValue();
|
|
|
+ this.triggerInterval = Math.max(1, triggerIntervalStat.sampleNextValue());
|
|
|
this.lastTrigger = lastTrigger;
|
|
|
this.jitter = jitter;
|
|
|
currentJitter = (short)Math.round(Math.random()*jitter);
|
|
@@ -199,7 +198,7 @@ public class Port implements Schedulable {
|
|
|
public void setTriggerHandler(ProbabilityDistributionHandler triggerHandler){
|
|
|
this.triggerIntervalStat = triggerHandler;
|
|
|
boolean removed = SimulationManager.removeEvent(this);
|
|
|
- this.triggerInterval = triggerHandler.sampleNextValue();
|
|
|
+ this.triggerInterval = Math.max(1, triggerHandler.sampleNextValue());
|
|
|
if(removed)
|
|
|
SimulationManager.scheduleEvent(this);
|
|
|
}
|
|
@@ -209,7 +208,7 @@ public class Port implements Schedulable {
|
|
|
*/
|
|
|
public void resampleTriggerInterval(){
|
|
|
boolean removed = SimulationManager.removeEvent(this);
|
|
|
- this.triggerInterval = triggerIntervalStat.sampleNextValue();
|
|
|
+ this.triggerInterval = Math.max(triggerIntervalStat.sampleNextValue(),1);
|
|
|
if(removed)
|
|
|
SimulationManager.scheduleEvent(this);
|
|
|
}
|
|
@@ -356,7 +355,7 @@ public class Port implements Schedulable {
|
|
|
connection.getLink().addPackets(packets);
|
|
|
|
|
|
|
|
|
- triggerInterval = triggerIntervalStat.sampleNextValue();
|
|
|
+ triggerInterval = Math.max(1,triggerIntervalStat.sampleNextValue());
|
|
|
|
|
|
if(status==Port.SENDING && connection.getStatus()==Connection.ACTIVE)
|
|
|
SimulationManager.scheduleEvent(this);
|