Commit 4d6ed478 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Inital version of scalable information dissemination

parent 869b97bb
......@@ -201,6 +201,9 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
public void placeComponent(SimLocationActuator actuator) {
if (!initialized) {
initializeModel();
VehicleMovementModel.getRoadNetwork();
initialized = true;
}
// Initial placement
......
......@@ -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.exception.NoAdditionalRouteAvailableException;
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.tudresden.sumo.cmd.Edge;
import de.tudresden.sumo.cmd.Junction;
......@@ -84,7 +84,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
private RoadNetwork _roadNetwork;
private RoutingAlgorithm _algorithm = new BreadthFirstSearchRoutingAlgorithm();
private RoutingAlgorithm _algorithm = new DijkstraAlgorithm();
public static synchronized TraciSimulationController createSimulationController(String pSumoExe, String pConfigFile) {
if (!CONTROLLER.containsKey(pConfigFile)) {
......@@ -418,7 +418,10 @@ public class TraciSimulationController implements VehicleController, SimulationS
@Override
public RoadNetworkRoute getCurrentRoute(String pVehicleID) {
if (_positons.containsKey(pVehicleID)) {
return _positons.get(pVehicleID).getRoute();
VehicleInformationContainer route = _positons.get(pVehicleID);
if (route != null) {
return route.getRoute();
}
}
return null;
}
......@@ -709,6 +712,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
e.printStackTrace();
}
}
RoadNetwork.CURRENT_ROAD_NETWORK = _roadNetwork;
}
public double getMaxSpeed(String laneID) {
......@@ -802,13 +807,29 @@ public class TraciSimulationController implements VehicleController, SimulationS
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
public boolean isEdgeUsable(String pEdgeID) {
if (_observedAreaSet) {
List<Location> laneShape = getLaneShape(_roadNetwork.getEdge(pEdgeID).getLanes().get(0).getLaneID());
for (Location location : laneShape) {
if (_startX <= location.getLongitude() && location.getLongitude() <= _endX && _startY <= location.getLatitude() && location.getLatitude() <= _endY) {
return true;
List<RoadNetworkLane> lanes = _roadNetwork.getEdge(pEdgeID).getLanes();
if (lanes.size() > 0) {
List<Location> laneShape = getLaneShape(lanes.get(0).getLaneID());
for (Location location : laneShape) {
if (0 <= location.getLongitude() && location.getLongitude() <= _endX - _startX && 0 <= location.getLatitude() && location.getLatitude() <= _endY - _startY) {
return true;
}
}
}
return false;
......
......@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
......@@ -53,21 +53,21 @@ import de.tudarmstadt.maki.simonstrator.api.component.overlay.NodeInformation;
/**
* Generic component that visualizes information from nodes implementing the
* {@link NodeInformation} interface.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, Jul 9, 2015
*/
public class NodeInfoComponentVis extends JComponent
implements VisualizationComponent {
implements VisualizationComponent {
protected Collection<NodeVis> nodes = new LinkedList<>();
private JMenu menu = new JMenu("Node Info");
protected boolean[] activeLayers = null;
protected boolean[] activeLayers = new boolean[0];
boolean hideInactiveNodes = false;
private final String name;
public <T extends HostComponent> NodeInfoComponentVis(
......@@ -96,7 +96,7 @@ public class NodeInfoComponentVis extends JComponent
}
}, null, 0);
}
/**
* Hide rings for inactive nodes.
* @param hideOfflineNodes
......@@ -155,12 +155,12 @@ public class NodeInfoComponentVis extends JComponent
/**
* Visualization-fragments for Node-centric visualiation-information.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, Sep 22, 2013
*/
private class NodeVis {
public final VisNodeInformation visNodeInfo;
public final NodeInformation nodeInfo;
......@@ -174,22 +174,22 @@ public class NodeInfoComponentVis extends JComponent
private final Color[] baseColors = { Color.ORANGE, Color.BLUE, Color.RED,
Color.PINK, Color.GRAY, Color.GREEN, Color.CYAN,
Color.WHITE };
private final Color[] tuColors = {
private final Color[] tuColors = {
new Color(93, 133, 195), // 1a
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(233,80,62), // 9a
new Color(128, 69, 151), // 11a
new Color(0, 78, 138), // 1c
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(185, 15, 34), // 9c
new Color(97, 28, 115), // 11c
};
};
private Color[][] colors = null;
public NodeVis(Host host, NodeInformation nodeInfo) {
......@@ -197,7 +197,7 @@ public class NodeInfoComponentVis extends JComponent
this.host = (SimHost) host;
this.loc = this.host.getTopologyComponent().getRealPosition();
this.visNodeInfo = VisualizationInjector.getNodeInformation(host.getId());
/*
* Create per-info-option colors by deriving the color from the base color
*/
......@@ -211,31 +211,31 @@ public class NodeInfoComponentVis extends JComponent
* http://stackoverflow.com/questions/2355157/dynamically-
* creating-colors-with-different-brightness
*/
// float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(),
// baseColor.getGreen(), baseColor.getBlue(), null);
// float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(),
// baseColor.getGreen(), baseColor.getBlue(), null);
for (int i = 0; i < dimensionSize; i++) {
float hue = i / (float) dimensionSize;
// colors[dim][i] = Color.getHSBColor(hue, hsbVals[1],
// hsbVals[2]);
// colors[dim][i] = Color.getHSBColor(hue, hsbVals[1],
// hsbVals[2]);
colors[dim][i] = tuColors[i];
}
}
}
/**
* Called on one of the nodes to draw global objects such as a legend.
* Called before draw.
*
*
* @param g2
*/
public void drawLegend(Graphics2D g2) {
String[] dimensions = nodeInfo.getNodeColorDimensionDescriptions();
int segments = dimensions.length;
int segmentDegrees = (int) (360 / (double) segments);
int arcSize = 8;
g2.setStroke(new BasicStroke(3));
for (int color = 0; color < segments; color++) {
if (!activeLayers[color]) {
......@@ -256,7 +256,7 @@ public class NodeInfoComponentVis extends JComponent
}
public void draw(Graphics2D g2) {
if (hideInactiveNodes && !nodeInfo.isActive()) {
visNodeInfo.disableClickListener = true;
return;
......@@ -273,15 +273,15 @@ public class NodeInfoComponentVis extends JComponent
if (!nodeInfo.isActive()) {
return;
}
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
1.0f));
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
1.0f));
int segments = nodeInfo.getNodeColorDimensions();
int segmentDegrees = (int) (360 / (double) segments);
int arcSize = 8;
g2.setStroke(new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
for (int dim = 0; dim < segments; dim++) {
int value = nodeInfo.getNodeColor(dim);
......@@ -292,7 +292,7 @@ public class NodeInfoComponentVis extends JComponent
g2.drawArc(VisualizationInjector.scaleValue(center.x)-arcSize, VisualizationInjector.scaleValue(center.y)-arcSize, 2*arcSize, 2*arcSize, dim*segmentDegrees, segmentDegrees);
}
g2.setStroke(new BasicStroke(1));
String nodeDesc = nodeInfo.getNodeDescription();
g2.drawString(nodeDesc, center.x + 4, center.y + 4);
}
......@@ -313,7 +313,7 @@ public class NodeInfoComponentVis extends JComponent
public boolean isHidden() {
return false;
}
@Override
public String getDisplayName() {
return "Info: "+name;
......
......@@ -2,17 +2,17 @@
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
......@@ -27,6 +27,7 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
......@@ -58,15 +59,15 @@ import de.tud.kom.p2psim.impl.util.guirunner.seed.SeedChooser;
* A window to select a configuration file to run PFS from. Useful for
* developers switching between different configuration files many times, as well as
* for presentations etc.
*
*
* @author Leo Nobach
* @version 3.0, 25.11.2008
*
*
*/
public class GUIRunner extends JFrame implements WindowListener, KeyListener {
/**
*
*
*/
private static final long serialVersionUID = 6126914669745711438L;
......@@ -93,11 +94,11 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
public static LastOpened lastOpened = new LastOpened();
public static RunnerController ctrl = new RunnerController();
JSplitPane splitPane;
JTextField searchBar;
DirView dirView;
public GUIRunner() {
......@@ -113,8 +114,15 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
int winWidth = Config.getValue(CONF_PATH_WIDTH, 600);
int winHeight = Config.getValue(CONF_PATH_HEIGHT, 600);
this.setSize(winWidth, winHeight);
this.setLocation(new Point(Config.getValue(CONF_PATH_POSX, 0), Config
.getValue(CONF_PATH_POSY, 0)));
Point point = new Point(Config.getValue(CONF_PATH_POSX, 0), Config
.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());
......@@ -122,11 +130,11 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
JScrollPane sp = new JScrollPane(dirView);
this.add(new ButtonBar(), BorderLayout.SOUTH);
JPanel sidepanel = new JPanel();
sidepanel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
SeedChooser seed = new SeedChooser(ctrl.getDetermination());
seed.setBorder(BorderFactory.createTitledBorder("Seed options"));
c.gridx = 0;
......@@ -141,19 +149,19 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
c.gridy = 1;
c.weighty = 1;
sidepanel.add(vars, c);
JComponent variations = new VariationSelector(ctrl).getComponent();
variations.setBorder(BorderFactory.createTitledBorder("Variations"));
c.gridy = 2;
c.weighty = 0;
sidepanel.add(variations, c);
JComponent desc = new DescriptionWnd(ctrl).getComponent();
desc.setBorder(BorderFactory.createTitledBorder("Description"));
c.gridy = 3;
c.weighty = 1;
sidepanel.add(desc, c);
searchBar = new JTextField();
searchBar.addKeyListener(new KeyAdapter() {
@Override
......@@ -162,14 +170,14 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
dirView.updateUI();
}
});
JSplitPane searchDirViewSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, searchBar, sp);
searchDirViewSplitPane.setEnabled(false);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sidepanel, searchDirViewSplitPane);
splitPane.setDividerLocation(Config.getValue(SPLITTER_CONF_PATH, 400));
this.add(splitPane, BorderLayout.CENTER);
GlobalKeyEventDispatcher disp = new GlobalKeyEventDispatcher(this);
disp.addKeyListener(this);
......@@ -178,7 +186,7 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
public class ButtonBar extends JPanel implements ActionListener {
/**
*
*
*/
private static final long serialVersionUID = -7482502225920138689L;
......@@ -206,7 +214,7 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
}
public void closeRunner() {
disposeRunner();
disposeRunner();
System.exit(0);
}
......
......@@ -140,6 +140,7 @@ implements CachingComponent, ConnectivityListener {
if (!_cache.containsKey(pCacheEntry.getClass())) {
_cache.put(pCacheEntry.getClass(), new ArrayList<>());
}
List<PointInformation> entries = _cache.get(pCacheEntry.getClass());
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