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
ConstructorsConstructorDescriptionSumoTraciConnection(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 TypeMethodDescriptionvoidAdds the observer.voidAdds a custom option to the SUMO command line before executing it.voidclose()Closes the connection, quits the simulator, frees any stale resource and makes all Vehicle instances inactive.do_job_get(SumoCommand cmd) Do job get.voiddo_job_set(SumoCommand cmd) Do job set.voidDo subscription.voidDo timestep.voiddo_timestep(double targetTime) Do timestep.booleanisClosed()Returnstrueif the connection was closed by the user, or if anIOExceptionwas thrown after the connection was made.voidprintSumoError(boolean b) Prints the sumo error.voidprintSumoOutput(boolean b) Prints the sumo output.voidRuns a SUMO instance and tries to connect at it.voidrunServer(int _remotePort) Runs a SUMO instance and tries to connect at it.voidsetOrder(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, ornullif 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()Returnstrueif the connection was closed by the user, or if anIOExceptionwas 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
-