Added empty data sources, to be used by VisualiserRace.
Created FrameRateTracker which can be used to track framerate. Updated RequestToJoinEnum and JoinAcceptanceEnum to match the agreed connection API. Added AssignPlayerBoat message, which is used internally on the client to assign the player a source ID once they have connected. Fixed some race conditions in the MessageRouter. Updated ConnectionAcceptor.CheckClientConnection to wait slightly longer before removing connection (there was a slight race condition before). Race no longer has a reference to LatestMessages. LatestMessages no longer has specific messages types in it. Created RaceState class, which contains the state that is shared between VisualiserRaceState and MockRaceState (currently only used on visualiser). Split VisualiserRace into VisualiserRaceState and VisualiserRaceService. Added the VisualiserRace commands (BoatLocatonCommand, RaceStatusCommand, etc...). Slightly increased the preferred width of race.fxml table columns. issues #27 #37 #35 #story[1095]
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import shared.model.Boat;
|
||||
import shared.model.Mark;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An empty {@link BoatDataSource}. Can be used to initialise a race with no data.
|
||||
*/
|
||||
public class EmptyBoatDataSource implements BoatDataSource {
|
||||
|
||||
/**
|
||||
* A map of source ID to boat for all boats in the race.
|
||||
*/
|
||||
private final Map<Integer, Boat> boatMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A map of source ID to mark for all marks in the race.
|
||||
*/
|
||||
private final Map<Integer, Mark> markerMap = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
public EmptyBoatDataSource() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the boats that are going to participate in this race
|
||||
* @return Dictionary of boats that are to participate in this race indexed by SourceID
|
||||
*/
|
||||
@Override
|
||||
public Map<Integer, Boat> getBoats() {
|
||||
return boatMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the marker Boats that are participating in this race
|
||||
* @return Dictionary of the Markers Boats that are in this race indexed by their Source ID.
|
||||
*/
|
||||
@Override
|
||||
public Map<Integer, Mark> getMarkerBoats() {
|
||||
return markerMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import shared.model.CompoundMark;
|
||||
import shared.model.GPSCoordinate;
|
||||
import shared.model.Leg;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An empty {@link RaceDataSource}. Can be used to initialise a race with no data.
|
||||
*/
|
||||
public class EmptyRaceDataSource implements RaceDataSource {
|
||||
|
||||
|
||||
/**
|
||||
* The GPS coordinate of the top left of the race boundary.
|
||||
*/
|
||||
private GPSCoordinate mapTopLeft = new GPSCoordinate(0, 0);
|
||||
|
||||
/**
|
||||
* The GPS coordinate of the bottom right of the race boundary.
|
||||
*/
|
||||
private GPSCoordinate mapBottomRight = new GPSCoordinate(0, 0);
|
||||
|
||||
|
||||
/**
|
||||
* A list of GPS coordinates that make up the boundary of the race.
|
||||
*/
|
||||
private final List<GPSCoordinate> boundary = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* A map between compoundMarkID and a CompoundMark for all CompoundMarks in a race.
|
||||
*/
|
||||
private final Map<Integer, CompoundMark> compoundMarkMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A list of boat sourceIDs participating in the race.
|
||||
*/
|
||||
private final List<Integer> participants = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* A list of legs in the race.
|
||||
*/
|
||||
private final List<Leg> legs = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* The time that the race.xml file was created.
|
||||
*/
|
||||
private ZonedDateTime creationTimeDate = ZonedDateTime.now();
|
||||
|
||||
/**
|
||||
* The time that the race should start at, if it hasn't been postponed.
|
||||
*/
|
||||
private ZonedDateTime raceStartTime = ZonedDateTime.now().plusMinutes(5);
|
||||
|
||||
/**
|
||||
* Whether or not the race has been postponed.
|
||||
*/
|
||||
private boolean postpone = false;
|
||||
|
||||
|
||||
/**
|
||||
* The ID number of the race.
|
||||
*/
|
||||
private int raceID = 0;
|
||||
|
||||
/**
|
||||
* The type of the race.
|
||||
*/
|
||||
private RaceTypeEnum raceType = RaceTypeEnum.NOT_A_RACE_TYPE;
|
||||
|
||||
|
||||
|
||||
public EmptyRaceDataSource() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<GPSCoordinate> getBoundary() {
|
||||
return boundary;
|
||||
}
|
||||
|
||||
public GPSCoordinate getMapTopLeft() {
|
||||
return mapTopLeft;
|
||||
}
|
||||
|
||||
public GPSCoordinate getMapBottomRight() {
|
||||
return mapBottomRight;
|
||||
}
|
||||
|
||||
public List<Leg> getLegs() {
|
||||
return legs;
|
||||
}
|
||||
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return new ArrayList<>(compoundMarkMap.values());
|
||||
}
|
||||
|
||||
|
||||
public ZonedDateTime getCreationDateTime() {
|
||||
return creationTimeDate;
|
||||
}
|
||||
|
||||
public ZonedDateTime getStartDateTime() {
|
||||
return raceStartTime;
|
||||
}
|
||||
|
||||
public int getRaceId() {
|
||||
return raceID;
|
||||
}
|
||||
|
||||
public RaceTypeEnum getRaceType() {
|
||||
return raceType;
|
||||
}
|
||||
|
||||
public boolean getPostponed() {
|
||||
return postpone;
|
||||
}
|
||||
|
||||
public List<Integer> getParticipants() {
|
||||
return participants;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import shared.model.GPSCoordinate;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* An empty {@link RegattaDataSource}. Can be used to initialise a race with no data.
|
||||
*/
|
||||
public class EmptyRegattaDataSource implements RegattaDataSource {
|
||||
/**
|
||||
* The regatta ID.
|
||||
*/
|
||||
private int regattaID = 0;
|
||||
|
||||
/**
|
||||
* The regatta name.
|
||||
*/
|
||||
private String regattaName = "";
|
||||
|
||||
/**
|
||||
* The race ID.
|
||||
*/
|
||||
private int raceID = 0;
|
||||
|
||||
/**
|
||||
* The course name.
|
||||
*/
|
||||
private String courseName = "";
|
||||
|
||||
/**
|
||||
* The central latitude of the course.
|
||||
*/
|
||||
private double centralLatitude = 0;
|
||||
|
||||
/**
|
||||
* The central longitude of the course.
|
||||
*/
|
||||
private double centralLongitude = 0;
|
||||
|
||||
/**
|
||||
* The central altitude of the course.
|
||||
*/
|
||||
private double centralAltitude = 0;
|
||||
|
||||
/**
|
||||
* The UTC offset of the course.
|
||||
*/
|
||||
private float utcOffset = 0;
|
||||
|
||||
/**
|
||||
* The magnetic variation of the course.
|
||||
*/
|
||||
private float magneticVariation = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public EmptyRegattaDataSource() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int getRegattaID() {
|
||||
return regattaID;
|
||||
}
|
||||
|
||||
|
||||
public String getRegattaName() {
|
||||
return regattaName;
|
||||
}
|
||||
|
||||
|
||||
public int getRaceID() {
|
||||
return raceID;
|
||||
}
|
||||
|
||||
|
||||
public String getCourseName() {
|
||||
return courseName;
|
||||
}
|
||||
|
||||
|
||||
public double getCentralLatitude() {
|
||||
return centralLatitude;
|
||||
}
|
||||
|
||||
|
||||
public double getCentralLongitude() {
|
||||
return centralLongitude;
|
||||
}
|
||||
|
||||
|
||||
public double getCentralAltitude() {
|
||||
return centralAltitude;
|
||||
}
|
||||
|
||||
|
||||
public float getUtcOffset() {
|
||||
return utcOffset;
|
||||
}
|
||||
|
||||
|
||||
public float getMagneticVariation() {
|
||||
return magneticVariation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the GPS coorindates of the centre of the regatta.
|
||||
* @return The gps coordinate for the centre of the regatta.
|
||||
*/
|
||||
public GPSCoordinate getGPSCoordinate() {
|
||||
return new GPSCoordinate(centralLatitude, centralLongitude);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package shared.exceptions;
|
||||
|
||||
/**
|
||||
* An exception thrown when a specific mark cannot be found.
|
||||
*/
|
||||
public class MarkNotFoundException extends Exception {
|
||||
|
||||
public MarkNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MarkNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package shared.model;
|
||||
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to track the framerate of something.
|
||||
* Use {@link #incrementFps(long)} to update it, and {@link #fpsProperty()} to observe it.
|
||||
*/
|
||||
public class FrameRateTracker {
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private int currentFps = 0;
|
||||
|
||||
/**
|
||||
* The number of frames per second we generated over the last 1 second period.
|
||||
*/
|
||||
private IntegerProperty lastFps = new SimpleIntegerProperty(0);
|
||||
|
||||
/**
|
||||
* The time, in milliseconds, since we last reset our {@link #currentFps} counter.
|
||||
*/
|
||||
private long lastFpsResetTime;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link FrameRateTracker}. Use {@link #incrementFps(long)} to update it, and {@link #fpsProperty()} to observe it.
|
||||
*/
|
||||
public FrameRateTracker() {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of frames generated per second.
|
||||
* @return Frames per second.
|
||||
*/
|
||||
public int getFps() {
|
||||
return lastFps.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fps property.
|
||||
* @return The fps property.
|
||||
*/
|
||||
public IntegerProperty fpsProperty() {
|
||||
return lastFps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
||||
* @param timePeriod Time, in milliseconds, to add to {@link #lastFpsResetTime}.
|
||||
*/
|
||||
private void incrementFps(long timePeriod) {
|
||||
//Increment.
|
||||
this.currentFps++;
|
||||
|
||||
//Add period to timer.
|
||||
this.lastFpsResetTime += timePeriod;
|
||||
|
||||
//If we have reached 1 second period, snapshot the framerate and reset.
|
||||
if (this.lastFpsResetTime > 1000) {
|
||||
this.lastFps.set(this.currentFps);
|
||||
|
||||
this.currentFps = 0;
|
||||
this.lastFpsResetTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Timer used to update the framerate.
|
||||
* This is used because we care about frames in the javaFX thread.
|
||||
*/
|
||||
private AnimationTimer timer = new AnimationTimer() {
|
||||
|
||||
long previousFrameTime = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
|
||||
long currentFrameTime = System.currentTimeMillis();
|
||||
long framePeriod = currentFrameTime - previousFrameTime;
|
||||
|
||||
//Increment fps.
|
||||
incrementFps(framePeriod);
|
||||
|
||||
previousFrameTime = currentFrameTime;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Stops the {@link FrameRateTracker}'s timer.
|
||||
*/
|
||||
public void stop() {
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,17 +6,17 @@ import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import network.Messages.LatestMessages;
|
||||
import shared.dataInput.BoatDataSource;
|
||||
import shared.dataInput.RaceDataSource;
|
||||
import shared.dataInput.RegattaDataSource;
|
||||
import visualiser.model.VisualiserRaceEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a yacht race.
|
||||
* This is a base class inherited by {@link mock.model.MockRace} and {@link visualiser.model.VisualiserRace}.
|
||||
* This is a base class inherited by {@link mock.model.MockRace} and {@link VisualiserRaceEvent}.
|
||||
* 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 {
|
||||
@@ -37,11 +37,6 @@ public abstract class Race {
|
||||
*/
|
||||
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.
|
||||
@@ -116,16 +111,14 @@ public abstract class Race {
|
||||
* @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 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.
|
||||
this.raceDataSource = raceDataSource;
|
||||
this.boatDataSource = boatDataSource;
|
||||
this.regattaDataSource = regattaDataSource;
|
||||
|
||||
this.latestMessages = latestMessages;
|
||||
|
||||
|
||||
//Marks.
|
||||
@@ -241,7 +234,7 @@ public abstract class Race {
|
||||
* @param windBearing New wind bearing.
|
||||
* @param windSpeedKnots New wind speed, in knots.
|
||||
*/
|
||||
protected void setWind(Bearing windBearing, double windSpeedKnots) {
|
||||
public void setWind(Bearing windBearing, double windSpeedKnots) {
|
||||
Wind wind = new Wind(windBearing, windSpeedKnots);
|
||||
setWind(wind);
|
||||
}
|
||||
@@ -250,7 +243,7 @@ public abstract class Race {
|
||||
* Updates the race to have a specified wind (bearing and speed).
|
||||
* @param wind New wind.
|
||||
*/
|
||||
protected void setWind(Wind wind) {
|
||||
public void setWind(Wind wind) {
|
||||
this.raceWind.setValue(wind);
|
||||
}
|
||||
|
||||
@@ -316,6 +309,23 @@ public abstract class Race {
|
||||
return boundary;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the marks of the race.
|
||||
* @return Marks of the race.
|
||||
*/
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return compoundMarks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legs of the race.
|
||||
* @return Legs of the race.
|
||||
*/
|
||||
public List<Leg> getLegs() {
|
||||
return legs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of frames generated per second.
|
||||
* @return Frames per second.
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
package shared.model;
|
||||
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import shared.dataInput.BoatDataSource;
|
||||
import shared.dataInput.RaceDataSource;
|
||||
import shared.dataInput.RegattaDataSource;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a yacht race.
|
||||
* This is a base class inherited by {@link mock.model.MockRace} and {@link visualiser.model.VisualiserRaceState}.
|
||||
* 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 RaceState {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Data source for race information.
|
||||
*/
|
||||
private RaceDataSource raceDataSource;
|
||||
|
||||
/**
|
||||
* Data source for boat information.
|
||||
*/
|
||||
private BoatDataSource boatDataSource;
|
||||
|
||||
/**
|
||||
* Data source for regatta information.
|
||||
*/
|
||||
private RegattaDataSource regattaDataSource;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The clock which tracks the race's start time, current time, and elapsed duration.
|
||||
*/
|
||||
private RaceClock raceClock;
|
||||
|
||||
|
||||
/**
|
||||
* The current status of the race.
|
||||
*/
|
||||
private RaceStatusEnum raceStatusEnum;
|
||||
|
||||
|
||||
/**
|
||||
* The race's wind.
|
||||
*/
|
||||
private Property<Wind> raceWind = new SimpleObjectProperty<>();
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an empty race object.
|
||||
* This is initialised into a "default" state, with no data.
|
||||
*/
|
||||
public RaceState() {
|
||||
|
||||
//Race clock.
|
||||
this.raceClock = new RaceClock(ZonedDateTime.now());
|
||||
|
||||
//Race status.
|
||||
this.setRaceStatusEnum(RaceStatusEnum.NOT_ACTIVE);
|
||||
|
||||
//Wind.
|
||||
this.setWind(Bearing.fromDegrees(0), 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the boats in the race.
|
||||
* This sets their starting positions and current legs.
|
||||
*/
|
||||
protected abstract void initialiseBoats();
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected void useLegsList(List<Leg> legs) {
|
||||
//We add a "dummy" leg at the end of the race.
|
||||
if (legs.size() > 0) {
|
||||
getLegs().add(new Leg("Finish", getLegs().size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether or not a specific leg is the last leg in the race.
|
||||
* @param leg The leg to check.
|
||||
* @return Returns true if it is the last, false otherwise.
|
||||
*/
|
||||
protected boolean isLastLeg(Leg leg) {
|
||||
|
||||
//Get the last leg.
|
||||
Leg lastLeg = getLegs().get(getLegs().size() - 1);
|
||||
|
||||
//Check its ID.
|
||||
int lastLegID = lastLeg.getLegNumber();
|
||||
|
||||
//Get the specified leg's ID.
|
||||
int legID = leg.getLegNumber();
|
||||
|
||||
|
||||
//Check if they are the same.
|
||||
return legID == lastLegID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the race data source for the race.
|
||||
* @param raceDataSource New race data source.
|
||||
*/
|
||||
public void setRaceDataSource(RaceDataSource raceDataSource) {
|
||||
this.raceDataSource = raceDataSource;
|
||||
this.getRaceClock().setStartingTime(raceDataSource.getStartDateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the boat data source for the race.
|
||||
* @param boatDataSource New boat data source.
|
||||
*/
|
||||
public void setBoatDataSource(BoatDataSource boatDataSource) {
|
||||
this.boatDataSource = boatDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the regatta data source for the race.
|
||||
* @param regattaDataSource New regatta data source.
|
||||
*/
|
||||
public void setRegattaDataSource(RegattaDataSource regattaDataSource) {
|
||||
this.regattaDataSource = regattaDataSource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the race data source for the race.
|
||||
* @return Race data source.
|
||||
*/
|
||||
public RaceDataSource getRaceDataSource() {
|
||||
return raceDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the race data source for the race.
|
||||
* @return Race data source.
|
||||
*/
|
||||
public BoatDataSource getBoatDataSource() {
|
||||
return boatDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the race data source for the race.
|
||||
* @return Race data source.
|
||||
*/
|
||||
public RegattaDataSource getRegattaDataSource() {
|
||||
return regattaDataSource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of {@link Mark} boats.
|
||||
* @return List of mark boats.
|
||||
*/
|
||||
public List<Mark> getMarks() {
|
||||
return new ArrayList<>(boatDataSource.getMarkerBoats().values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of sourceIDs participating in the race.
|
||||
* @return List of sourceIDs participating in the race.
|
||||
*/
|
||||
public List<Integer> getParticipants() {
|
||||
return raceDataSource.getParticipants();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current race status.
|
||||
* @return The current race status.
|
||||
*/
|
||||
public RaceStatusEnum getRaceStatusEnum() {
|
||||
return raceStatusEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current race status.
|
||||
* @param raceStatusEnum The new status of the race.
|
||||
*/
|
||||
public void setRaceStatusEnum(RaceStatusEnum raceStatusEnum) {
|
||||
this.raceStatusEnum = raceStatusEnum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type of race this is.
|
||||
* @return The type of race this is.
|
||||
*/
|
||||
public RaceTypeEnum getRaceType() {
|
||||
return raceDataSource.getRaceType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the regatta.
|
||||
* @return The name of the regatta.
|
||||
*/
|
||||
public String getRegattaName() {
|
||||
return regattaDataSource.getRegattaName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the race to have a specified wind bearing and speed.
|
||||
* @param windBearing New wind bearing.
|
||||
* @param windSpeedKnots New wind speed, in knots.
|
||||
*/
|
||||
public void setWind(Bearing windBearing, double windSpeedKnots) {
|
||||
Wind wind = new Wind(windBearing, windSpeedKnots);
|
||||
setWind(wind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the race to have a specified wind (bearing and speed).
|
||||
* @param wind New wind.
|
||||
*/
|
||||
public void setWind(Wind wind) {
|
||||
this.raceWind.setValue(wind);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the wind bearing.
|
||||
* @return The wind bearing.
|
||||
*/
|
||||
public Bearing getWindDirection() {
|
||||
return raceWind.getValue().getWindDirection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wind speed.
|
||||
* Measured in knots.
|
||||
* @return The wind speed.
|
||||
*/
|
||||
public double 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.
|
||||
* This is used to track the start time, current time, and elapsed duration of the race.
|
||||
* @return The RaceClock for the race.
|
||||
*/
|
||||
public RaceClock getRaceClock() {
|
||||
return raceClock;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of legs in the race.
|
||||
* @return The number of legs in the race.
|
||||
*/
|
||||
public int getLegCount() {
|
||||
//We minus one, as we have added an extra "dummy" leg.
|
||||
return getLegs().size() - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the race boundary.
|
||||
* @return The race boundary.
|
||||
*/
|
||||
public List<GPSCoordinate> getBoundary() {
|
||||
return raceDataSource.getBoundary();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the marks of the race.
|
||||
* @return Marks of the race.
|
||||
*/
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return raceDataSource.getCompoundMarks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legs of the race.
|
||||
* @return Legs of the race.
|
||||
*/
|
||||
public List<Leg> getLegs() {
|
||||
return raceDataSource.getLegs();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID of the race.
|
||||
* @return ID of the race.
|
||||
*/
|
||||
public int getRaceId() {
|
||||
return raceDataSource.getRaceId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID of the regatta.
|
||||
* @return The ID of the regatta.
|
||||
*/
|
||||
public int getRegattaID() {
|
||||
return regattaDataSource.getRegattaID();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the course.
|
||||
* @return Name of the course.
|
||||
*/
|
||||
public String getCourseName() {
|
||||
return regattaDataSource.getCourseName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -50,4 +50,5 @@ public interface RunnableWithFramePeriod extends Runnable {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user