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

Made RoadNetwork accessable from Applications via VehicleMovementModel

parent 1024f054
......@@ -54,6 +54,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInformationProvider
import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class VehicleMovementModel implements MovementModel, EventHandler, FutureLocationSensor {
......@@ -379,17 +380,17 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
if (!idComponentMatcher.containsKey(vehicle)) {
SimLocationActuator simLocationActuator = freeComponents.poll();
VehicleInformationComponent vehicularHostComponent;
try {
vehicularHostComponent = simLocationActuator.getHost().getComponent(VehicleInformationComponent.class);
} catch (ComponentNotAvailableException e) {
Host host = simLocationActuator.getHost();
vehicularHostComponent = new DefaultVehicleInformationComponent(host, _controller, _extractor);
host.registerComponent(vehicularHostComponent);
}
vehicularHostComponent.setVehicleID(vehicle);
if (simLocationActuator != null) {
VehicleInformationComponent vehicularHostComponent;
try {
vehicularHostComponent = simLocationActuator.getHost().getComponent(VehicleInformationComponent.class);
} catch (ComponentNotAvailableException e) {
Host host = simLocationActuator.getHost();
vehicularHostComponent = new DefaultVehicleInformationComponent(host, _controller, _extractor);
host.registerComponent(vehicularHostComponent);
}
vehicularHostComponent.setVehicleID(vehicle);
idComponentMatcher.put(vehicle, simLocationActuator);
hostVehicleIDMatching.put(simLocationActuator.getHost().getId(), vehicle);
} else {
......@@ -399,6 +400,10 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
return idComponentMatcher.get(vehicle);
}
public RoadNetwork getRoadNetwork() {
return _extractor.getRoadNetwork();
}
/**
* Returns the future location of a certain host.
* @param pHost The host for which the location is being requested.
......
......@@ -3,6 +3,7 @@ package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.contr
import java.util.List;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.information.Position;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
public interface SimulationSetupExtractor {
......@@ -14,5 +15,5 @@ public interface SimulationSetupExtractor {
double getScenarioWidth();
double getScenarioHeight();
// RoadNetwork getScenarioRoadNetwork();
RoadNetwork getRoadNetwork();
}
......@@ -407,6 +407,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
return roadNetworkRoute.getDestination();
}
@Override
public RoadNetwork getRoadNetwork() {
obtainRoadNetwork();
......
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