Class VehicleManager

java.lang.Object
real_time_traffic_simulation_with_java.wrapper.VehicleManager

public class VehicleManager extends Object
Wrapper class for TraaS to manage vehicles in the simulation
  • Constructor Summary

    Constructors
    Constructor
    Description
    VehicleManager(it.polito.appeal.traci.SumoTraciConnection connection)
    Wrapper class for TraaS to manage vehicles in the simulation
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String vehID, String routeID, String color, String speed_in_ms)
    Inject a vehicle of default type into the simulation immediately if possible when called Generate a new route with a unique ID = vehicleID from start_edges to end_edges Set the color of the vehicle as user's choice, default to WHITE if invalid color string is given
    double
    getAngle(String vehicleID)
    Get angle of a vehicle (degree), starting from the North (0 degree) and measured clockwise
    de.tudresden.sumo.objects.SumoColor
    getColor(String vehicleID)
    Get color of a vehicle
    int
    Get number of running vehicles, vehicles finished route or not yet be injected are not included
    getEdgeID(String vehicleID)
    Get edge ID that the vehicle is currently on, including junction edges
    Get list of filtered running vehicle IDs, vehicles finished route or not yet be injected are not included
    Get list of running vehicle IDs, vehicles finished route or not yet be injected are not included
    getLaneID(String vehicleID)
    Get lane ID that the vehicle is currently on, including junction lanes
    de.tudresden.sumo.objects.SumoPosition2D
    getPosition(String vehicleID)
    Get position of a vehicle in Cartesian coordinates
    double
    getSpeed(String vehicleID)
    Get speed of a vehicle (km/h)
    Create and get a List of VehicleData for all vehicles
    void
    setColor(String vehicleID, de.tudresden.sumo.objects.SumoColor color)
    Set color of a vehicle
    void
    setFilter(String color, String edge)
    Set filter for vehicles (color, edge)

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VehicleManager

      public VehicleManager(it.polito.appeal.traci.SumoTraciConnection connection)
      Wrapper class for TraaS to manage vehicles in the simulation
      Parameters:
      connection - connection to Sumo
  • Method Details

    • setFilter

      public void setFilter(String color, String edge)
      Set filter for vehicles (color, edge)
    • getIDList

      public List<String> getIDList() throws Exception
      Get list of running vehicle IDs, vehicles finished route or not yet be injected are not included
      Returns:
      a List type String of running vehicle IDs
      Throws:
      Exception
    • getFilteredIDList

      public List<String> getFilteredIDList() throws Exception
      Get list of filtered running vehicle IDs, vehicles finished route or not yet be injected are not included
      Returns:
      a List type String of filtered running vehicle IDs
      Throws:
      Exception
    • getCount

      public int getCount()
      Get number of running vehicles, vehicles finished route or not yet be injected are not included
      Returns:
      an int number of running vehicles
    • getPosition

      public de.tudresden.sumo.objects.SumoPosition2D getPosition(String vehicleID) throws Exception
      Get position of a vehicle in Cartesian coordinates
      Parameters:
      vehicleID - ID of the vehicle
      Returns:
      a SumoPosition2D object representing the position of the vehicle
      Throws:
      Exception
    • getLaneID

      public String getLaneID(String vehicleID) throws Exception
      Get lane ID that the vehicle is currently on, including junction lanes
      Returns:
      a String lane ID that the vehicle is currently on
      Throws:
      Exception
    • getEdgeID

      public String getEdgeID(String vehicleID) throws Exception
      Get edge ID that the vehicle is currently on, including junction edges
      Parameters:
      vehicleID - ID of the vehicle
      Returns:
      a String edge ID that the vehicle is currently on
      Throws:
      Exception
    • getSpeed

      public double getSpeed(String vehicleID)
      Get speed of a vehicle (km/h)
      Parameters:
      vehicleID - ID of the vehicle
      Returns:
      a double speed of the vehicle (km/h)
    • getAngle

      public double getAngle(String vehicleID)
      Get angle of a vehicle (degree), starting from the North (0 degree) and measured clockwise
      Parameters:
      vehicleID - ID of the vehicle
      Returns:
      a double angle of the vehicle (degree)
    • setColor

      public void setColor(String vehicleID, de.tudresden.sumo.objects.SumoColor color)
      Set color of a vehicle
      Parameters:
      vehicleID - ID of the vehicle
      color - SumoColor object representing the color to be set
    • getColor

      public de.tudresden.sumo.objects.SumoColor getColor(String vehicleID) throws Exception
      Get color of a vehicle
      Parameters:
      vehicleID - ID of the vehicle
      Returns:
      a SumoColor object representing the color of the vehicle
      Throws:
      Exception
    • add

      public void add(String vehID, String routeID, String color, String speed_in_ms)
      Inject a vehicle of default type into the simulation immediately if possible when called Generate a new route with a unique ID = vehicleID from start_edges to end_edges Set the color of the vehicle as user's choice, default to WHITE if invalid color string is given
      Parameters:
      vehID - ID of the vehicle
      routeID - ID of the route
      color - String representing the color of the vehicle
    • getVehicleDataList

      public List<VehicleData> getVehicleDataList() throws Exception
      Create and get a List of VehicleData for all vehicles
      Returns:
      a List of VehicleData for all vehicles
      Throws:
      Exception