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

Allow node placement in modular movement model

parent 930bb6e9
...@@ -125,6 +125,8 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac ...@@ -125,6 +125,8 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
protected Random rand = Randoms.getRandom(ModularMovementModel.class); protected Random rand = Randoms.getRandom(ModularMovementModel.class);
protected boolean placeNodesAtAP = false;
public ModularMovementModel() { public ModularMovementModel() {
this.worldDimensions = Binder.getComponentOrNull(Topology.class) this.worldDimensions = Binder.getComponentOrNull(Topology.class)
.getWorldDimensions(); .getWorldDimensions();
...@@ -132,6 +134,10 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac ...@@ -132,6 +134,10 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
// scheduling initalization! // scheduling initalization!
Event.scheduleImmediately(this, null, EVENT_INIT); Event.scheduleImmediately(this, null, EVENT_INIT);
} }
public void setPlaceNodes(boolean placeNodes) {
this.placeNodesAtAP = placeNodes;
}
/** /**
* This Method will be not called from the Components. So we call this * This Method will be not called from the Components. So we call this
...@@ -173,6 +179,14 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac ...@@ -173,6 +179,14 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
// strategy // strategy
for (SimLocationActuator ms : moveableHosts) { for (SimLocationActuator ms : moveableHosts) {
attractionAssigment.addComponent(ms); attractionAssigment.addComponent(ms);
if(placeNodesAtAP) {
IAttractionPoint assignment = attractionAssigment.getAssignment(ms);
double apRadius = (assignment.hasRadius() ? Math.max(assignment.getRadius(), 25.0) : 25.0);
ms.updateCurrentLocation(this.addGaussianOffsetToPosition(new PositionVector(assignment), apRadius / 3));
attractionAssigment.updateTargetAttractionPoint(ms, assignment);
}
} }
setTimeBetweenMoveOperations(timeBetweenMoveOperation); setTimeBetweenMoveOperations(timeBetweenMoveOperation);
......
...@@ -61,11 +61,7 @@ public class SocialGroupMovementModel extends ModularMovementModel { ...@@ -61,11 +61,7 @@ public class SocialGroupMovementModel extends ModularMovementModel {
private Set<SimLocationActuator> singleHosts = new LinkedHashSet<SimLocationActuator>(); private Set<SimLocationActuator> singleHosts = new LinkedHashSet<SimLocationActuator>();
private int numberOfSingleHosts; private int numberOfSingleHosts;
private boolean placeNodesAtAP = false;
public void setPlaceNodes(boolean placeNodes) {
this.placeNodesAtAP = placeNodes;
}
@Override @Override
public void initialize() { public void initialize() {
......
...@@ -152,7 +152,7 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior { ...@@ -152,7 +152,7 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
delay = Time.MINUTE; delay = Time.MINUTE;
} }
System.out.println(Time.getFormattedTime(delay) ); // System.out.println(Time.getFormattedTime(delay) );
Event.scheduleWithDelay(delay, new EventHandler() { Event.scheduleWithDelay(delay, new EventHandler() {
@Override @Override
......
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