Package it.polito.appeal.traci
Class SumoTraciConnection
java.lang.Object
it.polito.appeal.traci.SumoTraciConnection
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
ConstructorDescriptionSumoTraciConnection
(int remotePort) Instantiates a new sumo traci connection.SumoTraciConnection
(String sumo_bin) Instantiates a new sumo traci connection.SumoTraciConnection
(String configFile, int randomSeed, boolean useGeoOffset) Instantiates a new sumo traci connection.SumoTraciConnection
(String sumo_bin, String configFile) Instantiates a new sumo traci connection.SumoTraciConnection
(String sumo_bin, String net_file, String route_file) Instantiates a new sumo traci connection.SumoTraciConnection
(String sumo_bin, String net_file, String route_file, String additional_file) Instantiates a new sumo traci connection.SumoTraciConnection
(String sumo_bin, String net_file, String route_file, String additional_file, String gui_settings) Instantiates a new sumo traci connection.SumoTraciConnection
(SocketAddress sockAddr) Instantiates a new sumo traci connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the observer.void
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.do_job_get
(SumoCommand cmd) Do job get.void
do_job_set
(SumoCommand cmd) Do job set.void
Do subscription.void
Do timestep.void
do_timestep
(double targetTime) Do timestep.boolean
isClosed()
Returnstrue
if the connection was closed by the user, or if anIOException
was thrown after the connection was made.void
printSumoError
(boolean b) Prints the sumo error.void
printSumoOutput
(boolean b) Prints the sumo output.void
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) Sets the order.
-
Constructor Details
-
SumoTraciConnection
Instantiates a new sumo traci connection.- Parameters:
sumo_bin
- the sumo bin
-
SumoTraciConnection
Instantiates a new sumo traci connection.- Parameters:
sumo_bin
- the sumo binnet_file
- the net fileroute_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 binnet_file
- the net fileroute_file
- the route fileadditional_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 binnet_file
- the net fileroute_file
- the route fileadditional_file
- the additional filegui_settings
- the gui settings
-
SumoTraciConnection
Instantiates a new sumo traci connection.- Parameters:
sumo_bin
- the sumo binconfigFile
- the config file
-
SumoTraciConnection
Instantiates a new sumo traci connection.- Parameters:
configFile
- the config filerandomSeed
- the random seeduseGeoOffset
- the use geo offset
-
SumoTraciConnection
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
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
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 dashesvalue
- the option value, ornull
if the option has no value
-
runServer
Runs a SUMO instance and tries to connect at it.- Throws:
IOException
- if something wrong occurs while starting SUMO or connecting at it.
-
runServer
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()Returnstrue
if the connection was closed by the user, or if anIOException
was thrown after the connection was made.- Returns:
- boolean
- See Also:
-
do_job_set
Do job set.- Parameters:
cmd
- the cmd- Throws:
Exception
- the exception
-
do_job_get
Do job get.- Parameters:
cmd
- the cmd- Returns:
- the object
- Throws:
Exception
- the exception
-
setOrder
Sets the order.- Parameters:
index
- the new order- Throws:
Exception
- the exception
-
do_timestep
Do timestep.- Throws:
Exception
- the exception
-
do_timestep
Do timestep.- Parameters:
targetTime
- the target time- Throws:
Exception
- the exception
-
addObserver
Adds the observer.- Parameters:
o
- the o
-
do_subscription
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
-