|
|
|
|
@ -24,6 +24,7 @@ import java.util.Random;
|
|
|
|
|
public class Race implements Runnable {
|
|
|
|
|
|
|
|
|
|
protected ObservableList<Boat> startingBoats;
|
|
|
|
|
protected ObservableList<CompoundMark> compoundMarks;
|
|
|
|
|
protected List<Leg> legs;
|
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
|
@ -36,6 +37,7 @@ public class Race implements Runnable {
|
|
|
|
|
public Race(RaceDataSource raceData, MockOutput mockOutput) {
|
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(raceData.getBoats());
|
|
|
|
|
this.legs = raceData.getLegs();
|
|
|
|
|
this.compoundMarks = FXCollections.observableArrayList(raceData.getCompoundMarks());
|
|
|
|
|
this.legs.add(new Leg("Finish", this.legs.size()));
|
|
|
|
|
this.raceId = raceData.getRaceId();
|
|
|
|
|
this.mockOutput = mockOutput;
|
|
|
|
|
@ -50,6 +52,19 @@ public class Race implements Runnable {
|
|
|
|
|
countdownTimer.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse the marker boats through mock output
|
|
|
|
|
*/
|
|
|
|
|
public void parseMarks() {
|
|
|
|
|
for (CompoundMark mark : compoundMarks){
|
|
|
|
|
mockOutput.parseBoatLocation(mark.getMark1Source().getSourceID(), mark.getMark1().getLatitude(), mark.getMark1().getLongitude(),0,0);
|
|
|
|
|
if (mark.getMark2Source()!=null){
|
|
|
|
|
mockOutput.parseBoatLocation(mark.getMark2Source().getSourceID(), mark.getMark2().getLatitude(), mark.getMark2().getLongitude(),0,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Countdown timer until race starts.
|
|
|
|
|
*/
|
|
|
|
|
@ -72,6 +87,7 @@ public class Race implements Runnable {
|
|
|
|
|
boat.getCurrentPosition().getLongitude(), boat.getHeading(), 0);
|
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.PRESTART, 0));
|
|
|
|
|
}
|
|
|
|
|
parseMarks();
|
|
|
|
|
|
|
|
|
|
int raceStatusNumber = timeLeft <= 60000 / scaleFactor && timeLeft > 0? 2 : 1;
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, raceStatusNumber, startTime, 0, 2300, 1, boatStatuses);
|
|
|
|
|
@ -116,6 +132,7 @@ public class Race implements Runnable {
|
|
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
parseMarks();
|
|
|
|
|
boatOffset = (boatOffset + 1) % (startingBoats.size());
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 3, startTime, 0, 2300, 2, boatStatuses);
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
|
|