1 | package de.uka.ipd.sdq.simulation.abstractsimengine.ssj; |
2 | |
3 | import umontreal.iro.lecuyer.simevents.Event; |
4 | import umontreal.iro.lecuyer.simevents.Simulator; |
5 | import umontreal.iro.lecuyer.simevents.eventlist.SplayTree; |
6 | import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractExperiment; |
7 | |
8 | /** |
9 | * @author Steffen Becker |
10 | * @author Philipp Merkle |
11 | */ |
12 | public class SSJExperiment extends AbstractExperiment { |
13 | |
14 | private final Simulator simulator; |
15 | |
16 | public SSJExperiment(final SSJModel model) { |
17 | super(model); |
18 | |
19 | this.simulator = new Simulator(); |
20 | this.simulator.init(new SplayTree()); |
21 | |
22 | this.scheduleEvent(this.CHECK_EVENT, 1); |
23 | } |
24 | |
25 | public double getCurrentSimulationTime() { |
26 | return this.simulator.time(); |
27 | } |
28 | |
29 | public Simulator getSimulator() { |
30 | return this.simulator; |
31 | } |
32 | |
33 | @Override |
34 | public void scheduleEvent(final IEvent event, final double delay) { |
35 | new Event(this.simulator) { |
36 | @Override |
37 | public void actions() { |
38 | event.run(); |
39 | } |
40 | }.schedule(delay); |
41 | } |
42 | |
43 | @Override |
44 | public void startSimulator() { |
45 | this.simulator.start(); |
46 | } |
47 | |
48 | @Override |
49 | public void stopSimulator() { |
50 | this.simulator.stop(); |
51 | } |
52 | |
53 | } |