Implemented functionality for mock to parse marker boats throughout race.
-Added getter to CompoundMark to get the Mark value. #story[881]
This commit is contained in:
@@ -27,6 +27,10 @@ public class CompoundMark extends Marker{
|
||||
|
||||
}
|
||||
|
||||
public Mark getMark1Source() { return mark1; }
|
||||
|
||||
public Mark getMark2Source() { return mark2; }
|
||||
|
||||
public GPSCoordinate getMark1() {
|
||||
return mark1.getPosition();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user