Refactored and moved RaceXMLReader to shared/dataInput.

RaceStatus can provide windspeed in knots in addition to mm/sec.
RaceDataSource now provides a list of participating boat sourceIDs instead of boats.
Added a RegattaDataSource interface.
Angle, Azimuth, Bearing and mutable - careful.
Boat has positionInRace.
CompoundMarks have an ID and name.
Marks can be moved (setPosition(...)).

Refactored Mock.Race, Visualiser.StreamedCourse, Visualiser.StreamedRace, into (shared) Race, MockRace, VisualiserRace.

VisualiserBoat has color.
Added xml and polar files into resources folder.
This commit is contained in:
fjc40
2017-07-06 01:30:55 +12:00
parent 7f027c8cc5
commit 8d36d89570
35 changed files with 1806 additions and 1221 deletions
@@ -1,7 +1,8 @@
package network.Messages;
import seng302.Networking.Messages.Enums.BoatStatusEnum;
import seng302.Networking.Utils.ByteConverter;
import network.Messages.Enums.BoatStatusEnum;
import network.Utils.ByteConverter;
/**
* Created by hba56 on 23/04/17.
@@ -22,7 +22,7 @@ public enum RaceTypeEnum {
/**
* Used to indicate that a given byte value is invalid.
*/
NOT_A_STATUS(-1);
NOT_A_RACE_TYPE(-1);
/**
@@ -48,6 +48,29 @@ public enum RaceTypeEnum {
}
/**
* Attempts to convert a string into a RaceTypeEnum.
* Ignores case.
* Treats anything starting with "fleet" as {@link #FLEET_RACE}, and anything starting with "match" as {@link #MATCH_RACE}.
* @param value The string to convert.
* @return The RaceTypeEnum.
*/
public static RaceTypeEnum fromString(String value) {
//Convert to lower case.
value = value.toLowerCase();
if (value.startsWith("fleet")) {
return FLEET_RACE;
} else if (value.startsWith("match")) {
return MATCH_RACE;
} else {
return NOT_A_RACE_TYPE;
}
}
/**
* Stores a mapping between Byte values and RaceStatusEnum values.
*/
@@ -74,8 +97,8 @@ public enum RaceTypeEnum {
RaceTypeEnum type = RaceTypeEnum.byteToStatusMap.get(raceTypeEnum);
if (type == null) {
//If the byte value wasn't found, return the NOT_A_STATUS RaceTypeEnum.
return RaceTypeEnum.NOT_A_STATUS;
//If the byte value wasn't found, return the NOT_A_RACE_TYPE RaceTypeEnum.
return RaceTypeEnum.NOT_A_RACE_TYPE;
} else {
//Otherwise, return the RaceTypeEnum.
return type;
@@ -1,7 +1,9 @@
package network.Messages;
import seng302.Networking.Messages.Enums.MessageType;
import seng302.Networking.Utils.AC35UnitConverter;
import network.Messages.Enums.MessageType;
import network.Utils.AC35UnitConverter;
import shared.model.Constants;
import java.util.List;
@@ -12,7 +14,7 @@ public class RaceStatus extends AC35Data {
private long currentTime;
private int raceID;
private int raceStatus;
private byte raceStatus;
private long expectedStartTime;
private int windDirection;
private int windSpeed;
@@ -49,7 +51,7 @@ public class RaceStatus extends AC35Data {
*
* @return race status number
*/
public int getRaceStatus()
public byte getRaceStatus()
{
return raceStatus;
}
@@ -64,6 +66,10 @@ public class RaceStatus extends AC35Data {
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;
@@ -124,6 +130,14 @@ public class RaceStatus extends AC35Data {
}
public double getScaledWindDirection() {
return (double) AC35UnitConverter.convertHeading(windDirection);
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);
}
}