Merge remote-tracking branch 'origin/splitIntoTwoModules' into splitIntoTwoModules

# Conflicts:
#	visualiser/src/main/java/seng302/Controllers/StartController.java
This commit is contained in:
cbt24
2017-05-04 14:15:21 +12:00
17 changed files with 160 additions and 41 deletions
@@ -117,7 +117,7 @@ public class RaceController extends Controller {
* Initializes and runs the race, based on the user's chosen scale factor
* Currently uses an example racecourse
*
* @param visualiserInput
* @param visualiserInput input from network
*/
public void startRace(VisualiserInput visualiserInput) {
StreamedRace newRace = new StreamedRace(visualiserInput, this);
@@ -44,12 +44,14 @@ public class StartController extends Controller implements Observer {
@FXML private Label timer;
private ZonedDateTime startingTime;
@FXML private Label raceStatusLabel;
//@FXML Button fifteenMinButton;
private RaceClock raceClock;
private StreamedCourse raceData;
private int raceStat;
private VisualiserInput visualiserInput;
@@ -94,6 +96,7 @@ public class StartController extends Controller implements Observer {
/**
* Countdown timer until race starts. Use PRERACE_TIME to set countdown duration.
* @param scaleFactor factor to scale by
*/
protected void countdownTimer() {
new AnimationTimer() {
@@ -101,6 +104,9 @@ public class StartController extends Controller implements Observer {
public void handle(long arg0) {
ZonedDateTime currentTime = raceClock.getTime();
if (visualiserInput.getRaceStatus().getRaceStatus()==2) {
raceStat = visualiserInput.getRaceStatus().getRaceStatus();
raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus());
if (raceStat==2 || raceStat == 3) {
updateTime("Race is starting...");
stop();
parent.beginRace(visualiserInput);
@@ -29,6 +29,7 @@ public class BoatXMLReader extends XMLReader {
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
*/
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException {
this(filePath, true);
@@ -41,6 +42,7 @@ public class BoatXMLReader extends XMLReader {
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
*/
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException {
super(filePath);
@@ -49,6 +51,13 @@ public class BoatXMLReader extends XMLReader {
}
}
/**
* Constructor for Boat XML Reader
* @param xmlString sting to read
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException {
super(xmlString);
read();
@@ -46,6 +46,8 @@ public class StreamedCourseXMLReader extends XMLReader {
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
this(filePath, true);
@@ -58,6 +60,8 @@ public class StreamedCourseXMLReader extends XMLReader {
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
super(filePath);
@@ -66,17 +70,35 @@ public class StreamedCourseXMLReader extends XMLReader {
}
}
/**
* Constructor for Streamed Race XML
* @param xmlString string to read
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
super(xmlString);
read();
}
/**
* reads
* @throws ParseException error
* @throws StreamedCourseXMLException error
*/
private void read() throws ParseException, StreamedCourseXMLException {
readRace();
readParticipants();
readCourse();
}
/**
* reads a race
* @throws ParseException error
*/
private void readRace() throws ParseException {
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
Element settings = (Element) doc.getElementsByTagName("Race").item(0);
@@ -111,6 +133,10 @@ public class StreamedCourseXMLReader extends XMLReader {
}
}
/**
* reads a course
* @throws StreamedCourseXMLException error
*/
private void readCourse() throws StreamedCourseXMLException {
readCompoundMarks();
readCompoundMarkSequence();
@@ -1,11 +1,15 @@
package seng302.Mock;
import seng302.*;
import seng302.Controllers.RaceController;
import seng302.Model.*;
import seng302.GPSCoordinate;
import seng302.Model.Boat;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.Model.Race;
import seng302.Networking.Utils.BoatStatusMessage;
import seng302.Networking.Utils.Enums.BoatStatus;
import seng302.Networking.Utils.BoatLocationMessage;
import seng302.VisualiserInput;
/**
* Created by jjg64 on 21/04/17.
@@ -48,7 +52,6 @@ public class StreamedRace extends Race {
*
* @param boat Boat that the position is to be updated for.
* @param timeElapsed Time that has elapse since the start of the the race.
* @see BoatInRace
*/
protected void checkPosition(Boat boat, long timeElapsed) {
StreamedCourse raceData = visualiserInput.getCourse();
@@ -92,6 +95,11 @@ public class StreamedRace extends Race {
}
}
/**
* sets the position of a boat from coordinate
* @param boat the boat to set
* @param coordinate the position of the boat
*/
protected void setPosition(Boat boat, GPSCoordinate coordinate) {
boat.setCurrentPosition(coordinate);
}
@@ -59,10 +59,10 @@ public abstract class Race implements Runnable {
/**
* @deprecated
* @param startingBoats
* @param legs
* @param controller
* @param scaleFactor
* @param startingBoats boats starting the race
* @param legs legs in race
* @param controller controller for the race
* @param scaleFactor factor to scale by
*/
public Race(Boat[] startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
this(Arrays.asList(startingBoats), legs, controller, scaleFactor);
@@ -66,7 +66,8 @@ public class RaceClock {
/**
* Get ZonedDateTime corresponding to local time zone and given UTC time.
* @param time
* @param time time in mills
* @return local date time
*/
public ZonedDateTime getLocalTime(long time) {
Date utcTime = new Date(time);
@@ -23,6 +23,7 @@ public class RaceConnection {
/**
* Tries to create a socket to hostname and port, indicates status after test.
* @return true if socket can connect
*/
@SuppressWarnings("unused")
public boolean check() {
@@ -134,7 +134,7 @@ public class VisualiserInput implements Runnable
/**
* Returns get Mark Rounding Boat Source ID, MarkRound
* @return
* @return the mark rounding
*/
public Map<Integer, MarkRounding> getMarkRounding() {
return markRounding;
@@ -145,7 +145,7 @@ public class VisualiserInput implements Runnable
* for the whole message then reads that and returns the byte array
* @param inStream inputStream from socket
* @return encoded binary messsage bytes
* @throws IOException
* @throws IOException made by the inputstream reading
*/
private static byte[] getBytes(InputStream inStream) throws IOException {
while (inStream.available() < 15){