Commit 0ea85b13 authored by Clemens Krug's avatar Clemens Krug
Browse files

Restructuring / Debug Monitor

~ Restructured some of the components
+ Debug Monitor to get information about the specific nodes.
parent dfddaec2
......@@ -56,6 +56,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
private String osmFileLocation; //use pbf-format, because osm-format causes problems (xml-problems)
private String graphFolderFiles;
private String movementType; //car, bike or foot
private String defaultMovement;
private String navigationalType; //fastest,
private double latLeft; //Values from -90 to 90; always smaller than latRight
private double latRight; //Values from -90 to 90
......@@ -89,11 +90,16 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
public Either<PositionVector, Boolean> nextPosition(SimLocationActuator comp, PositionVector destination)
{
return nextPosition(comp, destination, movementType);
return nextPosition(comp, destination, defaultMovement);
}
public Either<PositionVector, Boolean> nextPosition(SimLocationActuator comp,
PositionVector destination, String movementType) {
if(movementType == null || movementType.equals("") || !this.movementType.contains(movementType))
throw new AssertionError("Invalid movement type: " + movementType);
if(!init) init();
PositionVector newPosition = null;
if (destination
......@@ -112,6 +118,10 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
if(rsp.hasErrors()) {
System.err.println("Requested Points (" + startPosition[0] + ", " + startPosition[1]
+ ") or (" + destinationPosition[0] + ", " + destinationPosition[1] + ") are out of the bounding box.");
System.out.println("Error for host: " + comp.getHost().getId().valueAsString());
System.out.println(rsp.getErrors());
System.out.println();
pointList = new PointList();
pointList.add(new GHPoint(destination.getLatitude(), destination.getLongitude()));
......@@ -185,6 +195,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
public void setMovementType(String movementType) {
this.movementType = movementType;
defaultMovement = movementType.split(",")[0];
}
public void setNavigationalType(String navigationalType) {
......
......@@ -6,7 +6,12 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
import java.util.*;
/**
* Created by Clemens on 04.01.2017.
* This {@link ITransitionStrategy} works with manual assignments. Initially components will be assigned
* one of the attraction points, but at any further point, the set list of attraction points doesn't really matter.
* New target can be assigned by using the {@link #updateTargetAttractionPoint(SimLocationActuator, AttractionPoint)} method,
* otherwise the components will stop moving upon reaching their target.
*
* @author Clemens Krug
*/
public class ManualAssignmentStrategy implements ITransitionStrategy
{
......
......@@ -13,19 +13,35 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import java.util.*;
/**
* Created by Clemens on 15.02.2017.
* This {@link ITransitionStrategy} makes clients move around randomly in a specified area. You can specify the target
* area center via the {@link #updateTargetAttractionPoint(SimLocationActuator, AttractionPoint)} method. The client will then start
* to roam the area randomly till a new target area is assigned.
*
* @author Clemens Krug
*/
public class RandomInAreaTransitionStrategy implements ITransitionStrategy
{
private Random random;
private LinkedHashSet<AttractionPoint> aPoints = new LinkedHashSet<>();
/**
* These are the target area centers the clients have assigned.
*/
private Map<SimLocationActuator, AttractionPoint> assignments = new HashMap<>();
/**
* These are the current spots inside the target area where the client is currently heading.
*/
private Map<SimLocationActuator, AttractionPoint> currentTarget = new HashMap<>();
private List<AttractionAssignmentListener> listeners = new LinkedList<>();
/**
* The radius the target area should have. Should be set via XML config file.
*/
private int defaultRadius;
public RandomInAreaTransitionStrategy()
......@@ -63,6 +79,7 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
@Override
public void addComponent(SimLocationActuator ms) {
if(!assignments.containsKey(ms))
{
AttractionPoint aPoint = aPoints.iterator().next();
......@@ -85,13 +102,6 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
listeners.forEach(listener -> listener.updatedAttractionAssignment(comp, attractionPoint));
}
public void updateTargetAttractionPoint(SimLocationActuator comp, AttractionPoint attractionPoint, int radius)
{
assignments.put(comp, attractionPoint);
currentTarget.put(comp, nextRandomPosition(attractionPoint, radius));
listeners.forEach(listener -> listener.updatedAttractionAssignment(comp, attractionPoint));
}
public void setDefaultRadius(int radius)
{
this.defaultRadius = radius;
......@@ -99,6 +109,8 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
private BasicAttractionPoint nextRandomPosition(Location center, int radius)
{
assert defaultRadius > 0 : "An area radius must be specified for the RandomInAreaTransitionStrategy! Did you set the 'DefaultRadius' property for this transition?";
double x = center.getLongitude();
double y = center.getLatitude();
......
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