Commit 7b723ca7 authored by Julian Zobel's avatar Julian Zobel
Browse files

-- Renamed the Attraction Point Interface from AttractionPoint to IAttractionPoint

-- Removed the single use DefaultHostCounter and implemented as static functionality as it resemles the simulated situation.
parent 01e48533
......@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.api.topology.movement;
import java.util.Set;
import de.tud.kom.p2psim.api.topology.TopologyComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* A movement model for a group of {@link TopologyComponent}s. The movement
......@@ -61,7 +61,7 @@ public interface MovementModel {
* @param targetAttractionPoint
*/
default public void changeTargetLocation(SimLocationActuator actuator,
AttractionPoint targetAttractionPoint)
IAttractionPoint targetAttractionPoint)
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
......@@ -75,7 +75,7 @@ public interface MovementModel {
* @param actuator
* @return target AttractionPoint
*/
default public AttractionPoint getTargetLocation(
default public IAttractionPoint getTargetLocation(
SimLocationActuator actuator) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
......@@ -86,7 +86,7 @@ public interface MovementModel {
* @return
* @throws UnsupportedOperationException
*/
default public Set<AttractionPoint> getAllAttractionPoints()
default public Set<IAttractionPoint> getAllAttractionPoints()
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
......
......@@ -29,7 +29,7 @@ import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import de.tud.kom.p2psim.impl.energy.UAVReplacementCharger;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.communication.BaseToUAVInterface;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.communication.UAVToBaseInterface;
......@@ -81,17 +81,17 @@ public class BaseTopologyComponent extends AbstractTopologyComponent {
}
@Override
public Set<AttractionPoint> getAllAttractionPoints() {
public Set<IAttractionPoint> getAllAttractionPoints() {
throw new UnsupportedOperationException();
}
@Override
public void setTargetAttractionPoint(AttractionPoint targetAttractionPoint) {
public void setTargetAttractionPoint(IAttractionPoint targetAttractionPoint) {
throw new UnsupportedOperationException();
}
@Override
public AttractionPoint getCurrentTargetAttractionPoint() {
public IAttractionPoint getCurrentTargetAttractionPoint() {
throw new UnsupportedOperationException();
}
......
......@@ -32,7 +32,7 @@ import de.tud.kom.p2psim.api.topology.movement.MovementModel;
import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
......@@ -102,18 +102,18 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
}
@Override
public void setTargetAttractionPoint(AttractionPoint targetAttractionPoint)
public void setTargetAttractionPoint(IAttractionPoint targetAttractionPoint)
throws UnsupportedOperationException {
movementModel.changeTargetLocation(this, targetAttractionPoint);
}
@Override
public AttractionPoint getCurrentTargetAttractionPoint() {
public IAttractionPoint getCurrentTargetAttractionPoint() {
return movementModel.getTargetLocation(this);
}
@Override
public Set<AttractionPoint> getAllAttractionPoints() {
public Set<IAttractionPoint> getAllAttractionPoints() {
return movementModel.getAllAttractionPoints();
}
......
......@@ -40,7 +40,7 @@ import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectedCallback;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseDisconnectedCallback;
......@@ -220,7 +220,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
@Override
public Set<AttractionPoint> getAllAttractionPoints() {
public Set<IAttractionPoint> getAllAttractionPoints() {
throw new UnsupportedOperationException();
}
......@@ -252,12 +252,12 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
@Override
public void setTargetAttractionPoint(AttractionPoint targetAttractionPoint) {
public void setTargetAttractionPoint(IAttractionPoint targetAttractionPoint) {
throw new UnsupportedOperationException();
}
@Override
public AttractionPoint getCurrentTargetAttractionPoint() {
public IAttractionPoint getCurrentTargetAttractionPoint() {
throw new UnsupportedOperationException();
}
......
......@@ -40,12 +40,12 @@ import de.tud.kom.p2psim.impl.topology.movement.modularosm.transition.FixedAssig
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* Movement of the {@link AttractionPoint}s in the {@link ModularMovementModel}.
* {@link AttractionPoint}s follow path given via a .csv file.
* Movement of the {@link IAttractionPoint}s in the {@link ModularMovementModel}.
* {@link IAttractionPoint}s follow path given via a .csv file.
*
* @author Nils Richerzhagen
* @version 1.0, 02.08.2014
......@@ -141,7 +141,7 @@ public class CsvMovement extends AbstractMovementModel {
double yDelta = (targetPos.getY() - actPos.getY()) / steps;
String groupId = transitionStrategy
.getGroupIdOfAttractionPoint((AttractionPoint) comp);
.getGroupIdOfAttractionPoint((IAttractionPoint) comp);
if (!(groupId == null)) {
......
......@@ -42,7 +42,7 @@ import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
*
......@@ -64,9 +64,9 @@ public class StreetMovement implements MovementModel, EventHandler {
private Map<SimLocationActuator, PositionVector> positions = new LinkedHashMap<SimLocationActuator, PositionVector>();
private Map<SimLocationActuator, AttractionPoint> attractionOfClients = new LinkedHashMap<SimLocationActuator, AttractionPoint>();
private Map<SimLocationActuator, IAttractionPoint> attractionOfClients = new LinkedHashMap<SimLocationActuator, IAttractionPoint>();
List<AttractionPoint> attractionPoints = new LinkedList<AttractionPoint>();
List<IAttractionPoint> attractionPoints = new LinkedList<IAttractionPoint>();
private boolean initialized = false;
......@@ -113,10 +113,10 @@ public class StreetMovement implements MovementModel, EventHandler {
private void initializeStartingPosition(SimLocationActuator ms) {
// set an initial attraction point
int index = rand.nextInt(attractionPoints.size());
AttractionPoint a = attractionPoints.get(index);
IAttractionPoint a = attractionPoints.get(index);
attractionOfClients.put(ms, a);
AttractionPoint b = this.returnNextOrLastAttractionPoint(index);
IAttractionPoint b = this.returnNextOrLastAttractionPoint(index);
PositionVector startingPosition = this.returnRandomPositionBetweenPoints(a,b);
......@@ -133,8 +133,8 @@ public class StreetMovement implements MovementModel, EventHandler {
* @param b Attraction Point B
* @return PositionVector of a randomly selected point on the connecting line of the attraction points
*/
private PositionVector returnRandomPositionBetweenPoints(AttractionPoint a,
AttractionPoint b) {
private PositionVector returnRandomPositionBetweenPoints(IAttractionPoint a,
IAttractionPoint b) {
double longMin, longMax, latMin, latMax, longNew, latNew;
// Points have different longitude, so only search for random value for longitude
......@@ -186,7 +186,7 @@ public class StreetMovement implements MovementModel, EventHandler {
}
@Override
public void changeTargetLocation(SimLocationActuator actuator, AttractionPoint ap) {
public void changeTargetLocation(SimLocationActuator actuator, IAttractionPoint ap) {
/*
* Set a new target AP for the current actuator
*/
......@@ -214,7 +214,7 @@ public class StreetMovement implements MovementModel, EventHandler {
* Move all nodes towards their assigned attraction point
*/
protected void move() {
for (Entry<SimLocationActuator, AttractionPoint> entry : attractionOfClients.entrySet()) {
for (Entry<SimLocationActuator, IAttractionPoint> entry : attractionOfClients.entrySet()) {
SimLocationActuator ms = entry.getKey();
PositionVector attractionCenter = (PositionVector) entry.getValue();
......@@ -275,7 +275,7 @@ public class StreetMovement implements MovementModel, EventHandler {
* @param index Index of the attraction point, for which another attraction point should be returned
* @return Attraction Point
*/
private AttractionPoint returnNextOrLastAttractionPoint(int index) {
private IAttractionPoint returnNextOrLastAttractionPoint(int index) {
boolean updownrand = rand.nextBoolean();
if(updownrand) {
......@@ -296,11 +296,11 @@ public class StreetMovement implements MovementModel, EventHandler {
}
}
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
return attractionPoints;
}
public void setAttractionPoint(AttractionPoint point) {
public void setAttractionPoint(IAttractionPoint point) {
this.attractionPoints.add(point);
}
}
......@@ -18,55 +18,23 @@
*
*/
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.hostcount;
package de.tud.kom.p2psim.impl.topology.movement.modularosm;
import java.util.Set;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* Serves as an interface to count the number of hosts currently within POI areas.
*
* @author Marcel Verst
* @version 1.0, 22.11.2018
*/
public interface IAttractionPointHostCounter {
/**
* Initializes class variables.
*
* @author Marcel Verst
*/
public void initialize(ModularMovementModel movementModel);
public interface IAttractionBasedMovementMonitor {
public void onAllNodeMovementCompleted(Set<SimLocationActuator> nodes);
public void onAttractionPointAdded(IAttractionPoint attractionpoint);
public void onAttractionPointRemoved(IAttractionPoint attractionpoint);
public void onUpdateAttractionAssignment(SimLocationActuator node, IAttractionPoint attractionpoint);
/**
* Calculates the current number of hosts within each POI.
*
* Adds host to a POI, if the host is within POI area, but not already registered to the POI.
* Removes host from the POI, if the host is not within the POI area, but still registered to the POI.
*
* @author Marcel Verst
*/
public void updateHostCount();
/**
* Returns the number of hosts within a specific POI.
*
* @param AttractionPoint The POI to be checked.
* @return Integer
*
* @author Marcel Verst
*/
public int getHostCountOfAttractionPoint(AttractionPoint attractionPoint);
/**
* Returns a set of all hosts currently located within a specific POI area.
*
* @param AttractionPoint The POI to be checked.
* @return Set<SimLocationActuator>
*
* @author Marcel Verst
*/
public Set<SimLocationActuator> getHostsOfAttractionPoint(AttractionPoint attractionPoint);
}
\ No newline at end of file
}
......@@ -48,21 +48,21 @@ import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* Modular Movement Model uses different models/strategies to create a movement
* model. In this implementation, it has 3 different models/strategies.
* <p>
* M0: AttractionGenerator -> Generates the {@link AttractionPoint}s and place
* them on the map. The {@link AttractionPoint}s can't be moved, because they
* M0: AttractionGenerator -> Generates the {@link IAttractionPoint}s and place
* them on the map. The {@link IAttractionPoint}s can't be moved, because they
* are static POIs from real-world data!
* <p>
* M1: A general {@link MovementModel} is not used, because we use static
* attraction points.
* <p>
* M2: The {@link IAttractionAssigmentStrategy}! It takes the Hosts, which should be moved
* around, but calculates only the assignment to the {@link AttractionPoint}s.
* around, but calculates only the assignment to the {@link IAttractionPoint}s.
* It doesn't move the Hosts! It will be only assignment a new AttractionPoint!
*
* <p>
......@@ -79,7 +79,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
* the AttractionPoints will be handled by the movement model in M1! <br>
* Further it contains an offset for every Host, which will be added to the
* destination point (AttractionPoint), so that not all hosts, which are
* assigned to one {@link AttractionPoint}, lies on the same point.<br>
* assigned to one {@link IAttractionPoint}, lies on the same point.<br>
*
* CHANGELOG
*
......@@ -186,7 +186,7 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
}
@Override
public void changeTargetLocation(SimLocationActuator actuator, AttractionPoint ap) {
public void changeTargetLocation(SimLocationActuator actuator, IAttractionPoint ap) {
attractionAssigment.updateTargetAttractionPoint(actuator, ap);
}
......@@ -215,7 +215,7 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
@Override
public void updatedAttractionAssignment(SimLocationActuator component,
AttractionPoint newAssignment) {
IAttractionPoint newAssignment) {
/*
* Use this method to calculate the offset and target location for a
......@@ -368,7 +368,7 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
}
@Override
public AttractionPoint getTargetLocation(SimLocationActuator actuator) {
public IAttractionPoint getTargetLocation(SimLocationActuator actuator) {
return attractionAssigment.getAssignment(actuator);
}
......@@ -377,7 +377,7 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
*
* @return
*/
public List<AttractionPoint> getAttractionPoints() {
return new Vector<AttractionPoint>(IAttractionGenerator.attractionPoints);
public List<IAttractionPoint> getAttractionPoints() {
return new Vector<IAttractionPoint>(IAttractionGenerator.attractionPoints);
}
}
......@@ -46,7 +46,7 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Oracle;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route.RouteSegment;
......@@ -268,7 +268,7 @@ public class ModularMovementModelViz extends JComponent
{
Composite gc = g2.getComposite();
for (AttractionPoint aPoint : movementModel.getAttractionPoints()) {
for (IAttractionPoint aPoint : movementModel.getAttractionPoints()) {
Point point = ((PositionVector) aPoint).asPoint();
// draw border
g2.setColor(Color.BLACK);
......
......@@ -10,7 +10,7 @@ import de.tud.kom.p2psim.impl.util.Either;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.NodeDebugMonitor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import java.util.HashMap;
import java.util.LinkedList;
......@@ -222,7 +222,7 @@ public class ModularMultiTypeMovementModel extends ModularMovementModel
}
@Override
public void changeTargetLocation(SimLocationActuator actuator, AttractionPoint ap) {
public void changeTargetLocation(SimLocationActuator actuator, IAttractionPoint ap) {
if(transitions.containsKey(actuator)) transitions.get(actuator).updateTargetAttractionPoint(actuator, ap);
else attractionAssigment.updateTargetAttractionPoint(actuator, ap);
}
......@@ -234,13 +234,13 @@ public class ModularMultiTypeMovementModel extends ModularMovementModel
}
@Override
public AttractionPoint getTargetLocation(SimLocationActuator actuator) {
public IAttractionPoint getTargetLocation(SimLocationActuator actuator) {
if(transitions.containsKey(actuator)) return transitions.get(actuator).getAssignment(actuator);
else return attractionAssigment.getAssignment(actuator);
}
@Override
public void updatedAttractionAssignment(SimLocationActuator component, AttractionPoint newAssignment) {
public void updatedAttractionAssignment(SimLocationActuator component, IAttractionPoint newAssignment) {
//Notifications of listeners get suppressed in setup phase to prevent multiple assignments of destinations.
if(suppressListenerNotify) return;
super.updatedAttractionAssignment(component, newAssignment);
......
......@@ -21,6 +21,7 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm;
import java.net.UnknownHostException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
......@@ -32,7 +33,6 @@ import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.api.topology.movement.local.LocalMovementStrategy;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionGenerator;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.hostcount.IAttractionPointHostCounter;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.groups.MovementGroupContainer;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.groups.SocialMovementGroup;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.groups.groupencounter.IGroupEncounterBehavior;
......@@ -43,7 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
*
......@@ -55,8 +55,7 @@ public class SocialGroupMovementModel extends ModularMovementModel {
protected MovementGroupContainer groupContainer;
protected IGroupFormingBehavior groupFormingBehavior;
protected IGroupEncounterBehavior groupEncounterBehavior;
protected IAttractionPointHostCounter attractionPointHostCounter;
private Set<SimLocationActuator> singleHosts = new LinkedHashSet<SimLocationActuator>();
private int numberOfSingleHosts;
......@@ -71,7 +70,6 @@ public class SocialGroupMovementModel extends ModularMovementModel {
if (!initialized) {
groupContainer = MovementGroupContainer.getInstance();
attractionPointHostCounter.initialize(this);
groupFormingBehavior.initialize(this);
groupEncounterBehavior.initialize(this);
......@@ -111,7 +109,7 @@ public class SocialGroupMovementModel extends ModularMovementModel {
for (SimLocationActuator ms : moveableHosts) {
attractionAssigment.addComponent(ms);
if(placeNodesAtAP) {
AttractionPoint assignment = attractionAssigment.getAssignment(ms);
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));
......@@ -157,10 +155,7 @@ public class SocialGroupMovementModel extends ModularMovementModel {
*/
@Override
protected void move() {
// Update the number of hosts within each attraction point.
attractionPointHostCounter.updateHostCount();
// Check POIs if groups can be created. Delete groups, if destination reached.
groupFormingBehavior.manageGroups();
......@@ -170,9 +165,21 @@ public class SocialGroupMovementModel extends ModularMovementModel {
/*
* Moves all nodes according to definition in group movement method
*/
for (SimLocationActuator component : moveableHosts) {
assert currentTargets.containsKey(component);
doGroupMovement(component, currentTargets.get(component));
for (SimLocationActuator host : moveableHosts) {
assert currentTargets.containsKey(host);
// Single Host Movement
if(singleHosts.contains(host) || !groupContainer.isGroupMember(host)) {
doLocalMovement(host, currentTargets.get(host));
}
else if(groupContainer.isGroupMember(host)){
doGroupMovement(host, currentTargets.get(host));
}
else {
throw new UnsupportedOperationException("SimLocationActuator " + host + " is neither in a group nor a single node");
}
}
Event.scheduleWithDelay(timeBetweenMoveOperation, this, null, EVENT_MOVE);
}
......@@ -188,44 +195,38 @@ public class SocialGroupMovementModel extends ModularMovementModel {
* @param PositionVector Destination of the host.
*/
protected void doGroupMovement(SimLocationActuator host, PositionVector destination) {
// Single Host Movement
if(singleHosts.contains(host) || !groupContainer.isGroupMember(host)) {
doLocalMovement(host, destination);
}
// Group Related Movement
else if(groupContainer.isGroupMember(host)){
if(movesToGroupMeetingPoint(host)) {
if(hostIsAtMeetingPoint(host)) {
if(groupAtMP(host)) {
SocialMovementGroup group = groupContainer.getGroupOfHost(host);
AttractionPoint currAp = group.getLeader().getCurrentTargetAttractionPoint();
PositionVector currDest = group.getDestination();
group.setMeetingPoint(currDest);
for(SimLocationActuator participant : group.getMembers()) {
attractionAssigment.updateTargetAttractionPoint(participant, currAp);
}
if(movesToGroupMeetingPoint(host)) {
if(hostIsAtMeetingPoint(host)) {
if(groupAtMP(host)) {
SocialMovementGroup group = groupContainer.getGroupOfHost(host);
IAttractionPoint currAp = group.getLeader().getCurrentTargetAttractionPoint();
PositionVector currDest = group.getDestination();
group.setMeetingPoint(currDest);
for(SimLocationActuator participant : group.getMembers()) {
attractionAssigment.updateTargetAttractionPoint(participant, currAp);
}
}
// MP not reached. Move to MP.
else {
PositionVector mp = groupContainer.getGroupOfHost(host).getMeetingPoint();
doLocalMovement(host, mp);
}
}
// MP reached. Move to destination.
// MP not reached. Move to MP.
else {
if(groupContainer.isLeader(host)) {
if(!groupContainer.isWaiting(groupContainer.getGroupOfHost(host))) {
doLocalMovement(host, destination);
}
}
else {
followLeader(host);
PositionVector mp = groupContainer.getGroupOfHost(host).getMeetingPoint();
doLocalMovement(host, mp);
}
}
// MP reached. Move to destination.
else {
if(groupContainer.isLeader(host)) {
if(!groupContainer.isWaiting(groupContainer.getGroupOfHost(host))) {
doLocalMovement(host, destination);
}
}
else {
followLeader(host);
}
}
}
/*
......@@ -308,8 +309,8 @@ public class SocialGroupMovementModel extends ModularMovementModel {
System.out.println();
}
AttractionPoint leaderDestination = leader.getCurrentTargetAttractionPoint();
AttractionPoint hostDestination = host.getCurrentTargetAttractionPoint();
IAttractionPoint leaderDestination = leader.getCurrentTargetAttractionPoint();
IAttractionPoint hostDestination = host.getCurrentTargetAttractionPoint();
// Update target attraction point if not already done
if(leaderDestination != null && hostDestination != leaderDestination) {
......@@ -350,14 +351,6 @@ public class SocialGroupMovementModel extends ModularMovementModel {
this.groupEncounterBehavior = defaultGroupEncounterBehavior;
}
public void setAttractionPointHostCounter(IAttractionPointHostCounter attractionPointHostCounter) {
if (attractionPointHostCounter == null) {
throw new ConfigurationException(
"HostCountStrategy is missing in ModularMovementModel!");
}
this.attractionPointHostCounter = attractionPointHostCounter;
}
public IAttractionAssigmentStrategy getAttractionAssignmentStrategy() {
return attractionAssigment;
}
......@@ -369,10 +362,6 @@ public class SocialGroupMovementModel extends ModularMovementModel {
public LocalMovementStrategy getMovementStrategy() {
return localMovementStrategy;
}
public IAttractionPointHostCounter getAttractionPointHostCounter() {
return attractionPointHostCounter;
}
public void setNumberOfSingleHosts(int numberOfSingleHosts) {
this.numberOfSingleHosts = numberOfSingleHosts;
......@@ -391,8 +380,8 @@ public class SocialGroupMovementModel extends ModularMovementModel {
*
* @return
*/
public List<AttractionPoint> getAttractionPoints() {
return new Vector<AttractionPoint>(IAttractionGenerator.attractionPoints);
public List<IAttractionPoint> getAttractionPoints() {
return new Vector<IAttractionPoint>(IAttractionGenerator.attractionPoints);
}
......
......@@ -26,10 +26,10 @@ import java.util.Random;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* In the current implementation, {@link AttractionPoint}s cannot move anymore.
* In the current implementation, {@link IAttractionPoint}s cannot move anymore.
* We hold a static list of attraction points to ensure that there exists only
* one instance of each name at a time.
*
......@@ -40,7 +40,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*/
public class AttractionPointImpl extends BasicAttractionPoint {
protected static Random rnd = Randoms.getRandom(AttractionPoint.class);
protected static Random rnd = Randoms.getRandom(IAttractionPoint.class);
protected static Map<String, AttractionPointImpl> instances = new LinkedHashMap<>();
protected long pauseTimeMin = -1;
......@@ -69,7 +69,7 @@ public class AttractionPointImpl extends BasicAttractionPoint {
}
@Override
public AttractionPoint clone(String newName) {
public IAttractionPoint clone(String newName) {
return new AttractionPointImpl(name, this, weight, radius, pauseTimeMin, pauseTimeMax);
}
......
......@@ -21,12 +21,12 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.Analyzer;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
public interface AttractionPointMonitor extends Analyzer {
public void addedAttractionPoint(AttractionPoint ap);
public void addedAttractionPoint(IAttractionPoint ap);
public void removedAttractionPoint(AttractionPoint ap);
public void removedAttractionPoint(IAttractionPoint ap);
}
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* A basic attraction point, as simple as it can get. Really just a named location
* without any checks performed.
*/
public class BasicAttractionPoint extends PositionVector implements AttractionPoint
public class BasicAttractionPoint extends PositionVector implements IAttractionPoint
{
protected String name;
......@@ -28,7 +28,7 @@ public class BasicAttractionPoint extends PositionVector implements AttractionPo
}
@Override
public AttractionPoint clone(String newName) {
public IAttractionPoint clone(String newName) {
return new BasicAttractionPoint(newName, this);
}
......
......@@ -20,7 +20,7 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* For simple scenarios: add attraction points by specifying a coordinate.
......@@ -32,11 +32,11 @@ public class ConfigAttractionGenerator implements IAttractionGenerator {
@Override
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
return attractionPoints;
}
public void setAttractionPoint(AttractionPoint point) {
public void setAttractionPoint(IAttractionPoint point) {
attractionPoints.add(point);
}
......
......@@ -30,7 +30,7 @@ import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
......@@ -45,7 +45,7 @@ public class ConfigDynamicAttractionGenerator implements IAttractionGenerator {
private LinkedList<TemporalAttractionPoint> allAPs = new LinkedList<>();
@Override
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
return attractionPoints;
}
......
......@@ -29,11 +29,11 @@ import java.util.List;
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.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* Generates a given number of {@link AttractionPoint}s and sets the Position
* Generates a given number of {@link IAttractionPoint}s and sets the Position
* according to a given CSV file.
*
* @author Nils Richerzhagen
......@@ -67,7 +67,7 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
}
@Override
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
if (attractionPoints == null) {
readData();
}
......@@ -98,7 +98,7 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
+ y);
continue;
}
AttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
IAttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
ap.setRadius(radius);
addAttractionPoint(ap);
......@@ -125,7 +125,7 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
continue;
}
AttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
IAttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
ap.setRadius(r);
addAttractionPoint(ap);
......
......@@ -24,13 +24,13 @@ import java.util.List;
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.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* Implementation of the interface {@link AttractionGenerator}.
*
* Generates the given number of {@link AttractionPoint}s and sets the
* Generates the given number of {@link IAttractionPoint}s and sets the
* position randomly within the world dimensions.
*
* @author Julian Zobel
......@@ -52,7 +52,7 @@ public class EquidistantSquareAttractionGenerator implements IAttractionGenerato
}
@Override
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
if(attractionPoints.isEmpty())
createAttractionPoints();
......@@ -65,19 +65,19 @@ public class EquidistantSquareAttractionGenerator implements IAttractionGenerato
double y = worldDimension.getY() / 2;
PositionVector p1 = new PositionVector(x - squareSize, y - squareSize);
AttractionPoint ap1 = new AttractionPointImpl("AP1", p1);
IAttractionPoint ap1 = new AttractionPointImpl("AP1", p1);
attractionPoints.add(ap1);
PositionVector p2 = new PositionVector(x - squareSize, y + squareSize);
AttractionPoint ap2 = new AttractionPointImpl("AP2", p2);
IAttractionPoint ap2 = new AttractionPointImpl("AP2", p2);
attractionPoints.add(ap2);
PositionVector p3 = new PositionVector(x + squareSize, y - squareSize);
AttractionPoint ap3 = new AttractionPointImpl("AP3", p3);
IAttractionPoint ap3 = new AttractionPointImpl("AP3", p3);
attractionPoints.add(ap3);
PositionVector p4 = new PositionVector(x + squareSize, y + squareSize);
AttractionPoint ap4 = new AttractionPointImpl("AP4", p4);
IAttractionPoint ap4 = new AttractionPointImpl("AP4", p4);
attractionPoints.add(ap4);
}
......
......@@ -24,25 +24,25 @@ import java.util.LinkedList;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
/**
* Interface for {@link AttractionPoint} generators. Will generate a given amount of attraction points.
* Interface for {@link IAttractionPoint} generators. Will generate a given amount of attraction points.
*
* @author Christoph Muenker, Julian Zobel
* @version 1.1, 09 2018
*/
public interface IAttractionGenerator {
static LinkedList<AttractionPoint> attractionPoints = new LinkedList<>();
static LinkedList<IAttractionPoint> attractionPoints = new LinkedList<>();
public List<AttractionPoint> getAttractionPoints();
public List<IAttractionPoint> getAttractionPoints();
/**
* Remove an {@link AttractionPoint} from the list
* Remove an {@link IAttractionPoint} from the list
* @param ap
*/
default void removeAttractionPoint(AttractionPoint ap) {
default void removeAttractionPoint(IAttractionPoint ap) {
if(Monitor.hasAnalyzer(AttractionPointMonitor.class)) {
Monitor.getOrNull(AttractionPointMonitor.class).removedAttractionPoint(ap);
......@@ -52,10 +52,10 @@ public interface IAttractionGenerator {
}
/**
* Add an {@link AttractionPoint} to the list
* Add an {@link IAttractionPoint} to the list
* @param ap
*/
default void addAttractionPoint(AttractionPoint ap) {
default void addAttractionPoint(IAttractionPoint ap) {
if(ap == null) {
Monitor.log(IAttractionGenerator.class, Level.ERROR, "IAttractionGenerator: Tried to add NULL as Attraction Point");
......
......@@ -32,7 +32,7 @@ import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
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.component.sensor.location.IAttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
......@@ -95,7 +95,7 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
}
@Override
public List<AttractionPoint> getAttractionPoints() {
public List<IAttractionPoint> getAttractionPoints() {
if(attractionPoints.size() == 0) {
String poiString = "";
JSONArray allPOI = null;
......
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