merging with wake remake #story[820]

This commit is contained in:
Peter Galloway
2017-05-01 20:09:51 +12:00
parent 130efa3a51
commit 33ae7beeb4
7 changed files with 28 additions and 20 deletions
+2 -2
View File
@@ -26,8 +26,8 @@ public class App extends Application
sr = new StreamReceiver("localhost", 8085, "TestThread1"); sr = new StreamReceiver("localhost", 8085, "TestThread1");
} }
else{ else{
// sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1"); sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1");
sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1"); //sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1");
} }
sr.start(); sr.start();
@@ -166,7 +166,7 @@ public class CanvasController {
positionPacket = movementQueue.take(); positionPacket = movementQueue.take();
Point2D p2d = latLonToXY(positionPacket.getLat(), positionPacket.getLon()); Point2D p2d = latLonToXY(positionPacket.getLat(), positionPacket.getLon());
double heading = 360.0 / 0xffff * positionPacket.getHeading(); 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){ } catch (InterruptedException e){
e.printStackTrace(); e.printStackTrace();
} }
+16 -14
View File
@@ -179,10 +179,10 @@ public class BoatGroup extends RaceObject{
* @param rotation Rotation to move graphics to. * @param rotation Rotation to move graphics to.
* @param raceIds RaceID of the object to move. * @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)) { if (hasRaceId(raceIds)) {
destinationSet = true; destinationSet = true;
boat.setVelocity(StreamParser.boatSpeeds.get((long)boat.getId())); boat.setVelocity(groundSpeed);
if (currentRotation < 0) if (currentRotation < 0)
currentRotation = 360 - currentRotation; currentRotation = 360 - currentRotation;
double dx = newXValue - boatPoly.getLayoutX(); double dx = newXValue - boatPoly.getLayoutX();
@@ -227,19 +227,21 @@ public class BoatGroup extends RaceObject{
} }
public void setDestination (double newXValue, double newYValue, int... 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 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) { public void rotateTo (double rotation) {
currentRotation = rotation; currentRotation = rotation;
+2 -1
View File
@@ -59,9 +59,10 @@ public abstract class RaceObject extends Group {
* @param x X co-ordinate to move the graphics to. * @param x X co-ordinate to move the graphics to.
* @param y Y 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 rotation Rotation to move graphics to.
* @param groundSpeed boat groundspeed.
* @param raceIds RaceID of the object to move. * @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 * 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). * set to the co-ordinates (x, y).
@@ -102,7 +102,7 @@ public class MarkGroup extends RaceObject {
//moveTo(points[0].getX(), points[0].getY()); //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); setDestination(x, y, raceIds);
this.rotationalGoal = rotation; this.rotationalGoal = rotation;
calculateRotationalVelocity(); calculateRotationalVelocity();
@@ -5,6 +5,7 @@ import javafx.geometry.Point3D;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.models.Boat;
import seng302.models.parsers.packets.BoatPositionPacket; import seng302.models.parsers.packets.BoatPositionPacket;
import seng302.models.parsers.packets.StreamPacket; import seng302.models.parsers.packets.StreamPacket;
@@ -337,7 +338,7 @@ public class StreamParser extends Thread{
long heading = bytesToLong(headingBytes); long heading = bytesToLong(headingBytes);
double groundSpeed = bytesToLong(groundSpeedBytes)/1000.0; double groundSpeed = bytesToLong(groundSpeedBytes)/1000.0;
short s = (short) ((groundSpeedBytes[1] & 0xFF) << 8 | (groundSpeedBytes[0] & 0xFF)); 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); BoatPositionPacket boatPacket = new BoatPositionPacket(boatId, timeValid, lat, lon, heading, groundSpeed);
@@ -32,4 +32,8 @@ public class BoatPositionPacket {
public double getHeading() { public double getHeading() {
return heading; return heading;
} }
public double getGroundSpeed() {
return groundSpeed;
}
} }