Merge remote-tracking branch 'origin/sprint4_master' into story36_boundary_fix_attempt_2

# Conflicts:
#	mock/src/main/java/seng302/Model/Race.java
Resolved.

Also reverted the change to the prestart and preparatory time, as they had gotten flipped around (prestart is > 3min to start, preparatory is < 1 min to start).
main
fjc40 9 years ago
commit 1bd9fdd931

@ -50,8 +50,8 @@ public abstract class XMLReader {
/** /**
* Alternate constructor * Alternate constructor
* @param xmlFile * @param xmlFile File to be read
* @param isWholeFile * @param isWholeFile boolean value whether entire file is being passed
*/ */
public XMLReader(String xmlFile, Boolean isWholeFile) { public XMLReader(String xmlFile, Boolean isWholeFile) {
@ -91,9 +91,9 @@ public abstract class XMLReader {
/** /**
* Get the contents of the XML FILe. * Get the contents of the XML FILe.
* @param document * @param document holds all xml information
* @return * @return String representation of document
* @throws TransformerException * @throws TransformerException when document is malformed, and cannot be turned into a string
*/ */
public static String getContents(Document document) throws TransformerException { public static String getContents(Document document) throws TransformerException {
DOMSource source = new DOMSource(document); DOMSource source = new DOMSource(document);

@ -108,10 +108,11 @@ public class MockOutput implements Runnable
* @param lon longitude of boat * @param lon longitude of boat
* @param heading heading of boat * @param heading heading of boat
* @param speed speed of boat * @param speed speed of boat
* @param time historical time of race
*/ */
public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed){ public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed, long time){
BoatLocation boatLocation = new BoatLocation(sourceID, lat, lon, boatLocationSequenceNumber, heading, speed); BoatLocation boatLocation = new BoatLocation(sourceID, lat, lon, boatLocationSequenceNumber, heading, speed, time);
//iterates the sequence number //iterates the sequence number
boatLocationSequenceNumber++; boatLocationSequenceNumber++;

@ -81,6 +81,8 @@ public class Boat {
*/ */
private long timeSinceTackChange = 0; private long timeSinceTackChange = 0;
private long estimatedTime = 0;
/** /**
* Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table. * Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table.
@ -442,4 +444,11 @@ public class Boat {
return distanceTravelledMeters; return distanceTravelledMeters;
} }
public long getEstimatedTime() {
return estimatedTime;
}
public void setEstimatedTime(long estimatedTime) {
this.estimatedTime = estimatedTime;
}
} }

@ -18,6 +18,8 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import static java.lang.Math.cos;
/** /**
* Represents a yacht race. * Represents a yacht race.
@ -181,7 +183,7 @@ public class Race implements Runnable {
*/ */
private void parseIndividualMark(Mark mark) { private void parseIndividualMark(Mark mark) {
this.mockOutput.parseBoatLocation(mark.getSourceID(), mark.getPosition().getLatitude(), mark.getPosition().getLongitude(),0,0); this.mockOutput.parseBoatLocation(mark.getSourceID(), mark.getPosition().getLatitude(), mark.getPosition().getLongitude(),0,0, totalTimeElapsed+startTime);
} }
@ -210,7 +212,8 @@ public class Race implements Runnable {
boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLatitude(),
boat.getCurrentPosition().getLongitude(), boat.getCurrentPosition().getLongitude(),
boat.getBearing().degrees(), boat.getBearing().degrees(),
boat.getCurrentSpeed() boat.getCurrentSpeed(),
startTime + totalTimeElapsed
); );
} }
@ -261,7 +264,7 @@ public class Race implements Runnable {
//Add each boat status to the status list. //Add each boat status to the status list.
for (Boat boat : boats) { for (Boat boat : boats) {
BoatStatus boatStatus = new BoatStatus(boat.getSourceID(), boat.getStatus(), boat.getCurrentLeg().getLegNumber()); BoatStatus boatStatus = new BoatStatus(boat.getSourceID(), boat.getStatus(), boat.getCurrentLeg().getLegNumber(), boat.getEstimatedTime());
boatStatuses.add(boatStatus); boatStatuses.add(boatStatus);
} }
@ -379,11 +382,13 @@ public class Race implements Runnable {
} else { } else {
//Otherwise, the race is over! //Otherwise, the race is over!
System.out.println("test");
raceFinished.start(); raceFinished.start();
setRaceStatusEnum(RaceStatusEnum.FINISHED); setRaceStatusEnum(RaceStatusEnum.FINISHED);
this.stop(); this.stop();
} }
if (getNumberOfActiveBoats() != 0) {
// Change wind direction // Change wind direction
changeWindDir(); changeWindDir();
@ -400,6 +405,7 @@ public class Race implements Runnable {
//Update the last frame time. //Update the last frame time.
this.lastFrameTime = currentTime; this.lastFrameTime = currentTime;
} }
}
}; };
/** /**
@ -409,7 +415,7 @@ public class Race implements Runnable {
int iters = 0; int iters = 0;
@Override @Override
public void handle(long now) { public void handle(long now) {
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 4, startTime, 0, 2300, 2, null); RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 4, startTime, 0, 2300, 2, new ArrayList<>());
mockOutput.parseRaceStatus(raceStatus); mockOutput.parseRaceStatus(raceStatus);
if (iters > 500){ if (iters > 500){
mockOutput.stop(); mockOutput.stop();
@ -625,10 +631,11 @@ public class Race implements Runnable {
if (!willStayInsideCourse) { if (!willStayInsideCourse) {
boat.setVMG(newVMG); boat.setVMG(newVMG);
} }
} }
} }
this.updateEstimatedTime(boat);
//Check the boats position (update leg and stuff). //Check the boats position (update leg and stuff).
this.checkPosition(boat, totalTimeElapsed); this.checkPosition(boat, totalTimeElapsed);
@ -757,7 +764,6 @@ public class Race implements Runnable {
boat.setTimeFinished(timeElapsed); boat.setTimeFinished(timeElapsed);
boat.setCurrentSpeed(0); boat.setCurrentSpeed(0);
boat.setStatus(BoatStatusEnum.FINISHED); boat.setStatus(BoatStatusEnum.FINISHED);
} else if (doNotFinish()) { } else if (doNotFinish()) {
//Boat has pulled out of race. //Boat has pulled out of race.
boat.setTimeFinished(timeElapsed); boat.setTimeFinished(timeElapsed);
@ -909,4 +915,16 @@ public class Race implements Runnable {
protected int getWind(){ protected int getWind(){
return windDir; return windDir;
} }
/**
* Updates the boat's estimated time to next mark if positive
* @param boat to estimate time given its velocity
*/
private void updateEstimatedTime(Boat boat) {
double velocityToMark = boat.getCurrentSpeed() * cos(boat.getBearing().radians() - boat.calculateBearingToNextMarker().radians()) / Constants.KnotsToMMPerSecond;
if (velocityToMark > 0) {
long timeFromNow = (long)(1000*boat.calculateDistanceToNextMarker()/velocityToMark);
boat.setEstimatedTime(startTime + totalTimeElapsed + timeFromNow);
}
}
} }

