diff --git a/src/main/java/seng302/App.java b/src/main/java/seng302/App.java index dc6de280..68107866 100644 --- a/src/main/java/seng302/App.java +++ b/src/main/java/seng302/App.java @@ -26,8 +26,8 @@ public class App extends Application sr = new StreamReceiver("localhost", 8085, "TestThread1"); } else{ -// sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1"); - sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1"); + sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1"); + //sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1"); } sr.start(); diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index 6ee934b1..94721e39 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -166,7 +166,7 @@ public class CanvasController { positionPacket = movementQueue.take(); Point2D p2d = latLonToXY(positionPacket.getLat(), positionPacket.getLon()); double heading = 360.0 / 0xffff * positionPacket.getHeading(); - raceObject.setDestination(p2d.getX(), p2d.getY(), heading, (int) id); + raceObject.setDestination(p2d.getX(), p2d.getY(), heading, positionPacket.getGroundSpeed(), (int) id); } catch (InterruptedException e){ e.printStackTrace(); } diff --git a/src/main/java/seng302/models/BoatGroup.java b/src/main/java/seng302/models/BoatGroup.java index 618a3b59..d53edfe2 100644 --- a/src/main/java/seng302/models/BoatGroup.java +++ b/src/main/java/seng302/models/BoatGroup.java @@ -179,10 +179,10 @@ public class BoatGroup extends RaceObject{ * @param rotation Rotation to move graphics to. * @param raceIds RaceID of the object to move. */ - public void setDestination (double newXValue, double newYValue, double rotation, int... raceIds) { + public void setDestination (double newXValue, double newYValue, double rotation, double groundSpeed, int... raceIds) { if (hasRaceId(raceIds)) { destinationSet = true; - boat.setVelocity(StreamParser.boatSpeeds.get((long)boat.getId())); + boat.setVelocity(groundSpeed); if (currentRotation < 0) currentRotation = 360 - currentRotation; double dx = newXValue - boatPoly.getLayoutX(); @@ -227,19 +227,21 @@ public class BoatGroup extends RaceObject{ } public void setDestination (double newXValue, double newYValue, int... raceIDs) { - destinationSet = true; - - if (hasRaceId(raceIDs)) { - double rotation = Math.abs( - Math.toDegrees( - Math.atan( - (newYValue - boatPoly.getLayoutY()) / (newXValue - boatPoly.getLayoutX()) - ) - ) - ); - setDestination(newXValue, newYValue, rotation, raceIDs); - } } +// public void setDestination (double newXValue, double newYValue, int... raceIDs) { +// destinationSet = true; +// +// if (hasRaceId(raceIDs)) { +// double rotation = Math.abs( +// Math.toDegrees( +// Math.atan( +// (newYValue - boatPoly.getLayoutY()) / (newXValue - boatPoly.getLayoutX()) +// ) +// ) +// ); +// setDestination(newXValue, newYValue, rotation, raceIDs); +// } +// } public void rotateTo (double rotation) { currentRotation = rotation; diff --git a/src/main/java/seng302/models/RaceObject.java b/src/main/java/seng302/models/RaceObject.java index af29cb5c..21eaece9 100644 --- a/src/main/java/seng302/models/RaceObject.java +++ b/src/main/java/seng302/models/RaceObject.java @@ -59,9 +59,10 @@ public abstract class RaceObject extends Group { * @param x X co-ordinate to move the graphics to. * @param y Y co-ordinate to move the graphics to. * @param rotation Rotation to move graphics to. + * @param groundSpeed boat groundspeed. * @param raceIds RaceID of the object to move. */ - public abstract void setDestination (double x, double y, double rotation, int... raceIds); + public abstract void setDestination (double x, double y, double rotation, double groundSpeed, int... raceIds); /** * Sets the destination of everything within the RaceObject that has an ID in the array raceIds. The destination is * set to the co-ordinates (x, y). diff --git a/src/main/java/seng302/models/mark/MarkGroup.java b/src/main/java/seng302/models/mark/MarkGroup.java index b0ef4768..916bcd41 100644 --- a/src/main/java/seng302/models/mark/MarkGroup.java +++ b/src/main/java/seng302/models/mark/MarkGroup.java @@ -102,7 +102,7 @@ public class MarkGroup extends RaceObject { //moveTo(points[0].getX(), points[0].getY()); } - public void setDestination (double x, double y, double rotation, int... raceIds) { + public void setDestination (double x, double y, double rotation, double groundSpeed, int... raceIds) { setDestination(x, y, raceIds); this.rotationalGoal = rotation; calculateRotationalVelocity(); diff --git a/src/main/java/seng302/models/parsers/StreamParser.java b/src/main/java/seng302/models/parsers/StreamParser.java index 34b76b80..47f3b123 100644 --- a/src/main/java/seng302/models/parsers/StreamParser.java +++ b/src/main/java/seng302/models/parsers/StreamParser.java @@ -5,6 +5,7 @@ import javafx.geometry.Point3D; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import seng302.models.Boat; import seng302.models.parsers.packets.BoatPositionPacket; import seng302.models.parsers.packets.StreamPacket; @@ -337,7 +338,7 @@ public class StreamParser extends Thread{ long heading = bytesToLong(headingBytes); double groundSpeed = bytesToLong(groundSpeedBytes)/1000.0; short s = (short) ((groundSpeedBytes[1] & 0xFF) << 8 | (groundSpeedBytes[0] & 0xFF)); - if ((int)deviceType == 1){ + if ((int)deviceType == 1 || (int)deviceType == 3){ BoatPositionPacket boatPacket = new BoatPositionPacket(boatId, timeValid, lat, lon, heading, groundSpeed); diff --git a/src/main/java/seng302/models/parsers/packets/BoatPositionPacket.java b/src/main/java/seng302/models/parsers/packets/BoatPositionPacket.java index b0b958df..d6f0700d 100644 --- a/src/main/java/seng302/models/parsers/packets/BoatPositionPacket.java +++ b/src/main/java/seng302/models/parsers/packets/BoatPositionPacket.java @@ -32,4 +32,8 @@ public class BoatPositionPacket { public double getHeading() { return heading; } + + public double getGroundSpeed() { + return groundSpeed; + } }