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

Adding speed control methods

parent 17c5d7d6
......@@ -52,4 +52,8 @@ public class VehicleInformationContainer {
public RoadNetworkRoute getRoute() {
return _route;
}
public void setSpeed(double vehicleSpeed) {
_speed = vehicleSpeed;
}
}
\ No newline at end of file
......@@ -246,7 +246,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
public String getVehicleType(String pVehicleID) {
String vehicleType = "private";
String vehicleType = "default";
SumoCommand typeCommand = Vehicle.getTypeID(pVehicleID);
......@@ -259,6 +259,12 @@ public class TraciSimulationController implements VehicleController, SimulationS
return vehicleType;
}
@Override
public void setVehicleSpeed(String pVehicleID, double pVehicleSpeed) {
SumoCommand typeCommand = Vehicle.setSpeed(pVehicleID, pVehicleSpeed);
execute(typeCommand);
}
private Location requestVehiclePosition(String pVehicleID) {
if (_vehiclesOutOfRange.containsKey(pVehicleID)) {
if (_vehiclesOutOfRange.get(pVehicleID) < _step) {
......@@ -296,7 +302,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
double timeTillNextJoin = diff / 50;
// _vehiclesOutOfRange.put(pVehicleID, _step + timeTillNextJoin);
//_vehiclesOutOfRange.put(pVehicleID, _step + timeTillNextJoin);
return null;
}
......
......@@ -210,6 +210,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
return null;
}
@Override
public void setVehicleSpeed(String pVehicleID, double pVehicleSpeed) {
_vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID).setSpeed(pVehicleSpeed);
}
@Override
public double getVehicleSpeed(String pVehicleID) {
return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID).getSpeed();
......
......@@ -124,6 +124,21 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
vehicleID = pVehicleID;
}
@Override
public String getVehicleID() {
return vehicleID;
}
@Override
public String getVehicleType() {
return controller.getVehicleType(vehicleID);
}
@Override
public void setVehicleSpeed(String vehicleID, double vehicleSpeed) {
controller.setVehicleSpeed(vehicleID, vehicleSpeed);
}
@Override
public void resetVehicleID() {
vehicleID = null;
......
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