|
|
|
|
@ -67,6 +67,11 @@ public class MockRace extends RaceState {
|
|
|
|
|
|
|
|
|
|
private long racePreparatoryTime = Constants.RacePreparatoryTime;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* True if the race has been manually started, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
private boolean hasBeenStarted = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a race object with a given RaceDataSource, BoatDataSource, and RegattaDataSource and sends events to the given mockOutput.
|
|
|
|
|
* @param boatDataSource Data source for boat related data (yachts and marker boats).
|
|
|
|
|
@ -157,6 +162,23 @@ public class MockRace extends RaceState {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delays the start of the race, if needed, to ensure that the race doesn't start until host wants it to.
|
|
|
|
|
* If the time until start is less that 5 minutes, it is extended to 10 minutes.
|
|
|
|
|
*/
|
|
|
|
|
public void delayRaceStart() {
|
|
|
|
|
long timeToStart = getRaceDataSource().getStartDateTime().toInstant().toEpochMilli() - System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
long fiveMinutesMilli = 5 * 60 * 1000;
|
|
|
|
|
long tenMinutesMilli = 10 * 60 * 1000;
|
|
|
|
|
|
|
|
|
|
if ((timeToStart < fiveMinutesMilli) && (timeToStart > 0) && !hasBeenStarted) {
|
|
|
|
|
startRace(tenMinutesMilli, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the race status enumeration based on the current time.
|
|
|
|
|
*/
|
|
|
|
|
@ -165,7 +187,6 @@ public class MockRace extends RaceState {
|
|
|
|
|
//The millisecond duration of the race. Negative means it hasn't started, so we flip sign.
|
|
|
|
|
long timeToStart = - this.getRaceClock().getDurationMilli();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (timeToStart > racePreStartTime) {
|
|
|
|
|
//Time > 3 minutes is the prestart period.
|
|
|
|
|
this.setRaceStatusEnum(RaceStatusEnum.PRESTART);
|
|
|
|
|
@ -203,9 +224,16 @@ public class MockRace extends RaceState {
|
|
|
|
|
/**
|
|
|
|
|
* Starts the race in #timeToStartMilli milliseconds.
|
|
|
|
|
* @param timeToStartMilli Millseconds before starting the race.
|
|
|
|
|
* @param manualStart True if the race has been manually started, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public void startRace(long timeToStartMilli) {
|
|
|
|
|
//TODO
|
|
|
|
|
public void startRace(long timeToStartMilli, boolean manualStart) {
|
|
|
|
|
this.hasBeenStarted = manualStart;
|
|
|
|
|
ZonedDateTime startTime = ZonedDateTime.now().plus(timeToStartMilli, ChronoUnit.MILLIS);
|
|
|
|
|
|
|
|
|
|
getRaceDataSource().setStartDateTime(startTime);
|
|
|
|
|
getRaceDataSource().incrementSequenceNumber();
|
|
|
|
|
|
|
|
|
|
this.getRaceClock().setStartingTime(getRaceDataSource().getStartDateTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|