@ -57,7 +57,7 @@ public class RaceTest{
Race testRace = new Race(raceDataSource, mockOutput); Race testRace = new Race(raceDataSource, mockOutput);
testRace.initialiseBoats(); testRace.initialiseBoats();
testRace.countdownTimer.handle(1); testRace.countdownTimer.handle(1);
verify(mockOutput, atLeast(boatDataSource.getBoats().size())).parseBoatLocation(anyInt(), anyDouble(), anyDouble(), anyDouble(), anyDouble()); verify(mockOutput, atLeast(boatDataSource.getBoats().size())).parseBoatLocation(anyInt(), anyDouble(), anyDouble(), anyDouble(), anyDouble(), anyLong());
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) { } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
e.printStackTrace(); e.printStackTrace();

@ -152,11 +152,11 @@ public class BoatLocation extends AC35Data {
this.rudderAngle = rudderAngle; this.rudderAngle = rudderAngle;
} }
public BoatLocation(int sourceID, double lat, double lon, long sequenceNumber, double heading, double boatSpeed) { public BoatLocation(int sourceID, double lat, double lon, long sequenceNumber, double heading, double boatSpeed, long time) {
super(MessageType.BOATLOCATION); super(MessageType.BOATLOCATION);
this.messageVersionNumber = (byte) 1; this.messageVersionNumber = (byte) 1;
this.time = System.currentTimeMillis(); this.time = time;
this.sourceID = sourceID; this.sourceID = sourceID;
this.sequenceNumber = sequenceNumber; this.sequenceNumber = sequenceNumber;
this.deviceType = 1; this.deviceType = 1;

@ -27,14 +27,14 @@ public class BoatStatus {
} }
public BoatStatus(int sourceID, BoatStatusEnum boatStatusEnum, int legNum) { public BoatStatus(int sourceID, BoatStatusEnum boatStatusEnum, int legNum, long estTimeAtNextMark) {
this.sourceID = sourceID; this.sourceID = sourceID;
this.boatStatus = boatStatusEnum.getValue(); this.boatStatus = boatStatusEnum.getValue();
this.legNumber = ByteConverter.intToBytes(legNum)[0]; this.legNumber = ByteConverter.intToBytes(legNum)[0];
this.numPenaltiesAwarded = 0; this.numPenaltiesAwarded = 0;
this.numPenaltiesServed = 0; this.numPenaltiesServed = 0;
this.estTimeAtFinish = 0; this.estTimeAtFinish = 0;
this.estTimeAtNextMark = 0; this.estTimeAtNextMark = estTimeAtNextMark;
} }

@ -37,6 +37,7 @@ public class RaceController extends Controller {
private static String speedCheckAnno = "speed"; private static String speedCheckAnno = "speed";
private static String pathCheckAnno = "path"; private static String pathCheckAnno = "path";
private static String timeCheckAnno = "time"; private static String timeCheckAnno = "time";
private static String estTimeCheckAnno = "est time";
private static int noBtn = 0; private static int noBtn = 0;
private static int hideBtn = 1; private static int hideBtn = 1;
@ -65,6 +66,7 @@ public class RaceController extends Controller {
@FXML CheckBox showAbbrev; @FXML CheckBox showAbbrev;
@FXML CheckBox showSpeed; @FXML CheckBox showSpeed;
@FXML CheckBox showTime; @FXML CheckBox showTime;
@FXML CheckBox showEstTime;
@FXML Label timer; @FXML Label timer;
@FXML Label FPS; @FXML Label FPS;
@FXML Label timeZone; @FXML Label timeZone;
@ -356,6 +358,7 @@ public class RaceController extends Controller {
annoShownBeforeHide.put(pathCheckAnno, showBoatPath.isSelected()); annoShownBeforeHide.put(pathCheckAnno, showBoatPath.isSelected());
annoShownBeforeHide.put(speedCheckAnno, showSpeed.isSelected()); annoShownBeforeHide.put(speedCheckAnno, showSpeed.isSelected());
annoShownBeforeHide.put(timeCheckAnno, showTime.isSelected()); annoShownBeforeHide.put(timeCheckAnno, showTime.isSelected());
annoShownBeforeHide.put(estTimeCheckAnno, showEstTime.isSelected());
} }
/** /**
@ -369,7 +372,8 @@ public class RaceController extends Controller {
importantAnno.put(abbrevCheckAnno, false); importantAnno.put(abbrevCheckAnno, false);
importantAnno.put(pathCheckAnno, false); importantAnno.put(pathCheckAnno, false);
importantAnno.put(speedCheckAnno, false); importantAnno.put(speedCheckAnno, false);
importantAnno.put(timeCheckAnno, true); importantAnno.put(timeCheckAnno, false);
importantAnno.put(estTimeCheckAnno, false);
annoShownBeforeHide = new HashMap<>(); annoShownBeforeHide = new HashMap<>();
annoShownBeforeHide.put(nameCheckAnno, true); annoShownBeforeHide.put(nameCheckAnno, true);
@ -377,6 +381,7 @@ public class RaceController extends Controller {
annoShownBeforeHide.put(pathCheckAnno, true); annoShownBeforeHide.put(pathCheckAnno, true);
annoShownBeforeHide.put(speedCheckAnno, true); annoShownBeforeHide.put(speedCheckAnno, true);
annoShownBeforeHide.put(timeCheckAnno, true); annoShownBeforeHide.put(timeCheckAnno, true);
annoShownBeforeHide.put(estTimeCheckAnno, true);
//listener for show name in annotation //listener for show name in annotation
showName.selectedProperty().addListener((ov, old_val, new_val) -> { showName.selectedProperty().addListener((ov, old_val, new_val) -> {
if (old_val != new_val) { if (old_val != new_val) {
@ -468,6 +473,23 @@ public class RaceController extends Controller {
prevBtnChecked = noBtn; prevBtnChecked = noBtn;
raceMap.update(); raceMap.update();
}); });
showEstTime.selectedProperty().addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoEstTime();
}
if (buttonChecked != hideBtn) {
if (prevBtnChecked == hideBtn && buttonChecked != showBtn){
storeCurrentAnnotationState();
} else {
annoShownBeforeHide.put(estTimeCheckAnno, showEstTime.isSelected());
}
if (buttonChecked == noBtn) {
annotationGroup.selectToggle(showAnnoRBTN);
}
}
prevBtnChecked = noBtn;
raceMap.update();
});
//listener to save currently selected annotation //listener to save currently selected annotation
saveAnno.setOnAction(event -> { saveAnno.setOnAction(event -> {
presetAnno.clear(); presetAnno.clear();
@ -476,6 +498,7 @@ public class RaceController extends Controller {
presetAnno.add(showSpeed.isSelected()); presetAnno.add(showSpeed.isSelected());
presetAnno.add(showBoatPath.isSelected()); presetAnno.add(showBoatPath.isSelected());
presetAnno.add(showTime.isSelected()); presetAnno.add(showTime.isSelected());
presetAnno.add(showEstTime.isSelected());
}); });
//listener for hiding //listener for hiding
hideAnnoRBTN.selectedProperty().addListener((ov, old_val, new_val) ->{ hideAnnoRBTN.selectedProperty().addListener((ov, old_val, new_val) ->{
@ -486,6 +509,7 @@ public class RaceController extends Controller {
showBoatPath.setSelected(false); showBoatPath.setSelected(false);
showSpeed.setSelected(false); showSpeed.setSelected(false);
showTime.setSelected(false); showTime.setSelected(false);
showEstTime.setSelected(false);
annotationGroup.selectToggle(hideAnnoRBTN); annotationGroup.selectToggle(hideAnnoRBTN);
raceMap.update(); raceMap.update();
buttonChecked = noBtn; buttonChecked = noBtn;
@ -499,6 +523,7 @@ public class RaceController extends Controller {
showBoatPath.setSelected(annoShownBeforeHide.get(pathCheckAnno)); showBoatPath.setSelected(annoShownBeforeHide.get(pathCheckAnno));
showSpeed.setSelected(annoShownBeforeHide.get(speedCheckAnno)); showSpeed.setSelected(annoShownBeforeHide.get(speedCheckAnno));
showTime.setSelected(annoShownBeforeHide.get(timeCheckAnno)); showTime.setSelected(annoShownBeforeHide.get(timeCheckAnno));
showEstTime.setSelected(annoShownBeforeHide.get(estTimeCheckAnno));
raceMap.update(); raceMap.update();
buttonChecked = noBtn; buttonChecked = noBtn;
prevBtnChecked = showBtn; prevBtnChecked = showBtn;
@ -511,6 +536,7 @@ public class RaceController extends Controller {
showSpeed.setSelected(true); showSpeed.setSelected(true);
showBoatPath.setSelected(false); showBoatPath.setSelected(false);
showTime.setSelected(false); showTime.setSelected(false);
showEstTime.setSelected(false);
annotationGroup.selectToggle(partialAnnoRBTN); annotationGroup.selectToggle(partialAnnoRBTN);
raceMap.update(); raceMap.update();
buttonChecked = noBtn; buttonChecked = noBtn;
@ -525,6 +551,7 @@ public class RaceController extends Controller {
showSpeed.setSelected(presetAnno.get(2)); showSpeed.setSelected(presetAnno.get(2));
showBoatPath.setSelected(presetAnno.get(3)); showBoatPath.setSelected(presetAnno.get(3));
showTime.setSelected(presetAnno.get(4)); showTime.setSelected(presetAnno.get(4));
showEstTime.setSelected(presetAnno.get(5));
annotationGroup.selectToggle(importantAnnoRBTN); annotationGroup.selectToggle(importantAnnoRBTN);
raceMap.update(); raceMap.update();
} }

@ -98,7 +98,6 @@ public class StartController extends Controller implements Observer {
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) {
System.out.println("countdown finished!");//TEMP DEBUG REMOVE
stop(); stop();
startWrapper.setVisible(false); startWrapper.setVisible(false);

@ -114,16 +114,17 @@ public class StreamedRace implements Runnable {
* Updates the boat's gps coordinates * Updates the boat's gps coordinates
* *
* @param boat to be updated * @param boat to be updated
* @param millisecondsElapsed time since last update
*/ */
private void updatePosition(Boat boat, int millisecondsElapsed) { private void updatePosition(Boat boat) {
int sourceID = boat.getSourceID(); int sourceID = boat.getSourceID();
BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID); BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID);
BoatStatus boatStatus = visualiserInput.getBoatStatusMessage(sourceID);
if(boatLocation != null) { if(boatLocation != null) {
double lat = boatLocation.getLatitudeDouble(); double lat = boatLocation.getLatitudeDouble();
double lon = boatLocation.getLongitudeDouble(); double lon = boatLocation.getLongitudeDouble();
boat.setCurrentPosition(new GPSCoordinate(lat, lon)); boat.setCurrentPosition(new GPSCoordinate(lat, lon));
boat.setHeading(boatLocation.getHeadingDegrees()); boat.setHeading(boatLocation.getHeadingDegrees());
boat.setEstTime(convertEstTime(boatStatus.getEstTimeAtNextMark(), boatLocation.getTime()));
double MMPS_TO_KN = 0.001944; double MMPS_TO_KN = 0.001944;
boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN); boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN);
} }
@ -200,17 +201,18 @@ public class StreamedRace implements Runnable {
for (Boat boat : startingBoats) { for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) { if (boat != null && !boat.isFinished()) {
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS)); updatePosition(boat);
checkPosition(boat, totalTimeElapsed); checkPosition(boat, totalTimeElapsed);
} }
} }
for (Marker mark: boatMarkers){ for (Marker mark: boatMarkers){
if (mark != null){ if (mark != null){
updateMarker(mark); updateMarker(mark);
} }
} }
//System.out.println(boatsFinished + ":" + startingBoats.size());
if (visualiserInput.getRaceStatus().isFinished()){ if (visualiserInput.getRaceStatus().isFinished()) {
controller.finishRace(startingBoats); controller.finishRace(startingBoats);
stop(); stop();
} }
@ -258,4 +260,18 @@ public class StreamedRace implements Runnable {
return startingBoats; return startingBoats;
} }
/**
* Takes an estimated time an event will occur, and converts it to the number of seconds before the event will occur.
*
* @param estTimeMillis
* @return int difference between time the race started and the estimated time
*/
private int convertEstTime(long estTimeMillis, long currentTime) {
long estElapsedMillis = estTimeMillis - currentTime;
int estElapsedSecs = Math.round(estElapsedMillis/1000);
return estElapsedSecs;
}
} }

