|
|
|
@ -22,6 +22,8 @@ import java.net.Socket;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,14 +43,14 @@ public class StartController extends Controller implements Observer {
|
|
|
|
@FXML private Label timeZoneTime;
|
|
|
|
@FXML private Label timeZoneTime;
|
|
|
|
@FXML private Label timer;
|
|
|
|
@FXML private Label timer;
|
|
|
|
@FXML private Label raceStatusLabel;
|
|
|
|
@FXML private Label raceStatusLabel;
|
|
|
|
@FXML private int PRERACE_TIME = 10;
|
|
|
|
|
|
|
|
|
|
|
|
private ZonedDateTime startingTime;
|
|
|
|
|
|
|
|
|
|
|
|
//@FXML Button fifteenMinButton;
|
|
|
|
//@FXML Button fifteenMinButton;
|
|
|
|
|
|
|
|
|
|
|
|
private RaceClock raceClock;
|
|
|
|
private RaceClock raceClock;
|
|
|
|
|
|
|
|
|
|
|
|
private StreamedCourse raceData;
|
|
|
|
private StreamedCourse raceData;
|
|
|
|
private long timeLeft = 1;
|
|
|
|
|
|
|
|
private int raceStat;
|
|
|
|
private int raceStat;
|
|
|
|
|
|
|
|
|
|
|
|
private VisualiserInput visualiserInput;
|
|
|
|
private VisualiserInput visualiserInput;
|
|
|
|
@ -86,47 +88,21 @@ public class StartController extends Controller implements Observer {
|
|
|
|
boatCodeColumn.setCellValueFactory(new PropertyValueFactory<>("abbrev"));
|
|
|
|
boatCodeColumn.setCellValueFactory(new PropertyValueFactory<>("abbrev"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Updates the calculated time to the timer label
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param time The calculated time from calcTimer() method
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected void updateTime(String time) {
|
|
|
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
|
|
|
timer.setText(time);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Countdown timer until race starts.
|
|
|
|
* Countdown timer until race starts.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected void countdownTimer() {
|
|
|
|
protected void countdownTimer() {
|
|
|
|
new AnimationTimer() {
|
|
|
|
new AnimationTimer() {
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
long startTime = currentTime + PRERACE_TIME;
|
|
|
|
|
|
|
|
DateFormat timerFormat = new SimpleDateFormat("'Race Clock:' -HH:mm:ss");
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void handle(long arg0) {
|
|
|
|
public void handle(long arg0) {
|
|
|
|
System.out.println(raceStat);
|
|
|
|
|
|
|
|
timeLeft = startTime - currentTime;
|
|
|
|
|
|
|
|
raceStat = visualiserInput.getRaceStatus().getRaceStatus();
|
|
|
|
raceStat = visualiserInput.getRaceStatus().getRaceStatus();
|
|
|
|
raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus());
|
|
|
|
raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus());
|
|
|
|
if (raceStat==2 || raceStat == 3) {
|
|
|
|
if (raceStat==2 || raceStat == 3) {
|
|
|
|
updateTime("Race is starting...");
|
|
|
|
|
|
|
|
stop();
|
|
|
|
stop();
|
|
|
|
parent.beginRace(visualiserInput);
|
|
|
|
parent.beginRace(visualiserInput, raceClock);
|
|
|
|
startWrapper.setVisible(false);
|
|
|
|
startWrapper.setVisible(false);
|
|
|
|
start.setVisible(false);
|
|
|
|
start.setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (raceStat==4 || raceStat==8) {
|
|
|
|
|
|
|
|
updateTime("Race has ended. Waiting for next race.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (raceStat==10 || raceStat==1){
|
|
|
|
|
|
|
|
updateTime(timerFormat.format(currentTime));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -134,26 +110,22 @@ public class StartController extends Controller implements Observer {
|
|
|
|
private void setRaceClock() {
|
|
|
|
private void setRaceClock() {
|
|
|
|
raceClock = new RaceClock(raceData.getZonedDateTime());
|
|
|
|
raceClock = new RaceClock(raceData.getZonedDateTime());
|
|
|
|
timeZoneTime.textProperty().bind(raceClock.timeStringProperty());
|
|
|
|
timeZoneTime.textProperty().bind(raceClock.timeStringProperty());
|
|
|
|
|
|
|
|
raceClock.run();
|
|
|
|
new AnimationTimer() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long arg0) {
|
|
|
|
|
|
|
|
raceClock.updateTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setStartingTime() {
|
|
|
|
private void setStartingTime() {
|
|
|
|
String dateFormat = "'Starting time:' HH:mm dd/MM/YYYY";
|
|
|
|
String dateFormat = "'Starting time:' HH:mm dd/MM/YYYY";
|
|
|
|
Platform.runLater(()-> {
|
|
|
|
Platform.runLater(()-> {
|
|
|
|
long utcTime = visualiserInput.getRaceStatus().getExpectedStartTime();
|
|
|
|
long utcTime = visualiserInput.getRaceStatus().getExpectedStartTime();
|
|
|
|
raceStartLabel.setText(DateTimeFormatter.ofPattern(dateFormat).format(raceClock.getLocalTime(utcTime)));
|
|
|
|
raceClock.setStartingTime(raceClock.getLocalTime(utcTime));
|
|
|
|
|
|
|
|
raceStartLabel.setText(DateTimeFormatter.ofPattern(dateFormat).format(raceClock.getStartingTime()));
|
|
|
|
|
|
|
|
timer.textProperty().bind(raceClock.durationProperty());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setCurrentTime() {
|
|
|
|
private void setCurrentTime() {
|
|
|
|
Platform.runLater(()->
|
|
|
|
Platform.runLater(()->
|
|
|
|
raceClock.setTime(raceClock.getLocalTime(visualiserInput.getRaceStatus().getCurrentTime()))
|
|
|
|
raceClock.setUTCTime(visualiserInput.getRaceStatus().getCurrentTime())
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -168,8 +140,8 @@ public class StartController extends Controller implements Observer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (((StreamedCourse) o).hasReadCourse()) {
|
|
|
|
if (((StreamedCourse) o).hasReadCourse()) {
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
while(visualiserInput.getRaceStatus() == null);
|
|
|
|
|
|
|
|
setRaceClock();
|
|
|
|
setRaceClock();
|
|
|
|
|
|
|
|
while(visualiserInput.getRaceStatus() == null); // TODO - replace with observer on VisualiserInput
|
|
|
|
setStartingTime();
|
|
|
|
setStartingTime();
|
|
|
|
setCurrentTime();
|
|
|
|
setCurrentTime();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|