mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge remote-tracking branch 'origin/develop' into story36_elapsed_time
# Conflicts: # src/main/java/seng302/models/BoatGroup.java
This commit is contained in:
@@ -62,6 +62,8 @@ public class App extends Application
|
|||||||
}
|
}
|
||||||
//Change the StreamReceiver in this else block to change the default data source.
|
//Change the StreamReceiver in this else block to change the default data source.
|
||||||
else{
|
else{
|
||||||
|
// sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
|
||||||
|
|
||||||
sr = new StreamReceiver("localhost", 4949, "RaceStream");
|
sr = new StreamReceiver("localhost", 4949, "RaceStream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import javafx.scene.shape.Polygon;
|
|||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import seng302.models.parsers.StreamParser;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -91,6 +94,9 @@ public class BoatGroup extends RaceObject{
|
|||||||
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()));
|
legTimeObject = new Text(String.valueOf(boat.getMarkRoundingTime()));
|
||||||
|
DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
|
String timeToNextMark = format.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
||||||
|
estTimeToNextMarkObject = new Text("Next mark: " + timeToNextMark);
|
||||||
|
|
||||||
teamNameObject.setX(TEAMNAME_X_OFFSET);
|
teamNameObject.setX(TEAMNAME_X_OFFSET);
|
||||||
teamNameObject.setY(TEAMNAME_Y_OFFSET);
|
teamNameObject.setY(TEAMNAME_Y_OFFSET);
|
||||||
@@ -250,6 +256,9 @@ 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()));
|
legTimeObject.setText(String.valueOf(boat.getMarkRoundingTime()));
|
||||||
|
DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
|
String timeToNextMark = format.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
||||||
|
estTimeToNextMarkObject.setText("Next mark: " + timeToNextMark);
|
||||||
} else {
|
} else {
|
||||||
setToInitialLocation = true;
|
setToInitialLocation = true;
|
||||||
rotationalGoal = rotation;
|
rotationalGoal = rotation;
|
||||||
|
|||||||
@@ -238,11 +238,11 @@ public class StreamParser extends Thread{
|
|||||||
Yacht boat = boats.get((int)(long) boatStatusSourceID);
|
Yacht boat = boats.get((int)(long) boatStatusSourceID);
|
||||||
boat.setBoatStatus((int)payload[28 + (i * 20)]);
|
boat.setBoatStatus((int)payload[28 + (i * 20)]);
|
||||||
boat.setLegNumber((int)payload[29 + (i * 20)]);
|
boat.setLegNumber((int)payload[29 + (i * 20)]);
|
||||||
boat.setPenaltiesAwarded((int)payload[29 + (i * 20)]);
|
boat.setPenaltiesAwarded((int)payload[30 + (i * 20)]);
|
||||||
boat.setPenaltiesServed((int)payload[30 + (i * 20)]);
|
boat.setPenaltiesServed((int)payload[31 + (i * 20)]);
|
||||||
Long estTimeAtNextMark = bytesToLong(Arrays.copyOfRange(payload,31 + (i * 20),37+ (i * 20)));
|
Long estTimeAtNextMark = bytesToLong(Arrays.copyOfRange(payload,32 + (i * 20),38+ (i * 20)));
|
||||||
boat.setEstimateTimeAtNextMark(estTimeAtNextMark);
|
boat.setEstimateTimeAtNextMark(estTimeAtNextMark);
|
||||||
Long estTimeAtFinish = bytesToLong(Arrays.copyOfRange(payload,37 + (i * 20),43+ (i * 20)));
|
Long estTimeAtFinish = bytesToLong(Arrays.copyOfRange(payload,38 + (i * 20),44+ (i * 20)));
|
||||||
boat.setEstimateTimeAtFinish(estTimeAtFinish);
|
boat.setEstimateTimeAtFinish(estTimeAtFinish);
|
||||||
boatsPos.put(estTimeAtFinish, boat);
|
boatsPos.put(estTimeAtFinish, boat);
|
||||||
// String boatStatus = "SourceID: " + boatStatusSourceID;
|
// String boatStatus = "SourceID: " + boatStatusSourceID;
|
||||||
@@ -580,6 +580,15 @@ public class StreamParser extends Thread{
|
|||||||
return boatsPos;
|
return boatsPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns current time in stream in long
|
||||||
|
*
|
||||||
|
* @return a long value of current time
|
||||||
|
*/
|
||||||
|
public static Long getCurrentTimeLong() {
|
||||||
|
return currentTimeLong;
|
||||||
|
}
|
||||||
|
|
||||||
public static void appClose(){
|
public static void appClose(){
|
||||||
appRunning = false;
|
appRunning = false;
|
||||||
System.out.println("[CLIENT] Shutting down stream parser");
|
System.out.println("[CLIENT] Shutting down stream parser");
|
||||||
|
|||||||
Reference in New Issue
Block a user