diff --git a/mock/src/main/java/seng302/MockOutput.java b/mock/src/main/java/seng302/MockOutput.java index f5ee2e4c..dd268698 100644 --- a/mock/src/main/java/seng302/MockOutput.java +++ b/mock/src/main/java/seng302/MockOutput.java @@ -85,6 +85,11 @@ public class MockOutput implements Runnable /** * Used to give the mocOutput information about boat location to be made into a message and sent + * @param sourceID id of the boat + * @param lat latitude of boat + * @param lon longitude of boat + * @param heading heading of boat + * @param speed speed of boat */ public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed){ diff --git a/mock/src/main/java/seng302/Model/Race.java b/mock/src/main/java/seng302/Model/Race.java index a23c4cfd..3dc72c86 100644 --- a/mock/src/main/java/seng302/Model/Race.java +++ b/mock/src/main/java/seng302/Model/Race.java @@ -111,8 +111,8 @@ public class Race implements Runnable { AnimationTimer timer = new AnimationTimer() { long currentTime = System.currentTimeMillis(); long startTime = currentTime + (PRERACE_TIME / scaleFactor); - long minutes; - long hours; + //long minutes; + //long hours; long timeLeft; @Override diff --git a/mock/src/test/java/seng302/Model/BoatTest.java b/mock/src/test/java/seng302/Model/BoatTest.java index 47cc5e73..75b01939 100644 --- a/mock/src/test/java/seng302/Model/BoatTest.java +++ b/mock/src/test/java/seng302/Model/BoatTest.java @@ -93,6 +93,4 @@ public class BoatTest { TEST_BOAT.setCurrentLeg(start); assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8); } - - } diff --git a/network/src/main/java/seng302/Networking/Utils/BoatLocationMessage.java b/network/src/main/java/seng302/Networking/Utils/BoatLocationMessage.java index 2a60a528..6e9b3704 100644 --- a/network/src/main/java/seng302/Networking/Utils/BoatLocationMessage.java +++ b/network/src/main/java/seng302/Networking/Utils/BoatLocationMessage.java @@ -100,28 +100,28 @@ public class BoatLocationMessage extends AC35Data /** * Ctor, with all parameters. * - * @param messageVersionNumber - * @param time - * @param sourceID - * @param sequenceNumber - * @param deviceType - * @param latitude - * @param longitude - * @param altitude - * @param heading - * @param pitch - * @param roll - * @param boatSpeed - * @param boatCOG - * @param boatSOG - * @param apparentWindSpeed - * @param apparentWindAngle - * @param trueWindSpeed - * @param trueWindDirection - * @param trueWindAngle - * @param currentDrift - * @param currentSet - * @param rudderAngle + * @param messageVersionNumber message number + * @param time time of message + * @param sourceID id of boat + * @param sequenceNumber number of boat message + * @param deviceType type of boat + * @param latitude lat of boat + * @param longitude lon of boat + * @param altitude altitude of boat + * @param heading heading of boat + * @param pitch pitch of boat + * @param roll roll of boat + * @param boatSpeed boats speed + * @param boatCOG boat cog + * @param boatSOG boat sog + * @param apparentWindSpeed wind speed + * @param apparentWindAngle wind angle + * @param trueWindSpeed true wind speed + * @param trueWindDirection true wind direction + * @param trueWindAngle true wind angle + * @param currentDrift current drift + * @param currentSet current set + * @param rudderAngle rudder angle */ 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, int trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) { super(MessageType.BOATLOCATION); diff --git a/network/src/main/java/seng302/Networking/Utils/ByteConverter.java b/network/src/main/java/seng302/Networking/Utils/ByteConverter.java index aac6afed..7df204da 100644 --- a/network/src/main/java/seng302/Networking/Utils/ByteConverter.java +++ b/network/src/main/java/seng302/Networking/Utils/ByteConverter.java @@ -25,15 +25,28 @@ public class ByteConverter { //Integer ////////////////////////////////////////////////// + /** + * @param bite bite to convert + * @return int + */ public static int bytesToInt(byte bite){ byte[] bytes = {bite}; return bytesToInt(bytes, ByteOrder.LITTLE_ENDIAN); } + /** + * @param bytes bytes to convert + * @return int + */ public static int bytesToInt(byte[] bytes){ return bytesToInt(bytes, ByteOrder.LITTLE_ENDIAN); } + /** + * @param bytes bytes to convert + * @param byteOrder order of the bytes + * @return int + */ public static int bytesToInt(byte[] bytes, ByteOrder byteOrder){ byte[] bites = convertBytesToNum(bytes,byteOrder, IntegerSize); return ByteBuffer.wrap(bites).order(byteOrder).getInt(); @@ -144,7 +157,7 @@ public class ByteConverter { * @param i the integer to be converted * @param size Size that the byte array should be * @param byteOrder the order that the bytes should be ie Big Endian - * @return + * @return bytes array */ public static byte[] intToBytes(int i ,int size, ByteOrder byteOrder){ ByteBuffer buffer = ByteBuffer.allocate(IntegerSize); @@ -171,7 +184,7 @@ public class ByteConverter { * @param i the Long to be converted * @param size Size that the byte array should be * @param byteOrder the order that the bytes should be ie Big Endian - * @return + * @return byte array */ public static byte[] longToBytes(long i ,int size, ByteOrder byteOrder){ ByteBuffer buffer = ByteBuffer.allocate(LongSize); @@ -198,7 +211,7 @@ public class ByteConverter { * @param i the Short to be converted * @param size Size that the byte array should be * @param byteOrder the order that the bytes should be ie Big Endian - * @return + * @return byte array */ public static byte[] shortToBytes(short i ,int size, ByteOrder byteOrder){ ByteBuffer buffer = ByteBuffer.allocate(ShortSize); @@ -225,7 +238,7 @@ public class ByteConverter { * @param i the Char to be converted * @param size Size that the byte array should be * @param byteOrder the order that the bytes should be ie Big Endian - * @return + * @return byte array */ public static byte[] charToBytes(char i ,int size, ByteOrder byteOrder){ ByteBuffer buffer = ByteBuffer.allocate(CharSize); diff --git a/network/src/test/java/seng302/Networking/AC35UnitConverter.java b/network/src/test/java/seng302/Networking/AC35UnitConverter.java new file mode 100644 index 00000000..0471c8f2 --- /dev/null +++ b/network/src/test/java/seng302/Networking/AC35UnitConverter.java @@ -0,0 +1,40 @@ +package seng302.Networking; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static seng302.Networking.Utils.AC35UnitConverter.*; + +/** + * Created by fwy13 on 4/05/17. + */ +public class AC35UnitConverter { + + @Test + public void testConvertGPS(){ + assertTrue(convertGPS(0) == 0); + assertTrue(convertGPS(Integer.MAX_VALUE) == (double)Integer.MAX_VALUE * 180.0 / Math.pow(2, 31)); + + } + + + @Test + public void testConvertGPSToInt(){ + assertTrue(convertGPSToInt(0) == 0); + assertTrue(convertGPSToInt(180) == (int)2147483648.0); + + } + + @Test + public void testConvertHeading(){ + assertTrue(convertHeading(0) == 0); + assertTrue(convertHeading(65536) == 360.0); + } + + + @Test + public void testConvertTrueWindAngle(){ + assertTrue(convertTrueWindAngle(0) == 0); + assertTrue(convertTrueWindAngle(32768) == 180.0); + } +} diff --git a/visualiser/src/main/java/seng302/Controllers/RaceController.java b/visualiser/src/main/java/seng302/Controllers/RaceController.java index e1195dab..00a55023 100644 --- a/visualiser/src/main/java/seng302/Controllers/RaceController.java +++ b/visualiser/src/main/java/seng302/Controllers/RaceController.java @@ -117,7 +117,7 @@ public class RaceController extends Controller { * Initializes and runs the race, based on the user's chosen scale factor * Currently uses an example racecourse * - * @param visualiserInput + * @param visualiserInput input from network */ public void startRace(VisualiserInput visualiserInput) { StreamedRace newRace = new StreamedRace(visualiserInput, this); diff --git a/visualiser/src/main/java/seng302/Controllers/StartController.java b/visualiser/src/main/java/seng302/Controllers/StartController.java index ad173df1..4034391e 100644 --- a/visualiser/src/main/java/seng302/Controllers/StartController.java +++ b/visualiser/src/main/java/seng302/Controllers/StartController.java @@ -40,6 +40,7 @@ public class StartController extends Controller implements Observer { @FXML private TableColumn boatCodeColumn; @FXML private Label timeZoneTime; @FXML private Label timer; + @FXML private Label raceStatusLabel; @FXML private int PRERACE_TIME = 10; //@FXML Button fifteenMinButton; @@ -48,6 +49,7 @@ public class StartController extends Controller implements Observer { private StreamedCourse raceData; private long timeLeft = 1; + private int raceStat; private VisualiserInput visualiserInput; @@ -98,6 +100,7 @@ public class StartController extends Controller implements Observer { /** * Countdown timer until race starts. Use PRERACE_TIME to set countdown duration. + * @param scaleFactor factor to scale by */ protected void countdownTimer(int scaleFactor) { new AnimationTimer() { @@ -107,7 +110,9 @@ public class StartController extends Controller implements Observer { @Override public void handle(long arg0) { timeLeft = startTime - currentTime; - if (visualiserInput.getRaceStatus().getRaceStatus()==2) { + raceStat = visualiserInput.getRaceStatus().getRaceStatus(); + raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus()); + if (raceStat==2 || raceStat == 3) { updateTime("Race is starting..."); stop(); parent.beginRace(visualiserInput); diff --git a/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java b/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java index d7dc45d3..cac0f5f9 100644 --- a/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java +++ b/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java @@ -29,6 +29,7 @@ public class BoatXMLReader extends XMLReader { * @throws IOException error * @throws SAXException error * @throws ParserConfigurationException error + * @throws ParseException error */ public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException { this(filePath, true); @@ -41,6 +42,7 @@ public class BoatXMLReader extends XMLReader { * @throws IOException error * @throws SAXException error * @throws ParserConfigurationException error + * @throws ParseException error */ public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException { super(filePath); @@ -49,6 +51,13 @@ public class BoatXMLReader extends XMLReader { } } + /** + * Constructor for Boat XML Reader + * @param xmlString sting to read + * @throws IOException error + * @throws SAXException error + * @throws ParserConfigurationException error + */ public BoatXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException { super(xmlString); read(); diff --git a/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java b/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java index c58e715c..6a54d1a8 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java @@ -46,6 +46,8 @@ public class StreamedCourseXMLReader extends XMLReader { * @throws IOException error * @throws SAXException error * @throws ParserConfigurationException error + * @throws ParseException error + * @throws StreamedCourseXMLException error */ public StreamedCourseXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException { this(filePath, true); @@ -58,6 +60,8 @@ public class StreamedCourseXMLReader extends XMLReader { * @throws IOException error * @throws SAXException error * @throws ParserConfigurationException error + * @throws ParseException error + * @throws StreamedCourseXMLException error */ public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException { super(filePath); @@ -66,17 +70,35 @@ public class StreamedCourseXMLReader extends XMLReader { } } + /** + * Constructor for Streamed Race XML + * @param xmlString string to read + * @throws IOException error + * @throws SAXException error + * @throws ParserConfigurationException error + * @throws ParseException error + * @throws StreamedCourseXMLException error + */ public StreamedCourseXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException { super(xmlString); read(); } + /** + * reads + * @throws ParseException error + * @throws StreamedCourseXMLException error + */ private void read() throws ParseException, StreamedCourseXMLException { readRace(); readParticipants(); readCourse(); } + /** + * reads a race + * @throws ParseException error + */ private void readRace() throws ParseException { DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME; Element settings = (Element) doc.getElementsByTagName("Race").item(0); @@ -111,6 +133,10 @@ public class StreamedCourseXMLReader extends XMLReader { } } + /** + * reads a course + * @throws StreamedCourseXMLException error + */ private void readCourse() throws StreamedCourseXMLException { readCompoundMarks(); readCompoundMarkSequence(); diff --git a/visualiser/src/main/java/seng302/Mock/StreamedRace.java b/visualiser/src/main/java/seng302/Mock/StreamedRace.java index c5194d5f..433c2230 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedRace.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedRace.java @@ -1,11 +1,15 @@ package seng302.Mock; -import seng302.*; import seng302.Controllers.RaceController; -import seng302.Model.*; +import seng302.GPSCoordinate; +import seng302.Model.Boat; +import seng302.Model.Leg; +import seng302.Model.Marker; +import seng302.Model.Race; import seng302.Networking.Utils.BoatStatusMessage; import seng302.Networking.Utils.Enums.BoatStatus; import seng302.Networking.Utils.BoatLocationMessage; +import seng302.VisualiserInput; /** * Created by jjg64 on 21/04/17. @@ -48,7 +52,6 @@ public class StreamedRace extends Race { * * @param boat Boat that the position is to be updated for. * @param timeElapsed Time that has elapse since the start of the the race. - * @see BoatInRace */ protected void checkPosition(Boat boat, long timeElapsed) { StreamedCourse raceData = visualiserInput.getCourse(); @@ -92,6 +95,11 @@ public class StreamedRace extends Race { } } + /** + * sets the position of a boat from coordinate + * @param boat the boat to set + * @param coordinate the position of the boat + */ protected void setPosition(Boat boat, GPSCoordinate coordinate) { boat.setCurrentPosition(coordinate); } diff --git a/visualiser/src/main/java/seng302/Model/Race.java b/visualiser/src/main/java/seng302/Model/Race.java index edc40181..b3085432 100644 --- a/visualiser/src/main/java/seng302/Model/Race.java +++ b/visualiser/src/main/java/seng302/Model/Race.java @@ -59,10 +59,10 @@ public abstract class Race implements Runnable { /** * @deprecated - * @param startingBoats - * @param legs - * @param controller - * @param scaleFactor + * @param startingBoats boats starting the race + * @param legs legs in race + * @param controller controller for the race + * @param scaleFactor factor to scale by */ public Race(Boat[] startingBoats, List legs, RaceController controller, int scaleFactor) { this(Arrays.asList(startingBoats), legs, controller, scaleFactor); diff --git a/visualiser/src/main/java/seng302/Model/RaceClock.java b/visualiser/src/main/java/seng302/Model/RaceClock.java index 93b85b7c..83679454 100644 --- a/visualiser/src/main/java/seng302/Model/RaceClock.java +++ b/visualiser/src/main/java/seng302/Model/RaceClock.java @@ -66,7 +66,8 @@ public class RaceClock { /** * Get ZonedDateTime corresponding to local time zone and given UTC time. - * @param time + * @param time time in mills + * @return local date time */ public ZonedDateTime getLocalTime(long time) { Date utcTime = new Date(time); diff --git a/visualiser/src/main/java/seng302/RaceConnection.java b/visualiser/src/main/java/seng302/RaceConnection.java index 97a2f232..e78362e6 100644 --- a/visualiser/src/main/java/seng302/RaceConnection.java +++ b/visualiser/src/main/java/seng302/RaceConnection.java @@ -23,6 +23,7 @@ public class RaceConnection { /** * Tries to create a socket to hostname and port, indicates status after test. + * @return true if socket can connect */ @SuppressWarnings("unused") public boolean check() { diff --git a/visualiser/src/main/java/seng302/VisualiserInput.java b/visualiser/src/main/java/seng302/VisualiserInput.java index 012e954a..4a426968 100644 --- a/visualiser/src/main/java/seng302/VisualiserInput.java +++ b/visualiser/src/main/java/seng302/VisualiserInput.java @@ -134,7 +134,7 @@ public class VisualiserInput implements Runnable /** * Returns get Mark Rounding Boat Source ID, MarkRound - * @return + * @return the mark rounding */ public Map getMarkRounding() { return markRounding; @@ -145,7 +145,7 @@ public class VisualiserInput implements Runnable * for the whole message then reads that and returns the byte array * @param inStream inputStream from socket * @return encoded binary messsage bytes - * @throws IOException + * @throws IOException made by the inputstream reading */ private static byte[] getBytes(InputStream inStream) throws IOException { while (inStream.available() < 15){ diff --git a/visualiser/src/main/resources/scenes/start.fxml b/visualiser/src/main/resources/scenes/start.fxml index ca3c2e3a..2a6971a5 100644 --- a/visualiser/src/main/resources/scenes/start.fxml +++ b/visualiser/src/main/resources/scenes/start.fxml @@ -50,6 +50,7 @@ +