@ -29,6 +29,7 @@ public class Boat {
private boolean started = false; private boolean started = false;
private boolean dnf = false; private boolean dnf = false;
private int sourceID; private int sourceID;
private int estTime;
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>(); private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
private long nextValidTime = 0; private long nextValidTime = 0;
@ -248,4 +249,21 @@ public class Boat {
public void setTimeSinceLastMark(ZonedDateTime timeSinceLastMark) { public void setTimeSinceLastMark(ZonedDateTime timeSinceLastMark) {
this.timeSinceLastMark = timeSinceLastMark; this.timeSinceLastMark = timeSinceLastMark;
} }
public void setEstTime(int estTime) { this.estTime = estTime; }
public String getFormattedEstTime() {
if (estTime < 0) {
return " -";
}
if (estTime <= 60) {
return " " + estTime + "s";
} else {
int seconds = estTime % 60;
int minutes = (estTime - seconds) / 60;
return String.format(" %dm %ds", minutes, seconds);
}
}
} }

@ -31,6 +31,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
private boolean annoAbbrev = true; private boolean annoAbbrev = true;
private boolean annoSpeed = true; private boolean annoSpeed = true;
private boolean annoPath = true; private boolean annoPath = true;
private boolean annoEstTime = true;
private boolean annoTimeSinceLastMark = true; private boolean annoTimeSinceLastMark = true;
private List<Color> colours; private List<Color> colours;
private final List<Marker> markers; private final List<Marker> markers;
@ -177,7 +178,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
* @param coordinate coordinate the text appears * @param coordinate coordinate the text appears
* @param timeSinceLastMark time since the last mark was passed * @param timeSinceLastMark time since the last mark was passed
*/ */
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, ZonedDateTime timeSinceLastMark) { private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, String estTime, ZonedDateTime timeSinceLastMark) {
String text = ""; String text = "";
//Check name toggle value //Check name toggle value
if (annoName){ if (annoName){
@ -191,10 +192,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
if (annoSpeed){ if (annoSpeed){
text += String.format("%.2fkn ", speed); text += String.format("%.2fkn ", speed);
} }
if (annoEstTime) {
text += estTime;
}
//Check time since last mark toggle value //Check time since last mark toggle value
if(annoTimeSinceLastMark){ if(annoTimeSinceLastMark){
Duration timeSince = Duration.between(timeSinceLastMark, raceClock.getTime()); Duration timeSince = Duration.between(timeSinceLastMark, raceClock.getTime());
text += String.format("%d", timeSince.getSeconds()); text += String.format(" %ds ", timeSince.getSeconds());
} }
//String text = String.format("%s, %2$.2fkn", name, speed); //String text = String.format("%s, %2$.2fkn", name, speed);
long xCoord = coordinate.getX() + 20; long xCoord = coordinate.getX() + 20;
@ -277,6 +281,10 @@ public class ResizableRaceCanvas extends ResizableCanvas {
annoPath = !annoPath; annoPath = !annoPath;
} }
public void toggleAnnoEstTime() {
annoEstTime = !annoEstTime;
}
/** /**
* Toggle boat time display in annotation * Toggle boat time display in annotation
*/ */
@ -320,7 +328,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) { if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
boat.setTimeSinceLastMark(raceClock.getTime()); boat.setTimeSinceLastMark(raceClock.getTime());
} }
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getTimeSinceLastMark()); displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
//TODO this needs to be fixed. //TODO this needs to be fixed.
drawTrack(boat, boatColours.get(sourceID)); drawTrack(boat, boatColours.get(sourceID));
} }

