Commit 173e49b1 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Update for diss

parent 4c2d8f4c
...@@ -539,8 +539,12 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -539,8 +539,12 @@ public class TraciSimulationController implements VehicleController, SimulationS
SumoCommand netBoundaryCommand = Simulation.getNetBoundary(); SumoCommand netBoundaryCommand = Simulation.getNetBoundary();
try { try {
SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand); SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand);
return Math.max(netBoundary.x_max - netBoundary.x_min, 10); if (_observedAreaSet) {
return Math.max(Math.min(netBoundary.x_max, _endX) - Math.max(netBoundary.x_min, _startX), 10);
} else {
return Math.max(netBoundary.x_max - netBoundary.x_min, 10);
}
} catch (Exception e) { } catch (Exception e) {
//Nothing to do //Nothing to do
} }
...@@ -553,7 +557,11 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -553,7 +557,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
try { try {
SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand); SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand);
return Math.max(netBoundary.y_max - netBoundary.y_min, 10); if (_observedAreaSet) {
return Math.max(Math.min(netBoundary.y_max, _endY) - Math.max(netBoundary.y_min, _startY), 10);
} else {
return Math.max(netBoundary.y_max - netBoundary.y_min, 10);
}
} catch (Exception e) { } catch (Exception e) {
//Nothing to do //Nothing to do
} }
...@@ -814,6 +822,7 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -814,6 +822,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
for (SumoPosition2D location : geometry.coords) { for (SumoPosition2D location : geometry.coords) {
if (!isObservedAreaSet()) { if (!isObservedAreaSet()) {
positions.add(new PositionVector(location.x, location.y)); positions.add(new PositionVector(location.x, location.y));
set = true;
} else { } else {
if (_startX <= location.x && location.x <= _endX && _startY <= location.y && location.y <= _endY) { if (_startX <= location.x && location.x <= _endX && _startY <= location.y && location.y <= _endY) {
set = true; set = true;
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab * Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
* *
* This file is part of PeerfactSim.KOM. * This file is part of PeerfactSim.KOM.
* *
* PeerfactSim.KOM is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* PeerfactSim.KOM is distributed in the hope that it will be useful, * PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>. * along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
* *
...@@ -48,12 +48,12 @@ import de.tudarmstadt.maki.simonstrator.api.component.topology.TopologyProvider; ...@@ -48,12 +48,12 @@ import de.tudarmstadt.maki.simonstrator.api.component.topology.TopologyProvider;
/** /**
* This class gives access to the hosts of the scenario. To work, it has to be * This class gives access to the hosts of the scenario. To work, it has to be
* referenced in the configuration file after the host builder. * referenced in the configuration file after the host builder.
* *
* The purpose of this class is to enable a global knowledge for analyzing. It * The purpose of this class is to enable a global knowledge for analyzing. It
* is not meant to be used within any functional parts of simulated systems. * is not meant to be used within any functional parts of simulated systems.
* *
* @author Julius Rueckert * @author Julius Rueckert
* *
*/ */
public class GlobalOracle implements OracleComponent { public class GlobalOracle implements OracleComponent {
...@@ -77,7 +77,7 @@ public class GlobalOracle implements OracleComponent { ...@@ -77,7 +77,7 @@ public class GlobalOracle implements OracleComponent {
/** /**
* Initial population with hosts. * Initial population with hosts.
* *
* @param hostBuilder * @param hostBuilder
*/ */
public static void populate(List<SimHost> allHosts) { public static void populate(List<SimHost> allHosts) {
...@@ -107,7 +107,7 @@ public class GlobalOracle implements OracleComponent { ...@@ -107,7 +107,7 @@ public class GlobalOracle implements OracleComponent {
/** /**
* Sets the bootstrap hosts. To be called by netLayer. * Sets the bootstrap hosts. To be called by netLayer.
* *
* @param bootstrapList * @param bootstrapList
* the new bootstrap hosts * the new bootstrap hosts
*/ */
...@@ -117,7 +117,7 @@ public class GlobalOracle implements OracleComponent { ...@@ -117,7 +117,7 @@ public class GlobalOracle implements OracleComponent {
/** /**
* Gets the bootstrap hosts. * Gets the bootstrap hosts.
* *
* @return the bootstrap hosts * @return the bootstrap hosts
*/ */
public static List<NetID> getBootstrapHosts() { public static List<NetID> getBootstrapHosts() {
...@@ -126,7 +126,7 @@ public class GlobalOracle implements OracleComponent { ...@@ -126,7 +126,7 @@ public class GlobalOracle implements OracleComponent {
/** /**
* Gets the random host. * Gets the random host.
* *
* @return the random host * @return the random host
*/ */
public static NetID getRandomHost() { public static NetID getRandomHost() {
...@@ -136,7 +136,7 @@ public class GlobalOracle implements OracleComponent { ...@@ -136,7 +136,7 @@ public class GlobalOracle implements OracleComponent {
/** /**
* Gets the first host. * Gets the first host.
* *
* @return the first host * @return the first host
*/ */
public static NetID getFirstHost() { public static NetID getFirstHost() {
...@@ -180,17 +180,22 @@ public class GlobalOracle implements OracleComponent { ...@@ -180,17 +180,22 @@ public class GlobalOracle implements OracleComponent {
return new ArrayList<Host>(hosts); return new ArrayList<Host>(hosts);
} }
@Override
public Host getHostByID(long pValue) {
return hostIDtoHosts.get(pValue);
}
@Override @Override
public boolean isSimulation() { public boolean isSimulation() {
return true; return true;
} }
/** /**
* Returns a global view of the topology for the specified mechanism. The * Returns a global view of the topology for the specified mechanism. The
* mechanism must be a HostComponent that is registered at the local host. * mechanism must be a HostComponent that is registered at the local host.
* Otherwise, this method will not be able to find the local mechanism * Otherwise, this method will not be able to find the local mechanism
* objects. * objects.
* *
* @param component * @param component
* @param identifier * @param identifier
* @return * @return
...@@ -239,17 +244,17 @@ public class GlobalOracle implements OracleComponent { ...@@ -239,17 +244,17 @@ public class GlobalOracle implements OracleComponent {
IEdge copy = graph.createEdge(edge.fromId(), edge.toId()); IEdge copy = graph.createEdge(edge.fromId(), edge.toId());
copy.addPropertiesFrom(edge); copy.addPropertiesFrom(edge);
} }
return graph; return graph;
} }
/** /**
* Returns available topology identifiers for the given component. Throws an * Returns available topology identifiers for the given component. Throws an
* {@link ComponentNotAvailableException} if the component is not available * {@link ComponentNotAvailableException} if the component is not available
* on any node in the network. Assumes that all instances of a given * on any node in the network. Assumes that all instances of a given
* component class provide the same topology identifiers. * component class provide the same topology identifiers.
* *
* @throws ComponentNotAvailableException * @throws ComponentNotAvailableException
*/ */
public static <T extends TopologyProvider> Iterable<TopologyID> getTopologyIdentifiers( public static <T extends TopologyProvider> Iterable<TopologyID> getTopologyIdentifiers(
Class<T> component) throws ComponentNotAvailableException { Class<T> component) throws ComponentNotAvailableException {
...@@ -269,16 +274,16 @@ public class GlobalOracle implements OracleComponent { ...@@ -269,16 +274,16 @@ public class GlobalOracle implements OracleComponent {
// in various scenarios // in various scenarios
} }
} }
throw new ComponentNotAvailableException(); throw new ComponentNotAvailableException();
} }
/** /**
* Checks whether the host with the given NetID is online using a global * Checks whether the host with the given NetID is online using a global
* list of all hosts in the current scenario. * list of all hosts in the current scenario.
* *
* @param receiver * @param receiver
* @return true if online * @return true if online
*/ */
......
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