|
|
|
@ -7,7 +7,6 @@ import javafx.beans.property.SimpleObjectProperty;
|
|
|
|
import mock.model.collider.ColliderRegistry;
|
|
|
|
import mock.model.collider.ColliderRegistry;
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
import network.Messages.Enums.RaceTypeEnum;
|
|
|
|
import network.Messages.Enums.RaceTypeEnum;
|
|
|
|
import network.Messages.LatestMessages;
|
|
|
|
|
|
|
|
import shared.dataInput.BoatDataSource;
|
|
|
|
import shared.dataInput.BoatDataSource;
|
|
|
|
import shared.dataInput.RaceDataSource;
|
|
|
|
import shared.dataInput.RaceDataSource;
|
|
|
|
import shared.dataInput.RegattaDataSource;
|
|
|
|
import shared.dataInput.RegattaDataSource;
|
|
|
|
@ -33,11 +32,6 @@ public abstract class Race {
|
|
|
|
* The source of regatta related data.
|
|
|
|
* The source of regatta related data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RegattaDataSource regattaDataSource;
|
|
|
|
protected RegattaDataSource regattaDataSource;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* The collection of latest race messages.
|
|
|
|
|
|
|
|
* Can be either read from or written to.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected LatestMessages latestMessages;
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* A list of compound marks in the race.
|
|
|
|
* A list of compound marks in the race.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -80,7 +74,7 @@ public abstract class Race {
|
|
|
|
protected ColliderRegistry colliderRegistry;
|
|
|
|
protected ColliderRegistry colliderRegistry;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The number of frames per second.
|
|
|
|
* The number of frames per second.
|
|
|
|
* We essentially track the number of frames generated per second, over a one second period. When {@link #lastFpsResetTime} reaches 1 second, {@link #currentFps} is reset.
|
|
|
|
* We essentially track the number of frames generated per second, over a one second period. When {@link #lastFpsResetTime} reaches 1 second, currentFps is reset.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private int currentFps = 0;
|
|
|
|
private int currentFps = 0;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -92,53 +86,38 @@ public abstract class Race {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private long lastFpsResetTime;
|
|
|
|
private long lastFpsResetTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructs a race object with a given BoatDataSource, RaceDataSource, and RegattaDataSource.
|
|
|
|
* Constructs a race object with a given BoatDataSource, RaceDataSource, and RegattaDataSource.
|
|
|
|
* @param boatDataSource Data source for boat related data (yachts and marker boats).
|
|
|
|
* @param boatDataSource Data source for boat related data (yachts and marker boats).
|
|
|
|
* @param raceDataSource Data source for race related data (participating boats, legs, etc...).
|
|
|
|
* @param raceDataSource Data source for race related data (participating boats, legs, etc...).
|
|
|
|
* @param regattaDataSource Data source for race related data (course name, location, timezone, etc...).
|
|
|
|
* @param regattaDataSource Data source for race related data (course name, location, timezone, etc...).
|
|
|
|
* @param latestMessages The collection of latest messages, which can be written to, or read from.
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Race(BoatDataSource boatDataSource, RaceDataSource raceDataSource, RegattaDataSource regattaDataSource, LatestMessages latestMessages) {
|
|
|
|
public Race(BoatDataSource boatDataSource, RaceDataSource raceDataSource, RegattaDataSource regattaDataSource) {
|
|
|
|
|
|
|
|
|
|
|
|
//Keep a reference to data sources.
|
|
|
|
//Keep a reference to data sources.
|
|
|
|
this.raceDataSource = raceDataSource;
|
|
|
|
this.raceDataSource = raceDataSource;
|
|
|
|
this.boatDataSource = boatDataSource;
|
|
|
|
this.boatDataSource = boatDataSource;
|
|
|
|
this.regattaDataSource = regattaDataSource;
|
|
|
|
this.regattaDataSource = regattaDataSource;
|
|
|
|
|
|
|
|
|
|
|
|
this.latestMessages = latestMessages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Marks.
|
|
|
|
//Marks.
|
|
|
|
this.compoundMarks = raceDataSource.getCompoundMarks();
|
|
|
|
this.compoundMarks = raceDataSource.getCompoundMarks();
|
|
|
|
|
|
|
|
|
|
|
|
//Boundaries.
|
|
|
|
//Boundaries.
|
|
|
|
this.boundary = raceDataSource.getBoundary();
|
|
|
|
this.boundary = raceDataSource.getBoundary();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Legs.
|
|
|
|
//Legs.
|
|
|
|
this.useLegsList(raceDataSource.getLegs());
|
|
|
|
this.useLegsList(raceDataSource.getLegs());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Race ID.
|
|
|
|
//Race ID.
|
|
|
|
this.raceId = raceDataSource.getRaceId();
|
|
|
|
this.raceId = raceDataSource.getRaceId();
|
|
|
|
|
|
|
|
|
|
|
|
//Regatta name.
|
|
|
|
//Regatta name.
|
|
|
|
this.regattaName = regattaDataSource.getRegattaName();
|
|
|
|
this.regattaName = regattaDataSource.getRegattaName();
|
|
|
|
|
|
|
|
|
|
|
|
//Race clock.
|
|
|
|
//Race clock.
|
|
|
|
this.raceClock = new RaceClock(this.raceDataSource.getStartDateTime());
|
|
|
|
this.raceClock = new RaceClock(this.raceDataSource.getStartDateTime());
|
|
|
|
|
|
|
|
|
|
|
|
//Race status.
|
|
|
|
//Race status.
|
|
|
|
this.setRaceStatusEnum(RaceStatusEnum.NOT_ACTIVE);
|
|
|
|
this.setRaceStatusEnum(RaceStatusEnum.NOT_ACTIVE);
|
|
|
|
//Race type.
|
|
|
|
//Race type.
|
|
|
|
this.raceType = raceDataSource.getRaceType();
|
|
|
|
this.raceType = raceDataSource.getRaceType();
|
|
|
|
|
|
|
|
|
|
|
|
//Wind.
|
|
|
|
//Wind.
|
|
|
|
this.setWind(Bearing.fromDegrees(0), 0);
|
|
|
|
this.setWind(Bearing.fromDegrees(0), 0);
|
|
|
|
|
|
|
|
// Set up colliders
|
|
|
|
this.colliderRegistry = new ColliderRegistry();
|
|
|
|
this.colliderRegistry = new ColliderRegistry();
|
|
|
|
this.colliderRegistry.addAllColliders(compoundMarks);
|
|
|
|
this.colliderRegistry.addAllColliders(compoundMarks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -153,7 +132,6 @@ public abstract class Race {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected abstract void initialiseBoats();
|
|
|
|
protected abstract void initialiseBoats();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Updates the race to use a new list of legs, and adds a dummy "Finish" leg at the end.
|
|
|
|
* Updates the race to use a new list of legs, and adds a dummy "Finish" leg at the end.
|
|
|
|
* @param legs The new list of legs to use.
|
|
|
|
* @param legs The new list of legs to use.
|
|
|
|
@ -185,10 +163,6 @@ public abstract class Race {
|
|
|
|
return legID == lastLegID;
|
|
|
|
return legID == lastLegID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the current race status.
|
|
|
|
* Returns the current race status.
|
|
|
|
* @return The current race status.
|
|
|
|
* @return The current race status.
|
|
|
|
@ -205,7 +179,6 @@ public abstract class Race {
|
|
|
|
this.raceStatusEnum = raceStatusEnum;
|
|
|
|
this.raceStatusEnum = raceStatusEnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the type of race this is.
|
|
|
|
* Returns the type of race this is.
|
|
|
|
* @return The type of race this is.
|
|
|
|
* @return The type of race this is.
|
|
|
|
@ -222,7 +195,6 @@ public abstract class Race {
|
|
|
|
return regattaName;
|
|
|
|
return regattaName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Updates the race to have a specified wind bearing and speed.
|
|
|
|
* Updates the race to have a specified wind bearing and speed.
|
|
|
|
* @param windBearing New wind bearing.
|
|
|
|
* @param windBearing New wind bearing.
|
|
|
|
@ -241,7 +213,6 @@ public abstract class Race {
|
|
|
|
this.raceWind.setValue(wind);
|
|
|
|
this.raceWind.setValue(wind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the wind bearing.
|
|
|
|
* Returns the wind bearing.
|
|
|
|
* @return The wind bearing.
|
|
|
|
* @return The wind bearing.
|
|
|
|
@ -268,7 +239,6 @@ public abstract class Race {
|
|
|
|
return raceClock;
|
|
|
|
return raceClock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the RaceDataSource used for the race.
|
|
|
|
* Returns the RaceDataSource used for the race.
|
|
|
|
* @return The RaceDataSource used for the race.
|
|
|
|
* @return The RaceDataSource used for the race.
|
|
|
|
@ -286,7 +256,6 @@ public abstract class Race {
|
|
|
|
return legs.size() - 1;
|
|
|
|
return legs.size() - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the race boundary.
|
|
|
|
* Returns the race boundary.
|
|
|
|
* @return The race boundary.
|
|
|
|
* @return The race boundary.
|
|
|
|
@ -295,12 +264,21 @@ public abstract class Race {
|
|
|
|
return boundary;
|
|
|
|
return boundary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns the marks of the race.
|
|
|
|
|
|
|
|
* @return Marks of the race.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public List<CompoundMark> getCompoundMarks() {
|
|
|
|
|
|
|
|
return compoundMarks;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the number of frames generated per second.
|
|
|
|
* Returns the legs of the race.
|
|
|
|
* @return Frames per second.
|
|
|
|
* @return Legs of the race.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public int getFps() {
|
|
|
|
public List<Leg> getLegs() {
|
|
|
|
return lastFps.getValue();
|
|
|
|
return legs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -311,7 +289,6 @@ public abstract class Race {
|
|
|
|
return lastFps;
|
|
|
|
return lastFps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
|
|
|
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
|
|
|
* @param timePeriod Time, in milliseconds, to add to {@link #lastFpsResetTime}.
|
|
|
|
* @param timePeriod Time, in milliseconds, to add to {@link #lastFpsResetTime}.
|
|
|
|
|