|
|
|
@ -4,6 +4,7 @@ import javafx.beans.property.IntegerProperty;
|
|
|
|
import javafx.beans.property.Property;
|
|
|
|
import javafx.beans.property.Property;
|
|
|
|
import javafx.beans.property.SimpleIntegerProperty;
|
|
|
|
import javafx.beans.property.SimpleIntegerProperty;
|
|
|
|
import javafx.beans.property.SimpleObjectProperty;
|
|
|
|
import javafx.beans.property.SimpleObjectProperty;
|
|
|
|
|
|
|
|
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 network.Messages.LatestMessages;
|
|
|
|
@ -20,90 +21,72 @@ import java.util.List;
|
|
|
|
* Has a course, state, wind, boundaries, etc.... Boats are added by inheriting classes (see {@link Boat}, {@link mock.model.MockBoat}, {@link visualiser.model.VisualiserBoat}.
|
|
|
|
* Has a course, state, wind, boundaries, etc.... Boats are added by inheriting classes (see {@link Boat}, {@link mock.model.MockBoat}, {@link visualiser.model.VisualiserBoat}.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public abstract class Race {
|
|
|
|
public abstract class Race {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The source of race related data.
|
|
|
|
* The source of race related data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RaceDataSource raceDataSource;
|
|
|
|
protected RaceDataSource raceDataSource;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The source of boat related data.
|
|
|
|
* The source of boat related data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected BoatDataSource boatDataSource;
|
|
|
|
protected BoatDataSource boatDataSource;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The source of regatta related data.
|
|
|
|
* The source of regatta related data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RegattaDataSource regattaDataSource;
|
|
|
|
protected RegattaDataSource regattaDataSource;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The collection of latest race messages.
|
|
|
|
* The collection of latest race messages.
|
|
|
|
* Can be either read from or written to.
|
|
|
|
* Can be either read from or written to.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected LatestMessages latestMessages;
|
|
|
|
protected LatestMessages latestMessages;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* A list of compound marks in the race.
|
|
|
|
* A list of compound marks in the race.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected List<CompoundMark> compoundMarks;
|
|
|
|
protected List<CompoundMark> compoundMarks;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* A list of legs in the race.
|
|
|
|
* A list of legs in the race.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected List<Leg> legs;
|
|
|
|
protected List<Leg> legs;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* A list of coordinates describing the boundary of the course.
|
|
|
|
* A list of coordinates describing the boundary of the course.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected List<GPSCoordinate> boundary;
|
|
|
|
protected List<GPSCoordinate> boundary;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The clock which tracks the race's start time, current time, and elapsed duration.
|
|
|
|
* The clock which tracks the race's start time, current time, and elapsed duration.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RaceClock raceClock;
|
|
|
|
protected RaceClock raceClock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The race ID of the course.
|
|
|
|
* The race ID of the course.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected int raceId;
|
|
|
|
protected int raceId;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The name of the regatta.
|
|
|
|
* The name of the regatta.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected String regattaName;
|
|
|
|
protected String regattaName;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The current status of the race.
|
|
|
|
* The current status of the race.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RaceStatusEnum raceStatusEnum;
|
|
|
|
protected RaceStatusEnum raceStatusEnum;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The type of race this is.
|
|
|
|
* The type of race this is.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected RaceTypeEnum raceType;
|
|
|
|
protected RaceTypeEnum raceType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The race's wind.
|
|
|
|
* The race's wind.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected Property<Wind> raceWind = new SimpleObjectProperty<>();
|
|
|
|
protected Property<Wind> raceWind = new SimpleObjectProperty<>();
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Registry for all collider object in this race
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
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, {@link #currentFps} is reset.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private int currentFps = 0;
|
|
|
|
private int currentFps = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The number of frames per second we generated over the last 1 second period.
|
|
|
|
* The number of frames per second we generated over the last 1 second period.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private IntegerProperty lastFps = new SimpleIntegerProperty(0);
|
|
|
|
private IntegerProperty lastFps = new SimpleIntegerProperty(0);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The time, in milliseconds, since we last reset our {@link #currentFps} counter.
|
|
|
|
* The time, in milliseconds, since we last reset our {@link #currentFps} counter.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -156,9 +139,13 @@ public abstract class Race {
|
|
|
|
//Wind.
|
|
|
|
//Wind.
|
|
|
|
this.setWind(Bearing.fromDegrees(0), 0);
|
|
|
|
this.setWind(Bearing.fromDegrees(0), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.colliderRegistry = new ColliderRegistry();
|
|
|
|
|
|
|
|
this.colliderRegistry.addAllColliders(compoundMarks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ColliderRegistry getColliderRegistry() {
|
|
|
|
|
|
|
|
return colliderRegistry;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initialise the boats in the race.
|
|
|
|
* Initialise the boats in the race.
|
|
|
|
@ -272,14 +259,6 @@ public abstract class Race {
|
|
|
|
return raceWind.getValue().getWindSpeed();
|
|
|
|
return raceWind.getValue().getWindSpeed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns the race's wind.
|
|
|
|
|
|
|
|
* @return The race's wind.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Property<Wind> windProperty() {
|
|
|
|
|
|
|
|
return raceWind;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the RaceClock for this race.
|
|
|
|
* Returns the RaceClock for this race.
|
|
|
|
* This is used to track the start time, current time, and elapsed duration of the race.
|
|
|
|
* This is used to track the start time, current time, and elapsed duration of the race.
|
|
|
|
|