Merge branch 'master' into MapWindRotation

# Conflicts:
#	racevisionGame/src/main/java/mock/app/Event.java
#	racevisionGame/src/main/java/mock/model/MockRace.java
#	racevisionGame/src/main/java/visualiser/app/VisualiserInput.java
#	racevisionGame/src/main/java/visualiser/model/VisualiserRace.java
This commit is contained in:
Fan-Wu Yang
2017-08-14 03:54:02 +12:00
114 changed files with 7215 additions and 2441 deletions
@@ -38,7 +38,7 @@ public class Constants {
/**
* The race pre-start time, in milliseconds. 3 minutes.
*/
public static final long RacePreStartTime = 3 * 60 * 1000;
public static final long RacePreStartTime = 1 * 10 * 1000;
/**
@@ -1,7 +1,9 @@
package shared.model;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import network.Messages.Enums.RaceStatusEnum;
import network.Messages.Enums.RaceTypeEnum;
import network.Messages.LatestMessages;
@@ -17,7 +19,7 @@ import java.util.List;
* This is a base class inherited by {@link mock.model.MockRace} and {@link visualiser.model.VisualiserRace}.
* 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 implements Runnable {
public abstract class Race {
/**
@@ -41,18 +43,6 @@ public abstract class Race implements Runnable {
*/
protected LatestMessages latestMessages;
/**
* The sequence number of the latest BoatLocation message sent or received.
*/
protected int boatLocationSequenceNumber = 1;
/**
* The sequence number of the latest RaceStatus message sent or received.
*/
protected int raceStatusSequenceNumber = 1;
/**
* A list of compound marks in the race.
*/
@@ -98,15 +88,9 @@ public abstract class Race implements Runnable {
/**
* The current wind direction bearing.
* The race's wind.
*/
protected Bearing windDirection;
/**
* Wind speed (knots).
* Convert this to millimeters per second before passing to RaceStatus.
*/
protected double windSpeed;
protected Property<Wind> raceWind = new SimpleObjectProperty<>();
/**
@@ -169,11 +153,8 @@ public abstract class Race implements Runnable {
//Race type.
this.raceType = raceDataSource.getRaceType();
//Wind speed.
this.windSpeed = 0;
//Wind direction.
this.windDirection = Bearing.fromDegrees(0);
//Wind.
this.setWind(Bearing.fromDegrees(0), 0);
}
@@ -233,7 +214,7 @@ public abstract class Race implements Runnable {
* Sets the current race status.
* @param raceStatusEnum The new status of the race.
*/
protected void setRaceStatusEnum(RaceStatusEnum raceStatusEnum) {
public void setRaceStatusEnum(RaceStatusEnum raceStatusEnum) {
this.raceStatusEnum = raceStatusEnum;
}
@@ -254,12 +235,32 @@ public abstract class Race implements Runnable {
return regattaName;
}
/**
* Updates the race to have a specified wind bearing and speed.
* @param windBearing New wind bearing.
* @param windSpeedKnots New wind speed, in knots.
*/
protected 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.
*/
protected void setWind(Wind wind) {
this.raceWind.setValue(wind);
}
/**
* Returns the wind bearing.
* @return The wind bearing.
*/
public Bearing getWindDirection() {
return windDirection;
return raceWind.getValue().getWindDirection();
}
/**
@@ -268,7 +269,15 @@ public abstract class Race implements Runnable {
* @return The wind speed.
*/
public double getWindSpeed() {
return windSpeed;
return raceWind.getValue().getWindSpeed();
}
/**
* Returns the race's wind.
* @return The race's wind.
*/
public Property<Wind> windProperty() {
return raceWind;
}
/**
@@ -343,4 +352,8 @@ public abstract class Race implements Runnable {
this.lastFpsResetTime = 0;
}
}
public int getRaceId() {
return raceId;
}
}
@@ -0,0 +1,51 @@
package shared.model;
/**
* This class encapsulates the wind during a race.
* It has speed and a bearing.
* This is intended to be immutable.
*/
public class Wind {
/**
* The current wind direction bearing.
*/
private Bearing windDirection;
/**
* Wind speed (knots).
* Convert this to millimeters per second before passing to RaceStatus.
*/
private double windSpeed;
/**
* Constructs a new wind object, with a given direction and speed, in knots.
* @param windDirection The direction of the wind.
* @param windSpeed The speed of the wind, in knots.
*/
public Wind(Bearing windDirection, double windSpeed) {
this.windDirection = windDirection;
this.windSpeed = windSpeed;
}
/**
* Returns the race wind's bearing.
* @return The race wind's bearing.
*/
public Bearing getWindDirection() {
return windDirection;
}
/**
* Returns the race wind's speed, in knots.
* @return The race wind's speed, in knots.
*/
public double getWindSpeed() {
return windSpeed;
}
}