Added testing.

This commit is contained in:
Calum
2017-05-04 12:46:01 +12:00
parent 7f40fb6283
commit 3aefb14faf
7 changed files with 180 additions and 40 deletions
+2 -1
View File
@@ -53,8 +53,9 @@ public class App extends Application
break;
}
}
//Change the StreamReceiver in this else block to change the default data source.
else{
sr = new StreamReceiver("localhost", 8085, "RaceStream");
sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
}
sr.start();
+4
View File
@@ -22,6 +22,10 @@ public class Boat {
private String shortName;
private int id;
/**
* For testing only.
* @param teamName Boat team name.
*/
public Boat(String teamName) {
this.teamName = teamName;
this.velocity = 10; // Default velocity
+7 -23
View File
@@ -202,39 +202,21 @@ public class BoatGroup extends RaceObject{
if (currentRotation < 0)
currentRotation = 360 - currentRotation;
double dx = newXValue - boatPoly.getLayoutX();
// if ((dx > 0 && pixelVelocityX < 0) || (dx < 0 && pixelVelocityX > 0)) {
// pixelVelocityX = 0;
// } else {
pixelVelocityX = dx / expectedUpdateInterval;
// }
double dy = newYValue - boatPoly.getLayoutY();
//Check movement is reasonable. Assumes a 1000 * 1000 canvas
if (Math.abs(dx) > 50 || Math.abs(dy) > 50) {
// System.out.println("dx = " + dx);
// System.out.println("dy = " + dy);
dx = 0;
dy = 0;
moveTo(newXValue, newYValue);
}
//Slight delay on changing X/Y direction that could help jitter. Disabled since there was an issue with
//packets that might be causing it.
// if ((dx > 0 && pixelVelocityX < 0) || (dx < 0 && pixelVelocityX > 0)) {
// pixelVelocityX = 0;
// } else {
// pixelVelocityX = dx / expectedUpdateInterval;
// }
// if ((dy > 0 && pixelVelocityY < 0) || (dy < 0 && pixelVelocityY > 0)) {
// pixelVelocityY = 0;
// } else {
// pixelVelocityY = dy / expectedUpdateInterval;
// }
pixelVelocityX = dx / expectedUpdateInterval;
pixelVelocityY = dy / expectedUpdateInterval;
rotationalGoal = rotation;
calculateRotationalVelocity();
if (wakeGenerationDelay > 0) {
wake.rotate(rotationalGoal);
rotateTo(rotationalGoal);
rotateTo(rotationalGoal); //Need to test with this removed.
rotationalVelocity = 0;
wakeGenerationDelay--;
} else {
@@ -243,7 +225,7 @@ public class BoatGroup extends RaceObject{
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
} else {
setToInitialLocation = true;
rotationalGoal = rotation;
rotationalGoal = rotation;;
moveTo(newXValue, newYValue, rotation);
}
}
@@ -288,8 +270,7 @@ public class BoatGroup extends RaceObject{
public void rotateTo (double rotation) {
currentRotation = rotation;
boatPoly.getTransforms().clear();
boatPoly.getTransforms().add(new Rotate(rotation));
boatPoly.getTransforms().setAll(new Rotate(rotation));
}
public void forceRotation () {
@@ -361,6 +342,9 @@ public class BoatGroup extends RaceObject{
* @param stage The stage that the BoatGroup is added to.
*/
public void setStage (Stage stage) {
/* TODO: 4/05/17 cir27 - Find a way to get the stage to this point. Need to pass it through multiple controllers.
App.start() -> Controller.setContentPane -> RaceViewController -> CanvasController
*/
this.stage = stage;
this.stage.iconifiedProperty().addListener(e -> {
isMaximized = !stage.isIconified();
+3 -3
View File
@@ -60,9 +60,9 @@ class Wake extends Group {
if (sum < (max / 3))
rotate (rotationGoal); //In relatively straight segments the wake snaps to match the boats current position.
//This stops the wake from eventually becoming out of sync with the boat.
// if (Math.abs(rotationalVelocity) > 0.5) {
// rotationalVelocity = 0;
// }
if (Math.abs(rotationalVelocity) > 0.5) {
rotationalVelocity = 0;
}
//Update the index of the array of recent velocities that each wake uses. Each wake is 3 velocities behind the
//next smallest wake.
velocityIndices[0] = (13 + (velocityIndices[0] - 1) % 13) % 13;
@@ -58,12 +58,7 @@ public class MarkGroup extends RaceObject {
nodePixelVelocitiesX = new double[]{0d,0d};
nodePixelVelocitiesY = new double[]{0d,0d};
nodeDestinations = new Point2D[2];
// markCircle = new Circle(
// (points[1].getX() - points[0].getX()) / 2d,
// (points[1].getY() - points[0].getY()) / 2d,
// MARK_RADIUS,
// color
//
markCircle = new Circle(
points[0].getX(),
points[0].getY(),
@@ -72,12 +67,7 @@ public class MarkGroup extends RaceObject {
);
nodeDestinations[0] = new Point2D(markCircle.getCenterX(), markCircle.getCenterY());
super.getChildren().add(markCircle);
// markCircle = new Circle(
// -(points[1].getX() - points[0].getX()) / 2d,
// -(points[1].getY() - points[0].getY()) / 2d,
// MARK_RADIUS,
// color
// );
markCircle = new Circle(
points[1].getX(),
points[1].getY(),
@@ -99,7 +89,6 @@ public class MarkGroup extends RaceObject {
}
super.getChildren().add(line);
}
//moveTo(points[0].getX(), points[0].getY());
}
public void setDestination (double x, double y, double rotation, double groundSpeed, int... raceIds) {