Class SumoTraciConnection


  • public class SumoTraciConnection
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      SumoTraciConnection​(int remotePort)  
      SumoTraciConnection​(java.lang.String sumo_bin)  
      SumoTraciConnection​(java.lang.String configFile, int randomSeed, boolean useGeoOffset)  
      SumoTraciConnection​(java.lang.String sumo_bin, java.lang.String configFile)  
      SumoTraciConnection​(java.lang.String sumo_bin, java.lang.String net_file, java.lang.String route_file)  
      SumoTraciConnection​(java.lang.String sumo_bin, java.lang.String net_file, java.lang.String route_file, java.lang.String additional_file)  
      SumoTraciConnection​(java.lang.String sumo_bin, java.lang.String net_file, java.lang.String route_file, java.lang.String additional_file, java.lang.String gui_settings)  
      SumoTraciConnection​(java.net.SocketAddress sockAddr)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addObserver​(java.util.Observer o)  
      void addOption​(java.lang.String option, java.lang.String value)
      Adds a custom option to the SUMO command line before executing it.
      void close()
      Closes the connection, quits the simulator, frees any stale resource and makes all Vehicle instances inactive.
      java.lang.Object do_job_get​(SumoCommand cmd)  
      void do_job_set​(SumoCommand cmd)  
      void do_subscription​(Subscription cs)  
      void do_timestep()  
      void do_timestep​(double targetTime)  
      boolean isClosed()
      Returns true if the connection was closed by the user, or if an IOException was thrown after the connection was made.
      void printSumoError​(boolean b)  
      void printSumoOutput​(boolean b)  
      void runServer()
      Runs a SUMO instance and tries to connect at it.
      void runServer​(int _remotePort)
      Runs a SUMO instance and tries to connect at it.
      void setOrder​(int index)  
      • Methods inherited from class java.lang.Object

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

      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String sumo_bin)
      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String sumo_bin,
                                   java.lang.String net_file,
                                   java.lang.String route_file)
      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String sumo_bin,
                                   java.lang.String net_file,
                                   java.lang.String route_file,
                                   java.lang.String additional_file)
      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String sumo_bin,
                                   java.lang.String net_file,
                                   java.lang.String route_file,
                                   java.lang.String additional_file,
                                   java.lang.String gui_settings)
      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String sumo_bin,
                                   java.lang.String configFile)
      • SumoTraciConnection

        public SumoTraciConnection​(java.lang.String configFile,
                                   int randomSeed,
                                   boolean useGeoOffset)
      • SumoTraciConnection

        public SumoTraciConnection​(int remotePort)
                            throws java.io.IOException,
                                   java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • SumoTraciConnection

        public SumoTraciConnection​(java.net.SocketAddress sockAddr)
                            throws java.io.IOException,
                                   java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
    • Method Detail

      • addOption

        public void addOption​(java.lang.String option,
                              java.lang.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 java.io.IOException
        Runs a SUMO instance and tries to connect at it.
        Throws:
        java.io.IOException - if something wrong occurs while starting SUMO or connecting at it.
      • runServer

        public void runServer​(int _remotePort)
                       throws java.io.IOException
        Runs a SUMO instance and tries to connect at it.
        Throws:
        java.io.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:
        close()
      • do_job_set

        public void do_job_set​(SumoCommand cmd)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • do_job_get

        public java.lang.Object do_job_get​(SumoCommand cmd)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setOrder

        public void setOrder​(int index)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • do_timestep

        public void do_timestep()
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • do_timestep

        public void do_timestep​(double targetTime)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • addObserver

        public void addObserver​(java.util.Observer o)
      • do_subscription

        public void do_subscription​(Subscription cs)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • printSumoOutput

        public void printSumoOutput​(boolean b)
      • printSumoError

        public void printSumoError​(boolean b)