You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
3.0 KiB
144 lines
3.0 KiB
package network.Messages;
|
|
|
|
|
|
import network.Messages.Enums.MessageType;
|
|
import network.Utils.AC35UnitConverter;
|
|
import shared.model.Constants;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Created by fwy13 on 25/04/17.
|
|
*/
|
|
public class RaceStatus extends AC35Data {
|
|
|
|
private long currentTime;
|
|
private int raceID;
|
|
private byte raceStatus;
|
|
private long expectedStartTime;
|
|
private int windDirection;
|
|
private int windSpeed;
|
|
private int raceType;
|
|
private List<BoatStatus> boatStatuses;
|
|
|
|
public RaceStatus(long currentTime, int raceID, byte raceStatus, long expectedStartTime, int windDirection, int windSpeed, int raceType, List<BoatStatus> boatStatuses){
|
|
super(MessageType.RACESTATUS);
|
|
this.currentTime = currentTime;
|
|
this.raceID = raceID;
|
|
this.raceStatus = raceStatus;
|
|
this.expectedStartTime = expectedStartTime;
|
|
this.windDirection = windDirection;
|
|
this.windSpeed = windSpeed;
|
|
this.raceType = raceType;
|
|
this.boatStatuses = boatStatuses;//note this is not a copy so any alterations to the parent will affect this.
|
|
}
|
|
|
|
|
|
|
|
///Getters.
|
|
|
|
public long getCurrentTime()
|
|
{
|
|
return currentTime;
|
|
}
|
|
|
|
public int getRaceID()
|
|
{
|
|
return raceID;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return race status number
|
|
*/
|
|
public byte getRaceStatus()
|
|
{
|
|
return raceStatus;
|
|
}
|
|
|
|
public long getExpectedStartTime()
|
|
{
|
|
return expectedStartTime;
|
|
}
|
|
|
|
public int getWindDirection()
|
|
{
|
|
return windDirection;
|
|
}
|
|
|
|
/**
|
|
* Returns the wind speed for this race status, in millimeters per second.
|
|
* @return Wind speed in millimeters per second.
|
|
*/
|
|
public int getWindSpeed()
|
|
{
|
|
return windSpeed;
|
|
}
|
|
|
|
public int getRaceType()
|
|
{
|
|
return raceType;
|
|
}
|
|
|
|
public List<BoatStatus> getBoatStatuses()
|
|
{
|
|
return boatStatuses;
|
|
}
|
|
|
|
public boolean isNotActive() {
|
|
return raceStatus == 0;
|
|
}
|
|
|
|
public boolean isWarning() {
|
|
return raceStatus == 1;
|
|
}
|
|
|
|
public boolean isPreparatory() {
|
|
return raceStatus == 2;
|
|
}
|
|
|
|
public boolean isStarted() {
|
|
return raceStatus == 3;
|
|
}
|
|
|
|
public boolean isFinished() {
|
|
return raceStatus == 4;
|
|
}
|
|
|
|
public boolean isRetired() {
|
|
return raceStatus == 5;
|
|
}
|
|
|
|
public boolean isAbandoned() {
|
|
return raceStatus == 6;
|
|
}
|
|
|
|
public boolean isPostponed() {
|
|
return raceStatus == 7;
|
|
}
|
|
|
|
public boolean isTerminated() {
|
|
return raceStatus == 8;
|
|
}
|
|
|
|
public boolean isStartTimeSet() {
|
|
return raceStatus != 9;
|
|
}
|
|
|
|
public boolean isPrestart() {
|
|
return raceStatus == 10;
|
|
}
|
|
|
|
public double getScaledWindDirection() {
|
|
return AC35UnitConverter.convertHeading(windDirection);
|
|
}
|
|
|
|
/**
|
|
* Returns the wind speed for this race status, in knots.
|
|
* @return Wind speed in knots.
|
|
*/
|
|
public double getWindSpeedKnots() {
|
|
return (windSpeed / Constants.KnotsToMMPerSecond);
|
|
}
|
|
}
|