Merge branch 'fix_time_since_last_marker' into 'sprint4_master'

Fix time since last marker

Visualiser:
Fixed the issue where a boat's time since last mark started counting from when the race screen loaded.
It now starts counting when the race actually starts.


See merge request !13
main
Hamish Ball 9 years ago
commit 992b6c91fc

@ -69,7 +69,7 @@ public class Race implements Runnable {
* Frame periods are multiplied by this to get the amount of time a single frame represents.
* E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred.
*/
private int scaleFactor = 15;
private int scaleFactor = 5;
/**
* The race ID of the course.

@ -51,5 +51,10 @@ public class MainController extends Controller {
AnchorPane.setBottomAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setLeftAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setRightAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setTopAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setBottomAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setLeftAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setRightAnchor(finishController.finishWrapper, 0.0);
}
}

@ -185,9 +185,7 @@ public class StreamedRace implements Runnable {
System.setProperty("javafx.animation.fullspeed", "true");
for (Boat boat : startingBoats) {
boat.setStarted(true);
}
new AnimationTimer() {
@ -199,18 +197,27 @@ public class StreamedRace implements Runnable {
public void handle(long arg0) {
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
//Check if the race has actually started.
if (visualiserInput.getRaceStatus().isStarted()) {
//Set all boats to started.
for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) {
updatePosition(boat);
checkPosition(boat, totalTimeElapsed);
}
boat.setStarted(true);
}
}
for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) {
updatePosition(boat);
checkPosition(boat, totalTimeElapsed);
}
for (Marker mark: boatMarkers){
if (mark != null){
updateMarker(mark);
}
}
for (Marker mark: boatMarkers){
if (mark != null){
updateMarker(mark);
}
}
if (visualiserInput.getRaceStatus().isFinished()) {
controller.finishRace(startingBoats);

@ -328,6 +328,12 @@ public class ResizableRaceCanvas extends ResizableCanvas {
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
if (boat.isStarted() == false) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
//TODO this needs to be fixed.
drawTrack(boat, boatColours.get(sourceID));

Loading…
Cancel
Save