Mock.Race:
Fixed an issue where boats sometimes sailed towards the wind when attempting to turn from bearing just under 360 degrees to a bearing just over 360 degrees. This required an update to the boundary detection code. Visualiser: Appear to have fixed issue where clock didn't display correctly. Previous commit only fixed certain circumstances. #story[873]
This commit is contained in:
@@ -54,6 +54,9 @@ public class StartController extends Controller implements Observer {
|
||||
///Tracks whether the race has been started (that is, has startRaceNoScaling() be called).
|
||||
private boolean hasRaceStarted = false;
|
||||
|
||||
//Tracks whether or not a clock has been created and setup, which occurs after receiving enough information.
|
||||
private boolean hasCreatedClock = false;
|
||||
|
||||
/**
|
||||
* Begins the race with a scale factor of 1
|
||||
*/
|
||||
@@ -106,7 +109,14 @@ public class StartController extends Controller implements Observer {
|
||||
|
||||
private void setRaceClock() {
|
||||
raceClock = new RaceClock(raceData.getZonedDateTime());
|
||||
timeZoneTime.textProperty().bind(raceClock.timeStringProperty());
|
||||
|
||||
raceClock.timeStringProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timeZoneTime.setText(newValue);
|
||||
});
|
||||
});
|
||||
//TEMP REMOVE
|
||||
//timeZoneTime.textProperty().bind(raceClock.timeStringProperty());
|
||||
raceClock.run();
|
||||
}
|
||||
|
||||
@@ -116,7 +126,12 @@ public class StartController extends Controller implements Observer {
|
||||
long utcTime = visualiserInput.getRaceStatus().getExpectedStartTime();
|
||||
raceClock.setStartingTime(raceClock.getLocalTime(utcTime));
|
||||
raceStartLabel.setText(DateTimeFormatter.ofPattern(dateFormat).format(raceClock.getStartingTime()));
|
||||
timer.textProperty().bind(raceClock.durationProperty());
|
||||
|
||||
raceClock.durationProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Platform.runLater(() -> {
|
||||
timer.setText(newValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -138,12 +153,15 @@ public class StartController extends Controller implements Observer {
|
||||
}
|
||||
if (streamedCourse.hasReadCourse()) {
|
||||
Platform.runLater(() -> {
|
||||
setRaceClock();
|
||||
if(visualiserInput.getRaceStatus() == null){
|
||||
return;//TEMP BUG FIX if the race isn't sending race status messages (our mock currently doesn't), then it would block the javafx thread with the previous while loop.
|
||||
}// TODO - replace with observer on VisualiserInput
|
||||
setStartingTime();
|
||||
setCurrentTime();
|
||||
if (!this.hasCreatedClock) {
|
||||
this.hasCreatedClock = true;
|
||||
setRaceClock();
|
||||
if (visualiserInput.getRaceStatus() == null) {
|
||||
return;//TEMP BUG FIX if the race isn't sending race status messages (our mock currently doesn't), then it would block the javafx thread with the previous while loop.
|
||||
}// TODO - replace with observer on VisualiserInput
|
||||
setStartingTime();
|
||||
setCurrentTime();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public class RaceClock implements Runnable {
|
||||
this.time = time;
|
||||
this.timeString.set(DateTimeFormatter.ofPattern("HH:mm:ss dd/MM/YYYY Z").format(time));
|
||||
this.lastTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
if(startingTime != null) {
|
||||
long seconds = Duration.between(startingTime.toLocalDateTime(), time.toLocalDateTime()).getSeconds();
|
||||
if(seconds < 0)
|
||||
@@ -66,6 +68,7 @@ public class RaceClock implements Runnable {
|
||||
else
|
||||
duration.set(String.format("Time: %02d:%02d:%02d", seconds/3600, (seconds%3600)/60, seconds%60));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user