Commit eeeb8d71 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

First working version of Gateway Selection

parent 6c78240c
...@@ -28,9 +28,9 @@ import java.util.Random; ...@@ -28,9 +28,9 @@ import java.util.Random;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.BumpProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.bump.BumpProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
......
...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host; ...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.FogProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.fog.FogProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
......
...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host; ...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.HazardProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.hazard.HazardProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
...@@ -90,6 +90,7 @@ public class HazardEnvironmentSensorPlugin implements EnvironmentSensorPlugin { ...@@ -90,6 +90,7 @@ public class HazardEnvironmentSensorPlugin implements EnvironmentSensorPlugin {
List<EnvironmentProperty> properties = new ArrayList<>(); List<EnvironmentProperty> properties = new ArrayList<>();
EnvironmentProperty property = new HazardProperty(location, edge, hazard); EnvironmentProperty property = new HazardProperty(location, edge, hazard);
properties.add(property); properties.add(property);
return properties; return properties;
} catch (InformationNotAvailableException e) { } catch (InformationNotAvailableException e) {
throw new AssertionError(SiSTypes.ROAD_EDGE + " and " + SiSTypes.PHY_LOCATION + " are required!"); throw new AssertionError(SiSTypes.ROAD_EDGE + " and " + SiSTypes.PHY_LOCATION + " are required!");
......
...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host; ...@@ -29,8 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RainProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.rain.RainProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
......
...@@ -30,7 +30,7 @@ import de.tudarmstadt.maki.simonstrator.api.Randoms; ...@@ -30,7 +30,7 @@ import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.TrafficSignProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.trafficsign.TrafficSignProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest; import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
package de.tudarmstadt.maki.simonstrator.api.component.vehicular; package de.tudarmstadt.maki.simonstrator.api.component.vehicular;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent; import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VehicleProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteActuator; import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteActuator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.VehicularRouteSensor; import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.VehicularRouteSensor;
...@@ -31,6 +32,8 @@ public interface VehicleInformationComponent ...@@ -31,6 +32,8 @@ public interface VehicleInformationComponent
extends HostComponent, VehicularRouteSensor, RouteActuator, SpeedSensor, SpeedActuator, LocationSensor { extends HostComponent, VehicularRouteSensor, RouteActuator, SpeedSensor, SpeedActuator, LocationSensor {
void setVehicleID(String vehicleID); void setVehicleID(String vehicleID);
VehicleProperty getVehicleProperty();
boolean isValid(); boolean isValid();
void resetVehicleID(); void resetVehicleID();
......
...@@ -28,7 +28,6 @@ import java.util.Map; ...@@ -28,7 +28,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController;
public class RoadNetwork implements RoadNetworkEdgeListener { public class RoadNetwork implements RoadNetworkEdgeListener {
...@@ -80,7 +79,7 @@ public class RoadNetwork implements RoadNetworkEdgeListener { ...@@ -80,7 +79,7 @@ public class RoadNetwork implements RoadNetworkEdgeListener {
return new ArrayList<>(_roadNetwork.values()); return new ArrayList<>(_roadNetwork.values());
} }
public List<RoadNetworkEdge> getAvailableEdgesInObservedArea() { public List<RoadNetworkEdge> getUsableEdges() {
if (_visibleEdges == null) { if (_visibleEdges == null) {
if (!_edgeController.isObservedAreaSet()) { if (!_edgeController.isObservedAreaSet()) {
_visibleEdges = new ArrayList<>(_roadNetwork.values()); _visibleEdges = new ArrayList<>(_roadNetwork.values());
...@@ -89,12 +88,7 @@ public class RoadNetwork implements RoadNetworkEdgeListener { ...@@ -89,12 +88,7 @@ public class RoadNetwork implements RoadNetworkEdgeListener {
List<RoadNetworkEdge> result = new ArrayList<>(); List<RoadNetworkEdge> result = new ArrayList<>();
for (RoadNetworkEdge roadNetworkEdge : allEdges) { for (RoadNetworkEdge roadNetworkEdge : allEdges) {
Location edgePosition = roadNetworkEdge.getEdgePosition(); if (_edgeController.isEdgeUsable(roadNetworkEdge.getEdgeID())) {
if (edgePosition.getLongitude() >= _edgeController.getStartX()
&& edgePosition.getLongitude() <= _edgeController.getEndX()
&& edgePosition.getLatitude() >= _edgeController.getStartY()
&& edgePosition.getLatitude() <= _edgeController.getEndY()) {
result.add(roadNetworkEdge); result.add(roadNetworkEdge);
} }
} }
......
...@@ -3,6 +3,8 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.t ...@@ -3,6 +3,8 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.t
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent; import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic; import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyCostEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyCostEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
...@@ -35,7 +37,8 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic ...@@ -35,7 +37,8 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic
public boolean matchesInformationRequirements(PointInformation<?> pInformation) { public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
if (pInformation instanceof RoadInformation) { if (pInformation instanceof RoadInformation) {
RoadInformation roadInfo = (RoadInformation) pInformation; RoadInformation roadInfo = (RoadInformation) pInformation;
double costsForMissingInformation = roadInfo.getValue().getCostsForMissingInformation(); PropertyCostEstimator costEstimator = PropertyCostEstimatorFactory.getPropertyCostEstimator();
double costsForMissingInformation = costEstimator.calculateCosts(roadInfo.getValue());
if (costsForMissingInformation >= _costs) { if (costsForMissingInformation >= _costs) {
return true; return true;
...@@ -54,4 +57,9 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic ...@@ -54,4 +57,9 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic
return Double.compare(_costs, pArg0._costs); return Double.compare(_costs, pArg0._costs);
} }
@Override
public String toString() {
return "Costs: " + Double.toString(_costs);
}
} }
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