Commit 92b88c53 authored by Jose Ignacio Monreal Bailey's avatar Jose Ignacio Monreal Bailey
Browse files

Adding method to check that the traffic light id is a valid traffic light

parent 7e29528b
...@@ -329,6 +329,24 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -329,6 +329,24 @@ public class TraciSimulationController implements VehicleController, SimulationS
execute(definitionCommand); execute(definitionCommand);
} }
@Override
public boolean isValidTrafficLightId(String nextTL) {
boolean isValid = false;
SumoCommand trafficLightCommand = Trafficlight.getIDList();
Object object = requestObject(trafficLightCommand);
SumoStringList trafficLightList = (SumoStringList)object;
for (String trafficLightId : trafficLightList) {
if (trafficLightId.equalsIgnoreCase(nextTL)) {
isValid = true;
break;
}
}
return isValid;
}
@Override @Override
public String getDefinition(String trafficLightId) { public String getDefinition(String trafficLightId) {
SumoCommand definitionCommand = Trafficlight.getCompleteRedYellowGreenDefinition(trafficLightId); SumoCommand definitionCommand = Trafficlight.getCompleteRedYellowGreenDefinition(trafficLightId);
......
package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml; package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.csv.RoadSideUnitInformationHandler; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.csv.RoadSideUnitInformationHandler;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
...@@ -24,6 +14,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.traf ...@@ -24,6 +14,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.traf
import de.tudresden.ws.container.SumoTLSController; import de.tudresden.ws.container.SumoTLSController;
import de.tudresden.ws.container.SumoTLSProgram; import de.tudresden.ws.container.SumoTLSProgram;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.FileInputStream;
import java.util.*;
public class XMLSimulationController implements VehicleController, SimulationSetupExtractor, Runnable, TrafficLightController { public class XMLSimulationController implements VehicleController, SimulationSetupExtractor, Runnable, TrafficLightController {
private String _vehicleDataPath; private String _vehicleDataPath;
private String _roadSideUnitDataPath; private String _roadSideUnitDataPath;
...@@ -120,6 +115,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -120,6 +115,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
} }
@Override
public boolean isValidTrafficLightId(String nextTL) {
return false;
}
public VehicleInformationContainer requestVehicleInformation(String pVehicleID) { public VehicleInformationContainer requestVehicleInformation(String pVehicleID) {
return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID); return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID);
} }
......
...@@ -173,6 +173,11 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo ...@@ -173,6 +173,11 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
controller.setCompleteRedYellowGreenDefinition(trafficLightId, sumoTLSProgram); controller.setCompleteRedYellowGreenDefinition(trafficLightId, sumoTLSProgram);
} }
@Override
public boolean isValidTrafficLightId(String nextTL) {
return controller.isValidTrafficLightId(nextTL);
}
@Override @Override
public void initialize() { 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