@ -88,6 +88,10 @@ public class VisualiserInput implements Runnable {
return boatLocationMap.get(sourceID); return boatLocationMap.get(sourceID);
} }
public BoatStatus getBoatStatusMessage(int sourceID) {
return boatStatusMap.get(sourceID);
}
/** /**
* Calculates the time since last heartbeat, in milliseconds. * Calculates the time since last heartbeat, in milliseconds.
* @return Time since last heartbeat, in milliseconds.. * @return Time since last heartbeat, in milliseconds..

@ -1,12 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.chart.*?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.chart.LineChart?>
<?import javafx.scene.layout.*?> <?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<SplitPane fx:id="race" dividerPositions="0.7" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController"> <SplitPane fx:id="race" dividerPositions="0.7" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
@ -24,7 +36,7 @@
<children> <children>
<Accordion> <Accordion>
<panes> <panes>
<TitledPane animated="false" text="Annotation Control"> <TitledPane animated="false" prefHeight="395.0" prefWidth="222.0" text="Annotation Control">
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0"> <AnchorPane minHeight="0.0" minWidth="0.0">
<children> <children>
@ -33,13 +45,14 @@
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0" /> <CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0" />
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="75.0" /> <CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="75.0" />
<CheckBox fx:id="showTime" mnemonicParsing="false" selected="true" text="Show Boat Leg Time" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" /> <CheckBox fx:id="showTime" mnemonicParsing="false" selected="true" text="Show Boat Leg Time" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" />
<Separator prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" /> <CheckBox fx:id="showEstTime" mnemonicParsing="false" selected="true" text="Show Est. Time to Next Mark" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" />
<Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="130.0" /> <Separator layoutX="19.6" layoutY="175.6" prefHeight="0.0" prefWidth="200.0" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="150.0" />
<RadioButton fx:id="hideAnnoRBTN" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="155.0" /> <Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="150.0" />
<RadioButton fx:id="showAnnoRBTN" mnemonicParsing="false" text="Visible" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="180.0" /> <RadioButton fx:id="hideAnnoRBTN" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="175.0" />
<RadioButton fx:id="partialAnnoRBTN" mnemonicParsing="false" text="Partial" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="205.0" /> <RadioButton fx:id="showAnnoRBTN" mnemonicParsing="false" text="Visible" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="200.0" />
<RadioButton fx:id="importantAnnoRBTN" mnemonicParsing="false" text="Important" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="230.0" /> <RadioButton fx:id="partialAnnoRBTN" mnemonicParsing="false" text="Partial" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="225.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="255.0" /> <RadioButton fx:id="importantAnnoRBTN" mnemonicParsing="false" text="Important" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="250.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="126.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="275.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</content> </content>

@ -29,6 +29,7 @@ public class RaceConnectionTest {
assertTrue(onlineConnection.check()); assertTrue(onlineConnection.check());
} }
@Test @Test
public void offlineConnectionStatusOffline() { public void offlineConnectionStatusOffline() {
assertFalse(offlineConnection.check()); assertFalse(offlineConnection.check());

Loading…
Cancel
Save