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