Commit 8bc9fe82 authored by Tobias Meuser's avatar Tobias Meuser Committed by Jose Ignacio Monreal Bailey
Browse files

Inital version of scalable information dissemination

parent a86cc929
...@@ -201,6 +201,9 @@ public class VehicleMovementModel implements MovementModel, EventHandler { ...@@ -201,6 +201,9 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
public void placeComponent(SimLocationActuator actuator) { public void placeComponent(SimLocationActuator actuator) {
if (!initialized) { if (!initialized) {
initializeModel(); initializeModel();
VehicleMovementModel.getRoadNetwork();
initialized = true; initialized = true;
} }
// Initial placement // Initial placement
......
...@@ -30,7 +30,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road ...@@ -30,7 +30,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.SerializableRoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.SerializableRoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoAdditionalRouteAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoAdditionalRouteAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoExitAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoExitAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.BreadthFirstSearchRoutingAlgorithm; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.DijkstraAlgorithm;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.RoutingAlgorithm; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.RoutingAlgorithm;
import de.tudresden.sumo.cmd.Edge; import de.tudresden.sumo.cmd.Edge;
import de.tudresden.sumo.cmd.Junction; import de.tudresden.sumo.cmd.Junction;
...@@ -84,7 +84,7 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -84,7 +84,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
private RoadNetwork _roadNetwork; private RoadNetwork _roadNetwork;
private RoutingAlgorithm _algorithm = new BreadthFirstSearchRoutingAlgorithm(); private RoutingAlgorithm _algorithm = new DijkstraAlgorithm();
public static synchronized TraciSimulationController createSimulationController(String pSumoExe, String pConfigFile) { public static synchronized TraciSimulationController createSimulationController(String pSumoExe, String pConfigFile) {
if (!CONTROLLER.containsKey(pConfigFile)) { if (!CONTROLLER.containsKey(pConfigFile)) {
...@@ -418,7 +418,10 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -418,7 +418,10 @@ public class TraciSimulationController implements VehicleController, SimulationS
@Override @Override
public RoadNetworkRoute getCurrentRoute(String pVehicleID) { public RoadNetworkRoute getCurrentRoute(String pVehicleID) {
if (_positons.containsKey(pVehicleID)) { if (_positons.containsKey(pVehicleID)) {
return _positons.get(pVehicleID).getRoute(); VehicleInformationContainer route = _positons.get(pVehicleID);
if (route != null) {
return route.getRoute();
}
} }
return null; return null;
} }
...@@ -709,6 +712,8 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -709,6 +712,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
e.printStackTrace(); e.printStackTrace();
} }
} }
RoadNetwork.CURRENT_ROAD_NETWORK = _roadNetwork;
} }
public double getMaxSpeed(String laneID) { public double getMaxSpeed(String laneID) {
...@@ -802,15 +807,31 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -802,15 +807,31 @@ public class TraciSimulationController implements VehicleController, SimulationS
edge.setMaxSpeed(pMaxSpeed); edge.setMaxSpeed(pMaxSpeed);
} }
@Override
public double getEdgeLength(String pEdgeID) {
double length = 0;
for (RoadNetworkLane lane : _roadNetwork.getEdge(pEdgeID).getLanes()) {
SumoCommand speedCommand = Lane.getLength(lane.getLaneID());
Object object = requestObject(speedCommand);
length += (double) object;
}
return length / (_roadNetwork.getEdge(pEdgeID).getLaneAmount());
}
@Override @Override
public boolean isEdgeUsable(String pEdgeID) { public boolean isEdgeUsable(String pEdgeID) {
if (_observedAreaSet) { if (_observedAreaSet) {
List<Location> laneShape = getLaneShape(_roadNetwork.getEdge(pEdgeID).getLanes().get(0).getLaneID()); List<RoadNetworkLane> lanes = _roadNetwork.getEdge(pEdgeID).getLanes();
if (lanes.size() > 0) {
List<Location> laneShape = getLaneShape(lanes.get(0).getLaneID());
for (Location location : laneShape) { for (Location location : laneShape) {
if (_startX <= location.getLongitude() && location.getLongitude() <= _endX && _startY <= location.getLatitude() && location.getLatitude() <= _endY) { if (0 <= location.getLongitude() && location.getLongitude() <= _endX - _startX && 0 <= location.getLatitude() && location.getLatitude() <= _endY - _startY) {
return true; return true;
} }
} }
}
return false; return false;
} }
return true; return true;
......
...@@ -58,13 +58,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.overlay.NodeInformation; ...@@ -58,13 +58,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.overlay.NodeInformation;
* @version 1.0, Jul 9, 2015 * @version 1.0, Jul 9, 2015
*/ */
public class NodeInfoComponentVis extends JComponent public class NodeInfoComponentVis extends JComponent
implements VisualizationComponent { implements VisualizationComponent {
protected Collection<NodeVis> nodes = new LinkedList<>(); protected Collection<NodeVis> nodes = new LinkedList<>();
private JMenu menu = new JMenu("Node Info"); private JMenu menu = new JMenu("Node Info");
protected boolean[] activeLayers = null; protected boolean[] activeLayers = new boolean[0];
boolean hideInactiveNodes = false; boolean hideInactiveNodes = false;
...@@ -178,13 +178,13 @@ public class NodeInfoComponentVis extends JComponent ...@@ -178,13 +178,13 @@ public class NodeInfoComponentVis extends JComponent
private final Color[] tuColors = { private final Color[] tuColors = {
new Color(93, 133, 195), // 1a new Color(93, 133, 195), // 1a
new Color(80, 182, 149), // 3a new Color(80, 182, 149), // 3a
// new Color(221,223,72), // 5a // new Color(221,223,72), // 5a
new Color(248,186,60), // 7a new Color(248,186,60), // 7a
new Color(233,80,62), // 9a new Color(233,80,62), // 9a
new Color(128, 69, 151), // 11a new Color(128, 69, 151), // 11a
new Color(0, 78, 138), // 1c new Color(0, 78, 138), // 1c
new Color(0, 136, 119), // 3c new Color(0, 136, 119), // 3c
// new Color(177, 189, 0), // 5c // new Color(177, 189, 0), // 5c
new Color(210, 135, 0), // 7c new Color(210, 135, 0), // 7c
new Color(185, 15, 34), // 9c new Color(185, 15, 34), // 9c
new Color(97, 28, 115), // 11c new Color(97, 28, 115), // 11c
...@@ -211,12 +211,12 @@ public class NodeInfoComponentVis extends JComponent ...@@ -211,12 +211,12 @@ public class NodeInfoComponentVis extends JComponent
* http://stackoverflow.com/questions/2355157/dynamically- * http://stackoverflow.com/questions/2355157/dynamically-
* creating-colors-with-different-brightness * creating-colors-with-different-brightness
*/ */
// float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(), // float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(),
// baseColor.getGreen(), baseColor.getBlue(), null); // baseColor.getGreen(), baseColor.getBlue(), null);
for (int i = 0; i < dimensionSize; i++) { for (int i = 0; i < dimensionSize; i++) {
float hue = i / (float) dimensionSize; float hue = i / (float) dimensionSize;
// colors[dim][i] = Color.getHSBColor(hue, hsbVals[1], // colors[dim][i] = Color.getHSBColor(hue, hsbVals[1],
// hsbVals[2]); // hsbVals[2]);
colors[dim][i] = tuColors[i]; colors[dim][i] = tuColors[i];
} }
} }
......
...@@ -27,6 +27,7 @@ import java.awt.GridBagConstraints; ...@@ -27,6 +27,7 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.Point; import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
...@@ -113,8 +114,15 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener { ...@@ -113,8 +114,15 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
int winWidth = Config.getValue(CONF_PATH_WIDTH, 600); int winWidth = Config.getValue(CONF_PATH_WIDTH, 600);
int winHeight = Config.getValue(CONF_PATH_HEIGHT, 600); int winHeight = Config.getValue(CONF_PATH_HEIGHT, 600);
this.setSize(winWidth, winHeight); this.setSize(winWidth, winHeight);
this.setLocation(new Point(Config.getValue(CONF_PATH_POSX, 0), Config Point point = new Point(Config.getValue(CONF_PATH_POSX, 0), Config
.getValue(CONF_PATH_POSY, 0))); .getValue(CONF_PATH_POSY, 0));
if (point.getX() >= 0 && point.getY() >= 0
&& Toolkit.getDefaultToolkit().getScreenSize().getWidth()
< point.getX() - winWidth
&& Toolkit.getDefaultToolkit().getScreenSize().getHeight()
< point.getY() - winHeight) {
this.setLocation(point);
}
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
......
...@@ -140,6 +140,7 @@ implements CachingComponent, ConnectivityListener { ...@@ -140,6 +140,7 @@ implements CachingComponent, ConnectivityListener {
if (!_cache.containsKey(pCacheEntry.getClass())) { if (!_cache.containsKey(pCacheEntry.getClass())) {
_cache.put(pCacheEntry.getClass(), new ArrayList<>()); _cache.put(pCacheEntry.getClass(), new ArrayList<>());
} }
List<PointInformation> entries = _cache.get(pCacheEntry.getClass()); List<PointInformation> entries = _cache.get(pCacheEntry.getClass());
entries.add(pCacheEntry); entries.add(pCacheEntry);
} }
......
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