Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
b4e2bf3d
Commit
b4e2bf3d
authored
Sep 27, 2017
by
Björn Richerzhagen
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Use SimulationObserver to close connection to SUMO
parent
ec43a6f9
Changes
1
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
b4e2bf3d
...
...
@@ -14,6 +14,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Random
;
import
de.tud.kom.p2psim.api.simengine.SimulatorObserver
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
...
...
@@ -46,7 +47,7 @@ import de.tudresden.ws.container.SumoPosition2D;
import
de.tudresden.ws.container.SumoStringList
;
import
it.polito.appeal.traci.SumoTraciConnection
;
public
class
TraciSimulationController
implements
VehicleController
,
SimulationSetupExtractor
,
EdgeController
{
public
class
TraciSimulationController
implements
VehicleController
,
SimulationSetupExtractor
,
EdgeController
,
SimulatorObserver
{
private
static
final
File
TEMP_FILE
=
new
File
(
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
)),
"road_network.tmp"
);
private
List
<
RoadNetworkEdge
>
modifiedEdges
=
new
ArrayList
<>();
...
...
@@ -129,15 +130,18 @@ public class TraciSimulationController implements VehicleController, SimulationS
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
shutdownHook
));
_initalized
=
true
;
Event
.
scheduleWithDelay
(
Simulator
.
getEndTime
()-
Simulator
.
getCurrentTime
(),
new
EventHandler
()
{
}
}
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
public
void
simulationFinished
()
{
/*
* This is called by the simulation scheduler once the simulation is
* finished - it should be used to terminate the connection to SUMO.
*/
if
(
_connection
!=
null
&&
!
_connection
.
isClosed
())
{
_connection
.
close
();
}
},
null
,
0
);
}
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment