Merge branch 'splitIntoTwoModules' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into splitIntoTwoModules

main
Fan-Wu Yang 9 years ago
commit 037c09b059

@ -85,6 +85,11 @@ public class MockOutput implements Runnable
/**
* Used to give the mocOutput information about boat location to be made into a message and sent
* @param sourceID id of the boat
* @param lat latitude of boat
* @param lon longitude of boat
* @param heading heading of boat
* @param speed speed of boat
*/
public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed){

@ -111,8 +111,8 @@ public class Race implements Runnable {
AnimationTimer timer = new AnimationTimer() {
long currentTime = System.currentTimeMillis();
long startTime = currentTime + (PRERACE_TIME / scaleFactor);
long minutes;
long hours;
//long minutes;
//long hours;
long timeLeft;
@Override

@ -93,6 +93,4 @@ public class BoatTest {
TEST_BOAT.setCurrentLeg(start);
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
}
}

@ -100,28 +100,28 @@ public class BoatLocationMessage extends AC35Data
/**
* Ctor, with all parameters.
*
* @param messageVersionNumber
* @param time
* @param sourceID
* @param sequenceNumber
* @param deviceType
* @param latitude
* @param longitude
* @param altitude
* @param heading
* @param pitch
* @param roll
* @param boatSpeed
* @param boatCOG
* @param boatSOG
* @param apparentWindSpeed
* @param apparentWindAngle
* @param trueWindSpeed
* @param trueWindDirection
* @param trueWindAngle
* @param currentDrift
* @param currentSet
* @param rudderAngle
* @param messageVersionNumber message number
* @param time time of message
* @param sourceID id of boat
* @param sequenceNumber number of boat message
* @param deviceType type of boat
* @param latitude lat of boat
* @param longitude lon of boat
* @param altitude altitude of boat
* @param heading heading of boat
* @param pitch pitch of boat
* @param roll roll of boat
* @param boatSpeed boats speed
* @param boatCOG boat cog
* @param boatSOG boat sog
* @param apparentWindSpeed wind speed
* @param apparentWindAngle wind angle
* @param trueWindSpeed true wind speed
* @param trueWindDirection true wind direction
* @param trueWindAngle true wind angle
* @param currentDrift current drift
* @param currentSet current set
* @param rudderAngle rudder angle
*/
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, long sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, int trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
super(MessageType.BOATLOCATION);

@ -25,15 +25,28 @@ public class ByteConverter {
//Integer
//////////////////////////////////////////////////
/**
* @param bite bite to convert
* @return int
*/
public static int bytesToInt(byte bite){
byte[] bytes = {bite};
return bytesToInt(bytes, ByteOrder.LITTLE_ENDIAN);
}
/**
* @param bytes bytes to convert
* @return int
*/
public static int bytesToInt(byte[] bytes){
return bytesToInt(bytes, ByteOrder.LITTLE_ENDIAN);
}
/**
* @param bytes bytes to convert
* @param byteOrder order of the bytes
* @return int
*/
public static int bytesToInt(byte[] bytes, ByteOrder byteOrder){
byte[] bites = convertBytesToNum(bytes,byteOrder, IntegerSize);
return ByteBuffer.wrap(bites).order(byteOrder).getInt();
@ -144,7 +157,7 @@ public class ByteConverter {
* @param i the integer to be converted
* @param size Size that the byte array should be
* @param byteOrder the order that the bytes should be ie Big Endian
* @return
* @return bytes array
*/
public static byte[] intToBytes(int i ,int size, ByteOrder byteOrder){
ByteBuffer buffer = ByteBuffer.allocate(IntegerSize);
@ -171,7 +184,7 @@ public class ByteConverter {
* @param i the Long to be converted
* @param size Size that the byte array should be
* @param byteOrder the order that the bytes should be ie Big Endian
* @return
* @return byte array
*/
public static byte[] longToBytes(long i ,int size, ByteOrder byteOrder){
ByteBuffer buffer = ByteBuffer.allocate(LongSize);
@ -198,7 +211,7 @@ public class ByteConverter {
* @param i the Short to be converted
* @param size Size that the byte array should be
* @param byteOrder the order that the bytes should be ie Big Endian
* @return
* @return byte array
*/
public static byte[] shortToBytes(short i ,int size, ByteOrder byteOrder){
ByteBuffer buffer = ByteBuffer.allocate(ShortSize);
@ -225,7 +238,7 @@ public class ByteConverter {
* @param i the Char to be converted
* @param size Size that the byte array should be
* @param byteOrder the order that the bytes should be ie Big Endian
* @return
* @return byte array
*/
public static byte[] charToBytes(char i ,int size, ByteOrder byteOrder){
ByteBuffer buffer = ByteBuffer.allocate(CharSize);

@ -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);

@ -40,6 +40,7 @@ public class StartController extends Controller implements Observer {
@FXML private TableColumn<Boat, String> boatCodeColumn;
@FXML private Label timeZoneTime;
@FXML private Label timer;
@FXML private Label raceStatusLabel;
@FXML private int PRERACE_TIME = 10;
//@FXML Button fifteenMinButton;
@ -48,6 +49,7 @@ public class StartController extends Controller implements Observer {
private StreamedCourse raceData;
private long timeLeft = 1;
private int raceStat;
private VisualiserInput visualiserInput;
@ -98,6 +100,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(int scaleFactor) {
new AnimationTimer() {
@ -107,7 +110,9 @@ public class StartController extends Controller implements Observer {
@Override
public void handle(long arg0) {
timeLeft = startTime - currentTime;
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){

@ -50,6 +50,7 @@
<Font size="36.0" />
</font>
</Label>
<Label fx:id="raceStatusLabel" alignment="CENTER" text="Race Status:" textAlignment="CENTER" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
</children>
</GridPane>
</children>

Loading…
Cancel
Save