Renamed some directories, optimized imports, general code clean up

#story[778]
main
Erika Savell 9 years ago
parent 073102d1a3
commit 83dfe1a60c

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -88,7 +88,8 @@
<version>2.4.3</version>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>seng302.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>

@ -4,8 +4,10 @@ package seng302;
import javafx.application.Application;
import javafx.stage.Stage;
import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource;
import seng302.Mock.RegattaDataSource;
import seng302.DataInput.RaceDataSource;
import seng302.DataInput.RaceXMLReader;
import seng302.DataInput.RegattaDataSource;
import seng302.DataInput.RegattaXMLReader;
import seng302.Model.Event;
import javax.xml.parsers.ParserConfigurationException;

@ -1,8 +1,5 @@
package seng302;
import javafx.scene.paint.Color;
import seng302.Model.BoatInRace;
/**
* Constants that are used throughout the program
* Created by Erika on 19-Mar-17.

@ -3,11 +3,9 @@ package seng302.Data;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import seng302.Exceptions.InvalidBoatDataException;
import seng302.Model.BoatInRace;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@ -24,8 +22,8 @@ import java.util.List;
*/
public class BoatData {
private List<BoatInRace> boatData;
Document doc;
private List<BoatInRace> boatData;
public BoatData(List<BoatInRace> boatData) {
@ -34,6 +32,7 @@ public class BoatData {
/**
* Creates an AC35 officially formatted xml description of boats competing in a race
*
* @return String containing xml-formatted boats description
*/
public String createXML() {
@ -61,7 +60,7 @@ public class BoatData {
//Serialize document.
StringWriter stringWriter = new StringWriter();
StreamResult result = new StreamResult(stringWriter);
transformer.transform(source,result);
transformer.transform(source, result);
return stringWriter.toString();
@ -76,11 +75,12 @@ public class BoatData {
/**
* Runs through competing boats, creating an element for each
*
* @param boatsElement boats element to be added to
*/
private void appendIndividualBoats(Element boatsElement) {
for (int i=0; i < boatData.size(); i++) {
for (int i = 0; i < boatData.size(); i++) {
Element boat = doc.createElement("Boat");
appendType(boat);
appendSourceID(boat, i);
@ -97,6 +97,7 @@ public class BoatData {
/**
* Creates and appends type attribute of a boat
*
* @param boat element being added to
*/
private void appendType(Element boat) {
@ -108,8 +109,9 @@ public class BoatData {
/**
* Creates and appends sourceID attribute of a boat
*
* @param boat element being added to
* @param i boat number
* @param i boat number
*/
private void appendSourceID(Element boat, int i) {
//SourceID attribute
@ -120,6 +122,7 @@ public class BoatData {
/**
* Creates and appends shapeID attribute of a boat
*
* @param boat element being added to
*/
private void appendShapeID(Element boat) {
@ -131,6 +134,7 @@ public class BoatData {
/**
* Creates and appends hull name attribute of a boat
*
* @param boat element being added to
*/
private void appendHullNum(Element boat) {
@ -142,8 +146,9 @@ public class BoatData {
/**
* Creates and appends stow name attribute of a boat
*
* @param boat element being added to
* @param i boat number
* @param i boat number
*/
private void appendStoweName(Element boat, int i) {
//StoweName attribute
@ -154,8 +159,9 @@ public class BoatData {
/**
* Creates and appends short name attribute of a boat
*
* @param boat element being added to
* @param i boat number
* @param i boat number
*/
private void appendShortName(Element boat, int i) {
//ShortName attribute
@ -166,8 +172,9 @@ public class BoatData {
/**
* Creates and appends boat name attribute of a boat
*
* @param boat element being added to
* @param i boat number
* @param i boat number
*/
private void appendBoatName(Element boat, int i) {
//BoatName attribute
@ -178,8 +185,9 @@ public class BoatData {
/**
* Creates and appends gps attributes of a boat
*
* @param boat element being added to
* @param i boat number
* @param i boat number
*/
private void appendGPSCoords(Element boat, int i) {
//GPSCoord for element

@ -2,11 +2,11 @@ package seng302.Data;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import seng302.DataInput.RaceDataSource;
import seng302.Exceptions.InvalidRaceDataException;
import seng302.GPSCoordinate;
import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Marker;
import seng302.Mock.RaceDataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -36,6 +36,7 @@ public class RaceData {
/**
* Creates an AC35 officially formatted xml description of a race.
*
* @return String containing xml-formatted race description
*/
public String createXML() {
@ -158,6 +159,7 @@ public class RaceData {
/**
* Creates a mark element for insertion in a coumpound mark element
*
* @param marker GPS coordinates of the mark
* @return Element mark element
*/
@ -170,8 +172,9 @@ public class RaceData {
/**
* Creates a compound marker holding one or two marks,and a sequence number
*
* @param marker marker
* @param i sequence number
* @param i sequence number
* @return Element compound mark element
*/
private Element createCompoundMarker(Marker marker, int i) {
@ -190,6 +193,7 @@ public class RaceData {
/**
* Creates a corner element
*
* @param i sequence number
* @return Element corner element
*/

@ -2,8 +2,8 @@ package seng302.Data;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import seng302.DataInput.RegattaDataSource;
import seng302.Exceptions.InvalidRegattaDataException;
import seng302.Mock.RegattaDataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -32,6 +32,7 @@ public class RegattaData {
/**
* Creates an AC35 officially formatted xml description of a regatta
*
* @return String containing xml-formatted regatta description
*/
public String createXML() {
@ -55,7 +56,7 @@ public class RegattaData {
//Serialize document.
StringWriter stringWriter = new StringWriter();
StreamResult result = new StreamResult(stringWriter);
transformer.transform(source,result);
transformer.transform(source, result);
return stringWriter.toString();

@ -1,7 +1,7 @@
package seng302.Mock;
package seng302.DataInput;
import seng302.GPSCoordinate;
import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Leg;
import seng302.Model.Marker;
@ -12,14 +12,20 @@ import java.util.List;
*/
public interface RaceDataSource {
List<BoatInRace> getBoats();
List<Leg> getLegs();
List<GPSCoordinate> getBoundary();
List<Marker> getMarkers();
String getRaceId();
String getRaceType();
GPSCoordinate getMark();
GPSCoordinate getMapTopLeft();
GPSCoordinate getMapBottomRight();
}

@ -1,11 +1,11 @@
package seng302;
package seng302.DataInput;
import javafx.scene.paint.Color;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource;
import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Leg;
import seng302.Model.Marker;
@ -18,6 +18,7 @@ import java.util.List;
* Created by fwy13 on 26/03/2017.
*/
public class RaceXMLReader extends XMLReader implements RaceDataSource {
private static double COORDINATEPADDING = 0.0005;
private String raceID;
private List<BoatInRace> boats = new ArrayList<>();
private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
@ -25,14 +26,14 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private static double COORDINATEPADDING = 0.0005;
private List<Marker> markers = new ArrayList<>();
/**
* Constractor for Race XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RaceXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
@ -41,10 +42,11 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* COnstructor for Race XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RaceXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
@ -75,7 +77,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* Read all the boats in the XML file
*/
*/
public void readBoats() {
//get all boats
NodeList nBoats = doc.getElementsByTagName("boat");
@ -95,7 +97,6 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
}
/**
* Read all the boats in the XML file
*/
@ -198,6 +199,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return
*/
@ -207,7 +209,8 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag
* @return
*/
@ -217,9 +220,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag
* @param nodeIndex coordinate index
* @param nodeIndex coordinate index
* @return
*/
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
@ -230,6 +234,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a changes a marker to GPS coordinates into a marker
*
* @param markerNode marker to turn into coordinates
* @return
*/
@ -250,6 +255,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return
*/
@ -257,9 +263,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return getCoordinates(start, 0);
}
/**
/**
* gets a coordinates from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in
* @return
*/
@ -267,11 +274,12 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return getCoordinates(start, startIndex, 0);
}
/**
/**
* gets a coordinates from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in
* @param nodeIndex The coordinate index
* @param nodeIndex The coordinate index
* @return
*/
private GPSCoordinate getCoordinates(NodeList start, int startIndex, int nodeIndex) {
@ -349,9 +357,13 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return mapBottomRight;
}
public String getRaceId() { return raceID; }
public String getRaceId() {
return raceID;
}
public List<Marker> getMarkers() { return markers; }
public List<Marker> getMarkers() {
return markers;
}
public String getRaceType() {
return "FLEET";

@ -1,10 +1,10 @@
package seng302.Mock;
package seng302.DataInput;
import seng302.Model.Regatta;
/**
* Created by zwu18 on 25/04/17.
*/
public interface RegattaDataSource{
public interface RegattaDataSource {
Regatta getRegatta();
}

@ -1,11 +1,9 @@
package seng302;
package seng302.DataInput;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.Mock.RegattaDataSource;
import seng302.Model.Regatta;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
@ -18,9 +16,10 @@ public class RegattaXMLReader extends XMLReader implements RegattaDataSource {
/**
* Constructor for Regatta XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RegattaXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
@ -29,10 +28,11 @@ public class RegattaXMLReader extends XMLReader implements RegattaDataSource {
/**
* Constructor for Regatta XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {

@ -1,4 +1,4 @@
package seng302;
package seng302.DataInput;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

@ -7,15 +7,12 @@ package seng302.Exceptions;
/**
* An exception thrown when we cannot generate Boats.xml and send an XML message.
*/
public class InvalidBoatDataException extends RuntimeException
{
public class InvalidBoatDataException extends RuntimeException {
public InvalidBoatDataException()
{
public InvalidBoatDataException() {
}
public InvalidBoatDataException(String message)
{
public InvalidBoatDataException(String message) {
super(message);
}
}

@ -7,14 +7,11 @@ package seng302.Exceptions;
/**
* Exception thrown when we cannot generate Race.xml data, and send an XML message.
*/
public class InvalidRaceDataException extends RuntimeException
{
public InvalidRaceDataException()
{
public class InvalidRaceDataException extends RuntimeException {
public InvalidRaceDataException() {
}
public InvalidRaceDataException(String message)
{
public InvalidRaceDataException(String message) {
super(message);
}
}

@ -7,14 +7,11 @@ package seng302.Exceptions;
/**
* An exception thrown when a Regatta.xml message cannot be generated and sent.
*/
public class InvalidRegattaDataException extends RuntimeException
{
public InvalidRegattaDataException()
{
public class InvalidRegattaDataException extends RuntimeException {
public InvalidRegattaDataException() {
}
public InvalidRegattaDataException(String message)
{
public InvalidRegattaDataException(String message) {
super(message);
}
}

@ -19,7 +19,7 @@ public class Boat {
*
* @param name Name of the Boat.
* @param velocity Speed in m/s that the boat travels at.
* @param abbrev nam abbreviation
* @param abbrev nam abbreviation
*/
public Boat(String name, double velocity, String abbrev, int sourceID) {
this.velocity = velocity;
@ -52,8 +52,6 @@ public class Boat {
return velocity;
}
public int getSourceID() { return sourceID; }
/**
* Sets the speed of the boat in knots.
*
@ -64,6 +62,10 @@ public class Boat {
this.velocityProp.setValue(String.valueOf(Math.round(velocity)));
}
public int getSourceID() {
return sourceID;
}
/**
* Print method prints the name of the boat
*

@ -5,11 +5,8 @@ import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color;
import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Boat in the Race extends Boat.
@ -40,7 +37,7 @@ public class BoatInRace extends Boat {
* @param name Name of the boat.
* @param velocity Speed that the boat travels.
* @param colour Colour the boat will be displayed as on the map
* @param abbrev of boat
* @param abbrev of boat
*/
public BoatInRace(String name, double velocity, Color colour, String abbrev, int sourceID) {
super(name, velocity, abbrev, sourceID);
@ -49,6 +46,20 @@ public class BoatInRace extends Boat {
position = new SimpleStringProperty("-");
}
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
/**
* Calculates the azimuth of the travel via map coordinates of the raceMarkers
*
@ -66,20 +77,6 @@ public class BoatInRace extends Boat {
return calc.getAzimuth();
}
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
public double getHeading() {
return heading;
}
@ -258,20 +255,20 @@ public class BoatInRace extends Boat {
return position.get();
}
public StringProperty positionProperty() {
return position;
}
public void setPosition(String position) {
this.position.set(position);
}
public StringProperty positionProperty() {
return position;
}
/**
* Returns the current sequence number, and increments the internal value, such that that next call will return a value 1 larger than the current call.
*
* @return Current sequence number.
*/
public long getNextSequenceNumber(){
public long getNextSequenceNumber() {
//Make a copy of current value.
long oldNumber = this.sequenceNumber;
//Increment.

@ -3,12 +3,11 @@ package seng302.Model;
import seng302.Data.BoatData;
import seng302.Data.RaceData;
import seng302.Data.RegattaData;
import seng302.Mock.RegattaDataSource;
import seng302.DataInput.RaceDataSource;
import seng302.DataInput.RegattaDataSource;
import seng302.Exceptions.InvalidBoatDataException;
import seng302.Exceptions.InvalidRaceDataException;
import seng302.Exceptions.InvalidRegattaDataException;
import seng302.Mock.RaceDataSource;
/**
@ -24,8 +23,7 @@ public class Event {
this.regattaDataSource = regattaData;
}
public void start()
{
public void start() {
System.out.println("\nREGATTA DATA\n");//TEMP REMOVE debug
sendRegattaData();
System.out.println("\nRACE DATA\n");//TEMP REMOVE debug
@ -49,8 +47,7 @@ public class Event {
}
public void sendRaceData() throws InvalidRaceDataException
{
public void sendRaceData() throws InvalidRaceDataException {
RaceData raceData = new RaceData(raceDataSource);
//Serialize race data to an XML as a string.
String xmlString = raceData.createXML();
@ -58,8 +55,7 @@ public class Event {
System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call
}
public void sendBoatData() throws InvalidBoatDataException
{
public void sendBoatData() throws InvalidBoatDataException {
BoatData boatData = new BoatData(raceDataSource.getBoats());
//Serialize race data to an XML as a string.
String xmlString = boatData.createXML();

@ -1,4 +1,4 @@
package seng302;
package seng302.Model;
/**
* GPS Coordinate for the world map.

@ -2,7 +2,6 @@ package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants;
import seng302.GPSCoordinate;
/**
* Created by cbt24 on 6/03/17.
@ -17,9 +16,9 @@ public class Leg {
/**
* Leg Initialiser
*
* @param name Name of the Leg
* @param start marker
* @param end marker
* @param name Name of the Leg
* @param start marker
* @param end marker
* @param number Leg's position in race
*/
public Leg(String name, Marker start, Marker end, int number) {
@ -33,7 +32,7 @@ public class Leg {
/**
* Construction Method
*
* @param name Name of the Leg
* @param name Name of the Leg
* @param number leg number
*/
public Leg(String name, int number) {
@ -74,16 +73,14 @@ public class Leg {
return startMarker;
}
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public Marker getEndMarker() {
return endMarker;
}
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public void setEndMarker(Marker endMarker) {
this.endMarker = endMarker;
}

@ -1,7 +1,6 @@
package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D;

@ -2,17 +2,13 @@ package seng302.Model;
import javafx.animation.AnimationTimer;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants;
import seng302.GPSCoordinate;
import seng302.Mock.RaceDataSource;
import seng302.DataInput.RaceDataSource;
import seng302.RaceEventMessages.BoatLocationMessage;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
@ -29,18 +25,17 @@ public class Race implements Runnable {
protected List<Leg> legs;
protected int boatsFinished = 0;
protected long totalTimeElapsed;
private int lastFPS = 20;
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
protected int heartbeat = 0;
protected int scaleFactor;
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
private int lastFPS = 20;
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
/**
* Initailiser for Race
*
* @param boats Takes in an array of boats that are participating in the race.
* @param legs Number of marks in order that the boats pass in order to complete the race.
* @param boats Takes in an array of boats that are participating in the race.
* @param legs Number of marks in order that the boats pass in order to complete the race.
* @param scaleFactor for race
*/
public Race(List<BoatInRace> boats, List<Leg> legs, int scaleFactor) {
@ -60,6 +55,30 @@ public class Race implements Runnable {
this(raceData.getBoats(), raceData.getLegs(), scaleFactor);
}
/**
* Calculates the boats next GPS position based on its distance travelled and heading
*
* @param oldCoordinates GPS coordinates of the boat's starting position
* @param distanceTravelled distance in nautical miles
* @param azimuth boat's current direction. Value between -180 and 180
* @return The boat's new coordinate
*/
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
//Find new coordinate using current heading and distance
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
//Load start point into calculator
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
geodeticCalculator.setStartingGeographicPoint(startPoint);
//load direction and distance tranvelled into calculator
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
//get new point
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
}
/**
* Runnable for the thread.
*/
@ -73,6 +92,7 @@ public class Race implements Runnable {
AnimationTimer heartbeatTimer = new AnimationTimer() {
long currentHeartbeatTime = System.currentTimeMillis();
long endHeartbeatTime = System.currentTimeMillis() + 5000;
@Override
public void handle(long now) {
if (currentHeartbeatTime >= endHeartbeatTime) {
@ -100,7 +120,7 @@ public class Race implements Runnable {
protected void countdownTimer() {
AnimationTimer timer = new AnimationTimer() {
long currentTime = System.currentTimeMillis();
long startTime = currentTime + (PRERACE_TIME/scaleFactor);
long startTime = currentTime + (PRERACE_TIME / scaleFactor);
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
@ -114,7 +134,7 @@ public class Race implements Runnable {
stop();
simulateRace();
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
currentTimeInSeconds = (timeLeft * scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
@ -190,21 +210,21 @@ public class Race implements Runnable {
boatLocationMessage.setAltitude(0);//Junk value.
boatLocationMessage.setHeading(BoatLocationMessage.convertHeadingDoubleToInt(boat.getHeading()));
boatLocationMessage.setPitch((short)0);//Junk value.
boatLocationMessage.setRoll((short)0);//Junk value.
boatLocationMessage.setPitch((short) 0);//Junk value.
boatLocationMessage.setRoll((short) 0);//Junk value.
boatLocationMessage.setBoatSpeed(BoatLocationMessage.convertBoatSpeedDoubleToInt(boat.getVelocity()));
boatLocationMessage.setBoatCOG(0);//Junk value.
boatLocationMessage.setBoatSOG(0);//Junk value.
boatLocationMessage.setApparentWindSpeed(0);//Junk value.
boatLocationMessage.setApparentWindAngle((short)0);//Junk value.
boatLocationMessage.setApparentWindAngle((short) 0);//Junk value.
boatLocationMessage.setTrueWindSpeed(0);//Junk value.
boatLocationMessage.setTrueWindAngle((short)0);//Junk value.
boatLocationMessage.setTrueWindAngle((short) 0);//Junk value.
boatLocationMessage.setCurrentDrift(0);//Junk value.
boatLocationMessage.setCurrentSet(0);//Junk value.
boatLocationMessage.setRudderAngle((short)0);//Junk value.
boatLocationMessage.setRudderAngle((short) 0);//Junk value.
//We have finished creating the message.
//TODO at this point, we need to send the event to the visualiser.
@ -227,8 +247,8 @@ public class Race implements Runnable {
*/
protected void updatePositions() {
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
for(BoatInRace boat: startingBoats) {
if(boat != null) {
for (BoatInRace boat : startingBoats) {
if (boat != null) {
boat.setPosition(Integer.toString(startingBoats.indexOf(boat) + 1));
System.out.println(boat.toString() + " " + boat.getPosition());
if (boat.getCurrentLeg().getName().equals("DNF") || boat.getCurrentLeg().getLegNumber() == 0)
@ -294,6 +314,7 @@ public class Race implements Runnable {
/**
* Sets the chance each boat has of failing at a gate or marker
*
* @param chance percentage chance a boat has of failing per checkpoint.
*/
protected void setDnfChance(int chance) {
@ -310,7 +331,7 @@ public class Race implements Runnable {
/**
* Calculates the distance a boat has travelled and updates its current position according to this value.
*
* @param boat to be updated
* @param boat to be updated
* @param millisecondsElapsed since last update
*/
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
@ -360,30 +381,6 @@ public class Race implements Runnable {
}
}
/**
* Calculates the boats next GPS position based on its distance travelled and heading
*
* @param oldCoordinates GPS coordinates of the boat's starting position
* @param distanceTravelled distance in nautical miles
* @param azimuth boat's current direction. Value between -180 and 180
* @return The boat's new coordinate
*/
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
//Find new coordinate using current heading and distance
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
//Load start point into calculator
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
geodeticCalculator.setStartingGeographicPoint(startPoint);
//load direction and distance tranvelled into calculator
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
//get new point
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
}
/**
* Returns the boats that have started the race.
*

@ -4,7 +4,6 @@ import com.github.bfsmith.geotimezone.TimeZoneLookup;
import com.github.bfsmith.geotimezone.TimeZoneResult;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import seng302.GPSCoordinate;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -20,7 +19,7 @@ public class RaceClock {
private String timeZone;
private ZoneId zoneId;
public RaceClock(GPSCoordinate gpsCoordinate){
public RaceClock(GPSCoordinate gpsCoordinate) {
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());
zoneId = ZoneId.of(timeZoneResult.getResult());
@ -32,7 +31,7 @@ public class RaceClock {
timeZone = timeZoneFormatter.format(zonedDateTime);
}
public void updateTime(){
public void updateTime() {
LocalDateTime localDateTime = LocalDateTime.now(zoneId);
ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
time.setValue(dateTimeFormatter.format(zonedDateTime));

@ -16,14 +16,14 @@ public class BinaryMesageEncoder {
private byte[] message;
//private byte[] crc;
private byte headerSync1 = (byte)0x47;
private byte headerSync2 = (byte)0x83;
private byte headerSync1 = (byte) 0x47;
private byte headerSync2 = (byte) 0x83;
private byte headerMessageType;
private long headerTimeStamp;
private int headerSourceID;
private short headerMessageLength;
public BinaryMesageEncoder(MessageType headerMessageType, long headerTimeStamp, int headerSourceID, short headerMessageLength, byte[] message){
public BinaryMesageEncoder(MessageType headerMessageType, long headerTimeStamp, int headerSourceID, short headerMessageLength, byte[] message) {
//set the header
this.headerMessageType = headerMessageType.getValue();
this.headerTimeStamp = headerTimeStamp;
@ -45,7 +45,7 @@ public class BinaryMesageEncoder {
this.message = message;
//set full message
ByteBuffer tempMessageByteBuffer = ByteBuffer.allocate(19+this.headerMessageLength);
ByteBuffer tempMessageByteBuffer = ByteBuffer.allocate(19 + this.headerMessageLength);
tempMessageByteBuffer.put(this.header);
tempMessageByteBuffer.put(this.message);

@ -25,7 +25,7 @@ public class BinaryMessageDecoder {
this.fullMessage = fullMessage;
}
public void decode() throws IndexOutOfBoundsException{
public void decode() throws IndexOutOfBoundsException {
//get the header
this.header = Arrays.copyOfRange(this.fullMessage, 0, 15);
@ -43,37 +43,37 @@ public class BinaryMessageDecoder {
this.crc = Arrays.copyOfRange(this.fullMessage, this.fullMessage.length - 4, fullMessage.length);
//run through the checks
if (this.message.length != bytesToShort(this.headerMessageLength)){
if (this.message.length != bytesToShort(this.headerMessageLength)) {
System.err.println("message length in header does not equal the message length");
System.err.println("message length in header: " + bytesToInt(this.headerMessageLength));
System.err.println("message length: " + this.message.length);
}else if(this.headerSync1 != 0x47){
} else if (this.headerSync1 != 0x47) {
System.err.println("Sync byte 1 is wrong");
}else if(this.headerSync2 !=(byte) 0x83){
} else if (this.headerSync2 != (byte) 0x83) {
System.err.println("Sync byte 2 is wrong");
}else if(false){
} else if (false) {
//todo check crc
}
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);
@ -96,7 +96,7 @@ public class BinaryMessageDecoder {
return bytesToShort(this.headerMessageLength);
}
public int getMessageType(){
public int getMessageType() {
return (int) this.headerMessageType;
}

@ -42,66 +42,66 @@ public class BoatLocationDecoder {
seqNum = Arrays.copyOfRange(encodedBoatLocation, 11, 15);
deviceType = encodedBoatLocation[15];
latitude = Arrays.copyOfRange(encodedBoatLocation, 16, 20);
longitude = Arrays.copyOfRange(encodedBoatLocation,20, 24);
longitude = Arrays.copyOfRange(encodedBoatLocation, 20, 24);
altitude = Arrays.copyOfRange(encodedBoatLocation, 24, 28);
heading = Arrays.copyOfRange(encodedBoatLocation,28, 30);
pitch =Arrays.copyOfRange(encodedBoatLocation,30,32);
roll = Arrays.copyOfRange(encodedBoatLocation,32,34);
boatSpeed = Arrays.copyOfRange(encodedBoatLocation,34,36);
cog = Arrays.copyOfRange(encodedBoatLocation,36,38);
sog = Arrays.copyOfRange(encodedBoatLocation,38, 40);
heading = Arrays.copyOfRange(encodedBoatLocation, 28, 30);
pitch = Arrays.copyOfRange(encodedBoatLocation, 30, 32);
roll = Arrays.copyOfRange(encodedBoatLocation, 32, 34);
boatSpeed = Arrays.copyOfRange(encodedBoatLocation, 34, 36);
cog = Arrays.copyOfRange(encodedBoatLocation, 36, 38);
sog = Arrays.copyOfRange(encodedBoatLocation, 38, 40);
apparentWindSpeed = Arrays.copyOfRange(encodedBoatLocation, 40, 42);
apparentWindAngle = Arrays.copyOfRange(encodedBoatLocation, 42, 44);
trueWindSpeed = Arrays.copyOfRange(encodedBoatLocation,44, 46);
trueWindSpeed = Arrays.copyOfRange(encodedBoatLocation, 44, 46);
trueWindDirection = Arrays.copyOfRange(encodedBoatLocation, 46, 48);
trueWindAngle = Arrays.copyOfRange(encodedBoatLocation, 48, 50);
currentDrift = Arrays.copyOfRange(encodedBoatLocation,50,52);
currentSet = Arrays.copyOfRange(encodedBoatLocation,52, 54);
rudderAngle = Arrays.copyOfRange(encodedBoatLocation,54, 56);
currentDrift = Arrays.copyOfRange(encodedBoatLocation, 50, 52);
currentSet = Arrays.copyOfRange(encodedBoatLocation, 52, 54);
rudderAngle = Arrays.copyOfRange(encodedBoatLocation, 54, 56);
message = new BoatLocationMessage(messageVersionNumber, bytesToLong(time),
bytesToInt(sourceID), bytesToInt(seqNum),
deviceType, bytesToInt(latitude),
bytesToInt(longitude), bytesToInt(altitude),
twoByteToInt(heading), bytesToShort(pitch),
bytesToShort(roll), twoByteToInt(boatSpeed),
twoByteToInt(cog), twoByteToInt(sog),
twoByteToInt(apparentWindSpeed), bytesToShort(apparentWindAngle),
twoByteToInt(trueWindSpeed), bytesToShort(trueWindDirection),
bytesToShort(trueWindAngle), twoByteToInt(currentDrift),
twoByteToInt(currentSet), bytesToShort(rudderAngle)
bytesToInt(sourceID), bytesToInt(seqNum),
deviceType, bytesToInt(latitude),
bytesToInt(longitude), bytesToInt(altitude),
twoByteToInt(heading), bytesToShort(pitch),
bytesToShort(roll), twoByteToInt(boatSpeed),
twoByteToInt(cog), twoByteToInt(sog),
twoByteToInt(apparentWindSpeed), bytesToShort(apparentWindAngle),
twoByteToInt(trueWindSpeed), bytesToShort(trueWindDirection),
bytesToShort(trueWindAngle), twoByteToInt(currentDrift),
twoByteToInt(currentSet), bytesToShort(rudderAngle)
);
}
private int twoByteToInt(byte[] bytesInt){
private int twoByteToInt(byte[] bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int num = byteBuffer.getInt(0);
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong);
// byteBuffer.put(bytesLong[0]);
// byteBuffer.put(bytesLong[1]);

@ -22,11 +22,11 @@ public class CourseWindDecoder {
messageVersionNumber = encodedCourseWind[0];
byteWindID = encodedCourseWind[1];
loopCount = encodedCourseWind[2];
byte[] loopMessagesBytes = Arrays.copyOfRange(encodedCourseWind, 3, lengthInBytesOfMessages*loopCount+3);
byte[] loopMessagesBytes = Arrays.copyOfRange(encodedCourseWind, 3, lengthInBytesOfMessages * loopCount + 3);
int messageLoopIndex = 0;
for (int i=0; i < loopCount; i++) {
byte[] messageBytes = Arrays.copyOfRange(loopMessagesBytes, messageLoopIndex, messageLoopIndex+20);
for (int i = 0; i < loopCount; i++) {
byte[] messageBytes = Arrays.copyOfRange(loopMessagesBytes, messageLoopIndex, messageLoopIndex + 20);
ArrayList test = new ArrayList();
byte[] windId = Arrays.copyOfRange(messageBytes, 0, 1);
byte[] time = Arrays.copyOfRange(messageBytes, 1, 7);
@ -38,20 +38,20 @@ public class CourseWindDecoder {
byte[] flags = Arrays.copyOfRange(messageBytes, 19, 20);
CourseWind message = new CourseWind(windId[0], bytesToLong(time),
bytesToInt(raceID), twoByteToInt(windDirection),
twoByteToInt(windSpeed), twoByteToInt(bestUpwindAngle),
twoByteToInt(bestDownwindAngle), flags[0]);
bytesToInt(raceID), twoByteToInt(windDirection),
twoByteToInt(windSpeed), twoByteToInt(bestUpwindAngle),
twoByteToInt(bestDownwindAngle), flags[0]);
loopMessages.add(message);
messageLoopIndex += 20;
}
}
private int twoByteToInt(byte[] bytesInt){
private int twoByteToInt(byte[] bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int num = byteBuffer.getInt(0);
@ -59,17 +59,17 @@ public class CourseWindDecoder {
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -1,10 +1,7 @@
package seng302.Networking.MessageDecoders;
import seng302.Model.BoatInRace;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
/**
@ -40,32 +37,32 @@ public class RaceStartStatusDecoder {
notification = byteToChar(notificationType);
}
private char byteToChar(byte bytesInt){
private char byteToChar(byte bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
char num = byteBuffer.getChar(0);
return num;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -33,7 +33,7 @@ public class RaceStatusDecoder {
private ArrayList<BoatStatus> boats = new ArrayList<>();
public RaceStatusDecoder(byte[] encodedRaceStatus){
public RaceStatusDecoder(byte[] encodedRaceStatus) {
versionNum = encodedRaceStatus[0];
timeBytes = Arrays.copyOfRange(encodedRaceStatus, 1, 7);
raceID = Arrays.copyOfRange(encodedRaceStatus, 7, 11);
@ -43,7 +43,7 @@ public class RaceStatusDecoder {
windSpeed = Arrays.copyOfRange(encodedRaceStatus, 20, 22);
numBoats = encodedRaceStatus[22];
bytesRaceType = encodedRaceStatus[23];
boatsBytes = Arrays.copyOfRange(encodedRaceStatus, 24, 25+20*this.numBoats);
boatsBytes = Arrays.copyOfRange(encodedRaceStatus, 24, 25 + 20 * this.numBoats);
time = bytesToLong(timeBytes);
race = bytesToInt(raceID);
@ -55,8 +55,8 @@ public class RaceStatusDecoder {
int boatLoopIndex = 0;
for (int i=0; i < numberOfBoats; i++) {
byte[] boatBytes = Arrays.copyOfRange(boatsBytes, boatLoopIndex, boatLoopIndex+20);
for (int i = 0; i < numberOfBoats; i++) {
byte[] boatBytes = Arrays.copyOfRange(boatsBytes, boatLoopIndex, boatLoopIndex + 20);
byte[] sourceID = Arrays.copyOfRange(boatBytes, 1, 5);
byte boatStatus = boatBytes[5];
@ -66,7 +66,7 @@ public class RaceStatusDecoder {
byte[] estTimeAtNextMark = Arrays.copyOfRange(boatBytes, 9, 15);
byte[] estTimeAtFinish = Arrays.copyOfRange(boatBytes, 15, 20);
BoatStatus boat = new BoatStatus(bytesToInt(sourceID),boatStatus,
BoatStatus boat = new BoatStatus(bytesToInt(sourceID), boatStatus,
legNumber, numPenaltiesAwarded, numPenaltiesServed,
bytesToLong(estTimeAtNextMark), bytesToLong(estTimeAtFinish));
@ -75,24 +75,24 @@ public class RaceStatusDecoder {
}
}
private int byteToInt(byte bytesInt){
private int byteToInt(byte bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int intVal = byteBuffer.getInt(0);
return intVal;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;

@ -22,7 +22,7 @@ public class XMLMessageDecoder {
this.bytes = bytes;
}
public void decode(){
public void decode() {
byte[] ackNumberBytes = Arrays.copyOfRange(bytes, 1, 3);
byte[] timeStampBytes = Arrays.copyOfRange(bytes, 3, 9);
byte[] sequenceNumberBytes = Arrays.copyOfRange(bytes, 10, 12);
@ -40,7 +40,7 @@ public class XMLMessageDecoder {
this.xmlMessage = new String(xmlMessagebytes);
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer byteBuffer = ByteBuffer.allocate(2);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
byteBuffer.put(bytesShort[0]);
@ -49,11 +49,11 @@ public class XMLMessageDecoder {
return shortVal;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -15,15 +15,15 @@ import java.util.Arrays;
*/
public class RaceVisionByteEncoder {
public byte[] heartBeat(int seq){
public byte[] heartBeat(int seq) {
ByteBuffer heartBeat = ByteBuffer.allocate(4);
heartBeat.putInt(seq);
byte [] result = heartBeat.array();
byte[] result = heartBeat.array();
return result;
}
public byte[] raceStatus(long time, int race, int raceState, long startTime, short raceWindDir, short raceWindSpeed, int raceType, ArrayList<BoatInRace> boats){
ByteBuffer raceStatusMessage = ByteBuffer.allocate(24 + 20*boats.size());
public byte[] raceStatus(long time, int race, int raceState, long startTime, short raceWindDir, short raceWindSpeed, int raceType, ArrayList<BoatInRace> boats) {
ByteBuffer raceStatusMessage = ByteBuffer.allocate(24 + 20 * boats.size());
//Version Number 1 bytes
byte versionNum = 0b10; //this changes with the pdf. (2)
byte[] timeBytes = convert(time, 6);//time (6 bytes)
@ -45,12 +45,12 @@ public class RaceVisionByteEncoder {
raceStatusMessage.put(numBoats);
raceStatusMessage.put(bytesRaceType);
for (int i = 0; i < boats.size(); i++){
for (int i = 0; i < boats.size(); i++) {
int sourceID = 0; //TODO use boats source id.
byte[] legNum = convert(boats.get(i).getCurrentLeg().getLegNumber(), 1);
byte[] numPenalties = convert(0, 1); //TODO use boats in race penalties class
byte[] numPenaltiesServed = convert(0, 1);//TODO use boats in race penalites served.
byte[] estNextMarkTime = convert((long)0, 6);//TODO use boats estimated time to next mark.
byte[] estNextMarkTime = convert((long) 0, 6);//TODO use boats estimated time to next mark.
byte[] estFinishTime = convert((long) 0, 6);//TODO use boats estimated time to the finish.
raceStatusMessage.putInt(sourceID);
@ -64,7 +64,7 @@ public class RaceVisionByteEncoder {
return raceStatusMessage.array();
}
public byte[] displayTextMessage(RaceMessage[] message){
public byte[] displayTextMessage(RaceMessage[] message) {
//ByteBuffer result = ByteBuffer.allocate(4 + numLines * 32);
int messageVersionNumber = 0b1;//version number
short ackNum = 0;//no clue what this does just a placeholder for 2 bytes.
@ -77,16 +77,16 @@ public class RaceVisionByteEncoder {
ArrayList<byte[]> messages = new ArrayList<byte[]>();
int size = 4;
for (int i = 0; i < message.length; i ++){
for (int i = 0; i < message.length; i++) {
int messageLen = message[i].getMessageText().getBytes().length;
byte[] messageAsBytes = message[i].getMessageText().getBytes();
if (messageLen < 30){
if (messageLen < 30) {
messageLen = 30;
}
ByteBuffer mess = ByteBuffer.allocate(2 + messageLen);
mess.put(convert(message[i].getLineNumber(), 1));
mess.put(convert(messageLen, 1));
for (int j = 0; j < messageLen; j ++){
for (int j = 0; j < messageLen; j++) {
mess.put(messageAsBytes[j]);
}
messages.add(mess.array());
@ -98,14 +98,14 @@ public class RaceVisionByteEncoder {
result.putShort(ackNum);
result.put(messLines);
for(byte[] mess: messages){
for (byte[] mess : messages) {
result.put(mess);
}
return result.array();
}
public byte[] raceStartStatus(long time, short ack, long startTime, int raceID, char notification){
public byte[] raceStartStatus(long time, short ack, long startTime, int raceID, char notification) {
int messageVersion = 0b1;
byte[] timestamp = convert(time, 6);
byte[] ackNumber = convert(ack, 2);
@ -125,7 +125,7 @@ public class RaceVisionByteEncoder {
}
public byte[] yachtEventCode(long time, short acknowledgeNumber, int raceID, int destSourceID, int incidentID,
int eventID){
int eventID) {
int messageVersion = 0b10;
byte[] encodeTime = convert(time, 6);
short ackNum = acknowledgeNumber;
@ -145,7 +145,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] chatterText(int messageType, String message){
public byte[] chatterText(int messageType, String message) {
int messageVersion = 0b1;
byte[] type = convert(messageType, 1);
byte[] length = convert(message.length(), 1);
@ -160,7 +160,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] boatLocation(BoatLocationMessage boatLocationMessage){
public byte[] boatLocation(BoatLocationMessage boatLocationMessage) {
int messageVersionNumber = 0b1;
byte[] time = convert(boatLocationMessage.getTime(), 6);
byte[] sourceID = convert(boatLocationMessage.getSourceID(), 4);
@ -210,7 +210,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] markRounding(int time, int ackNumber, int raceID, int sourceID, int boatStatus, int roundingSide, int markType, int markID){
public byte[] markRounding(int time, int ackNumber, int raceID, int sourceID, int boatStatus, int roundingSide, int markType, int markID) {
int messageVersionNumber = 0b1;
byte[] byteTime = convert(time, 6);
byte[] byteAck = convert(ackNumber, 2);
@ -234,7 +234,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] courseWind(byte windID, ArrayList<CourseWind> courseWinds){
public byte[] courseWind(byte windID, ArrayList<CourseWind> courseWinds) {
int messageVersionNumber = 0b1;
byte byteWindID = windID;
byte[] loopcount = convert(courseWinds.size(), 1);
@ -242,7 +242,7 @@ public class RaceVisionByteEncoder {
result.put(convert(messageVersionNumber, 1));
result.put(byteWindID);
result.put(loopcount);
for (CourseWind wind: courseWinds){
for (CourseWind wind : courseWinds) {
result.put(convert(wind.getID(), 1));
result.put(convert(wind.getTime(), 6));
result.put(convert(wind.getRaceID(), 4));
@ -255,9 +255,9 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] averageWind(int time, int rawPeriod, int rawSampleSpeed, int period2, int speed2, int period3, int speed3, int period4, int speed4){
public byte[] averageWind(int time, int rawPeriod, int rawSampleSpeed, int period2, int speed2, int period3, int speed3, int period4, int speed4) {
int messageVersionNumber = 0b1;
byte[] byteTime = convert(time,6);
byte[] byteTime = convert(time, 6);
byte[] byteRawPeriod = convert(rawPeriod, 2);
byte[] byteRawSpeed = convert(rawSampleSpeed, 2);
byte[] bytePeriod2 = convert(period2, 2);
@ -281,13 +281,13 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] convert(String s, int size){
public byte[] convert(String s, int size) {
byte[] m = s.getBytes(Charset.forName("UTF-8"));
int length = m.length;
byte[] result;
if (length > 255){
if (length > 255) {
length = 255;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -295,12 +295,12 @@ public class RaceVisionByteEncoder {
return result;
}
public byte[] convert(int n, int size){
public byte[] convert(int n, int size) {
byte[] result;
if (size > 4){
if (size > 4) {
result = new byte[4];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -311,12 +311,12 @@ public class RaceVisionByteEncoder {
return result;
}
public byte[] convert(long n, int size){
public byte[] convert(long n, int size) {
byte[] result;
if (size > 8){
if (size > 8) {
result = new byte[8];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -328,12 +328,12 @@ public class RaceVisionByteEncoder {
}
public byte[] convert(short n, int size){
public byte[] convert(short n, int size) {
byte[] result;
if (size > 2){
if (size > 2) {
result = new byte[2];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}

@ -1,7 +1,6 @@
package seng302.Networking.MessageEncoders;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
/**

@ -7,8 +7,7 @@ package seng302.Networking.Utils;
/**
* Represents the information in a boat location message (AC streaming spec: 4.9).
*/
public class BoatLocationMessage
{
public class BoatLocationMessage {
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
@ -78,12 +77,12 @@ public class BoatLocationMessage
/**
* Ctor.
*/
public BoatLocationMessage()
{
public BoatLocationMessage() {
}
/**
* Ctor, with all parameters.
*
* @param messageVersionNumber
* @param time
* @param sourceID
@ -107,8 +106,7 @@ public class BoatLocationMessage
* @param currentSet
* @param rudderAngle
*/
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle)
{
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
this.messageVersionNumber = messageVersionNumber;
this.time = time;
this.sourceID = sourceID;
@ -137,173 +135,139 @@ public class BoatLocationMessage
//Getters and setters for message properties.
public byte getMessageVersionNumber()
{
public byte getMessageVersionNumber() {
return messageVersionNumber;
}
public void setMessageVersionNumber(byte messageVersionNumber)
{
public void setMessageVersionNumber(byte messageVersionNumber) {
this.messageVersionNumber = messageVersionNumber;
}
public long getTime()
{
public long getTime() {
return time;
}
public void setTime(long time)
{
public void setTime(long time) {
this.time = time;
}
public int getSourceID()
{
public int getSourceID() {
return sourceID;
}
public void setSourceID(int sourceID)
{
public void setSourceID(int sourceID) {
this.sourceID = sourceID;
}
public int getSequenceNumber()
{
public int getSequenceNumber() {
return sequenceNumber;
}
public void setSequenceNumber(int sequenceNumber)
{
public void setSequenceNumber(int sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
public byte getDeviceType()
{
public byte getDeviceType() {
return deviceType;
}
public void setDeviceType(byte deviceType)
{
public void setDeviceType(byte deviceType) {
this.deviceType = deviceType;
}
public int getLatitude()
{
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude)
{
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude()
{
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude)
{
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public int getAltitude()
{
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude)
{
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getHeading()
{
public int getHeading() {
return heading;
}
public void setHeading(int heading)
{
public void setHeading(int heading) {
this.heading = heading;
}
public short getPitch()
{
public short getPitch() {
return pitch;
}
public void setPitch(short pitch)
{
public void setPitch(short pitch) {
this.pitch = pitch;
}
public short getRoll()
{
public short getRoll() {
return roll;
}
public void setRoll(short roll)
{
public void setRoll(short roll) {
this.roll = roll;
}
public int getBoatSpeed()
{
public int getBoatSpeed() {
return boatSpeed;
}
public void setBoatSpeed(int boatSpeed)
{
public void setBoatSpeed(int boatSpeed) {
this.boatSpeed = boatSpeed;
}
public int getBoatCOG()
{
public int getBoatCOG() {
return boatCOG;
}
public void setBoatCOG(int boatCOG)
{
public void setBoatCOG(int boatCOG) {
this.boatCOG = boatCOG;
}
public int getBoatSOG()
{
public int getBoatSOG() {
return boatSOG;
}
public void setBoatSOG(int boatSOG)
{
public void setBoatSOG(int boatSOG) {
this.boatSOG = boatSOG;
}
public int getApparentWindSpeed()
{
public int getApparentWindSpeed() {
return apparentWindSpeed;
}
public void setApparentWindSpeed(int apparentWindSpeed)
{
public void setApparentWindSpeed(int apparentWindSpeed) {
this.apparentWindSpeed = apparentWindSpeed;
}
public short getApparentWindAngle()
{
public short getApparentWindAngle() {
return apparentWindAngle;
}
public void setApparentWindAngle(short apparentWindAngle)
{
public void setApparentWindAngle(short apparentWindAngle) {
this.apparentWindAngle = apparentWindAngle;
}
public int getTrueWindSpeed()
{
public int getTrueWindSpeed() {
return trueWindSpeed;
}
public void setTrueWindSpeed(int trueWindSpeed)
{
public void setTrueWindSpeed(int trueWindSpeed) {
this.trueWindSpeed = trueWindSpeed;
}
@ -315,43 +279,35 @@ public class BoatLocationMessage
this.trueWindDirection = trueWindDirection;
}
public short getTrueWindAngle()
{
public short getTrueWindAngle() {
return trueWindAngle;
}
public void setTrueWindAngle(short trueWindAngle)
{
public void setTrueWindAngle(short trueWindAngle) {
this.trueWindAngle = trueWindAngle;
}
public int getCurrentDrift()
{
public int getCurrentDrift() {
return currentDrift;
}
public void setCurrentDrift(int currentDrift)
{
public void setCurrentDrift(int currentDrift) {
this.currentDrift = currentDrift;
}
public int getCurrentSet()
{
public int getCurrentSet() {
return currentSet;
}
public void setCurrentSet(int currentSet)
{
public void setCurrentSet(int currentSet) {
this.currentSet = currentSet;
}
public short getRudderAngle()
{
public short getRudderAngle() {
return rudderAngle;
}
public void setRudderAngle(short rudderAngle)
{
public void setRudderAngle(short rudderAngle) {
this.rudderAngle = rudderAngle;
}
}

@ -9,7 +9,7 @@ public class CourseWind {
private long time;
public CourseWind(int ID, long time, int raceID, int windDirection, int windSpeed, int bestUpwindAngle, int bestDownwindAngle,
int flags){
int flags) {
this.ID = ID;
this.time = time;
this.raceID = raceID;

@ -10,7 +10,9 @@ public enum MessageType {
private byte value;
private MessageType(int value) { this.value = (byte)value; }
private MessageType(int value) {
this.value = (byte) value;
}
public byte getValue() {
return value;

@ -8,7 +8,7 @@ public class RaceMessage {
private int lineNumber;
private String messageText;
public RaceMessage(int lineNumber, String messageText){
public RaceMessage(int lineNumber, String messageText) {
this.lineNumber = lineNumber;
this.messageText = messageText;
}

@ -9,22 +9,7 @@ import seng302.Constants;
/**
* Represents the information in a boat location message (AC streaming spec: 4.9).
*/
public class BoatLocationMessage
{
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
///Time of the event - milliseconds since jan 1 1970. Proper type is 6 byte int.
private long time;
///Source ID of the boat.
private int sourceID;
///Sequence number of the message.
private long sequenceNumber;
///Device type of the message (physical source of the message).
private byte deviceType;
public class BoatLocationMessage {
public static final byte Unknown = 0;
public static final byte RacingYacht = 1;
public static final byte CommitteeBoat = 2;
@ -39,8 +24,16 @@ public class BoatLocationMessage
public static final byte WeatherStation = 11;
public static final byte Helicopter = 12;
public static final byte DataProcessingApplication = 13;
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
///Time of the event - milliseconds since jan 1 1970. Proper type is 6 byte int.
private long time;
///Source ID of the boat.
private int sourceID;
///Sequence number of the message.
private long sequenceNumber;
///Device type of the message (physical source of the message).
private byte deviceType;
///Latitude of the boat.
private int latitude;
@ -93,12 +86,12 @@ public class BoatLocationMessage
/**
* Ctor. Default.
*/
public BoatLocationMessage()
{
public BoatLocationMessage() {
}
/**
* Ctor, with all parameters.
*
* @param messageVersionNumber
* @param time
* @param sourceID
@ -121,8 +114,7 @@ public class BoatLocationMessage
* @param currentSet
* @param rudderAngle
*/
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, long sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle)
{
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, long sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
this.messageVersionNumber = messageVersionNumber;
this.time = time;
this.sourceID = sourceID;
@ -149,342 +141,289 @@ public class BoatLocationMessage
//Getters and setters for message properties.
/**
* Converts a double representing a latitude or longitude coordinate to an int, as required by the streaming spec format.
*
* @param coordinate Latitude or longitude to convert. Double.
* @return int representation of coordinate.
*/
public static int convertCoordinateDoubleToInt(double coordinate) {
int coordinateInt = (int) ((coordinate / 180.0) * 2147483648.0);
return coordinateInt;
}
/**
* Converts an int representing a latitude or longitude coordinate to a double, as required by the streaming spec format.
*
* @param coordinate Latitude or longitude to convert. int.
* @return double representation of coordinate.
*/
public static double convertCoordinateIntToDouble(int coordinate) {
double coordinateDouble = (double) ((coordinate * 180.0) / 2147483648.0);
return coordinateDouble;
}
/**
* Converts an int representing a heading to a double, as required by the streaming spec format.
*
* @param heading Heading to convert. int.
* @return double representation of heading.
*/
public static double convertHeadingIntToDouble(int heading) {
double headingDouble = (double) ((heading * 360.0) / 65536.0);
return headingDouble;
}
/**
* Converts a double representing a heading to an int, as required by the streaming spec format.
*
* @param heading Heading to convert. double.
* @return int representation of heading.
*/
public static int convertHeadingDoubleToInt(double heading) {
int headingInt = (int) ((heading / 360.0) * 65536.0);
return headingInt;
}
/**
* Converts a short representing the wind's true angle to a double, as required by the streaming spec format.
*
* @param angle Angle to convert. short.
* @return double representation of heading.
*/
public static double convertTrueWindAngleShortToDouble(short angle) {
double angleDouble = (double) ((angle * 180.0) / 32768.0);
return angleDouble;
}
/**
* Converts a double representing the wind's true angle to a short, as required by the streaming spec format.
*
* @param angle Angle to convert. double.
* @return short representation of heading.
*/
public static short convertTrueWindAngleShortToDouble(double angle) {
short angleShort = (short) ((angle / 180.0) * 32768.0);
return angleShort;
}
/**
* Converts a double representing the speed of a boat in knots to an int in millimeters per second, as required by the streaming spec format.
*
* @param speed Speed in knots, stored as a double.
* @return Speed in millimeters per second, stored as an int (using only the two least significant bytes).
*/
public static int convertBoatSpeedDoubleToInt(double speed) {
//Calculate meters per second.
double metersPerSecond = speed * Constants.KnotsToMetersPerSecondConversionFactor;
//Calculate millimeters per second.
double millimetersPerSecond = metersPerSecond * 1000.0;
//Convert to an int.
int millimetersPerSecondInt = (int) Math.round(millimetersPerSecond);
return millimetersPerSecondInt;
}
/**
* Converts an int representing the speed of a boat in millimeters per second to a double in knots, as required by the streaming spec format.
*
* @param speed Speed in millimeters per second, stored as an int.
* @return Speed in knots, stored as a double.
*/
public static double convertBoatSpeedIntToDouble(int speed) {
//Calculate meters per second.
double metersPerSecond = speed / 1000.0;
//Calculate knots.
double knots = metersPerSecond / Constants.KnotsToMetersPerSecondConversionFactor;
return knots;
}
public byte getMessageVersionNumber()
{
public byte getMessageVersionNumber() {
return messageVersionNumber;
}
public void setMessageVersionNumber(byte messageVersionNumber)
{
public void setMessageVersionNumber(byte messageVersionNumber) {
this.messageVersionNumber = messageVersionNumber;
}
public long getTime()
{
public long getTime() {
return time;
}
public void setTime(long time)
{
public void setTime(long time) {
this.time = time;
}
public int getSourceID()
{
public int getSourceID() {
return sourceID;
}
public void setSourceID(int sourceID)
{
public void setSourceID(int sourceID) {
this.sourceID = sourceID;
}
public long getSequenceNumber()
{
public long getSequenceNumber() {
return sequenceNumber;
}
public void setSequenceNumber(long sequenceNumber)
{
public void setSequenceNumber(long sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
public byte getDeviceType()
{
public byte getDeviceType() {
return deviceType;
}
public void setDeviceType(byte deviceType)
{
public void setDeviceType(byte deviceType) {
this.deviceType = deviceType;
}
public int getLatitude()
{
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude)
{
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude()
{
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude)
{
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public int getAltitude()
{
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude)
{
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getHeading()
{
public int getHeading() {
return heading;
}
public void setHeading(int heading)
{
public void setHeading(int heading) {
this.heading = heading;
}
public short getPitch()
{
public short getPitch() {
return pitch;
}
public void setPitch(short pitch)
{
public void setPitch(short pitch) {
this.pitch = pitch;
}
public short getRoll()
{
public short getRoll() {
return roll;
}
public void setRoll(short roll)
{
public void setRoll(short roll) {
this.roll = roll;
}
public int getBoatSpeed()
{
public int getBoatSpeed() {
return boatSpeed;
}
public void setBoatSpeed(int boatSpeed)
{
public void setBoatSpeed(int boatSpeed) {
this.boatSpeed = boatSpeed;
}
public int getBoatCOG()
{
public int getBoatCOG() {
return boatCOG;
}
public void setBoatCOG(int boatCOG)
{
public void setBoatCOG(int boatCOG) {
this.boatCOG = boatCOG;
}
public int getBoatSOG()
{
public int getBoatSOG() {
return boatSOG;
}
public void setBoatSOG(int boatSOG)
{
public void setBoatSOG(int boatSOG) {
this.boatSOG = boatSOG;
}
public int getApparentWindSpeed()
{
public int getApparentWindSpeed() {
return apparentWindSpeed;
}
public void setApparentWindSpeed(int apparentWindSpeed)
{
public void setApparentWindSpeed(int apparentWindSpeed) {
this.apparentWindSpeed = apparentWindSpeed;
}
public short getApparentWindAngle()
{
public short getApparentWindAngle() {
return apparentWindAngle;
}
public void setApparentWindAngle(short apparentWindAngle)
{
public void setApparentWindAngle(short apparentWindAngle) {
this.apparentWindAngle = apparentWindAngle;
}
public int getTrueWindSpeed()
{
public int getTrueWindSpeed() {
return trueWindSpeed;
}
public void setTrueWindSpeed(int trueWindSpeed)
{
public void setTrueWindSpeed(int trueWindSpeed) {
this.trueWindSpeed = trueWindSpeed;
}
public short getTrueWindAngle()
{
public short getTrueWindAngle() {
return trueWindAngle;
}
public void setTrueWindAngle(short trueWindAngle)
{
public void setTrueWindAngle(short trueWindAngle) {
this.trueWindAngle = trueWindAngle;
}
public int getCurrentDrift()
{
public int getCurrentDrift() {
return currentDrift;
}
public void setCurrentDrift(int currentDrift)
{
public void setCurrentDrift(int currentDrift) {
this.currentDrift = currentDrift;
}
public int getCurrentSet()
{
public int getCurrentSet() {
return currentSet;
}
public void setCurrentSet(int currentSet)
{
public void setCurrentSet(int currentSet) {
this.currentSet = currentSet;
}
public short getRudderAngle()
{
public short getRudderAngle() {
return rudderAngle;
}
public void setRudderAngle(short rudderAngle)
{
public void setRudderAngle(short rudderAngle) {
this.rudderAngle = rudderAngle;
}
/**
* Converts a double representing a latitude or longitude coordinate to an int, as required by the streaming spec format.
* @param coordinate Latitude or longitude to convert. Double.
* @return int representation of coordinate.
*/
public static int convertCoordinateDoubleToInt(double coordinate)
{
int coordinateInt = (int) ((coordinate / 180.0) * 2147483648.0);
return coordinateInt;
}
/**
* Converts an int representing a latitude or longitude coordinate to a double, as required by the streaming spec format.
* @param coordinate Latitude or longitude to convert. int.
* @return double representation of coordinate.
*/
public static double convertCoordinateIntToDouble(int coordinate)
{
double coordinateDouble = (double) ((coordinate * 180.0) / 2147483648.0);
return coordinateDouble;
}
/**
* Converts an int representing a heading to a double, as required by the streaming spec format.
* @param heading Heading to convert. int.
* @return double representation of heading.
*/
public static double convertHeadingIntToDouble(int heading)
{
double headingDouble = (double) ((heading * 360.0) / 65536.0);
return headingDouble;
}
/**
* Converts a double representing a heading to an int, as required by the streaming spec format.
* @param heading Heading to convert. double.
* @return int representation of heading.
*/
public static int convertHeadingDoubleToInt(double heading)
{
int headingInt = (int) ((heading / 360.0) * 65536.0);
return headingInt;
}
/**
* Converts a short representing the wind's true angle to a double, as required by the streaming spec format.
* @param angle Angle to convert. short.
* @return double representation of heading.
*/
public static double convertTrueWindAngleShortToDouble(short angle)
{
double angleDouble = (double) ((angle * 180.0) / 32768.0);
return angleDouble;
}
/**
* Converts a double representing the wind's true angle to a short, as required by the streaming spec format.
* @param angle Angle to convert. double.
* @return short representation of heading.
*/
public static short convertTrueWindAngleShortToDouble(double angle)
{
short angleShort = (short) ((angle / 180.0) * 32768.0);
return angleShort;
}
/**
* Converts a double representing the speed of a boat in knots to an int in millimeters per second, as required by the streaming spec format.
* @param speed Speed in knots, stored as a double.
* @return Speed in millimeters per second, stored as an int (using only the two least significant bytes).
*/
public static int convertBoatSpeedDoubleToInt(double speed)
{
//Calculate meters per second.
double metersPerSecond = speed * Constants.KnotsToMetersPerSecondConversionFactor;
//Calculate millimeters per second.
double millimetersPerSecond = metersPerSecond * 1000.0;
//Convert to an int.
int millimetersPerSecondInt = (int)Math.round(millimetersPerSecond);
return millimetersPerSecondInt;
}
/**
* Converts an int representing the speed of a boat in millimeters per second to a double in knots, as required by the streaming spec format.
* @param speed Speed in millimeters per second, stored as an int.
* @return Speed in knots, stored as a double.
*/
public static double convertBoatSpeedIntToDouble(int speed)
{
//Calculate meters per second.
double metersPerSecond = speed / 1000.0;
//Calculate knots.
double knots = metersPerSecond / Constants.KnotsToMetersPerSecondConversionFactor;
return knots;
}
@Override
public String toString()
{
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Message version number: ");

@ -3,14 +3,13 @@ package seng302.Data;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource;
import seng302.RaceXMLReader;
import seng302.DataInput.RaceDataSource;
import seng302.DataInput.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.fail;
/**
* Created by esa46 on 25/04/17.
@ -18,7 +17,7 @@ import static org.junit.Assert.fail;
public class RaceDataTest {
private static final String ROOT_TAG = "Race";
private static final String[] REQUIRED_TAGS = new String[] {
private static final String[] REQUIRED_TAGS = new String[]{
"RaceID", "RaceType", "CreationTimeDate", "RaceStartTime", "Participants", "Yacht",
"CompoundMarkSequence", "Course", "CompoundMark", "Mark", "CourseLimit", "Limit"
};
@ -48,7 +47,7 @@ public class RaceDataTest {
assertTrue(result.contains("<" + ROOT_TAG + ">"));
for (String tag : REQUIRED_TAGS) {
System.out.println(tag);
assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " ") );
assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " "));
}
}
@ -73,8 +72,8 @@ public class RaceDataTest {
@Test
public void idAndTypeAreEquivalent() {
String newId = result.substring(result.indexOf("<RaceID>" ) + 8, result.indexOf("</RaceID>"));
String newRaceType = result.substring(result.indexOf("<RaceType>" ) + 10, result.indexOf("</RaceType>"));
String newId = result.substring(result.indexOf("<RaceID>") + 8, result.indexOf("</RaceID>"));
String newRaceType = result.substring(result.indexOf("<RaceType>") + 10, result.indexOf("</RaceType>"));
assertTrue(raceDataSource.getRaceId().equals(newId));
assertTrue(raceDataSource.getRaceType().equals(newRaceType));

@ -2,12 +2,10 @@ package seng302.Mock;
import org.junit.Before;
import org.junit.Test;
import seng302.DataInput.RegattaXMLReader;
import seng302.Model.Regatta;
import seng302.RegattaXMLReader;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
/**
* Created by jjg64 on 19/04/17.
@ -16,7 +14,7 @@ public class RegattaXMLTest {
RegattaXMLReader regattaXMLReader;
@Before
public void findFile(){
public void findFile() {
try {
regattaXMLReader = new RegattaXMLReader("mockXML/regattaTest.xml", false);
} catch (Exception e) {

@ -1,14 +1,9 @@
package seng302.Model;
import javafx.scene.paint.Color;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import seng302.GPSCoordinate;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.*;
/**
* Created by esa46 on 22/03/17.
@ -147,13 +142,13 @@ public class BoatInRaceTest {
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
boat.setCurrentLeg(leg0deg);
boat.setCurrentPosition(new GPSCoordinate(0,0));
boat.setCurrentPosition(new GPSCoordinate(0, 0));
// Get latitude of endpoint of wake at 10 kn (longitude is 0)
double endpointAt10Kn = boat.getWake().getLatitude();
// Latitude of endpoint at 20 kn should be twice endpoint at 10 kn
boat.setVelocity(20);
assertEquals(2*endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
}
}

@ -3,9 +3,7 @@ package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import org.junit.Test;
import seng302.Constants;
import seng302.GPSCoordinate;
import java.awt.*;
import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals;

@ -2,7 +2,6 @@ package seng302.Model;
import org.junit.Ignore;
import org.junit.Test;
import seng302.GPSCoordinate;
import static org.junit.Assert.assertTrue;

@ -3,15 +3,8 @@ package seng302.Model;
import javafx.scene.paint.Color;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.GPSCoordinate;
import seng302.Mock.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
@ -27,7 +20,7 @@ public class RaceTest {
@Ignore
@Test
public void timerCanBeDisabled(){
public void timerCanBeDisabled() {
BoatInRace boat1 = new BoatInRace("Test 1", 10000, Color.ALICEBLUE, "t1", 1);
BoatInRace boat2 = new BoatInRace("Test 2", 10000, Color.BURLYWOOD, "t2", 2);
//BoatInRace[] boats = new BoatInRace[]{boat1, boat2};
@ -36,7 +29,8 @@ public class RaceTest {
boats.add(boat2);
ArrayList<Leg> legs = new ArrayList<>();
legs.add(START_LEG); legs.add(FINISH_LEG);
legs.add(START_LEG);
legs.add(FINISH_LEG);
Race race = new Race(boats, legs, 5);
race.setDnfChance(0);
@ -145,7 +139,7 @@ public class RaceTest {
float vel2 = (float) 1.999;
float vel3 = (float) 32.5;
float vel4 = 500;
BoatInRace boat1 = new BoatInRace("test", vel1, Color.ALICEBLUE, "tt",1);
BoatInRace boat1 = new BoatInRace("test", vel1, Color.ALICEBLUE, "tt", 1);
BoatInRace boat2 = new BoatInRace("test", vel2, Color.ALICEBLUE, "tt", 2);
BoatInRace boat3 = new BoatInRace("test", vel3, Color.ALICEBLUE, "tt", 3);
BoatInRace boat4 = new BoatInRace("test", vel4, Color.ALICEBLUE, "tt", 4);

@ -2,23 +2,19 @@ package seng302.Model;/**
* Created by Gondr on 26/03/2017.
*/
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.RaceXMLReader;
import seng302.DataInput.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
public class RaceXMLTest {
RaceXMLReader raceXMLReader;
@Test
public void canFindFile(){
public void canFindFile() {
try {
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
} catch (Exception e) {
@ -28,7 +24,7 @@ public class RaceXMLTest {
@Ignore
@Test
public void canReadBoats(){
public void canReadBoats() {
try {
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
raceXMLReader.readBoats();
@ -63,7 +59,7 @@ public class RaceXMLTest {
}
@Test
public void canReadLegs(){
public void canReadLegs() {
try {
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
raceXMLReader.readLegs();
@ -74,7 +70,7 @@ public class RaceXMLTest {
}
@Test
public void canReadCourse(){
public void canReadCourse() {
try {
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
raceXMLReader.readCourse();

@ -2,8 +2,6 @@ package seng302.Networking;
import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.BinaryMesageEncoder;
import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import seng302.Networking.Utils.MessageType;
@ -17,30 +15,30 @@ import java.io.InputStreamReader;
*/
public class BinaryMessageDecoderTest {
@Test
public void decodeTest(){
try{
public void decodeTest() {
try {
StringBuilder xmlString;
BufferedReader br = new BufferedReader(new InputStreamReader(
this.getClass().getResourceAsStream(("../../raceXML/Regatta.xml"))));
String line;
xmlString = new StringBuilder();
while((line=br.readLine())!= null){
while ((line = br.readLine()) != null) {
xmlString.append(line.trim());
}
long time = System.currentTimeMillis();
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte)1, (short)1, time, (byte)7, (short)1, (short)xmlString.length(), xmlString.toString());
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte) 1, (short) 1, time, (byte) 7, (short) 1, (short) xmlString.length(), xmlString.toString());
byte[] encodedMessage = testEncoder.encode();
BinaryMesageEncoder testMessage = new BinaryMesageEncoder(MessageType.XMLMESSAGE, time, 1, (short)encodedMessage.length, encodedMessage);
BinaryMesageEncoder testMessage = new BinaryMesageEncoder(MessageType.XMLMESSAGE, time, 1, (short) encodedMessage.length, encodedMessage);
BinaryMessageDecoder testDecoder = new BinaryMessageDecoder(testMessage.getFullMessage());
testDecoder.decode();
//message length
Assert.assertEquals((short) encodedMessage.length,testDecoder.getMessageLength());
Assert.assertEquals((short) encodedMessage.length, testDecoder.getMessageLength());
//time stamp
Assert.assertEquals(time,testDecoder.getTimeStamp());
Assert.assertEquals(time, testDecoder.getTimeStamp());
//source ID
Assert.assertEquals((short) 1, testDecoder.getSourceID());
//message type
@ -50,15 +48,15 @@ public class BinaryMessageDecoderTest {
decoderXML.decode();
//tests from seng302.Networking.MessageDecoders.XMLMessageDecoderTest to make sure the file is still good
Assert.assertEquals((byte)1, decoderXML.getMessageVersionNumber());
Assert.assertEquals((short)1, decoderXML.getAckNumber());
Assert.assertEquals((byte) 1, decoderXML.getMessageVersionNumber());
Assert.assertEquals((short) 1, decoderXML.getAckNumber());
Assert.assertEquals(time, decoderXML.getTimeStamp());
Assert.assertEquals((byte)7, decoderXML.getXmlMsgSubType());
Assert.assertEquals((short)1, decoderXML.getSequenceNumber());
Assert.assertEquals((short)xmlString.length(), decoderXML.getXmlMsgLength());
Assert.assertEquals((byte) 7, decoderXML.getXmlMsgSubType());
Assert.assertEquals((short) 1, decoderXML.getSequenceNumber());
Assert.assertEquals((short) xmlString.length(), decoderXML.getXmlMsgLength());
Assert.assertEquals(xmlString.toString(), decoderXML.getXmlMessage());
}catch (IOException e){
} catch (IOException e) {
System.out.println(e);
}
}

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
import seng302.Networking.Utils.BoatLocationMessage;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.BoatLocationMessage;
/**
@ -12,15 +11,15 @@ import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
*/
public class BoatLocationDecoderTest {
@Test
public void getByteArrayTest(){
public void getByteArrayTest() {
long time = System.currentTimeMillis();
BoatLocationMessage testMessage = new BoatLocationMessage((byte)1, time, (byte)2,
3, (byte) 1, 180, -180, 4, (short)5,
(short)6, (short)7, 8, 9, 10, 11,
(short) 12, 13,(short) 14 ,(short) 15,
BoatLocationMessage testMessage = new BoatLocationMessage((byte) 1, time, (byte) 2,
3, (byte) 1, 180, -180, 4, (short) 5,
(short) 6, (short) 7, 8, 9, 10, 11,
(short) 12, 13, (short) 14, (short) 15,
16, 17, (short) 18);
RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
byte [] testEncodedMessage = raceVisionByteEncoder.boatLocation(testMessage);
byte[] testEncodedMessage = raceVisionByteEncoder.boatLocation(testMessage);
BoatLocationDecoder testDecoder = new BoatLocationDecoder(testEncodedMessage);
BoatLocationMessage decodedTest = testDecoder.getMessage();

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.MessageDecoders.CourseWindDecoder;
import seng302.Networking.Utils.CourseWind;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.CourseWind;
import java.util.ArrayList;
@ -14,11 +13,11 @@ import java.util.ArrayList;
*/
public class CourseWindDecoderTest {
@Test
public void getByteArrayTest(){
public void getByteArrayTest() {
long time = System.currentTimeMillis();
CourseWind testCourseWind1 = new CourseWind(1, time, 2,
3, 4, 5,
7, 6);
3, 4, 5,
7, 6);
long time2 = System.currentTimeMillis();
CourseWind testCourseWind2 = new CourseWind(2, time2, 2,

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.MessageDecoders.RaceStartStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
/**
@ -10,13 +9,13 @@ import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
*/
public class RaceStartStatusDecoderTest {
@Test
public void getByteArrayTest(){
public void getByteArrayTest() {
long time = System.currentTimeMillis();
RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
long time2 = System.currentTimeMillis();
byte[] encodedRaceStartStatus = raceVisionByteEncoder.raceStartStatus(time, (short)1,
time2, 2, (char)3);
byte[] encodedRaceStartStatus = raceVisionByteEncoder.raceStartStatus(time, (short) 1,
time2, 2, (char) 3);
RaceStartStatusDecoder testDecoder = new RaceStartStatusDecoder(encodedRaceStartStatus);
@ -25,7 +24,7 @@ public class RaceStartStatusDecoderTest {
Assert.assertEquals(1, testDecoder.getAck());
Assert.assertEquals(time2, testDecoder.getStartTime());
Assert.assertEquals(2, testDecoder.getRaceID());
Assert.assertEquals((char)3, testDecoder.getNotification());
Assert.assertEquals((char) 3, testDecoder.getNotification());
}
}

@ -5,7 +5,6 @@ import org.junit.Assert;
import org.junit.Test;
import seng302.Model.BoatInRace;
import seng302.Model.Leg;
import seng302.Networking.MessageDecoders.RaceStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import java.util.ArrayList;
@ -15,7 +14,7 @@ import java.util.ArrayList;
*/
public class RaceStatusDecoderTest {
@Test
public void getByteArrayTest(){
public void getByteArrayTest() {
long time = System.currentTimeMillis();
BoatInRace boat1 = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt", 1);
Leg testLeg = new Leg("test leg", 1);
@ -30,7 +29,7 @@ public class RaceStatusDecoderTest {
RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
byte[] encodedRaceStatus = raceVisionByteEncoder.raceStatus(time, 1, 2, time2,
(short)2, (short)3,4, boats);
(short) 2, (short) 3, 4, boats);
RaceStatusDecoder decoderTest = new RaceStatusDecoder(encodedRaceStatus);
@ -39,8 +38,8 @@ public class RaceStatusDecoderTest {
Assert.assertEquals(1, decoderTest.getRace());
Assert.assertEquals(2, decoderTest.getRaceState());
Assert.assertEquals(time2, decoderTest.getStartTime());
Assert.assertEquals((short)2, decoderTest.getRaceWindDir());
Assert.assertEquals((short)3, decoderTest.getRaceWindSpeed());
Assert.assertEquals((short) 2, decoderTest.getRaceWindDir());
Assert.assertEquals((short) 3, decoderTest.getRaceWindSpeed());
Assert.assertEquals(0, decoderTest.getBoats().get(0).getBoatStatus());
Assert.assertEquals(0, decoderTest.getBoats().get(0).getLegNumber());

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.BufferedReader;
@ -14,18 +13,18 @@ import java.io.InputStreamReader;
*/
public class XMLMessageDecoderTest {
@Test
public void getByteArrayTest(){
try{
public void getByteArrayTest() {
try {
StringBuilder xmlString;
BufferedReader br = new BufferedReader(new InputStreamReader(
this.getClass().getResourceAsStream(("../../../raceXML/Regatta.xml"))));
String line;
xmlString = new StringBuilder();
while((line=br.readLine())!= null){
while ((line = br.readLine()) != null) {
xmlString.append(line.trim());
}
long time = System.currentTimeMillis();
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte)1, (short)1, time, (byte)7, (short)1, (short)xmlString.length(), xmlString.toString());
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte) 1, (short) 1, time, (byte) 7, (short) 1, (short) xmlString.length(), xmlString.toString());
byte[] encodedXML = testEncoder.encode();
@ -33,15 +32,15 @@ public class XMLMessageDecoderTest {
decoderXML.decode();
Assert.assertEquals((byte)1, decoderXML.getMessageVersionNumber());
Assert.assertEquals((short)1, decoderXML.getAckNumber());
Assert.assertEquals((byte) 1, decoderXML.getMessageVersionNumber());
Assert.assertEquals((short) 1, decoderXML.getAckNumber());
Assert.assertEquals(time, decoderXML.getTimeStamp());
Assert.assertEquals((byte)7, decoderXML.getXmlMsgSubType());
Assert.assertEquals((short)1, decoderXML.getSequenceNumber());
Assert.assertEquals((short)xmlString.length(), decoderXML.getXmlMsgLength());
Assert.assertEquals((byte) 7, decoderXML.getXmlMsgSubType());
Assert.assertEquals((short) 1, decoderXML.getSequenceNumber());
Assert.assertEquals((short) xmlString.length(), decoderXML.getXmlMsgLength());
Assert.assertEquals(xmlString.toString(), decoderXML.getXmlMessage());
}catch (IOException e){
} catch (IOException e) {
System.out.println(e);
}
}

@ -4,51 +4,53 @@ import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by hba56 on 19/04/17.
*/
public class XMLMessageEncoderTest {
@Test
public void getByteArrayTest(){
public void getByteArrayTest() {
StringBuilder xmlString;
try{
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
this.getClass().getResourceAsStream(("../../raceXML/Regatta.xml"))));
String line;
xmlString = new StringBuilder();
while((line=br.readLine())!= null){
while ((line = br.readLine()) != null) {
xmlString.append(line.trim());
}
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte)1, (short)1, System.currentTimeMillis(), (byte)7, (short)1, (short)xmlString.length(), xmlString.toString());
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte) 1, (short) 1, System.currentTimeMillis(), (byte) 7, (short) 1, (short) xmlString.length(), xmlString.toString());
byte[] encodedXML = testEncoder.encode();
//1 + 2 + 6 + 1 + 2 + 2 + 374
Assert.assertEquals(388, encodedXML.length);
}catch (IOException e){
} catch (IOException e) {
System.out.println(e);
}
}
@Test
public void getByteArrayNullTest(){
public void getByteArrayNullTest() {
StringBuilder xmlString;
try{
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
this.getClass().getResourceAsStream(("../../raceXML/Regatta.xml"))));
String line;
xmlString = new StringBuilder();
while((line=br.readLine())!= null){
while ((line = br.readLine()) != null) {
xmlString.append(line.trim());
}
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte)1, (short)1, System.currentTimeMillis(), (byte)7, (short)1, (short)1, xmlString.toString());
XMLMessageEncoder testEncoder = new XMLMessageEncoder((byte) 1, (short) 1, System.currentTimeMillis(), (byte) 7, (short) 1, (short) 1, xmlString.toString());
byte[] encodedXML = testEncoder.encode();
Assert.assertEquals(null, encodedXML);
}catch (IOException e){
} catch (IOException e) {
System.out.println(e);
}
}

@ -8,13 +8,13 @@
<Settings>
<RaceBoatType Type="AC45" />
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449" />
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
@ -24,13 +24,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659" />
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659" />
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659" />
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659" />
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
@ -40,13 +40,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278" />
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278" />
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278" />
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278" />
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
@ -56,13 +56,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1" />
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1" />
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1" />
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1" />
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
@ -72,13 +72,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75" />
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75" />
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75" />
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75" />
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
@ -88,83 +88,83 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46" />
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46" />
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46" />
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46" />
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752" />
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813" />
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34" />
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46" />
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387" />
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075" />
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793" />
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699" />
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699" />
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793" />
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075" />
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387" />
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46" />
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34" />
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813" />
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752" />
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2" />
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2" />
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2" />
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2" />
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699" />
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699" />
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699" />
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699" />
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5" />
<BoatShape ShapeID="5"/>
</BoatShapes>
@ -174,9 +174,9 @@
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000" />
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000" />
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
@ -184,9 +184,9 @@
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -194,17 +194,17 @@
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -212,9 +212,9 @@
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -222,17 +222,17 @@
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -240,9 +240,9 @@
BoatName="TEAM KOREA" Country="KOR">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000" />
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>

@ -4,116 +4,116 @@
<Modified>2017-04-19T15:49:40+1200</Modified>
<Version>1</Version>
<Settings>
<RaceBoatType Type="AC45" />
<BoatDimension BoatLength="14.019" HullLength="13.449" />
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659" />
<Vtx Seq="2" Y="18.359" X="-2.659" />
<Vtx Seq="3" Y="18.359" X="2.659" />
<Vtx Seq="4" Y="0" X="2.659" />
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278" />
<Vtx Seq="2" Y="8.876" X="-1.278" />
<Vtx Seq="3" Y="8.876" X="1.278" />
<Vtx Seq="4" Y="0" X="1.278" />
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1" />
<Vtx Seq="2" Y="8.3" X="-1.1" />
<Vtx Seq="3" Y="8.3" X="1.1" />
<Vtx Seq="4" Y="0" X="1.1" />
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75" />
<Vtx Seq="2" Y="3" X="-0.75" />
<Vtx Seq="3" Y="3" X="0.75" />
<Vtx Seq="4" Y="0" X="0.75" />
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46" />
<Vtx Seq="2" Y="13.449" X="-3.46" />
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="4" Y="13.449" X="3.46" />
<Vtx Seq="5" Y="0" X="3.46" />
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752" />
<Vtx Seq="2" Y="0" X="-2.813" />
<Vtx Seq="3" Y="0" X="-3.34" />
<Vtx Seq="4" Y="5.351" X="-3.46" />
<Vtx Seq="5" Y="10.544" X="-3.387" />
<Vtx Seq="6" Y="13.449" X="-3.075" />
<Vtx Seq="7" Y="10.851" X="-2.793" />
<Vtx Seq="8" Y="6.669" X="-2.699" />
<Vtx Seq="9" Y="6.669" X="2.699" />
<Vtx Seq="10" Y="10.851" X="2.793" />
<Vtx Seq="11" Y="13.449" X="3.075" />
<Vtx Seq="12" Y="10.544" X="3.387" />
<Vtx Seq="13" Y="5.351" X="3.46" />
<Vtx Seq="14" Y="0" X="3.34" />
<Vtx Seq="15" Y="0" X="2.813" />
<Vtx Seq="16" Y="1.769" X="2.752" />
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2" />
<Vtx Seq="2" Y="11.377" X="-0.2" />
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="4" Y="11.377" X="0.2" />
<Vtx Seq="5" Y="6.669" X="0.2" />
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699" />
<Vtx Seq="2" Y="6.438" X="-2.699" />
<Vtx Seq="3" Y="6.438" X="2.699" />
<Vtx Seq="4" Y="2" X="2.699" />
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5" />
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" ShortName="USA"
BoatName="ORACLE TEAM USA" Country="USA">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="102" ShapeID="4" HullNum="AC4502" ShortName="GBR"
BoatName="Land Rover BAR" Country="United Kingdom">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="103" ShapeID="4" HullNum="AC4503" ShortName="JPN"
BoatName="SoftBank Team Japan" Country="Japan">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="104" ShapeID="4" HullNum="AC4504" ShortName="FRA"
BoatName="Groupama Team France" Country="France">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="105" ShapeID="4" HullNum="AC4505" ShortName="SWE"
BoatName="Artemis Racing" Country="Sweden">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="106" ShapeID="4" HullNum="AC4506" ShortName="NZL"
BoatName="Emirates Team New Zealand" Country="New Zealand">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>

@ -2,43 +2,43 @@
<Race>
<RaceID>17041901</RaceID>
<RaceType>Fleet</RaceType>
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate >
<RaceStartTime Time="2019-06-01T13:30:00-0400" Postpone="false" />
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate>
<RaceStartTime Time="2019-06-01T13:30:00-0400" Postpone="false"/>
<Participants>
<Yacht SourceID="001" Entry="Port" />
<Yacht SourceID="002" Entry="Port" />
<Yacht SourceID="003" Entry="Port" />
<Yacht SourceID="004" Entry="Port" />
<Yacht SourceID="005" Entry="Port" />
<Yacht SourceID="006" Entry="Port" />
<Yacht SourceID="001" Entry="Port"/>
<Yacht SourceID="002" Entry="Port"/>
<Yacht SourceID="003" Entry="Port"/>
<Yacht SourceID="004" Entry="Port"/>
<Yacht SourceID="005" Entry="Port"/>
<Yacht SourceID="006" Entry="Port"/>
</Participants>
<Course>
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.296577" TargetLng="-64.854304" SourceID="101" />
<Mark SeqID="2" Name="PIN" TargetLat="32.293771" TargetLng="-64.855242" SourceID="102" />
<Mark SeqID="1" Name="PRO" TargetLat="32.296577" TargetLng="-64.854304" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.293771" TargetLng="-64.855242" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="32.293039" TargetLng="-64.843983" SourceID="103" />
<Mark Name="M1" TargetLat="32.293039" TargetLng="-64.843983" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="WindwardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.284680" TargetLng="-64.850045" SourceID="104" />
<Mark SeqID="2" Name="G2" TargetLat="32.280164" TargetLng="-64.847591" SourceID="105" />
<Mark SeqID="1" Name="G1" TargetLat="32.284680" TargetLng="-64.850045" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="32.280164" TargetLng="-64.847591" SourceID="105"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="LeewardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.309693" TargetLng="-64.835249" SourceID="106" />
<Mark SeqID="2" Name="G2" TargetLat="32.308046" TargetLng="-64.831785" SourceID="107" />
<Mark SeqID="1" Name="G1" TargetLat="32.309693" TargetLng="-64.835249" SourceID="106"/>
<Mark SeqID="2" Name="G2" TargetLat="32.308046" TargetLng="-64.831785" SourceID="107"/>
</CompoundMark>
<CompoundMark CompoundMarkID="5" Name="FinishLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.317379" TargetLng="-64.839291" SourceID="108" />
<Mark SeqID="2" Name="PIN" TargetLat="32.317257" TargetLng="-64.836260" SourceID="109" />
<Mark SeqID="1" Name="PRO" TargetLat="32.317379" TargetLng="-64.839291" SourceID="108"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.317257" TargetLng="-64.836260" SourceID="109"/>
</CompoundMark>
</Course>
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3" />
<Corner SeqID="4" CompoundMarkID="4" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3" />
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="5" CompoundMarkID="5" Rounding="SP" ZoneSize="3"/>
</CompoundMarkSequence>
<CourseLimit>

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -90,7 +90,8 @@
<version>2.4.3</version>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>seng302.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>

@ -1,7 +1,6 @@
package seng302.Controllers;
import javafx.fxml.Initializable;
import seng302.App;
import java.net.URL;
import java.util.ResourceBundle;
@ -25,7 +24,7 @@ public abstract class Controller implements Initializable {
/**
* Initialisation class that is run on start up.
*
* @param location resources location
* @param location resources location
* @param resources resources bundle
*/
@Override

@ -1,11 +1,8 @@
package seng302.Controllers;
import javafx.fxml.FXML;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import java.net.URL;
import java.util.ResourceBundle;
@ -14,20 +11,20 @@ import java.util.ResourceBundle;
* Created by fwy13 on 15/03/2017.
*/
public class MainController extends Controller {
@FXML StartController startController;
@FXML RaceController raceController;
@FXML
StartController startController;
@FXML
RaceController raceController;
public void beginRace(int scaleFactor, RaceDataSource raceData) {
raceController.startRace(scaleFactor, raceData);
}
/**
* Main Controller for the applications will house the menu and the displayed pane.
*
* @param location of resources
* @param location of resources
* @param resources bundle
*/
@Override

@ -1,25 +1,19 @@
package seng302.Controllers;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import org.xml.sax.SAXException;
import seng302.Mock.StreamedRace;
import seng302.Model.*;
import seng302.Model.BoatInRace;
import seng302.Model.Race;
import seng302.Model.RaceClock;
import seng302.Model.ResizableRaceCanvas;
import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle;
/**
@ -28,16 +22,11 @@ import java.util.ResourceBundle;
public class RaceController extends Controller {
@FXML
GridPane canvasBase;
//user saved data for annotation display
private ArrayList<Boolean> presetAnno;
ResizableRaceCanvas raceMap;
@FXML
SplitPane race;
@FXML
CheckBox showFPS;
@FXML
CheckBox showBoatPath;
@FXML
@ -48,7 +37,6 @@ public class RaceController extends Controller {
Label FPS;
@FXML
Label timeZone;
@FXML
CheckBox showName;
@FXML
@ -59,7 +47,6 @@ public class RaceController extends Controller {
Button saveAnno;
@FXML
Button showSetAnno;
@FXML
TableView<BoatInRace> boatInfoTable;
@FXML
@ -70,6 +57,8 @@ public class RaceController extends Controller {
TableColumn<BoatInRace, String> boatMarkColumn;
@FXML
TableColumn<BoatInRace, String> boatSpeedColumn;
//user saved data for annotation display
private ArrayList<Boolean> presetAnno;
/**
* Updates the ResizableRaceCanvas (raceMap) with most recent data

@ -17,7 +17,6 @@ import seng302.Mock.*;
import seng302.Model.BoatInRace;
import seng302.Model.RaceClock;
import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
@ -31,20 +30,28 @@ import java.util.ResourceBundle;
*/
public class StartController extends Controller {
@FXML private GridPane start;
@FXML private AnchorPane startWrapper;
@FXML private TableView<BoatInRace> boatNameTable;
@FXML private TableColumn<BoatInRace, String> boatNameColumn;
@FXML private TableColumn<BoatInRace, String> boatCodeColumn;
@FXML private Label timeZoneTime;
@FXML private Label timer;
@FXML private int PRERACE_TIME = 15000;
@FXML Button oneMinButton;
@FXML Button fiveMinButton;
@FXML Button fifteenMinButton;
@FXML
Button oneMinButton;
@FXML
Button fiveMinButton;
@FXML
Button fifteenMinButton;
@FXML
private GridPane start;
@FXML
private AnchorPane startWrapper;
@FXML
private TableView<BoatInRace> boatNameTable;
@FXML
private TableColumn<BoatInRace, String> boatNameColumn;
@FXML
private TableColumn<BoatInRace, String> boatCodeColumn;
@FXML
private Label timeZoneTime;
@FXML
private Label timer;
@FXML
private int PRERACE_TIME = 15000;
private RaceClock raceClock;
private RaceDataSource raceData;
@ -71,7 +78,7 @@ public class StartController extends Controller {
startRace(1);
}
private void startRace(int raceScale){
private void startRace(int raceScale) {
oneMinButton.setDisable(true);
fiveMinButton.setDisable(true);
@ -80,7 +87,7 @@ public class StartController extends Controller {
}
@Override
public void initialize(URL location, ResourceBundle resources){
public void initialize(URL location, ResourceBundle resources) {
raceData = null;
try {
StreamedCourse streamedCourse = new StreamedCourse(new BoatXMLReader("mockXML/boatXML/boatTest.xml"));
@ -102,7 +109,7 @@ public class StartController extends Controller {
setRaceClock();
}
public AnchorPane startWrapper(){
public AnchorPane startWrapper() {
return startWrapper;
}
@ -133,7 +140,7 @@ public class StartController extends Controller {
protected void countdownTimer(int scaleFactor) {
new AnimationTimer() {
long currentTime = System.currentTimeMillis();
long startTime = currentTime + (PRERACE_TIME/scaleFactor);
long startTime = currentTime + (PRERACE_TIME / scaleFactor);
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
@ -149,7 +156,7 @@ public class StartController extends Controller {
startWrapper.setVisible(false);
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
currentTimeInSeconds = (timeLeft * scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;

@ -3,13 +3,11 @@ package seng302.Mock;
import javafx.scene.paint.Color;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.text.ParseException;
import java.util.*;
@ -17,16 +15,17 @@ import java.util.*;
* Created by Joseph on 24/04/2017.
*/
public class BoatXMLReader extends XMLReader {
private static int currentColourIndex = 0;
Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Color> colours;
private static int currentColourIndex = 0;
/**
* Constructor for Boat XML Reader
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException {
@ -36,10 +35,11 @@ public class BoatXMLReader extends XMLReader {
/**
* Constructor for Boat XML Reader
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException {
@ -98,7 +98,8 @@ public class BoatXMLReader extends XMLReader {
String shortName = null;
String country = null;
if (exists(boat, "Type")) type = boat.getAttributes().getNamedItem("Type").getTextContent();
if (exists(boat, "SourceID")) sourceID = Integer.parseInt(boat.getAttributes().getNamedItem("SourceID").getTextContent());
if (exists(boat, "SourceID"))
sourceID = Integer.parseInt(boat.getAttributes().getNamedItem("SourceID").getTextContent());
if (exists(boat, "BoatName")) boatName = boat.getAttributes().getNamedItem("BoatName").getTextContent();
if (exists(boat, "ShortName")) shortName = boat.getAttributes().getNamedItem("ShortName").getTextContent();
if (exists(boat, "Country")) country = boat.getAttributes().getNamedItem("Country").getTextContent();

@ -3,7 +3,6 @@ package seng302.Mock;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.RaceDataSource;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
@ -17,9 +16,10 @@ public class RegattaXMLReader extends XMLReader {
/**
* Constructor for Regatta XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RegattaXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
@ -28,10 +28,11 @@ public class RegattaXMLReader extends XMLReader {
/**
* Constructor for Regatta XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {

@ -1,8 +1,6 @@
package seng302.Mock;
import javafx.scene.paint.Color;
import seng302.GPSCoordinate;
import seng302.Model.Boat;
import seng302.Model.BoatInRace;
/**
@ -27,8 +25,9 @@ public class StreamedBoat extends BoatInRace {
/**
* Overridden to ignore this function
* @deprecated
*
* @return 0
* @deprecated
*/
public double getScaledVelocity() {
return 0;
@ -36,8 +35,9 @@ public class StreamedBoat extends BoatInRace {
/**
* Overridden to ignore this function
* @deprecated
*
* @param velocity of boat
* @deprecated
*/
public void setScaledVelocity(double velocity) {
}

@ -7,7 +7,8 @@ import seng302.Model.RaceClock;
import seng302.RaceDataSource;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jjg64 on 21/04/17.
@ -42,14 +43,14 @@ public class StreamedCourse implements RaceDataSource {
}
}
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
this.regattaXMLReader = regattaXMLReader;
}
public RegattaXMLReader getRegattaXMLReader() {
return regattaXMLReader;
}
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
this.regattaXMLReader = regattaXMLReader;
}
public List<BoatInRace> getBoats() {
return new ArrayList<>(boatXMLReader.getStreamedBoatMap().values());
}

@ -22,22 +22,23 @@ import java.util.*;
*/
public class StreamedCourseXMLReader extends XMLReader {
private static double COORDINATEPADDING = 0.0005;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private Map<Integer,Element> marks = new HashMap<>();
private Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Leg> legs = new ArrayList<>();
Date creationTimeDate;
Date raceStartTime;
int raceID;
String raceType;
boolean postpone;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private Map<Integer, Element> marks = new HashMap<>();
private Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Leg> legs = new ArrayList<>();
/**
* Constructor for Streamed Race XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public StreamedCourseXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
@ -46,10 +47,11 @@ public class StreamedCourseXMLReader extends XMLReader {
/**
* Constructor for Streamed Race XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
@ -102,16 +104,17 @@ public class StreamedCourseXMLReader extends XMLReader {
*/
private void readCompoundMarks() {
Element nCourse = (Element) doc.getElementsByTagName("Course").item(0);
for(int i = 0; i < nCourse.getChildNodes().getLength(); i++) {
for (int i = 0; i < nCourse.getChildNodes().getLength(); i++) {
Node compoundMark = nCourse.getChildNodes().item(i);
if(compoundMark.getNodeName().equals("CompoundMark")) {
marks.put(getCompoundMarkID((Element)compoundMark),(Element)compoundMark);
if (compoundMark.getNodeName().equals("CompoundMark")) {
marks.put(getCompoundMarkID((Element) compoundMark), (Element) compoundMark);
}
}
}
/**
* Generates a Marker from the CompoundMark element with given ID.
*
* @param compoundMarkID index of required CompoundMark element
* @return generated Marker
* @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of marks
@ -122,10 +125,15 @@ public class StreamedCourseXMLReader extends XMLReader {
NodeList nMarks = compoundMark.getElementsByTagName("Mark");
Marker marker;
switch(nMarks.getLength()) {
case 1: marker = new Marker(getCoordinate((Element)nMarks.item(0))); break;
case 2: marker = new Marker(getCoordinate((Element)nMarks.item(0)), getCoordinate((Element)nMarks.item(1))); break;
default: throw new StreamedCourseXMLException();
switch (nMarks.getLength()) {
case 1:
marker = new Marker(getCoordinate((Element) nMarks.item(0)));
break;
case 2:
marker = new Marker(getCoordinate((Element) nMarks.item(0)), getCoordinate((Element) nMarks.item(1)));
break;
default:
throw new StreamedCourseXMLException();
}
return marker;
@ -134,11 +142,12 @@ public class StreamedCourseXMLReader extends XMLReader {
private GPSCoordinate getCoordinate(Element mark) {
double lat = Double.parseDouble(mark.getAttribute("TargetLat"));
double lon = Double.parseDouble(mark.getAttribute("TargetLng"));
return new GPSCoordinate(lat,lon);
return new GPSCoordinate(lat, lon);
}
/**
* Reads "compoundMarkID" attribute of CompoundMark or Corner element
*
* @param element with "compoundMarkID" attribute
* @return value of "compoundMarkID" attribute
*/
@ -148,6 +157,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/**
* Reads "name" attribute of CompoundMark element with corresponding CompoundMarkID
*
* @param compoundMarkID unique ID for CompoundMark element
* @return value of "name" attribute
*/
@ -157,17 +167,18 @@ public class StreamedCourseXMLReader extends XMLReader {
/**
* Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements.
*
* @throws StreamedCourseXMLException if markers cannot be resolved from CompoundMark
*/
private void readCompoundMarkSequence() throws StreamedCourseXMLException {
Element nCompoundMarkSequence = (Element) doc.getElementsByTagName("CompoundMarkSequence").item(0);
NodeList nCorners = nCompoundMarkSequence.getElementsByTagName("Corner");
Marker lastMarker = getMarker(getCompoundMarkID((Element)nCorners.item(0)));
String legName = getCompoundMarkName(getCompoundMarkID((Element)nCorners.item(0)));
for(int i = 1; i < nCorners.getLength(); i++) {
Element markXML = (Element)nCorners.item(i);
Marker lastMarker = getMarker(getCompoundMarkID((Element) nCorners.item(0)));
String legName = getCompoundMarkName(getCompoundMarkID((Element) nCorners.item(0)));
for (int i = 1; i < nCorners.getLength(); i++) {
Element markXML = (Element) nCorners.item(i);
Marker currentMarker = getMarker(getCompoundMarkID(markXML));
legs.add(new Leg(legName, lastMarker, currentMarker, i-1));
legs.add(new Leg(legName, lastMarker, currentMarker, i - 1));
lastMarker = currentMarker;
legName = getCompoundMarkName(getCompoundMarkID(markXML));
}
@ -175,7 +186,7 @@ public class StreamedCourseXMLReader extends XMLReader {
private void readCourseLimit() {
Element nCourseLimit = (Element) doc.getElementsByTagName("CourseLimit").item(0);
for(int i = 0; i < nCourseLimit.getChildNodes().getLength(); i++) {
for (int i = 0; i < nCourseLimit.getChildNodes().getLength(); i++) {
Node limit = nCourseLimit.getChildNodes().item(i);
if (limit.getNodeName().equals("Limit")) {
double lat = Double.parseDouble(limit.getAttributes().getNamedItem("Lat").getTextContent());

@ -1,14 +1,10 @@
package seng302.Mock;
import javafx.collections.FXCollections;
import seng302.Controllers.RaceController;
import seng302.Model.BoatInRace;
import seng302.Model.Leg;
import seng302.Model.Race;
import seng302.RaceDataSource;
import java.util.*;
/**
* Created by jjg64 on 21/04/17.
*/
@ -26,6 +22,7 @@ public class StreamedRace extends Race {
/**
* Checks if the boat cannot finish the race
*
* @return True if boat cannot finish the race
*/
protected boolean doNotFinish() {
@ -46,7 +43,7 @@ public class StreamedRace extends Race {
/**
* Updates the boat's gps coordinates
*
* @param boat to be updated
* @param boat to be updated
* @param millisecondsElapsed time since last update
*/
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {

@ -18,7 +18,7 @@ public class Boat {
*
* @param name Name of the Boat.
* @param velocity Speed in m/s that the boat travels at.
* @param abbrev nam abbreviation
* @param abbrev nam abbreviation
*/
public Boat(String name, double velocity, String abbrev) {
this.velocity = velocity;
@ -30,7 +30,7 @@ public class Boat {
/**
* Boat initialiser which keeps all of the information of the boat.
*
* @param name Name of the Boat.
* @param name Name of the Boat.
* @param abbrev nam abbreviation
*/
public Boat(String name, String abbrev) {

@ -17,8 +17,10 @@ import java.util.concurrent.ConcurrentLinkedQueue;
*/
public class BoatInRace extends Boat {
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
protected static float trackPointTimeInterval = 5000; // every 1 seconds
protected final int TRACK_POINT_LIMIT = 10;
protected Leg currentLeg;
private double scaledVelocity;
protected double distanceTravelledInLeg;
protected GPSCoordinate currentPosition;
protected long timeFinished;
@ -28,14 +30,10 @@ public class BoatInRace extends Boat {
protected boolean started = false;
protected StringProperty position;
protected double heading;
protected Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
protected long nextValidTime = 0;
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
protected static float trackPointTimeInterval = 5000; // every 1 seconds
protected final int TRACK_POINT_LIMIT = 10;
protected boolean trackVisible = true;
private double scaledVelocity;
/**
* Constructor method.
@ -43,7 +41,7 @@ public class BoatInRace extends Boat {
* @param name Name of the boat.
* @param velocity Speed that the boat travels.
* @param colour Colour the boat will be displayed as on the map
* @param abbrev of boat
* @param abbrev of boat
*/
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
super(name, velocity, abbrev);
@ -55,8 +53,8 @@ public class BoatInRace extends Boat {
/**
* Constructor method.
*
* @param name Name of the boat.
* @param colour Colour the boat will be displayed as on the map
* @param name Name of the boat.
* @param colour Colour the boat will be displayed as on the map
* @param abbrev of boat
*/
public BoatInRace(String name, Color colour, String abbrev) {
@ -66,6 +64,38 @@ public class BoatInRace extends Boat {
position = new SimpleStringProperty("-");
}
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
/**
* Get base track point time interval
*
* @return base track point time interval
*/
public static float getBaseTrackPointTimeInterval() {
return BASE_TRACK_POINT_TIME_INTERVAL;
}
/**
* Set track point time interval
*
* @param value track point time interval value
*/
public static void setTrackPointTimeInterval(float value) {
trackPointTimeInterval = value;
}
/**
* Calculates the azimuth of the travel via map coordinates of the raceMarkers
*
@ -83,20 +113,6 @@ public class BoatInRace extends Boat {
return calc.getAzimuth();
}
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
public double getHeading() {
return heading;
}
@ -276,16 +292,17 @@ public class BoatInRace extends Boat {
return position.get();
}
public StringProperty positionProperty() {
return position;
}
public void setPosition(String position) {
this.position.set(position);
}
public StringProperty positionProperty() {
return position;
}
/**
* Adds a new point to boat's track.
*
* @param coordinate of point on track
* @return whether add is successful
* @see seng302.Model.TrackPoint
@ -302,6 +319,7 @@ public class BoatInRace extends Boat {
/**
* Returns the boat's sampled track between start of race and current time.
*
* @return queue of track points
* @see seng302.Model.TrackPoint
*/
@ -311,6 +329,7 @@ public class BoatInRace extends Boat {
/**
* Returns whether track is visible
*
* @return true if visible
*/
public boolean isTrackVisible() {
@ -319,25 +338,10 @@ public class BoatInRace extends Boat {
/**
* Sets track visibility.
*
* @param trackVisible visible if true.
*/
public void setTrackVisible(boolean trackVisible) {
this.trackVisible = trackVisible;
}
/**
* Get base track point time interval
* @return base track point time interval
*/
public static float getBaseTrackPointTimeInterval() {
return BASE_TRACK_POINT_TIME_INTERVAL;
}
/**
* Set track point time interval
* @param value track point time interval value
*/
public static void setTrackPointTimeInterval(float value) {
trackPointTimeInterval = value;
}
}

@ -25,9 +25,9 @@ public class ConstantVelocityRace extends Race {
* Initialiser for a constant velocity race without standard data source
*
* @param startingBoats in race
* @param legs in race
* @param controller for graphics
* @param scaleFactor of timer
* @param legs in race
* @param controller for graphics
* @param scaleFactor of timer
*/
public ConstantVelocityRace(List<BoatInRace> startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
super(startingBoats, legs, controller, scaleFactor);
@ -37,10 +37,9 @@ public class ConstantVelocityRace extends Race {
* Initialiser for legacy tests
*
* @param startingBoats in race
* @param legs in race
* @param controller for graphics
* @param scaleFactor of timer
*
* @param legs in race
* @param controller for graphics
* @param scaleFactor of timer
* @deprecated Please use {@link #ConstantVelocityRace(List, List, RaceController, int) } for future tests.
*/
public ConstantVelocityRace(BoatInRace[] startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
@ -49,14 +48,39 @@ public class ConstantVelocityRace extends Race {
/**
* Initialiser for constant velocity race with standard data source
* @param raceData for race
* @param controller for graphics
*
* @param raceData for race
* @param controller for graphics
* @param scaleFactor of timer
*/
public ConstantVelocityRace(RaceDataSource raceData, RaceController controller, int scaleFactor) {
super(raceData, controller, scaleFactor);
}
/**
* Calculates the boats next GPS position based on its distance travelled and heading
*
* @param oldCoordinates GPS coordinates of the boat's starting position
* @param distanceTravelled distance in nautical miles
* @param azimuth boat's current direction. Value between -180 and 180
* @return The boat's new coordinate
*/
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
//Find new coordinate using current heading and distance
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
//Load start point into calculator
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
geodeticCalculator.setStartingGeographicPoint(startPoint);
//load direction and distance tranvelled into calculator
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
//get new point
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
}
public void initialiseBoats() {
Leg officialStart = legs.get(0);
String name = officialStart.getName();
@ -115,6 +139,7 @@ public class ConstantVelocityRace extends Race {
/**
* Sets the chance each boat has of failing at a gate or marker
*
* @param chance percentage chance a boat has of failing per checkpoint.
*/
protected void setDnfChance(int chance) {
@ -131,7 +156,7 @@ public class ConstantVelocityRace extends Race {
/**
* Calculates the distance a boat has travelled and updates its current position according to this value.
*
* @param boat to be updated
* @param boat to be updated
* @param millisecondsElapsed since last update
*/
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
@ -181,28 +206,4 @@ public class ConstantVelocityRace extends Race {
}
}
/**
* Calculates the boats next GPS position based on its distance travelled and heading
*
* @param oldCoordinates GPS coordinates of the boat's starting position
* @param distanceTravelled distance in nautical miles
* @param azimuth boat's current direction. Value between -180 and 180
* @return The boat's new coordinate
*/
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
//Find new coordinate using current heading and distance
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
//Load start point into calculator
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
geodeticCalculator.setStartingGeographicPoint(startPoint);
//load direction and distance tranvelled into calculator
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
//get new point
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
}
}

@ -17,9 +17,9 @@ public class Leg {
/**
* Leg Initialiser
*
* @param name Name of the Leg
* @param start marker
* @param end marker
* @param name Name of the Leg
* @param start marker
* @param end marker
* @param number Leg's position in race
*/
public Leg(String name, Marker start, Marker end, int number) {
@ -33,7 +33,7 @@ public class Leg {
/**
* Construction Method
*
* @param name Name of the Leg
* @param name Name of the Leg
* @param number leg number
*/
public Leg(String name, int number) {
@ -74,16 +74,14 @@ public class Leg {
return startMarker;
}
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public Marker getEndMarker() {
return endMarker;
}
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public void setEndMarker(Marker endMarker) {
this.endMarker = endMarker;
}

@ -5,16 +5,11 @@ import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.geotools.referencing.GeodeticCalculator;
import seng302.Controllers.RaceController;
import seng302.GPSCoordinate;
import seng302.RaceDataSource;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* Parent class for races
@ -27,19 +22,17 @@ public abstract class Race implements Runnable {
protected RaceController controller;
protected int boatsFinished = 0;
protected long totalTimeElapsed;
private int lastFPS = 20;
protected int scaleFactor;
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
private int lastFPS = 20;
private boolean timerEnabled = true; //boolean to determine if timer is ran
/**
* Initailiser for Race
*
* @param boats Takes in an array of boats that are participating in the race.
* @param legs Number of marks in order that the boats pass in order to complete the race.
* @param controller race controller
* @param boats Takes in an array of boats that are participating in the race.
* @param legs Number of marks in order that the boats pass in order to complete the race.
* @param controller race controller
* @param scaleFactor for race
*/
public Race(List<BoatInRace> boats, List<Leg> legs, RaceController controller, int scaleFactor) {
@ -66,6 +59,7 @@ public abstract class Race implements Runnable {
/**
* Checks if the boat cannot finish the race
*
* @return True if boat cannot finish the race
*/
protected abstract boolean doNotFinish();
@ -82,7 +76,7 @@ public abstract class Race implements Runnable {
/**
* Updates the boat's gps coordinates
*
* @param boat to be updated
* @param boat to be updated
* @param millisecondsElapsed time since last update
*/
protected abstract void updatePosition(BoatInRace boat, int millisecondsElapsed);
@ -111,7 +105,7 @@ public abstract class Race implements Runnable {
protected void countdownTimer() {
new AnimationTimer() {
long currentTime = System.currentTimeMillis();
long startTime = currentTime + (PRERACE_TIME/scaleFactor);
long startTime = currentTime + (PRERACE_TIME / scaleFactor);
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
@ -120,22 +114,22 @@ public abstract class Race implements Runnable {
@Override
public void handle(long arg0) {
timeLeft = startTime - currentTime;
if (timeLeft <= 0 && controller != null) {
updateTime("Race is starting...");
stop();
simulateRace();
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
minutes = minutes % 60;
if (controller != null) {
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
}
timeLeft = startTime - currentTime;
if (timeLeft <= 0 && controller != null) {
updateTime("Race is starting...");
stop();
simulateRace();
} else {
currentTimeInSeconds = (timeLeft * scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
minutes = minutes % 60;
if (controller != null) {
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
}
currentTime = System.currentTimeMillis();
}
currentTime = System.currentTimeMillis();
}
}.start();
}
@ -234,8 +228,8 @@ public abstract class Race implements Runnable {
*/
protected void updatePositions() {
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
for(BoatInRace boat: startingBoats) {
if(boat != null) {
for (BoatInRace boat : startingBoats) {
if (boat != null) {
boat.setPosition(Integer.toString(startingBoats.indexOf(boat) + 1));
if (boat.getCurrentLeg().getName().equals("DNF") || boat.getCurrentLeg().getLegNumber() == 0)
boat.setPosition("-");

@ -12,7 +12,6 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAmount;
/**
* Created by Gondr on 19/04/2017.
@ -39,6 +38,7 @@ public class RaceClock {
/**
* Sets time to arbitrary zoned time.
*
* @param time arbitrary time with timezone.
*/
public void setTime(ZonedDateTime time) {

@ -7,10 +7,8 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate;
import seng302.*;
import seng302.Controllers.RaceController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -19,6 +17,7 @@ import java.util.List;
* Created by fwy13 on 17/03/17.
*/
public class ResizableRaceCanvas extends Canvas {
double[] xpoints = {}, ypoints = {};
private GraphicsContext gc;
private RaceMap map;
private List<BoatInRace> boats;
@ -28,7 +27,6 @@ public class ResizableRaceCanvas extends Canvas {
private boolean annoSpeed = true;
private boolean annoPath = true;
private ArrayList<GPSCoordinate> raceBoundaries;
double[] xpoints = {}, ypoints = {};
public ResizableRaceCanvas(RaceDataSource raceData) {
gc = this.getGraphicsContext2D();
@ -163,15 +161,15 @@ public class ResizableRaceCanvas extends Canvas {
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate) {
String text = "";
//Check name toggle value
if (annoName){
if (annoName) {
text += String.format("%s ", name);
}
//Check abbreviation toggle value
if (annoAbbrev){
if (annoAbbrev) {
text += String.format("%s ", abbrev);
}
//Check speed toggle value
if (annoSpeed){
if (annoSpeed) {
text += String.format("%.2fkn", speed);
}
//String text = String.format("%s, %2$.2fkn", name, speed);
@ -338,13 +336,14 @@ public class ResizableRaceCanvas extends Canvas {
if (raceAnno)
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
if(boat.isTrackVisible()) drawTrack(boat);
if (boat.isTrackVisible()) drawTrack(boat);
}
}
}
/**
* Draws all track points for a given boat. Colour is set by boat, opacity by track point.
*
* @param boat whose track is displayed
* @see seng302.Model.TrackPoint
*/

@ -13,9 +13,10 @@ public class TrackPoint {
/**
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
*
* @param coordinate position of point on physical race map
* @param timeAdded system clock at time of addition
* @param expiry time to minimum opacity after added
* @param timeAdded system clock at time of addition
* @param expiry time to minimum opacity after added
*/
public TrackPoint(GPSCoordinate coordinate, long timeAdded, long expiry) {
this.coordinate = coordinate;
@ -26,6 +27,7 @@ public class TrackPoint {
/**
* Gets the position of the point on physical race map.
*
* @return GPS coordinate of point
*/
public GPSCoordinate getCoordinate() {
@ -34,14 +36,16 @@ public class TrackPoint {
/**
* Gets opacity of point scaled by age in proportion to expiry, between 1 and minimum opacity inclusive.
*
* @return greater of minimum opacity and scaled opacity
*/
public double getAlpha() {
return Double.max(minAlpha,1.0 - (double)(System.currentTimeMillis() - timeAdded) / expiry);
return Double.max(minAlpha, 1.0 - (double) (System.currentTimeMillis() - timeAdded) / expiry);
}
/**
* Gets time point was added to track.
*
* @return system clock at time of addition
*/
public long getTimeAdded() {

@ -16,14 +16,14 @@ public class BinaryMesageEncoder {
private byte[] message;
//private byte[] crc;
private byte headerSync1 = (byte)0x47;
private byte headerSync2 = (byte)0x83;
private byte headerSync1 = (byte) 0x47;
private byte headerSync2 = (byte) 0x83;
private byte headerMessageType;
private long headerTimeStamp;
private int headerSourceID;
private short headerMessageLength;
public BinaryMesageEncoder(MessageType headerMessageType, long headerTimeStamp, int headerSourceID, short headerMessageLength, byte[] message){
public BinaryMesageEncoder(MessageType headerMessageType, long headerTimeStamp, int headerSourceID, short headerMessageLength, byte[] message) {
//set the header
this.headerMessageType = headerMessageType.getValue();
this.headerTimeStamp = headerTimeStamp;
@ -45,7 +45,7 @@ public class BinaryMesageEncoder {
this.message = message;
//set full message
ByteBuffer tempMessageByteBuffer = ByteBuffer.allocate(19+this.headerMessageLength);
ByteBuffer tempMessageByteBuffer = ByteBuffer.allocate(19 + this.headerMessageLength);
tempMessageByteBuffer.put(this.header);
tempMessageByteBuffer.put(this.message);

@ -25,7 +25,7 @@ public class BinaryMessageDecoder {
this.fullMessage = fullMessage;
}
public void decode() throws IndexOutOfBoundsException{
public void decode() throws IndexOutOfBoundsException {
//get the header
this.header = Arrays.copyOfRange(this.fullMessage, 0, 15);
@ -43,37 +43,37 @@ public class BinaryMessageDecoder {
this.crc = Arrays.copyOfRange(this.fullMessage, this.fullMessage.length - 4, fullMessage.length);
//run through the checks
if (this.message.length != bytesToShort(this.headerMessageLength)){
if (this.message.length != bytesToShort(this.headerMessageLength)) {
System.err.println("message length in header does not equal the message length");
System.err.println("message length in header: " + bytesToInt(this.headerMessageLength));
System.err.println("message length: " + this.message.length);
}else if(this.headerSync1 != 0x47){
} else if (this.headerSync1 != 0x47) {
System.err.println("Sync byte 1 is wrong");
}else if(this.headerSync2 !=(byte) 0x83){
} else if (this.headerSync2 != (byte) 0x83) {
System.err.println("Sync byte 2 is wrong");
}else if(false){
} else if (false) {
//todo check crc
}
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);
@ -96,7 +96,7 @@ public class BinaryMessageDecoder {
return bytesToShort(this.headerMessageLength);
}
public int getMessageType(){
public int getMessageType() {
return (int) this.headerMessageType;
}

@ -42,66 +42,66 @@ public class BoatLocationDecoder {
seqNum = Arrays.copyOfRange(encodedBoatLocation, 11, 15);
deviceType = encodedBoatLocation[15];
latitude = Arrays.copyOfRange(encodedBoatLocation, 16, 20);
longitude = Arrays.copyOfRange(encodedBoatLocation,20, 24);
longitude = Arrays.copyOfRange(encodedBoatLocation, 20, 24);
altitude = Arrays.copyOfRange(encodedBoatLocation, 24, 28);
heading = Arrays.copyOfRange(encodedBoatLocation,28, 30);
pitch =Arrays.copyOfRange(encodedBoatLocation,30,32);
roll = Arrays.copyOfRange(encodedBoatLocation,32,34);
boatSpeed = Arrays.copyOfRange(encodedBoatLocation,34,36);
cog = Arrays.copyOfRange(encodedBoatLocation,36,38);
sog = Arrays.copyOfRange(encodedBoatLocation,38, 40);
heading = Arrays.copyOfRange(encodedBoatLocation, 28, 30);
pitch = Arrays.copyOfRange(encodedBoatLocation, 30, 32);
roll = Arrays.copyOfRange(encodedBoatLocation, 32, 34);
boatSpeed = Arrays.copyOfRange(encodedBoatLocation, 34, 36);
cog = Arrays.copyOfRange(encodedBoatLocation, 36, 38);
sog = Arrays.copyOfRange(encodedBoatLocation, 38, 40);
apparentWindSpeed = Arrays.copyOfRange(encodedBoatLocation, 40, 42);
apparentWindAngle = Arrays.copyOfRange(encodedBoatLocation, 42, 44);
trueWindSpeed = Arrays.copyOfRange(encodedBoatLocation,44, 46);
trueWindSpeed = Arrays.copyOfRange(encodedBoatLocation, 44, 46);
trueWindDirection = Arrays.copyOfRange(encodedBoatLocation, 46, 48);
trueWindAngle = Arrays.copyOfRange(encodedBoatLocation, 48, 50);
currentDrift = Arrays.copyOfRange(encodedBoatLocation,50,52);
currentSet = Arrays.copyOfRange(encodedBoatLocation,52, 54);
rudderAngle = Arrays.copyOfRange(encodedBoatLocation,54, 56);
currentDrift = Arrays.copyOfRange(encodedBoatLocation, 50, 52);
currentSet = Arrays.copyOfRange(encodedBoatLocation, 52, 54);
rudderAngle = Arrays.copyOfRange(encodedBoatLocation, 54, 56);
message = new BoatLocationMessage(messageVersionNumber, bytesToLong(time),
bytesToInt(sourceID), bytesToInt(seqNum),
deviceType, bytesToInt(latitude),
bytesToInt(longitude), bytesToInt(altitude),
twoByteToInt(heading), bytesToShort(pitch),
bytesToShort(roll), twoByteToInt(boatSpeed),
twoByteToInt(cog), twoByteToInt(sog),
twoByteToInt(apparentWindSpeed), bytesToShort(apparentWindAngle),
twoByteToInt(trueWindSpeed), bytesToShort(trueWindDirection),
bytesToShort(trueWindAngle), twoByteToInt(currentDrift),
twoByteToInt(currentSet), bytesToShort(rudderAngle)
bytesToInt(sourceID), bytesToInt(seqNum),
deviceType, bytesToInt(latitude),
bytesToInt(longitude), bytesToInt(altitude),
twoByteToInt(heading), bytesToShort(pitch),
bytesToShort(roll), twoByteToInt(boatSpeed),
twoByteToInt(cog), twoByteToInt(sog),
twoByteToInt(apparentWindSpeed), bytesToShort(apparentWindAngle),
twoByteToInt(trueWindSpeed), bytesToShort(trueWindDirection),
bytesToShort(trueWindAngle), twoByteToInt(currentDrift),
twoByteToInt(currentSet), bytesToShort(rudderAngle)
);
}
private int twoByteToInt(byte[] bytesInt){
private int twoByteToInt(byte[] bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int num = byteBuffer.getInt(0);
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong);
// byteBuffer.put(bytesLong[0]);
// byteBuffer.put(bytesLong[1]);

@ -22,11 +22,11 @@ public class CourseWindDecoder {
messageVersionNumber = encodedCourseWind[0];
byteWindID = encodedCourseWind[1];
loopCount = encodedCourseWind[2];
byte[] loopMessagesBytes = Arrays.copyOfRange(encodedCourseWind, 3, lengthInBytesOfMessages*loopCount+3);
byte[] loopMessagesBytes = Arrays.copyOfRange(encodedCourseWind, 3, lengthInBytesOfMessages * loopCount + 3);
int messageLoopIndex = 0;
for (int i=0; i < loopCount; i++) {
byte[] messageBytes = Arrays.copyOfRange(loopMessagesBytes, messageLoopIndex, messageLoopIndex+20);
for (int i = 0; i < loopCount; i++) {
byte[] messageBytes = Arrays.copyOfRange(loopMessagesBytes, messageLoopIndex, messageLoopIndex + 20);
ArrayList test = new ArrayList();
byte[] windId = Arrays.copyOfRange(messageBytes, 0, 1);
byte[] time = Arrays.copyOfRange(messageBytes, 1, 7);
@ -38,20 +38,20 @@ public class CourseWindDecoder {
byte[] flags = Arrays.copyOfRange(messageBytes, 19, 20);
CourseWind message = new CourseWind(windId[0], bytesToLong(time),
bytesToInt(raceID), twoByteToInt(windDirection),
twoByteToInt(windSpeed), twoByteToInt(bestUpwindAngle),
twoByteToInt(bestDownwindAngle), flags[0]);
bytesToInt(raceID), twoByteToInt(windDirection),
twoByteToInt(windSpeed), twoByteToInt(bestUpwindAngle),
twoByteToInt(bestDownwindAngle), flags[0]);
loopMessages.add(message);
messageLoopIndex += 20;
}
}
private int twoByteToInt(byte[] bytesInt){
private int twoByteToInt(byte[] bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int num = byteBuffer.getInt(0);
@ -59,17 +59,17 @@ public class CourseWindDecoder {
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -1,10 +1,7 @@
package seng302.Networking.MessageDecoders;
import seng302.Model.BoatInRace;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
/**
@ -40,32 +37,32 @@ public class RaceStartStatusDecoder {
notification = byteToChar(notificationType);
}
private char byteToChar(byte bytesInt){
private char byteToChar(byte bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
char num = byteBuffer.getChar(0);
return num;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -33,7 +33,7 @@ public class RaceStatusDecoder {
private ArrayList<BoatStatus> boats = new ArrayList<>();
public RaceStatusDecoder(byte[] encodedRaceStatus){
public RaceStatusDecoder(byte[] encodedRaceStatus) {
versionNum = encodedRaceStatus[0];
timeBytes = Arrays.copyOfRange(encodedRaceStatus, 1, 7);
raceID = Arrays.copyOfRange(encodedRaceStatus, 7, 11);
@ -43,7 +43,7 @@ public class RaceStatusDecoder {
windSpeed = Arrays.copyOfRange(encodedRaceStatus, 20, 22);
numBoats = encodedRaceStatus[22];
bytesRaceType = encodedRaceStatus[23];
boatsBytes = Arrays.copyOfRange(encodedRaceStatus, 24, 25+20*this.numBoats);
boatsBytes = Arrays.copyOfRange(encodedRaceStatus, 24, 25 + 20 * this.numBoats);
time = bytesToLong(timeBytes);
race = bytesToInt(raceID);
@ -55,8 +55,8 @@ public class RaceStatusDecoder {
int boatLoopIndex = 0;
for (int i=0; i < numberOfBoats; i++) {
byte[] boatBytes = Arrays.copyOfRange(boatsBytes, boatLoopIndex, boatLoopIndex+20);
for (int i = 0; i < numberOfBoats; i++) {
byte[] boatBytes = Arrays.copyOfRange(boatsBytes, boatLoopIndex, boatLoopIndex + 20);
byte[] sourceID = Arrays.copyOfRange(boatBytes, 1, 5);
byte boatStatus = boatBytes[5];
@ -66,7 +66,7 @@ public class RaceStatusDecoder {
byte[] estTimeAtNextMark = Arrays.copyOfRange(boatBytes, 9, 15);
byte[] estTimeAtFinish = Arrays.copyOfRange(boatBytes, 15, 20);
BoatStatus boat = new BoatStatus(bytesToInt(sourceID),boatStatus,
BoatStatus boat = new BoatStatus(bytesToInt(sourceID), boatStatus,
legNumber, numPenaltiesAwarded, numPenaltiesServed,
bytesToLong(estTimeAtNextMark), bytesToLong(estTimeAtFinish));
@ -75,24 +75,24 @@ public class RaceStatusDecoder {
}
}
private int byteToInt(byte bytesInt){
private int byteToInt(byte bytesInt) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesInt);
int intVal = byteBuffer.getInt(0);
return intVal;
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesShort);
short num = wrapped.getShort();
return num;
}
private int bytesToInt(byte[] bytesInt){
private int bytesToInt(byte[] bytesInt) {
ByteBuffer wrapped = ByteBuffer.wrap(bytesInt);
int num = wrapped.getInt();
return num;

@ -22,7 +22,7 @@ public class XMLMessageDecoder {
this.bytes = bytes;
}
public void decode(){
public void decode() {
byte[] ackNumberBytes = Arrays.copyOfRange(bytes, 1, 3);
byte[] timeStampBytes = Arrays.copyOfRange(bytes, 3, 9);
byte[] sequenceNumberBytes = Arrays.copyOfRange(bytes, 10, 12);
@ -40,7 +40,7 @@ public class XMLMessageDecoder {
this.xmlMessage = new String(xmlMessagebytes);
}
private short bytesToShort(byte[] bytesShort){
private short bytesToShort(byte[] bytesShort) {
ByteBuffer byteBuffer = ByteBuffer.allocate(2);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
byteBuffer.put(bytesShort[0]);
@ -49,11 +49,11 @@ public class XMLMessageDecoder {
return shortVal;
}
private long bytesToLong(byte[] bytesLong){
private long bytesToLong(byte[] bytesLong) {
ByteBuffer byteBuffer = ByteBuffer.allocate(8);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
byteBuffer.put((byte)0);
byteBuffer.put((byte)0);
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.put(bytesLong[0]);
byteBuffer.put(bytesLong[1]);
byteBuffer.put(bytesLong[2]);

@ -15,15 +15,15 @@ import java.util.Arrays;
*/
public class RaceVisionByteEncoder {
public byte[] heartBeat(int seq){
public byte[] heartBeat(int seq) {
ByteBuffer heartBeat = ByteBuffer.allocate(4);
heartBeat.putInt(seq);
byte [] result = heartBeat.array();
byte[] result = heartBeat.array();
return result;
}
public byte[] raceStatus(long time, int race, int raceState, long startTime, short raceWindDir, short raceWindSpeed, int raceType, ArrayList<BoatInRace> boats){
ByteBuffer raceStatusMessage = ByteBuffer.allocate(24 + 20*boats.size());
public byte[] raceStatus(long time, int race, int raceState, long startTime, short raceWindDir, short raceWindSpeed, int raceType, ArrayList<BoatInRace> boats) {
ByteBuffer raceStatusMessage = ByteBuffer.allocate(24 + 20 * boats.size());
//Version Number 1 bytes
byte versionNum = 0b10; //this changes with the pdf. (2)
byte[] timeBytes = convert(time, 6);//time (6 bytes)
@ -45,12 +45,12 @@ public class RaceVisionByteEncoder {
raceStatusMessage.put(numBoats);
raceStatusMessage.put(bytesRaceType);
for (int i = 0; i < boats.size(); i++){
for (int i = 0; i < boats.size(); i++) {
int sourceID = 0; //TODO use boats source id.
byte[] legNum = convert(boats.get(i).getCurrentLeg().getLegNumber(), 1);
byte[] numPenalties = convert(0, 1); //TODO use boats in race penalties class
byte[] numPenaltiesServed = convert(0, 1);//TODO use boats in race penalites served.
byte[] estNextMarkTime = convert((long)0, 6);//TODO use boats estimated time to next mark.
byte[] estNextMarkTime = convert((long) 0, 6);//TODO use boats estimated time to next mark.
byte[] estFinishTime = convert((long) 0, 6);//TODO use boats estimated time to the finish.
raceStatusMessage.putInt(sourceID);
@ -64,7 +64,7 @@ public class RaceVisionByteEncoder {
return raceStatusMessage.array();
}
public byte[] displayTextMessage(RaceMessage[] message){
public byte[] displayTextMessage(RaceMessage[] message) {
//ByteBuffer result = ByteBuffer.allocate(4 + numLines * 32);
int messageVersionNumber = 0b1;//version number
short ackNum = 0;//no clue what this does just a placeholder for 2 bytes.
@ -77,16 +77,16 @@ public class RaceVisionByteEncoder {
ArrayList<byte[]> messages = new ArrayList<byte[]>();
int size = 4;
for (int i = 0; i < message.length; i ++){
for (int i = 0; i < message.length; i++) {
int messageLen = message[i].getMessageText().getBytes().length;
byte[] messageAsBytes = message[i].getMessageText().getBytes();
if (messageLen < 30){
if (messageLen < 30) {
messageLen = 30;
}
ByteBuffer mess = ByteBuffer.allocate(2 + messageLen);
mess.put(convert(message[i].getLineNumber(), 1));
mess.put(convert(messageLen, 1));
for (int j = 0; j < messageLen; j ++){
for (int j = 0; j < messageLen; j++) {
mess.put(messageAsBytes[j]);
}
messages.add(mess.array());
@ -98,14 +98,14 @@ public class RaceVisionByteEncoder {
result.putShort(ackNum);
result.put(messLines);
for(byte[] mess: messages){
for (byte[] mess : messages) {
result.put(mess);
}
return result.array();
}
public byte[] raceStartStatus(long time, short ack, long startTime, int raceID, char notification){
public byte[] raceStartStatus(long time, short ack, long startTime, int raceID, char notification) {
int messageVersion = 0b1;
byte[] timestamp = convert(time, 6);
byte[] ackNumber = convert(ack, 2);
@ -125,7 +125,7 @@ public class RaceVisionByteEncoder {
}
public byte[] yachtEventCode(long time, short acknowledgeNumber, int raceID, int destSourceID, int incidentID,
int eventID){
int eventID) {
int messageVersion = 0b10;
byte[] encodeTime = convert(time, 6);
short ackNum = acknowledgeNumber;
@ -145,7 +145,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] chatterText(int messageType, String message){
public byte[] chatterText(int messageType, String message) {
int messageVersion = 0b1;
byte[] type = convert(messageType, 1);
byte[] length = convert(message.length(), 1);
@ -160,7 +160,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] boatLocation(BoatLocationMessage boatLocationMessage){
public byte[] boatLocation(BoatLocationMessage boatLocationMessage) {
int messageVersionNumber = 0b1;
byte[] time = convert(boatLocationMessage.getTime(), 6);
byte[] sourceID = convert(boatLocationMessage.getSourceID(), 4);
@ -210,7 +210,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] markRounding(int time, int ackNumber, int raceID, int sourceID, int boatStatus, int roundingSide, int markType, int markID){
public byte[] markRounding(int time, int ackNumber, int raceID, int sourceID, int boatStatus, int roundingSide, int markType, int markID) {
int messageVersionNumber = 0b1;
byte[] byteTime = convert(time, 6);
byte[] byteAck = convert(ackNumber, 2);
@ -234,7 +234,7 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] courseWind(byte windID, ArrayList<CourseWind> courseWinds){
public byte[] courseWind(byte windID, ArrayList<CourseWind> courseWinds) {
int messageVersionNumber = 0b1;
byte byteWindID = windID;
byte[] loopcount = convert(courseWinds.size(), 1);
@ -242,7 +242,7 @@ public class RaceVisionByteEncoder {
result.put(convert(messageVersionNumber, 1));
result.put(byteWindID);
result.put(loopcount);
for (CourseWind wind: courseWinds){
for (CourseWind wind : courseWinds) {
result.put(convert(wind.getID(), 1));
result.put(convert(wind.getTime(), 6));
result.put(convert(wind.getRaceID(), 4));
@ -255,9 +255,9 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] averageWind(int time, int rawPeriod, int rawSampleSpeed, int period2, int speed2, int period3, int speed3, int period4, int speed4){
public byte[] averageWind(int time, int rawPeriod, int rawSampleSpeed, int period2, int speed2, int period3, int speed3, int period4, int speed4) {
int messageVersionNumber = 0b1;
byte[] byteTime = convert(time,6);
byte[] byteTime = convert(time, 6);
byte[] byteRawPeriod = convert(rawPeriod, 2);
byte[] byteRawSpeed = convert(rawSampleSpeed, 2);
byte[] bytePeriod2 = convert(period2, 2);
@ -281,13 +281,13 @@ public class RaceVisionByteEncoder {
return result.array();
}
public byte[] convert(String s, int size){
public byte[] convert(String s, int size) {
byte[] m = s.getBytes(Charset.forName("UTF-8"));
int length = m.length;
byte[] result;
if (length > 255){
if (length > 255) {
length = 255;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -295,12 +295,12 @@ public class RaceVisionByteEncoder {
return result;
}
public byte[] convert(int n, int size){
public byte[] convert(int n, int size) {
byte[] result;
if (size > 4){
if (size > 4) {
result = new byte[4];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -311,12 +311,12 @@ public class RaceVisionByteEncoder {
return result;
}
public byte[] convert(long n, int size){
public byte[] convert(long n, int size) {
byte[] result;
if (size > 8){
if (size > 8) {
result = new byte[8];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}
@ -328,12 +328,12 @@ public class RaceVisionByteEncoder {
}
public byte[] convert(short n, int size){
public byte[] convert(short n, int size) {
byte[] result;
if (size > 2){
if (size > 2) {
result = new byte[2];
return result;
} else if (size < 1){
} else if (size < 1) {
result = new byte[0];
return result;
}

@ -1,7 +1,6 @@
package seng302.Networking.MessageEncoders;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
/**

@ -7,8 +7,7 @@ package seng302.Networking.Utils;
/**
* Represents the information in a boat location message (AC streaming spec: 4.9).
*/
public class BoatLocationMessage
{
public class BoatLocationMessage {
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
@ -78,12 +77,12 @@ public class BoatLocationMessage
/**
* Ctor.
*/
public BoatLocationMessage()
{
public BoatLocationMessage() {
}
/**
* Ctor, with all parameters.
*
* @param messageVersionNumber
* @param time
* @param sourceID
@ -107,8 +106,7 @@ public class BoatLocationMessage
* @param currentSet
* @param rudderAngle
*/
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle)
{
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
this.messageVersionNumber = messageVersionNumber;
this.time = time;
this.sourceID = sourceID;
@ -137,173 +135,139 @@ public class BoatLocationMessage
//Getters and setters for message properties.
public byte getMessageVersionNumber()
{
public byte getMessageVersionNumber() {
return messageVersionNumber;
}
public void setMessageVersionNumber(byte messageVersionNumber)
{
public void setMessageVersionNumber(byte messageVersionNumber) {
this.messageVersionNumber = messageVersionNumber;
}
public long getTime()
{
public long getTime() {
return time;
}
public void setTime(long time)
{
public void setTime(long time) {
this.time = time;
}
public int getSourceID()
{
public int getSourceID() {
return sourceID;
}
public void setSourceID(int sourceID)
{
public void setSourceID(int sourceID) {
this.sourceID = sourceID;
}
public int getSequenceNumber()
{
public int getSequenceNumber() {
return sequenceNumber;
}
public void setSequenceNumber(int sequenceNumber)
{
public void setSequenceNumber(int sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
public byte getDeviceType()
{
public byte getDeviceType() {
return deviceType;
}
public void setDeviceType(byte deviceType)
{
public void setDeviceType(byte deviceType) {
this.deviceType = deviceType;
}
public int getLatitude()
{
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude)
{
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude()
{
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude)
{
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public int getAltitude()
{
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude)
{
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getHeading()
{
public int getHeading() {
return heading;
}
public void setHeading(int heading)
{
public void setHeading(int heading) {
this.heading = heading;
}
public short getPitch()
{
public short getPitch() {
return pitch;
}
public void setPitch(short pitch)
{
public void setPitch(short pitch) {
this.pitch = pitch;
}
public short getRoll()
{
public short getRoll() {
return roll;
}
public void setRoll(short roll)
{
public void setRoll(short roll) {
this.roll = roll;
}
public int getBoatSpeed()
{
public int getBoatSpeed() {
return boatSpeed;
}
public void setBoatSpeed(int boatSpeed)
{
public void setBoatSpeed(int boatSpeed) {
this.boatSpeed = boatSpeed;
}
public int getBoatCOG()
{
public int getBoatCOG() {
return boatCOG;
}
public void setBoatCOG(int boatCOG)
{
public void setBoatCOG(int boatCOG) {
this.boatCOG = boatCOG;
}
public int getBoatSOG()
{
public int getBoatSOG() {
return boatSOG;
}
public void setBoatSOG(int boatSOG)
{
public void setBoatSOG(int boatSOG) {
this.boatSOG = boatSOG;
}
public int getApparentWindSpeed()
{
public int getApparentWindSpeed() {
return apparentWindSpeed;
}
public void setApparentWindSpeed(int apparentWindSpeed)
{
public void setApparentWindSpeed(int apparentWindSpeed) {
this.apparentWindSpeed = apparentWindSpeed;
}
public short getApparentWindAngle()
{
public short getApparentWindAngle() {
return apparentWindAngle;
}
public void setApparentWindAngle(short apparentWindAngle)
{
public void setApparentWindAngle(short apparentWindAngle) {
this.apparentWindAngle = apparentWindAngle;
}
public int getTrueWindSpeed()
{
public int getTrueWindSpeed() {
return trueWindSpeed;
}
public void setTrueWindSpeed(int trueWindSpeed)
{
public void setTrueWindSpeed(int trueWindSpeed) {
this.trueWindSpeed = trueWindSpeed;
}
@ -315,43 +279,35 @@ public class BoatLocationMessage
this.trueWindDirection = trueWindDirection;
}
public short getTrueWindAngle()
{
public short getTrueWindAngle() {
return trueWindAngle;
}
public void setTrueWindAngle(short trueWindAngle)
{
public void setTrueWindAngle(short trueWindAngle) {
this.trueWindAngle = trueWindAngle;
}
public int getCurrentDrift()
{
public int getCurrentDrift() {
return currentDrift;
}
public void setCurrentDrift(int currentDrift)
{
public void setCurrentDrift(int currentDrift) {
this.currentDrift = currentDrift;
}
public int getCurrentSet()
{
public int getCurrentSet() {
return currentSet;
}
public void setCurrentSet(int currentSet)
{
public void setCurrentSet(int currentSet) {
this.currentSet = currentSet;
}
public short getRudderAngle()
{
public short getRudderAngle() {
return rudderAngle;
}
public void setRudderAngle(short rudderAngle)
{
public void setRudderAngle(short rudderAngle) {
this.rudderAngle = rudderAngle;
}
}

@ -9,7 +9,7 @@ public class CourseWind {
private long time;
public CourseWind(int ID, long time, int raceID, int windDirection, int windSpeed, int bestUpwindAngle, int bestDownwindAngle,
int flags){
int flags) {
this.ID = ID;
this.time = time;
this.raceID = raceID;

@ -10,7 +10,9 @@ public enum MessageType {
private byte value;
private MessageType(int value) { this.value = (byte)value; }
private MessageType(int value) {
this.value = (byte) value;
}
public byte getValue() {
return value;

@ -8,7 +8,7 @@ public class RaceMessage {
private int lineNumber;
private String messageText;
public RaceMessage(int lineNumber, String messageText){
public RaceMessage(int lineNumber, String messageText) {
this.lineNumber = lineNumber;
this.messageText = messageText;
}

@ -11,10 +11,14 @@ import java.util.List;
*/
public interface RaceDataSource {
List<BoatInRace> getBoats();
List<Leg> getLegs();
List<GPSCoordinate> getBoundary();
ZonedDateTime getZonedDateTime();
GPSCoordinate getMapTopLeft();
GPSCoordinate getMapBottomRight();
}

@ -4,7 +4,10 @@ import javafx.scene.paint.Color;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.Model.*;
import seng302.Model.BoatInRace;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.Model.RaceClock;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
@ -16,19 +19,20 @@ import java.util.List;
* Created by fwy13 on 26/03/2017.
*/
public class RaceXMLReader extends XMLReader implements RaceDataSource {
private static double COORDINATEPADDING = 0.0005;
private List<BoatInRace> boats = new ArrayList<>();
private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
private List<Leg> legs = new ArrayList<>();
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private static double COORDINATEPADDING = 0.0005;
/**
* Constractor for Race XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RaceXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
@ -37,10 +41,11 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* COnstructor for Race XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RaceXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
@ -61,7 +66,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* Read all the boats in the XML file
*/
*/
public void readBoats() {
//get all boats
NodeList nBoats = doc.getElementsByTagName("boat");
@ -168,6 +173,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return
*/
@ -177,7 +183,8 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag
* @return
*/
@ -187,9 +194,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a marker from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag
* @param nodeIndex coordinate index
* @param nodeIndex coordinate index
* @return
*/
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
@ -200,6 +208,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a changes a marker to GPS coordinates into a marker
*
* @param markerNode marker to turn into coordinates
* @return
*/
@ -220,6 +229,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/**
* gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return
*/
@ -227,9 +237,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return getCoordinates(start, 0);
}
/**
/**
* gets a coordinates from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in
* @return
*/
@ -237,11 +248,12 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return getCoordinates(start, startIndex, 0);
}
/**
/**
* gets a coordinates from the XML file
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in
* @param nodeIndex The coordinate index
* @param nodeIndex The coordinate index
* @return
*/
private GPSCoordinate getCoordinates(NodeList start, int startIndex, int nodeIndex) {

@ -8,13 +8,13 @@
<Settings>
<RaceBoatType Type="AC45" />
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449" />
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
@ -24,13 +24,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659" />
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659" />
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659" />
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659" />
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
@ -40,13 +40,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278" />
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278" />
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278" />
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278" />
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
@ -56,13 +56,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1" />
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1" />
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1" />
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1" />
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
@ -72,13 +72,13 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75" />
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75" />
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75" />
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75" />
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
@ -88,83 +88,83 @@
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46" />
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46" />
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46" />
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46" />
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752" />
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813" />
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34" />
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46" />
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387" />
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075" />
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793" />
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699" />
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699" />
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793" />
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075" />
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387" />
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46" />
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34" />
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813" />
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752" />
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2" />
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2" />
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2" />
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2" />
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699" />
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699" />
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699" />
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699" />
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5" />
<BoatShape ShapeID="5"/>
</BoatShapes>
@ -174,9 +174,9 @@
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000" />
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000" />
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
@ -184,9 +184,9 @@
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -194,17 +194,17 @@
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -212,9 +212,9 @@
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -222,17 +222,17 @@
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000" />
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000" />
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
@ -240,9 +240,9 @@
BoatName="TEAM KOREA" Country="KOR">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000" />
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>

@ -6,15 +6,15 @@
<RaceType>Match</RaceType>
<CreationTimeDate>2011-08-06T13:25:00-0000</CreationTimeDate >
<CreationTimeDate>2011-08-06T13:25:00-0000</CreationTimeDate>
<RaceStartTime Time="2011-08-06T13:30:00-0700" Postpone="false" />
<RaceStartTime Time="2011-08-06T13:30:00-0700" Postpone="false"/>
<Participants>
<Yacht SourceID="101" Entry="Port" />
<Yacht SourceID="101" Entry="Port"/>
<Yacht SourceID="108" Entry="Stbd" />
<Yacht SourceID="108" Entry="Stbd"/>
</Participants>
@ -22,29 +22,29 @@
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="-36.83" TargetLng="174.83" SourceID="101" />
<Mark SeqID="1" Name="PRO" TargetLat="-36.83" TargetLng="174.83" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="-36.84" TargetLng="174.81" SourceID="102" />
<Mark SeqID="2" Name="PIN" TargetLat="-36.84" TargetLng="174.81" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="-36.63566590" TargetLng="174.88543944" SourceID="103" />
<Mark Name="M1" TargetLat="-36.63566590" TargetLng="174.88543944" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="M2">
<Mark Name="M2" TargetLat="-36.83" TargetLng="174.80" SourceID="102" />
<Mark Name="M2" TargetLat="-36.83" TargetLng="174.80" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="Gate">
<Mark SeqID="1" Name="G1" TargetLat="-36.63566590" TargetLng="174.97205159" SourceID="104" />
<Mark SeqID="1" Name="G1" TargetLat="-36.63566590" TargetLng="174.97205159" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="-36.64566590" TargetLng="174.98205159" SourceID="105" />
<Mark SeqID="2" Name="G2" TargetLat="-36.64566590" TargetLng="174.98205159" SourceID="105"/>
</CompoundMark>
@ -52,13 +52,13 @@
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Stbd" ZoneSize="6" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="Stbd" ZoneSize="6"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="6" />
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="6"/>
<Corner SeqID="5" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>

@ -4,116 +4,116 @@
<Modified>2017-04-19T15:49:40+1200</Modified>
<Version>1</Version>
<Settings>
<RaceBoatType Type="AC45" />
<BoatDimension BoatLength="14.019" HullLength="13.449" />
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659" />
<Vtx Seq="2" Y="18.359" X="-2.659" />
<Vtx Seq="3" Y="18.359" X="2.659" />
<Vtx Seq="4" Y="0" X="2.659" />
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278" />
<Vtx Seq="2" Y="8.876" X="-1.278" />
<Vtx Seq="3" Y="8.876" X="1.278" />
<Vtx Seq="4" Y="0" X="1.278" />
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1" />
<Vtx Seq="2" Y="8.3" X="-1.1" />
<Vtx Seq="3" Y="8.3" X="1.1" />
<Vtx Seq="4" Y="0" X="1.1" />
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75" />
<Vtx Seq="2" Y="3" X="-0.75" />
<Vtx Seq="3" Y="3" X="0.75" />
<Vtx Seq="4" Y="0" X="0.75" />
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46" />
<Vtx Seq="2" Y="13.449" X="-3.46" />
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="4" Y="13.449" X="3.46" />
<Vtx Seq="5" Y="0" X="3.46" />
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752" />
<Vtx Seq="2" Y="0" X="-2.813" />
<Vtx Seq="3" Y="0" X="-3.34" />
<Vtx Seq="4" Y="5.351" X="-3.46" />
<Vtx Seq="5" Y="10.544" X="-3.387" />
<Vtx Seq="6" Y="13.449" X="-3.075" />
<Vtx Seq="7" Y="10.851" X="-2.793" />
<Vtx Seq="8" Y="6.669" X="-2.699" />
<Vtx Seq="9" Y="6.669" X="2.699" />
<Vtx Seq="10" Y="10.851" X="2.793" />
<Vtx Seq="11" Y="13.449" X="3.075" />
<Vtx Seq="12" Y="10.544" X="3.387" />
<Vtx Seq="13" Y="5.351" X="3.46" />
<Vtx Seq="14" Y="0" X="3.34" />
<Vtx Seq="15" Y="0" X="2.813" />
<Vtx Seq="16" Y="1.769" X="2.752" />
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2" />
<Vtx Seq="2" Y="11.377" X="-0.2" />
<Vtx Seq="3" Y="14.019" X="0" />
<Vtx Seq="4" Y="11.377" X="0.2" />
<Vtx Seq="5" Y="6.669" X="0.2" />
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699" />
<Vtx Seq="2" Y="6.438" X="-2.699" />
<Vtx Seq="3" Y="6.438" X="2.699" />
<Vtx Seq="4" Y="2" X="2.699" />
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5" />
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" ShortName="USA"
BoatName="ORACLE TEAM USA" Country="USA">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="102" ShapeID="4" HullNum="AC4502" ShortName="GBR"
BoatName="Land Rover BAR" Country="United Kingdom">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="103" ShapeID="4" HullNum="AC4503" ShortName="JPN"
BoatName="SoftBank Team Japan" Country="Japan">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="104" ShapeID="4" HullNum="AC4504" ShortName="FRA"
BoatName="Groupama Team France" Country="France">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="105" ShapeID="4" HullNum="AC4505" ShortName="SWE"
BoatName="Artemis Racing" Country="Sweden">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="106" ShapeID="4" HullNum="AC4506" ShortName="NZL"
BoatName="Emirates Team New Zealand" Country="New Zealand">
<GPSposition Z="1.738" Y="0.625" X="0.001" />
<MastTop Z="21.496" Y="4.233" X="0.000" />
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>

@ -2,43 +2,43 @@
<Race>
<RaceID>17041901</RaceID>
<RaceType>Fleet</RaceType>
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate >
<RaceStartTime Time="2019-06-01T13:30:00-0400" Postpone="false" />
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate>
<RaceStartTime Time="2019-06-01T13:30:00-0400" Postpone="false"/>
<Participants>
<Yacht SourceID="001" Entry="Port" />
<Yacht SourceID="002" Entry="Port" />
<Yacht SourceID="003" Entry="Port" />
<Yacht SourceID="004" Entry="Port" />
<Yacht SourceID="005" Entry="Port" />
<Yacht SourceID="006" Entry="Port" />
<Yacht SourceID="001" Entry="Port"/>
<Yacht SourceID="002" Entry="Port"/>
<Yacht SourceID="003" Entry="Port"/>
<Yacht SourceID="004" Entry="Port"/>
<Yacht SourceID="005" Entry="Port"/>
<Yacht SourceID="006" Entry="Port"/>
</Participants>
<Course>
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.296577" TargetLng="-64.854304" SourceID="101" />
<Mark SeqID="2" Name="PIN" TargetLat="32.293771" TargetLng="-64.855242" SourceID="102" />
<Mark SeqID="1" Name="PRO" TargetLat="32.296577" TargetLng="-64.854304" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.293771" TargetLng="-64.855242" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="32.293039" TargetLng="-64.843983" SourceID="103" />
<Mark Name="M1" TargetLat="32.293039" TargetLng="-64.843983" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="WindwardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.284680" TargetLng="-64.850045" SourceID="104" />
<Mark SeqID="2" Name="G2" TargetLat="32.280164" TargetLng="-64.847591" SourceID="105" />
<Mark SeqID="1" Name="G1" TargetLat="32.284680" TargetLng="-64.850045" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="32.280164" TargetLng="-64.847591" SourceID="105"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="LeewardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.309693" TargetLng="-64.835249" SourceID="106" />
<Mark SeqID="2" Name="G2" TargetLat="32.308046" TargetLng="-64.831785" SourceID="107" />
<Mark SeqID="1" Name="G1" TargetLat="32.309693" TargetLng="-64.835249" SourceID="106"/>
<Mark SeqID="2" Name="G2" TargetLat="32.308046" TargetLng="-64.831785" SourceID="107"/>
</CompoundMark>
<CompoundMark CompoundMarkID="5" Name="FinishLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.317379" TargetLng="-64.839291" SourceID="108" />
<Mark SeqID="2" Name="PIN" TargetLat="32.317257" TargetLng="-64.836260" SourceID="109" />
<Mark SeqID="1" Name="PRO" TargetLat="32.317379" TargetLng="-64.839291" SourceID="108"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.317257" TargetLng="-64.836260" SourceID="109"/>
</CompoundMark>
</Course>
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3" />
<Corner SeqID="4" CompoundMarkID="4" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3" />
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="5" CompoundMarkID="5" Rounding="SP" ZoneSize="3"/>
</CompoundMarkSequence>
<CourseLimit>

@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController">
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="main" xmlns="http://javafx.com/javafx/8"
fx:controller="seng302.Controllers.MainController">
<children>
<fx:include source="race.fxml" fx:id="race"/>
<fx:include source="start.fxml" fx:id="start"/>

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<SplitPane fx:id="race" dividerPositions="0.7" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
<?import javafx.scene.text.Font?>
<SplitPane xmlns:fx="http://javafx.com/fxml/1" fx:id="race" dividerPositions="0.7" visible="false" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns="http://javafx.com/javafx/8" fx:controller="seng302.Controllers.RaceController">
<items>
<GridPane fx:id="canvasBase">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Pane prefHeight="200.0" prefWidth="400.0" GridPane.halignment="LEFT" GridPane.valignment="TOP">
@ -25,13 +24,28 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="240.0" prefWidth="200.0">
<children>
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="104.0" />
<CheckBox fx:id="showAnnotations" layoutX="-2.0" layoutY="14.0" mnemonicParsing="false" selected="true" text="Show Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false" selected="true" text="Show Boat Name" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="26.0" />
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false" selected="true" text="Show Boat Abbreviation" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="52.0" />
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="78.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Annotation" AnchorPane.topAnchor="130.0" />
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0" mnemonicParsing="false" text="Show Set Annotation" AnchorPane.topAnchor="160.0" />
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true"
text="Show Boat Paths" AnchorPane.leftAnchor="0.0"
AnchorPane.topAnchor="104.0"/>
<CheckBox fx:id="showAnnotations" layoutX="-2.0" layoutY="14.0"
mnemonicParsing="false" selected="true"
text="Show Annotations" AnchorPane.leftAnchor="0.0"
AnchorPane.topAnchor="0.0"/>
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false"
selected="true" text="Show Boat Name"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="26.0"/>
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false"
selected="true" text="Show Boat Abbreviation"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="52.0"/>
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false"
selected="true" text="Show Boat Speed"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="78.0"/>
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0"
mnemonicParsing="false" prefWidth="154.0" text="Save Annotation"
AnchorPane.topAnchor="130.0"/>
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0"
mnemonicParsing="false" text="Show Set Annotation"
AnchorPane.topAnchor="160.0"/>
</children>
</AnchorPane>
</content>
@ -40,7 +54,9 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<CheckBox fx:id="showFPS" layoutX="-14.0" layoutY="13.0" mnemonicParsing="false" selected="true" text="Show FPS" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="showFPS" layoutX="-14.0" layoutY="13.0"
mnemonicParsing="false" selected="true" text="Show FPS"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</children>
</AnchorPane>
</content>
@ -49,34 +65,40 @@
</Accordion>
</children>
</Pane>
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" maxHeight="20.0" text="0:0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" GridPane.halignment="RIGHT" GridPane.valignment="BOTTOM">
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" maxHeight="20.0" text="0:0"
AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" GridPane.halignment="RIGHT"
GridPane.valignment="BOTTOM">
<font>
<Font name="System Bold" size="15.0"/>
</font>
</Label>
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
GridPane.halignment="LEFT" GridPane.valignment="BOTTOM">
<font>
<Font name="System Bold" size="15.0" />
<Font name="System Bold" size="15.0"/>
</font>
</Label>
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" GridPane.halignment="LEFT" GridPane.valignment="BOTTOM">
<Label fx:id="timeZone" text="Label" GridPane.halignment="RIGHT" GridPane.valignment="BOTTOM">
<GridPane.margin>
<Insets bottom="20.0"/>
</GridPane.margin>
<font>
<Font name="System Bold" size="15.0" />
<Font name="System Bold" size="15.0"/>
</font>
</Label>
<Label fx:id="timeZone" text="Label" GridPane.halignment="RIGHT" GridPane.valignment="BOTTOM">
<GridPane.margin>
<Insets bottom="20.0" />
</GridPane.margin>
<font>
<Font name="System Bold" size="15.0" />
</font>
</Label>
</children>
</GridPane>
<AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0" GridPane.columnIndex="1">
<AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0"
GridPane.columnIndex="1">
<children>
<TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="-62.0" AnchorPane.topAnchor="0.0">
<TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="-62.0"
AnchorPane.topAnchor="0.0">
<columns>
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place" />
<TableColumn fx:id="boatTeamColumn" prefWidth="100.0" text="Team" />
<TableColumn fx:id="boatMarkColumn" prefWidth="130.0" text="Mark" />
<TableColumn fx:id="boatSpeedColumn" prefWidth="75.0" text="Speed" />
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place"/>
<TableColumn fx:id="boatTeamColumn" prefWidth="100.0" text="Team"/>
<TableColumn fx:id="boatMarkColumn" prefWidth="130.0" text="Mark"/>
<TableColumn fx:id="boatSpeedColumn" prefWidth="75.0" text="Speed"/>
</columns>
</TableView>
</children>

@ -1,57 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="startWrapper" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8"
fx:controller="seng302.Controllers.StartController">
<children>
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="250.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="250.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="116.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="257.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="50.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="53.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="116.5" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="257.5" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="50.5" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="53.5" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5" GridPane.halignment="CENTER">
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5"
GridPane.halignment="CENTER">
<font>
<Font size="36.0" />
<Font size="36.0"/>
</font>
</Text>
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace1Min" prefWidth="100.0" fx:id="oneMinButton" text="1 Minute" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4">
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace1Min"
prefWidth="100.0" fx:id="oneMinButton" text="1 Minute" GridPane.columnIndex="1"
GridPane.halignment="RIGHT" GridPane.rowIndex="4">
<GridPane.margin>
<Insets />
<Insets/>
</GridPane.margin>
</Button>
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" fx:id="fifteenMinButton" text="15 Minutes" GridPane.columnIndex="3" GridPane.halignment="LEFT" GridPane.rowIndex="4" />
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace5Min" prefWidth="100.0" fx:id="fiveMinButton" text="5 Minutes" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
<Label text="Select Race Duration:" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1">
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling"
prefWidth="100.0" fx:id="fifteenMinButton" text="15 Minutes" GridPane.columnIndex="3"
GridPane.halignment="LEFT" GridPane.rowIndex="4"/>
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace5Min"
prefWidth="100.0" fx:id="fiveMinButton" text="5 Minutes" GridPane.columnIndex="2"
GridPane.halignment="CENTER" GridPane.rowIndex="4"/>
<Label text="Select Race Duration:" GridPane.columnIndex="2" GridPane.halignment="CENTER"
GridPane.rowIndex="3"/>
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1"
GridPane.columnSpan="3" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="boatNameColumn" prefWidth="360.0" style="-fx-font-size: 16;" text="Team Name" />
<TableColumn fx:id="boatCodeColumn" prefWidth="133.0" style="-fx-font-size: 16;" text="Code" />
<TableColumn fx:id="boatNameColumn" prefWidth="360.0" style="-fx-font-size: 16;"
text="Team Name"/>
<TableColumn fx:id="boatCodeColumn" prefWidth="133.0" style="-fx-font-size: 16;" text="Code"/>
</columns>
</TableView>
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="timeZoneTime" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" />
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="timeZoneTime" GridPane.columnIndex="2"
GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER"/>
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER"
GridPane.rowIndex="5"/>
</children>
</GridPane>
</children>

@ -2,11 +2,7 @@ package seng302.Mock;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;

@ -3,9 +3,7 @@ package seng302.Mock;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
/**
* Created by jjg64 on 19/04/17.
@ -14,7 +12,7 @@ public class RegattaXMLTest {
RegattaXMLReader regattaXMLReader;
@Before
public void findFile(){
public void findFile() {
try {
regattaXMLReader = new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml");
} catch (Exception e) {

@ -8,7 +8,6 @@ import seng302.Model.Leg;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* Tests only work on the current version of mockXML/raceXML/raceTest.xml
@ -73,6 +72,6 @@ public class StreamedRaceTest {
"M2",
"Gate"
};
for(int i = 0; i < legs.size(); i++) assertEquals(expectedNames[i], legs.get(i).getName());
for (int i = 0; i < legs.size(); i++) assertEquals(expectedNames[i], legs.get(i).getName());
}
}

@ -1,14 +1,10 @@
package seng302.Model;
import javafx.scene.paint.Color;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import seng302.GPSCoordinate;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.*;
/**
* Created by esa46 on 22/03/17.
@ -146,13 +142,13 @@ public class BoatInRaceTest {
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
boat.setCurrentLeg(leg0deg);
boat.setCurrentPosition(new GPSCoordinate(0,0));
boat.setCurrentPosition(new GPSCoordinate(0, 0));
// Get latitude of endpoint of wake at 10 kn (longitude is 0)
double endpointAt10Kn = boat.getWake().getLatitude();
// Latitude of endpoint at 20 kn should be twice endpoint at 10 kn
boat.setVelocity(20);
assertEquals(2*endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
}
}

@ -7,7 +7,6 @@ import org.junit.Test;
import seng302.Constants;
import seng302.GPSCoordinate;
import java.lang.reflect.Array;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;

@ -5,7 +5,6 @@ import org.junit.Test;
import seng302.Constants;
import seng302.GPSCoordinate;
import java.awt.*;
import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save