|
|
|
@ -25,7 +25,7 @@ public abstract class Race implements Runnable {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
private int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
|
|
|
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
|
|
|
private boolean timerEnabled = true;
|
|
|
|
private boolean timerEnabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -80,7 +80,7 @@ public abstract class Race implements Runnable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void countdownTimer() {
|
|
|
|
protected void countdownTimer() {
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
long startTime = currentTime + PRERACE_TIME;
|
|
|
|
long startTime = currentTime + PRERACE_TIME;
|
|
|
|
long minutes;
|
|
|
|
long minutes;
|
|
|
|
@ -97,7 +97,9 @@ public abstract class Race implements Runnable {
|
|
|
|
remainingSeconds = currentTimeInSeconds % 60;
|
|
|
|
remainingSeconds = currentTimeInSeconds % 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
minutes = minutes % 60;
|
|
|
|
minutes = minutes % 60;
|
|
|
|
updateTime(String.format("Time until race starts: %02d:%02d:%02d", hours, minutes, remainingSeconds));
|
|
|
|
if (controller != null) {
|
|
|
|
|
|
|
|
updateTime(String.format("Time until race starts: %02d:%02d:%02d", hours, minutes, remainingSeconds));
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
timeLoopEnded = System.currentTimeMillis();
|
|
|
|
timeLoopEnded = System.currentTimeMillis();
|
|
|
|
Thread.sleep(SLEEP_TIME - (timeLoopEnded - currentTime));
|
|
|
|
Thread.sleep(SLEEP_TIME - (timeLoopEnded - currentTime));
|
|
|
|
@ -108,7 +110,7 @@ public abstract class Race implements Runnable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String calcTimer() {
|
|
|
|
protected String calcTimer() {
|
|
|
|
long minutes;
|
|
|
|
long minutes;
|
|
|
|
long currentTimeInSeconds;
|
|
|
|
long currentTimeInSeconds;
|
|
|
|
long remainingSeconds;
|
|
|
|
long remainingSeconds;
|
|
|
|
@ -122,7 +124,7 @@ public abstract class Race implements Runnable {
|
|
|
|
return String.format("Race clock: %02d:%02d:%02d", hours, minutes, remainingSeconds);
|
|
|
|
return String.format("Race clock: %02d:%02d:%02d", hours, minutes, remainingSeconds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateTime(String time){
|
|
|
|
protected void updateTime(String time){
|
|
|
|
|
|
|
|
|
|
|
|
Platform.runLater(() -> {controller.setTimer(time);});
|
|
|
|
Platform.runLater(() -> {controller.setTimer(time);});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|