Class SumoTraciConnection

java.lang.Object
it.polito.appeal.traci.SumoTraciConnection

public class SumoTraciConnection extends Object
Models a TCP/IP connection to a local or remote SUMO server via the TraCI protocol.
Author:
Enrico Gueli <enrico.gueli@gmail.com>, Mario Krumnow
  • Constructor Details

    • SumoTraciConnection

      public SumoTraciConnection(String sumo_bin)
      Instantiates a new sumo traci connection.
      Parameters:
      sumo_bin - the sumo bin
    • SumoTraciConnection

      public SumoTraciConnection(String sumo_bin, String net_file, String route_file)
      Instantiates a new sumo traci connection.
      Parameters:
      sumo_bin - the sumo bin
      net_file - the net file
      route_file - the route file
    • SumoTraciConnection

      public SumoTraciConnection(String sumo_bin, String net_file, String route_file, String additional_file)
      Instantiates a new sumo traci connection.
      Parameters:
      sumo_bin - the sumo bin
      net_file - the net file
      route_file - the route file
      additional_file - the additional file
    • SumoTraciConnection

      public SumoTraciConnection(String sumo_bin, String net_file, String route_file, String additional_file, String gui_settings)
      Instantiates a new sumo traci connection.
      Parameters:
      sumo_bin - the sumo bin
      net_file - the net file
      route_file - the route file
      additional_file - the additional file
      gui_settings - the gui settings
    • SumoTraciConnection

      public SumoTraciConnection(String sumo_bin, String configFile)
      Instantiates a new sumo traci connection.
      Parameters:
      sumo_bin - the sumo bin
      configFile - the config file
    • SumoTraciConnection

      public SumoTraciConnection(String configFile, int randomSeed, boolean useGeoOffset)
      Instantiates a new sumo traci connection.
      Parameters:
      configFile - the config file
      randomSeed - the random seed
      useGeoOffset - the use geo offset
    • SumoTraciConnection

      public SumoTraciConnection(int remotePort) throws IOException, InterruptedException
      Instantiates a new sumo traci connection.
      Parameters:
      remotePort - the remote port
      Throws:
      IOException - Signals that an I/O exception has occurred.
      InterruptedException - the interrupted exception
    • SumoTraciConnection

      public SumoTraciConnection(SocketAddress sockAddr) throws IOException, InterruptedException
      Instantiates a new sumo traci connection.
      Parameters:
      sockAddr - the sock addr
      Throws:
      IOException - Signals that an I/O exception has occurred.
      InterruptedException - the interrupted exception
  • Method Details

    • addOption

      public void addOption(String option, String value)
      Adds a custom option to the SUMO command line before executing it.
      Parameters:
      option - the option name, in long form (e.g. "no-warnings" instead of "W") and without initial dashes
      value - the option value, or null if the option has no value
    • runServer

      public void runServer() throws IOException
      Runs a SUMO instance and tries to connect at it.
      Throws:
      IOException - if something wrong occurs while starting SUMO or connecting at it.
    • runServer

      public void runServer(int _remotePort) throws IOException
      Runs a SUMO instance and tries to connect at it.
      Parameters:
      _remotePort - the remote port
      Throws:
      IOException - if something wrong occurs while starting SUMO or connecting at it.
    • close

      public void close()
      Closes the connection, quits the simulator, frees any stale resource and makes all Vehicle instances inactive.
    • isClosed

      public boolean isClosed()
      Returns true if the connection was closed by the user, or if an IOException was thrown after the connection was made.
      Returns:
      boolean
      See Also:
    • do_job_set

      public void do_job_set(SumoCommand cmd) throws Exception
      Do job set.
      Parameters:
      cmd - the cmd
      Throws:
      Exception - the exception
    • do_job_get

      public Object do_job_get(SumoCommand cmd) throws Exception
      Do job get.
      Parameters:
      cmd - the cmd
      Returns:
      the object
      Throws:
      Exception - the exception
    • setOrder

      public void setOrder(int index) throws Exception
      Sets the order.
      Parameters:
      index - the new order
      Throws:
      Exception - the exception
    • do_timestep

      public void do_timestep() throws Exception
      Do timestep.
      Throws:
      Exception - the exception
    • do_timestep

      public void do_timestep(double targetTime) throws Exception
      Do timestep.
      Parameters:
      targetTime - the target time
      Throws:
      Exception - the exception
    • addObserver

      public void addObserver(Observer o)
      Adds the observer.
      Parameters:
      o - the o
    • do_subscription

      public void do_subscription(Subscription cs) throws Exception
      Do subscription.
      Parameters:
      cs - the cs
      Throws:
      Exception - the exception
    • printSumoOutput

      public void printSumoOutput(boolean b)
      Prints the sumo output.
      Parameters:
      b - the b
    • printSumoError

      public void printSumoError(boolean b)
      Prints the sumo error.
      Parameters:
      b - the b