Commit ef0afde5 authored by Julian Zobel's avatar Julian Zobel
Browse files

Updated Churn generator

parent 83c15c58
......@@ -114,8 +114,17 @@ public class MaxPeerCountChurnGenerator
@XMLConfigurableConstructor({ "file", "maxNumberOfNodes" })
public MaxPeerCountChurnGenerator(String file, int maxNumberOfNodes) {
this.maxNumberOfNodes = maxNumberOfNodes;
parseTrace(file);
parseTrace(file);
}
@XMLConfigurableConstructor({ "churnStart", "maxNumberOfNodes", "burstLength" })
public MaxPeerCountChurnGenerator(long churnStart, int maxNumberOfNodes, long burstLength) {
this.maxNumberOfNodes = maxNumberOfNodes;
churnInfos.add(new ChurnInfo(churnStart, burstLength, maxNumberOfNodes));
this.setChurnStart(churnStart);
}
/**
* A class that implements the {@link LifecycleComponent}-interface and can
......
......@@ -25,6 +25,7 @@ import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* Implementation of the interface {@link AttractionGenerator}.
......@@ -38,12 +39,15 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
public class EquidistantSquareAttractionGenerator implements IAttractionGenerator {
private PositionVector worldDimension;
private double squareSize;
public EquidistantSquareAttractionGenerator() {
@XMLConfigurableConstructor({ "squareSize" })
public EquidistantSquareAttractionGenerator(double squareSize) {
this.worldDimension = Binder.getComponentOrNull(Topology.class)
.getWorldDimensions();
this.squareSize = squareSize;
createAttractionPoints();
}
......@@ -56,23 +60,23 @@ public class EquidistantSquareAttractionGenerator implements IAttractionGenerato
}
private void createAttractionPoints() {
double x = worldDimension.getX() / 2;
double y = worldDimension.getY() / 2;
double x = worldDimension.getX();
double y = worldDimension.getY();
PositionVector p1 = new PositionVector(x/4, y/4);
PositionVector p1 = new PositionVector(x - squareSize, y - squareSize);
AttractionPoint ap1 = new AttractionPointImpl("AP1", p1);
attractionPoints.add(ap1);
PositionVector p2 = new PositionVector(x/4 + x/2, y/4);
PositionVector p2 = new PositionVector(x - squareSize, y + squareSize);
AttractionPoint ap2 = new AttractionPointImpl("AP2", p2);
attractionPoints.add(ap2);
PositionVector p3 = new PositionVector(x/4 + x/2, y/4 + y/2);
PositionVector p3 = new PositionVector(x + squareSize, y - squareSize);
AttractionPoint ap3 = new AttractionPointImpl("AP3", p3);
attractionPoints.add(ap3);
PositionVector p4 = new PositionVector(x/4, y/4 + y/2);
PositionVector p4 = new PositionVector(x + squareSize, y + squareSize);
AttractionPoint ap4 = new AttractionPointImpl("AP4", p4);
attractionPoints.add(ap4);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment