Commit 5c1198c6 authored by jimonreal's avatar jimonreal Committed by Jose Ignacio Monreal Bailey
Browse files

Stopping simulation when there is no vehicle

parent fee642a0
......@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Random;
import de.tud.kom.p2psim.impl.util.Summary;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SUMOController;
import org.apache.commons.math.random.JDKRandomGenerator;
import org.apache.commons.math.random.RandomGenerator;
......@@ -552,4 +553,8 @@ public class Simulator implements RandomGeneratorComponent, GlobalComponent {
public void addObserver(SimulatorObserver observer) {
observers.add(observer);
}
public void setRunning(boolean b) {
this.running = b;
}
}
......@@ -16,10 +16,7 @@ import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.TrafficLightController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.*;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.LocationUtils;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.*;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoAdditionalRouteAvailableException;
......@@ -1196,4 +1193,13 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
return false;
}
@Override
public int getMinExpectedNumber() {
SumoCommand simulationCommand = Simulation.getMinExpectedNumber();
Object objectSimulation = requestObject(simulationCommand);
int expectedNumber = (int) objectSimulation;
return expectedNumber;
}
}
......@@ -93,6 +93,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
return false;
}
@Override
public int getMinExpectedNumber() {
return 0;
}
@Override
public Location getVehiclePosition(String pVehicleID) {
return getVehiclePosition(_step, pVehicleID);
......
......@@ -120,6 +120,10 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
}
}
public VehicleController getController() {
return controller;
}
@Override
public void setVehicleID(String pVehicleID) {
vehicleID = pVehicleID;
......
......@@ -37,6 +37,10 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
return numberOfMessagesSent;
}
public TrafficLightController getController() {
return controller;
}
@Override
public void setTrafficLightId(String pTrafficLightId) {
trafficLightId = pTrafficLightId;
......@@ -152,6 +156,11 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
return controller.getVehicleMaxSpeed(vehicleId);
}
@Override
public int getMinExpectedNumber() {
return controller.getMinExpectedNumber();
}
@Override
public void initialize() {
......
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