mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Prepared StreamParser.java, BoatGroup.java, Yacht.java for leg timer annotation (story 36)
#story[927]
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package seng302.controllers;
|
package seng302.controllers;
|
||||||
|
|
||||||
import javafx.animation.Animation;
|
|
||||||
import javafx.animation.KeyFrame;
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@@ -342,10 +341,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK)) {
|
if (importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK)) {
|
||||||
bg.setEstTimeToNextMarkVisible(true);
|
bg.setEstTimeToNextMarkObjectVisible(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bg.setEstTimeToNextMarkVisible(false);
|
bg.setEstTimeToNextMarkObjectVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +357,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
BoatGroup bg = (BoatGroup) ro;
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
bg.setTeamNameObjectVisible(false);
|
bg.setTeamNameObjectVisible(false);
|
||||||
bg.setVelocityObjectVisible(false);
|
bg.setVelocityObjectVisible(false);
|
||||||
bg.setEstTimeToNextMarkVisible(false);
|
bg.setEstTimeToNextMarkObjectVisible(false);
|
||||||
bg.setLineGroupVisible(false);
|
bg.setLineGroupVisible(false);
|
||||||
bg.setWakeVisible(false);
|
bg.setWakeVisible(false);
|
||||||
}
|
}
|
||||||
@@ -371,7 +370,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
BoatGroup bg = (BoatGroup) ro;
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
bg.setTeamNameObjectVisible(true);
|
bg.setTeamNameObjectVisible(true);
|
||||||
bg.setVelocityObjectVisible(false);
|
bg.setVelocityObjectVisible(false);
|
||||||
bg.setEstTimeToNextMarkVisible(false);
|
bg.setEstTimeToNextMarkObjectVisible(false);
|
||||||
bg.setLineGroupVisible(false);
|
bg.setLineGroupVisible(false);
|
||||||
bg.setWakeVisible(false);
|
bg.setWakeVisible(false);
|
||||||
}
|
}
|
||||||
@@ -393,7 +392,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
BoatGroup bg = (BoatGroup) ro;
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
bg.setTeamNameObjectVisible(true);
|
bg.setTeamNameObjectVisible(true);
|
||||||
bg.setVelocityObjectVisible(true);
|
bg.setVelocityObjectVisible(true);
|
||||||
bg.setEstTimeToNextMarkVisible(true);
|
bg.setEstTimeToNextMarkObjectVisible(true);
|
||||||
bg.setLineGroupVisible(true);
|
bg.setLineGroupVisible(true);
|
||||||
bg.setWakeVisible(true);
|
bg.setWakeVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class BoatGroup extends RaceObject{
|
|||||||
private static final double VELOCITY_Y_OFFSET = -17d;
|
private static final double VELOCITY_Y_OFFSET = -17d;
|
||||||
private static final double ESTTIMETONEXTMARK_X_OFFSET = 10d;
|
private static final double ESTTIMETONEXTMARK_X_OFFSET = 10d;
|
||||||
private static final double ESTTIMETONEXTMARK_Y_OFFSET = -5d;
|
private static final double ESTTIMETONEXTMARK_Y_OFFSET = -5d;
|
||||||
|
private static final double LEGTIME_X_OFFSET = 10d;
|
||||||
|
private static final double LEGTIME_Y_OFFSET = 7d;
|
||||||
private static final double BOAT_HEIGHT = 15d;
|
private static final double BOAT_HEIGHT = 15d;
|
||||||
private static final double BOAT_WIDTH = 10d;
|
private static final double BOAT_WIDTH = 10d;
|
||||||
//Variables for boat logic.
|
//Variables for boat logic.
|
||||||
@@ -41,6 +43,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
private Text teamNameObject;
|
private Text teamNameObject;
|
||||||
private Text velocityObject;
|
private Text velocityObject;
|
||||||
private Text estTimeToNextMarkObject;
|
private Text estTimeToNextMarkObject;
|
||||||
|
private Text legTimeObject;
|
||||||
private Wake wake;
|
private Wake wake;
|
||||||
//Handles boat moving when connecting to a stream
|
//Handles boat moving when connecting to a stream
|
||||||
private boolean setToInitialLocation = false;
|
private boolean setToInitialLocation = false;
|
||||||
@@ -87,6 +90,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
teamNameObject = new Text(boat.getShortName());
|
teamNameObject = new Text(boat.getShortName());
|
||||||
velocityObject = new Text(String.valueOf(boat.getVelocity()));
|
velocityObject = new Text(String.valueOf(boat.getVelocity()));
|
||||||
estTimeToNextMarkObject = new Text(String.valueOf(boat.getEstimateTimeAtNextMark()));
|
estTimeToNextMarkObject = new Text(String.valueOf(boat.getEstimateTimeAtNextMark()));
|
||||||
|
legTimeObject = new Text(String.valueOf(boat.getMarkRoundingTime()));
|
||||||
|
|
||||||
teamNameObject.setX(TEAMNAME_X_OFFSET);
|
teamNameObject.setX(TEAMNAME_X_OFFSET);
|
||||||
teamNameObject.setY(TEAMNAME_Y_OFFSET);
|
teamNameObject.setY(TEAMNAME_Y_OFFSET);
|
||||||
@@ -101,8 +105,12 @@ public class BoatGroup extends RaceObject{
|
|||||||
estTimeToNextMarkObject.setY(ESTTIMETONEXTMARK_Y_OFFSET);
|
estTimeToNextMarkObject.setY(ESTTIMETONEXTMARK_Y_OFFSET);
|
||||||
estTimeToNextMarkObject.relocate(estTimeToNextMarkObject.getX(), estTimeToNextMarkObject.getY());
|
estTimeToNextMarkObject.relocate(estTimeToNextMarkObject.getX(), estTimeToNextMarkObject.getY());
|
||||||
|
|
||||||
|
legTimeObject.setX(LEGTIME_X_OFFSET);
|
||||||
|
legTimeObject.setY(LEGTIME_Y_OFFSET);
|
||||||
|
legTimeObject.relocate(legTimeObject.getX(), legTimeObject.getY());
|
||||||
|
|
||||||
wake = new Wake(0, -BOAT_HEIGHT);
|
wake = new Wake(0, -BOAT_HEIGHT);
|
||||||
super.getChildren().addAll(teamNameObject, velocityObject, boatPoly, estTimeToNextMarkObject);
|
super.getChildren().addAll(teamNameObject, velocityObject, boatPoly, estTimeToNextMarkObject, legTimeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,6 +138,8 @@ public class BoatGroup extends RaceObject{
|
|||||||
velocityObject.setLayoutY(velocityObject.getLayoutY() + dy);
|
velocityObject.setLayoutY(velocityObject.getLayoutY() + dy);
|
||||||
estTimeToNextMarkObject.setLayoutX(estTimeToNextMarkObject.getLayoutX() + dx);
|
estTimeToNextMarkObject.setLayoutX(estTimeToNextMarkObject.getLayoutX() + dx);
|
||||||
estTimeToNextMarkObject.setLayoutY(estTimeToNextMarkObject.getLayoutY() + dy);
|
estTimeToNextMarkObject.setLayoutY(estTimeToNextMarkObject.getLayoutY() + dy);
|
||||||
|
legTimeObject.setLayoutX(legTimeObject.getLayoutX() + dx);
|
||||||
|
legTimeObject.setLayoutY(legTimeObject.getLayoutY() + dy);
|
||||||
wake.setLayoutX(wake.getLayoutX() + dx);
|
wake.setLayoutX(wake.getLayoutX() + dx);
|
||||||
wake.setLayoutY(wake.getLayoutY() + dy);
|
wake.setLayoutY(wake.getLayoutY() + dy);
|
||||||
rotateTo(rotation + currentRotation);
|
rotateTo(rotation + currentRotation);
|
||||||
@@ -160,6 +170,8 @@ public class BoatGroup extends RaceObject{
|
|||||||
velocityObject.setLayoutY(y);
|
velocityObject.setLayoutY(y);
|
||||||
estTimeToNextMarkObject.setLayoutX(x);
|
estTimeToNextMarkObject.setLayoutX(x);
|
||||||
estTimeToNextMarkObject.setLayoutY(y);
|
estTimeToNextMarkObject.setLayoutY(y);
|
||||||
|
legTimeObject.setLayoutX(x);
|
||||||
|
legTimeObject.setLayoutY(y);
|
||||||
wake.setLayoutX(x);
|
wake.setLayoutX(x);
|
||||||
wake.setLayoutY(y);
|
wake.setLayoutY(y);
|
||||||
wake.rotate(currentRotation);
|
wake.rotate(currentRotation);
|
||||||
@@ -237,6 +249,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
}
|
}
|
||||||
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
|
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
|
||||||
estTimeToNextMarkObject.setText(String.valueOf(boat.getEstimateTimeAtNextMark()));
|
estTimeToNextMarkObject.setText(String.valueOf(boat.getEstimateTimeAtNextMark()));
|
||||||
|
legTimeObject.setText(String.valueOf(boat.getMarkRoundingTime()));
|
||||||
} else {
|
} else {
|
||||||
setToInitialLocation = true;
|
setToInitialLocation = true;
|
||||||
rotationalGoal = rotation;
|
rotationalGoal = rotation;
|
||||||
@@ -300,10 +313,14 @@ public class BoatGroup extends RaceObject{
|
|||||||
velocityObject.setVisible(visible);
|
velocityObject.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEstTimeToNextMarkVisible(Boolean visible) {
|
public void setEstTimeToNextMarkObjectVisible(Boolean visible) {
|
||||||
estTimeToNextMarkObject.setVisible(visible);
|
estTimeToNextMarkObject.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLegObjectTime(Boolean visible) {
|
||||||
|
legTimeObject.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLineGroupVisible(Boolean visible) {
|
public void setLineGroupVisible(Boolean visible) {
|
||||||
lineGroup.setVisible(visible);
|
lineGroup.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import java.text.SimpleDateFormat;
|
|||||||
* also done outside Boat class because some old variables are not used anymore.
|
* also done outside Boat class because some old variables are not used anymore.
|
||||||
*/
|
*/
|
||||||
public class Yacht {
|
public class Yacht {
|
||||||
|
// Used in boat group
|
||||||
private Color colour;
|
private Color colour;
|
||||||
private double velocity;
|
private double velocity;
|
||||||
private Integer markLastPast;
|
|
||||||
|
|
||||||
private String boatType;
|
private String boatType;
|
||||||
private Integer sourceID;
|
private Integer sourceID;
|
||||||
@@ -30,6 +30,8 @@ public class Yacht {
|
|||||||
private Long estimateTimeAtNextMark;
|
private Long estimateTimeAtNextMark;
|
||||||
private Long estimateTimeAtFinish;
|
private Long estimateTimeAtFinish;
|
||||||
private String position;
|
private String position;
|
||||||
|
// Mark rounding
|
||||||
|
private Long markRoundingTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in EventTest and RaceTest.
|
* Used in EventTest and RaceTest.
|
||||||
@@ -157,11 +159,11 @@ public class Yacht {
|
|||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMarkLastPast() {
|
public Long getMarkRoundingTime() {
|
||||||
return markLastPast;
|
return markRoundingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkLastPast(Integer markLastPast) {
|
public void setMarkRoundingTime(Long markRoundingTime) {
|
||||||
this.markLastPast = markLastPast;
|
this.markRoundingTime = markRoundingTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class StreamParser extends Thread{
|
|||||||
private static Map<Integer, Yacht> boats = new HashMap<>();
|
private static Map<Integer, Yacht> boats = new HashMap<>();
|
||||||
private static Map<Long, Yacht> boatsPos = new TreeMap<>();
|
private static Map<Long, Yacht> boatsPos = new TreeMap<>();
|
||||||
private static double windDirection = 0;
|
private static double windDirection = 0;
|
||||||
|
private static Long currentTimeLong;
|
||||||
private static String currentTimeString;
|
private static String currentTimeString;
|
||||||
private static boolean appRunning;
|
private static boolean appRunning;
|
||||||
|
|
||||||
@@ -196,9 +197,11 @@ public class StreamParser extends Thread{
|
|||||||
long currentTime = bytesToLong(Arrays.copyOfRange(payload,1,7));
|
long currentTime = bytesToLong(Arrays.copyOfRange(payload,1,7));
|
||||||
long raceId = bytesToLong(Arrays.copyOfRange(payload,7,11));
|
long raceId = bytesToLong(Arrays.copyOfRange(payload,7,11));
|
||||||
int raceStatus = payload[11];
|
int raceStatus = payload[11];
|
||||||
// System.out.println("raceStatus = " + raceStatus);
|
|
||||||
long expectedStartTime = bytesToLong(Arrays.copyOfRange(payload,12,18));
|
long expectedStartTime = bytesToLong(Arrays.copyOfRange(payload,12,18));
|
||||||
|
long windDir = bytesToLong(Arrays.copyOfRange(payload,18,20));
|
||||||
|
long windSpeed = bytesToLong(Arrays.copyOfRange(payload,20,22));
|
||||||
|
|
||||||
|
currentTimeLong = currentTime;
|
||||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||||
if (xmlObject.getRegattaXML() != null) {
|
if (xmlObject.getRegattaXML() != null) {
|
||||||
format.setTimeZone(TimeZone.getTimeZone(getTimeZoneString()));
|
format.setTimeZone(TimeZone.getTimeZone(getTimeZoneString()));
|
||||||
@@ -206,7 +209,6 @@ public class StreamParser extends Thread{
|
|||||||
}
|
}
|
||||||
long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000;
|
long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000;
|
||||||
|
|
||||||
|
|
||||||
if (timeTillStart > 0) {
|
if (timeTillStart > 0) {
|
||||||
timeSinceStart = timeTillStart;
|
timeSinceStart = timeTillStart;
|
||||||
//System.out.println("Time till start: " + timeTillStart + " Seconds");
|
//System.out.println("Time till start: " + timeTillStart + " Seconds");
|
||||||
@@ -223,10 +225,10 @@ public class StreamParser extends Thread{
|
|||||||
//System.out.println("Time since start: " + -1 * timeTillStart + " Seconds");
|
//System.out.println("Time since start: " + -1 * timeTillStart + " Seconds");
|
||||||
timeSinceStart = timeTillStart;
|
timeSinceStart = timeTillStart;
|
||||||
}
|
}
|
||||||
long windDir = bytesToLong(Arrays.copyOfRange(payload,18,20));
|
|
||||||
double windDirFactor = 0x4000 / 90; //0x4000 is 90 degrees, 0x8000 is 180 degrees, etc...
|
double windDirFactor = 0x4000 / 90; //0x4000 is 90 degrees, 0x8000 is 180 degrees, etc...
|
||||||
windDirection = windDir / windDirFactor;
|
windDirection = windDir / windDirFactor;
|
||||||
long windSpeed = bytesToLong(Arrays.copyOfRange(payload,20,22));
|
|
||||||
int noBoats = payload[22];
|
int noBoats = payload[22];
|
||||||
int raceType = payload[23];
|
int raceType = payload[23];
|
||||||
// ArrayList<String> boatStatuses = new ArrayList<>();
|
// ArrayList<String> boatStatuses = new ArrayList<>();
|
||||||
@@ -429,6 +431,9 @@ public class StreamParser extends Thread{
|
|||||||
int roundingSide = payload[18];
|
int roundingSide = payload[18];
|
||||||
int markType = payload[19];
|
int markType = payload[19];
|
||||||
int markId = payload[20];
|
int markId = payload[20];
|
||||||
|
|
||||||
|
// assign mark rounding time to boat
|
||||||
|
boats.get((int)subjectId).setMarkRoundingTime(timeStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user