From dd480080c94e074ffcdd5b33820e9e0e2b7fab71 Mon Sep 17 00:00:00 2001 From: Kusal Ekanayake Date: Sun, 23 Apr 2017 14:57:26 +1200 Subject: [PATCH 01/37] Updated .mailmap to have the correct username for Kusal Ekanayake. --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 99d9ff08..c283ee3c 100644 --- a/.mailmap +++ b/.mailmap @@ -16,4 +16,5 @@ # https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html # http://stacktoheap.com/blog/2013/01/06/using-mailmap-to-fix-authors-list-in-git/ -Michael Rausch \ No newline at end of file +Michael Rausch +Kusal Ekanayake kre39 \ No newline at end of file From fdb84b66759ab5bac70a338128b79c7d969c32fa Mon Sep 17 00:00:00 2001 From: Haoming Yin Date: Sun, 23 Apr 2017 18:51:36 +1200 Subject: [PATCH 02/37] Update .mailmap for Haoming Yin's information. --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index c283ee3c..10e3c891 100644 --- a/.mailmap +++ b/.mailmap @@ -17,4 +17,5 @@ # http://stacktoheap.com/blog/2013/01/06/using-mailmap-to-fix-authors-list-in-git/ Michael Rausch -Kusal Ekanayake kre39 \ No newline at end of file +Kusal Ekanayake kre39 +Haoming Yin \ No newline at end of file From 672194adb4260864d05b5b0b192031c95640366a Mon Sep 17 00:00:00 2001 From: Peter Galloway Date: Sun, 23 Apr 2017 19:04:45 +1200 Subject: [PATCH 03/37] changed Peter Galloway's name to specified format --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 10e3c891..c1005f48 100644 --- a/.mailmap +++ b/.mailmap @@ -18,4 +18,5 @@ Michael Rausch Kusal Ekanayake kre39 -Haoming Yin \ No newline at end of file +Haoming Yin +Peter Galloway Peter \ No newline at end of file From b6fd90e9d7f8127cbc16b750dcf14690084b933d Mon Sep 17 00:00:00 2001 From: Zhi You Tan Date: Mon, 24 Apr 2017 18:33:06 +1200 Subject: [PATCH 04/37] Updated .mailmap for Zhi You Tan's information --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index c1005f48..6bb0a96c 100644 --- a/.mailmap +++ b/.mailmap @@ -19,4 +19,5 @@ Michael Rausch Kusal Ekanayake kre39 Haoming Yin -Peter Galloway Peter \ No newline at end of file +Peter Galloway Peter +Zhi You Tan zyt10 \ No newline at end of file From a77423b937b765eb0393d8acc12688d53eae7552 Mon Sep 17 00:00:00 2001 From: Michael Rausch Date: Mon, 1 May 2017 00:07:56 +1200 Subject: [PATCH 05/37] Added other email to .mailmap --- .mailmap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 6bb0a96c..e6a6f21e 100644 --- a/.mailmap +++ b/.mailmap @@ -16,8 +16,10 @@ # https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html # http://stacktoheap.com/blog/2013/01/06/using-mailmap-to-fix-authors-list-in-git/ -Michael Rausch +Michael Rausch Kusal Ekanayake kre39 Haoming Yin Peter Galloway Peter -Zhi You Tan zyt10 \ No newline at end of file +Zhi You Tan zyt10 + + From 04ce6f6103e7a42d124b4ca512b696962cb98f36 Mon Sep 17 00:00:00 2001 From: Kusal Ekanayake Date: Tue, 2 May 2017 14:18:40 +1200 Subject: [PATCH 06/37] Removed white behind fps counter --- src/main/java/seng302/App.java | 4 ++-- src/main/java/seng302/controllers/CanvasController.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/seng302/App.java b/src/main/java/seng302/App.java index bd4de5ef..c86ef5d1 100644 --- a/src/main/java/seng302/App.java +++ b/src/main/java/seng302/App.java @@ -34,8 +34,8 @@ public class App extends Application sr = new StreamReceiver("localhost", 8085, "RaceStream"); } else{ - sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"RaceStream"); -// sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream"); +// sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"RaceStream"); + sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream"); // sr = new StreamReceiver("localhost", 8085, "RaceStream"); } diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index 94721e39..b3406cb0 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -209,6 +209,8 @@ public class CanvasController { private void drawFps(int fps){ if (raceViewController.isDisplayFps()){ gc.clearRect(5,5,50,20); + gc.setFill(Color.SKYBLUE); + gc.fillRect(4,4,51,21); gc.setFill(Color.BLACK); gc.setFont(new Font(14)); gc.setLineWidth(3); From 3af15b2b95a82e7480d46910099b7e1d535b4493 Mon Sep 17 00:00:00 2001 From: Zhi You Tan Date: Tue, 2 May 2017 18:02:44 +1200 Subject: [PATCH 07/37] Updated wind direction on race view controller so it responds to the stream. #story[818] --- .../controllers/RaceViewController.java | 21 +++++++++++++++---- .../seng302/models/parsers/StreamParser.java | 12 +++++++++++ .../java/seng302/server/ServerThread.java | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/seng302/controllers/RaceViewController.java b/src/main/java/seng302/controllers/RaceViewController.java index 8468376d..6112be11 100644 --- a/src/main/java/seng302/controllers/RaceViewController.java +++ b/src/main/java/seng302/controllers/RaceViewController.java @@ -69,11 +69,11 @@ public class RaceViewController extends Thread{ includedCanvasController.initializeCanvas(); initializeTimer(); initializeSettings(); - + initialiseWindDirection(); //set wind direction!!!!!!! can't find another place to put my code --haoming - double windDirection = new ConfigParser("/config/config.xml").getWindDirection(); - windDirectionText.setText(String.format("%.1f°", windDirection)); - windArrowText.setRotate(windDirection); +// double windDirection = new ConfigParser("/config/config.xml").getWindDirection(); +// windDirectionText.setText(String.format("%.1f°", windDirection)); +// windArrowText.setRotate(windDirection); includedCanvasController.timer.start(); } @@ -145,6 +145,19 @@ public class RaceViewController extends Thread{ timerTimeline.playFromStart(); } + private void initialiseWindDirection() { + Timeline windDirTimeline = new Timeline(); + windDirTimeline.setCycleCount(Timeline.INDEFINITE); + windDirTimeline.getKeyFrames().add( + new KeyFrame(Duration.seconds(1), + event -> { + windDirectionText.setText(String.format("%.1f°", StreamParser.getWindDirection())); + windArrowText.setRotate(StreamParser.getWindDirection()); + }) + ); + windDirTimeline.playFromStart(); + } + /** * Generates time line for each boat, and stores time time into timelineInfos hash map */ diff --git a/src/main/java/seng302/models/parsers/StreamParser.java b/src/main/java/seng302/models/parsers/StreamParser.java index e2efd773..ff520e8a 100644 --- a/src/main/java/seng302/models/parsers/StreamParser.java +++ b/src/main/java/seng302/models/parsers/StreamParser.java @@ -39,6 +39,7 @@ public class StreamParser extends Thread{ private static boolean streamStatus = false; private static long timeSinceStart = -1; private static List boats = new ArrayList<>(); + private static double windDirection = 0; /** * Used to initialise the thread name and stream parser object so a thread can be executed @@ -194,6 +195,8 @@ public class StreamParser extends Thread{ timeSinceStart = timeTillStart; } long windDir = bytesToLong(Arrays.copyOfRange(payload,18,20)); + double windDirFactor = 0x4000 / 90; //0x4000 is 90 degrees, 0x8000 is 180 degrees, etc... + windDirection = windDir / windDirFactor; long windSpeed = bytesToLong(Arrays.copyOfRange(payload,20,22)); int noBoats = payload[22]; int raceType = payload[23]; @@ -487,5 +490,14 @@ public class StreamParser extends Thread{ public static XMLParser getXmlObject() { return xmlObject; } + + /** + * returns the wind direction in degrees + * + * @return a double wind direction value + */ + public static double getWindDirection() { + return windDirection; + } } diff --git a/src/main/java/seng302/server/ServerThread.java b/src/main/java/seng302/server/ServerThread.java index e4e5a84a..804ee5f5 100644 --- a/src/main/java/seng302/server/ServerThread.java +++ b/src/main/java/seng302/server/ServerThread.java @@ -265,7 +265,7 @@ public class ServerThread implements Runnable, Observer { for (Boat b : ((Simulator) o).getBoats()){ try { Message m = new BoatLocationMessage(b.getSourceID(), 1, b.getLat(), - b.getLng(), b.getHeadingCorner().getBearingToNextCorner(), + b.getLng(), b.getLastPassedCorner().getBearingToNextCorner(), ((long) b.getSpeed())); server.send(m); } catch (IOException e) { From 8233b75e0597b546c3edf2fe503ac2d108d4ceec Mon Sep 17 00:00:00 2001 From: Zhi You Tan Date: Tue, 2 May 2017 18:52:31 +1200 Subject: [PATCH 08/37] Fixed the start screen team list after merging. Team list shows boats competing in event again. #story[572] --- src/main/java/seng302/controllers/Controller.java | 11 +++++------ .../java/seng302/models/parsers/StreamParser.java | 11 +++++++---- src/main/java/seng302/models/parsers/XMLParser.java | 9 +++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main/java/seng302/controllers/Controller.java b/src/main/java/seng302/controllers/Controller.java index 2baa46c4..26f75d52 100644 --- a/src/main/java/seng302/controllers/Controller.java +++ b/src/main/java/seng302/controllers/Controller.java @@ -15,7 +15,6 @@ import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; -import seng302.models.Boat; import seng302.models.parsers.StreamParser; import seng302.models.parsers.XMLParser; @@ -124,18 +123,18 @@ public class Controller implements Initializable { } private void updateTeamList() { - ObservableList data = FXCollections.observableArrayList(); + ObservableList data = FXCollections.observableArrayList(); teamList.setItems(data); boatNameCol.setCellValueFactory( - new PropertyValueFactory("boatName") + new PropertyValueFactory("BoatName") ); shortNameCol.setCellValueFactory( - new PropertyValueFactory("shortName") + new PropertyValueFactory("ShortName") ); countryCol.setCellValueFactory( - new PropertyValueFactory("country") + new PropertyValueFactory("Country") ); - for (Boat boat : StreamParser.getBoats()) { + for (XMLParser.BoatXMLObject.Boat boat : StreamParser.getBoats()) { data.add(boat); } } diff --git a/src/main/java/seng302/models/parsers/StreamParser.java b/src/main/java/seng302/models/parsers/StreamParser.java index ff520e8a..b0eed3aa 100644 --- a/src/main/java/seng302/models/parsers/StreamParser.java +++ b/src/main/java/seng302/models/parsers/StreamParser.java @@ -5,7 +5,6 @@ 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; @@ -38,7 +37,7 @@ public class StreamParser extends Thread{ private static boolean raceFinished = false; private static boolean streamStatus = false; private static long timeSinceStart = -1; - private static List boats = new ArrayList<>(); + private static List boats = new ArrayList<>(); private static double windDirection = 0; /** @@ -202,7 +201,8 @@ public class StreamParser extends Thread{ int raceType = payload[23]; ArrayList boatStatuses = new ArrayList<>(); for (int i = 0; i < noBoats; i++){ - String boatStatus = "SourceID: " + bytesToLong(Arrays.copyOfRange(payload,24 + (i * 20),28+ (i * 20))); + Long boatStatusSourceID = bytesToLong(Arrays.copyOfRange(payload,24 + (i * 20),28+ (i * 20))); + String boatStatus = "SourceID: " + boatStatusSourceID; boatStatus += "\nBoat Status: " + (int)payload[28 + (i * 20)]; boatStatus += "\nLegNumber: " + (int)payload[29 + (i * 20)]; boatStatus += "\nPenaltiesAwarded: " + (int)payload[29 + (i * 20)]; @@ -258,6 +258,9 @@ public class StreamParser extends Thread{ } xmlObject.constructXML(doc, messageType); + if (messageType == 7) { //7 is the boat XML + boats = xmlObject.getBoatXML().getCompetingBoats(); + } } /** @@ -477,7 +480,7 @@ public class StreamParser extends Thread{ * * @return list of boats */ - public static List getBoats() { + public static List getBoats() { return boats; } diff --git a/src/main/java/seng302/models/parsers/XMLParser.java b/src/main/java/seng302/models/parsers/XMLParser.java index a50cbcbc..43016500 100644 --- a/src/main/java/seng302/models/parsers/XMLParser.java +++ b/src/main/java/seng302/models/parsers/XMLParser.java @@ -6,6 +6,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.ArrayList; +import java.util.List; /** * Class to create an XML object from the XML Packet Messages. @@ -393,6 +394,8 @@ public class XMLParser { //Boats ArrayList boats; + //Competing boats + List competingBoats = new ArrayList<>(); /** * Constructor for a BoatXMLObject. @@ -427,6 +430,9 @@ public class XMLParser { if (currentBoat.getNodeName().equals("Boat")) { Boat boat = new Boat(currentBoat); this.boats.add(boat); + if (boat.getBoatType().equals("Yacht")) { + competingBoats.add(boat); + } } //System.out.println(this.getBoats()); } @@ -442,6 +448,9 @@ public class XMLParser { public Double getCourseZoneSize() { return courseZoneSize; } public ArrayList getZoneLimits() { return zoneLimits; } public ArrayList getBoats() { return boats; } + public List getCompetingBoats() { + return competingBoats; + } public class Boat { From 6d02f05f05b0965899180e079f01daf5fb453ae6 Mon Sep 17 00:00:00 2001 From: William Muir Date: Tue, 2 May 2017 21:51:04 +1200 Subject: [PATCH 09/37] Quick change to stop adding course markers as they are dynamic and add them in the previous way --- src/main/java/seng302/controllers/CanvasController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index bb138e70..6f50aea7 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -41,7 +41,7 @@ public class CanvasController { private GraphicsContext gc; private final int MARK_SIZE = 10; - private final int BUFFER_SIZE = 150; + private final int BUFFER_SIZE = 50; private final int CANVAS_WIDTH = 1000; private final int CANVAS_HEIGHT = 1000; private final int LHS_BUFFER = BUFFER_SIZE; From 772ece25a0856cb3c144d9e5640deeebf75cc4b0 Mon Sep 17 00:00:00 2001 From: Zhi You Tan Date: Tue, 2 May 2017 22:39:33 +1200 Subject: [PATCH 10/37] Implemented real time race clock on the start screen using data from stream. #story[594] --- .../java/seng302/controllers/Controller.java | 17 ++++++++++++----- .../seng302/models/parsers/StreamParser.java | 11 +++++++++++ src/main/resources/views/MainView.fxml | 16 +++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/main/java/seng302/controllers/Controller.java b/src/main/java/seng302/controllers/Controller.java index 26f75d52..228369c0 100644 --- a/src/main/java/seng302/controllers/Controller.java +++ b/src/main/java/seng302/controllers/Controller.java @@ -22,10 +22,9 @@ import seng302.models.parsers.XMLParser; import javax.xml.crypto.dsig.XMLObject; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; -import java.util.ResourceBundle; -import java.util.Timer; -import java.util.TimerTask; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by michaelrausch on 21/03/17. @@ -47,6 +46,8 @@ public class Controller implements Initializable { private TableColumn shortNameCol; @FXML private TableColumn countryCol; + @FXML + private Label realTime; private void setContentPane(String jfxUrl){ try{ @@ -64,7 +65,9 @@ public class Controller implements Initializable { @Override public void initialize(URL location, ResourceBundle resources) { - + DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + realTime.setText(format.format(System.currentTimeMillis())); } /** @@ -74,6 +77,7 @@ public class Controller implements Initializable { if (StreamParser.isStreamStatus()) { XMLParser xmlParser = StreamParser.getXmlObject(); streamButton.setVisible(false); + realTime.setVisible(true); timeTillLive.setVisible(true); timeTillLive.setTextFill(Color.GREEN); timeTillLive.setText("Connecting..."); @@ -83,10 +87,12 @@ public class Controller implements Initializable { public void run() { Platform.runLater(() -> { if (StreamParser.isRaceFinished()) { + realTime.setText(StreamParser.getCurrentTimeString()); timeTillLive.setTextFill(Color.RED); timeTillLive.setText("Race finished! Waiting for new race..."); switchToRaceViewButton.setDisable(true); } else if (StreamParser.getTimeSinceStart() > 0) { + realTime.setText(StreamParser.getCurrentTimeString()); updateTeamList(); timeTillLive.setTextFill(Color.RED); switchToRaceViewButton.setDisable(false); @@ -98,6 +104,7 @@ public class Controller implements Initializable { String timerString = "-" + timerMinute + ":" + timerSecond + " minutes"; timeTillLive.setText(timerString); } else { + realTime.setText(StreamParser.getCurrentTimeString()); updateTeamList(); timeTillLive.setTextFill(Color.BLACK); switchToRaceViewButton.setDisable(false); diff --git a/src/main/java/seng302/models/parsers/StreamParser.java b/src/main/java/seng302/models/parsers/StreamParser.java index b0eed3aa..40ef23aa 100644 --- a/src/main/java/seng302/models/parsers/StreamParser.java +++ b/src/main/java/seng302/models/parsers/StreamParser.java @@ -39,6 +39,7 @@ public class StreamParser extends Thread{ private static long timeSinceStart = -1; private static List boats = new ArrayList<>(); private static double windDirection = 0; + private static String currentTimeString; /** * Used to initialise the thread name and stream parser object so a thread can be executed @@ -177,6 +178,7 @@ public class StreamParser extends Thread{ DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000; + currentTimeString = format.format((new Date (currentTime)).getTime()); if (timeTillStart > 0) { timeSinceStart = timeTillStart; System.out.println("Time till start: " + timeTillStart + " Seconds"); @@ -502,5 +504,14 @@ public class StreamParser extends Thread{ public static double getWindDirection() { return windDirection; } + + /** + * returns stream time in formatted string format + * + * @return String of stream time + */ + public static String getCurrentTimeString() { + return currentTimeString; + } } diff --git a/src/main/resources/views/MainView.fxml b/src/main/resources/views/MainView.fxml index cc38f3ed..dc275512 100644 --- a/src/main/resources/views/MainView.fxml +++ b/src/main/resources/views/MainView.fxml @@ -17,8 +17,9 @@ - - + + + @@ -38,14 +39,14 @@ -