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
f419b5c2
Commit
f419b5c2
authored
Sep 27, 2017
by
Björn Richerzhagen
Browse files
Use SimulationObserver to close connection to SUMO
parent
1f68e52b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
f419b5c2
...
@@ -14,6 +14,7 @@ import java.util.List;
...
@@ -14,6 +14,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
import
de.tud.kom.p2psim.api.simengine.SimulatorObserver
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
...
@@ -46,7 +47,7 @@ import de.tudresden.ws.container.SumoPosition2D;
...
@@ -46,7 +47,7 @@ import de.tudresden.ws.container.SumoPosition2D;
import
de.tudresden.ws.container.SumoStringList
;
import
de.tudresden.ws.container.SumoStringList
;
import
it.polito.appeal.traci.SumoTraciConnection
;
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
static
final
File
TEMP_FILE
=
new
File
(
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
)),
"road_network.tmp"
);
private
List
<
RoadNetworkEdge
>
modifiedEdges
=
new
ArrayList
<>();
private
List
<
RoadNetworkEdge
>
modifiedEdges
=
new
ArrayList
<>();
...
@@ -129,14 +130,17 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -129,14 +130,17 @@ public class TraciSimulationController implements VehicleController, SimulationS
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
shutdownHook
));
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
shutdownHook
));
_initalized
=
true
;
_initalized
=
true
;
}
Event
.
scheduleWithDelay
(
Simulator
.
getEndTime
()-
Simulator
.
getCurrentTime
(),
new
EventHandler
()
{
}
@Override
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
public
void
simulationFinished
()
{
_connection
.
close
();
/*
}
* This is called by the simulation scheduler once the simulation is
},
null
,
0
);
* finished - it should be used to terminate the connection to SUMO.
*/
if
(
_connection
!=
null
&&
!
_connection
.
isClosed
())
{
_connection
.
close
();
}
}
}
}
...
...
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