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
SumoCommand netBoundaryCommand = Simulation.getNetBoundary();
try {
SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand);
return Math.max(netBoundary.x_max - netBoundary.x_min, 10);
SumoBoundingBox netBoundary = (SumoBoundingBox) _connection.do_job_get(netBoundaryCommand);
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) {
//Nothing to do
}
......@@ -553,7 +557,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
try {
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) {
//Nothing to do
}
......@@ -814,6 +822,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
for (SumoPosition2D location : geometry.coords) {
if (!isObservedAreaSet()) {
positions.add(new PositionVector(location.x, location.y));
set = true;
} else {
if (_startX <= location.x && location.x <= _endX && _startY <= location.y && location.y <= _endY) {
set = true;
......
......@@ -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/>.
*
......@@ -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
* referenced in the configuration file after the host builder.
*
*
* 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.
*
*
* @author Julius Rueckert
*
*
*/
public class GlobalOracle implements OracleComponent {
......@@ -77,7 +77,7 @@ public class GlobalOracle implements OracleComponent {
/**
* Initial population with hosts.
*
*
* @param hostBuilder
*/
public static void populate(List<SimHost> allHosts) {
......@@ -107,7 +107,7 @@ public class GlobalOracle implements OracleComponent {
/**
* Sets the bootstrap hosts. To be called by netLayer.
*
*
* @param bootstrapList
* the new bootstrap hosts
*/
......@@ -117,7 +117,7 @@ public class GlobalOracle implements OracleComponent {
/**
* Gets the bootstrap hosts.
*
*
* @return the bootstrap hosts
*/
public static List<NetID> getBootstrapHosts() {
......@@ -126,7 +126,7 @@ public class GlobalOracle implements OracleComponent {
/**
* Gets the random host.
*
*
* @return the random host
*/
public static NetID getRandomHost() {
......@@ -136,7 +136,7 @@ public class GlobalOracle implements OracleComponent {
/**
* Gets the first host.
*
*
* @return the first host
*/
public static NetID getFirstHost() {
......@@ -180,17 +180,22 @@ public class GlobalOracle implements OracleComponent {
return new ArrayList<Host>(hosts);
}
@Override
public Host getHostByID(long pValue) {
return hostIDtoHosts.get(pValue);
}
@Override
public boolean isSimulation() {
return true;
}
/**
* Returns a global view of the topology for the specified mechanism. The
* mechanism must be a HostComponent that is registered at the local host.
* Otherwise, this method will not be able to find the local mechanism
* objects.
*
*
* @param component
* @param identifier
* @return
......@@ -239,17 +244,17 @@ public class GlobalOracle implements OracleComponent {
IEdge copy = graph.createEdge(edge.fromId(), edge.toId());
copy.addPropertiesFrom(edge);
}
return graph;
}
/**
* Returns available topology identifiers for the given component. Throws an
* {@link ComponentNotAvailableException} if the component is not available
* on any node in the network. Assumes that all instances of a given
* component class provide the same topology identifiers.
*
* @throws ComponentNotAvailableException
*
* @throws ComponentNotAvailableException
*/
public static <T extends TopologyProvider> Iterable<TopologyID> getTopologyIdentifiers(
Class<T> component) throws ComponentNotAvailableException {
......@@ -269,16 +274,16 @@ public class GlobalOracle implements OracleComponent {
// in various scenarios
}
}
throw new ComponentNotAvailableException();
}
/**
* Checks whether the host with the given NetID is online using a global
* list of all hosts in the current scenario.
*
*
* @param receiver
* @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