|
|
|
@ -31,7 +31,7 @@ public class Race implements Runnable {
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected int scaleFactor;
|
|
|
|
protected int scaleFactor;
|
|
|
|
protected int PRERACE_TIME = 12; //time in milliseconds to pause during pre-race
|
|
|
|
protected int PRERACE_TIME = 12000; //time in milliseconds to pause during pre-race
|
|
|
|
protected boolean countdownFinish = false;
|
|
|
|
protected boolean countdownFinish = false;
|
|
|
|
protected boolean runRace = true;
|
|
|
|
protected boolean runRace = true;
|
|
|
|
private int lastFPS = 20;
|
|
|
|
private int lastFPS = 20;
|
|
|
|
@ -66,10 +66,6 @@ public class Race implements Runnable {
|
|
|
|
this(raceData.getBoats(), raceData.getLegs(), scaleFactor, mockOutput);
|
|
|
|
this(raceData.getBoats(), raceData.getLegs(), scaleFactor, mockOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setRaceId(int raceId) {
|
|
|
|
|
|
|
|
this.raceId = raceId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Calculates the boats next GPS position based on its distance travelled and heading
|
|
|
|
* Calculates the boats next GPS position based on its distance travelled and heading
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -172,12 +168,13 @@ public class Race implements Runnable {
|
|
|
|
|
|
|
|
|
|
|
|
//For each boat, we update it's position, and generate a BoatLocationMessage.
|
|
|
|
//For each boat, we update it's position, and generate a BoatLocationMessage.
|
|
|
|
for (Boat boat : startingBoats) {
|
|
|
|
for (Boat boat : startingBoats) {
|
|
|
|
if (boat != null && boat.getTimeFinished() < 0) {
|
|
|
|
if (boat != null) {
|
|
|
|
//Update position.
|
|
|
|
//Update position.
|
|
|
|
|
|
|
|
if (boat.getTimeFinished() < 0) {
|
|
|
|
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
|
|
|
|
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
|
|
|
|
checkPosition(boat, totalTimeElapsed);
|
|
|
|
checkPosition(boat, totalTimeElapsed);
|
|
|
|
|
|
|
|
}
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude());
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude());
|
|
|
|
System.out.println("Sending boat status");
|
|
|
|
|
|
|
|
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
|
|
|
|
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
|
|
|
|
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|