forked from cmarini/NSE-Train-Control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulatorRunner.java
51 lines (41 loc) · 1.02 KB
/
SimulatorRunner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Simulator;
import CTC.CTCView;
import java.lang.Math;
public class SimulatorRunner
{
private static CTCView view;
private static Simulator s;
private static int clockRate = 60;
private static boolean isOpen;
public static void main(String[] args)
{
s = new Simulator();
view = new CTCView();
s.setView(view);
view.setSimulator(s);
isOpen = true;
while(isOpen)
{
int sleeptime = (int)(Math.ceil(clockRate/60.0));
s.run();
clockRate = view.getClockRate();
isOpen = view.getIsOpen();
sleep(sleeptime);
}
}
public static void sleep(long milliseconds)
{
Thread thread = new Thread();
try
{
thread.sleep(milliseconds);
}
catch (Exception e)
{
}
}
}