|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
package seng302;
|
|
|
|
|
import org.opengis.style.Mark;
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
import seng302.Mock.*;
|
|
|
|
|
import seng302.Networking.BinaryMessageDecoder;
|
|
|
|
|
@ -41,6 +42,14 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
|
|
|
|
|
private Map<Integer, BoatStatusMessage> boatStatus;
|
|
|
|
|
|
|
|
|
|
private AverageWind averageWind;
|
|
|
|
|
|
|
|
|
|
private CourseWinds courseWinds;
|
|
|
|
|
|
|
|
|
|
private Map<Integer, MarkRounding> markRounding;
|
|
|
|
|
|
|
|
|
|
private RaceStartStatus raceStartStatus;
|
|
|
|
|
|
|
|
|
|
public VisualiserInput(StreamedCourse course) throws IOException{
|
|
|
|
|
|
|
|
|
|
//connectionSocket = new Socket(InetAddress.getLocalHost(), 4942);
|
|
|
|
|
@ -49,6 +58,7 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
this.course = course;
|
|
|
|
|
this.boatLocation = new HashMap<>();
|
|
|
|
|
this.boatStatus = new HashMap<>();
|
|
|
|
|
this.markRounding = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//start Time
|
|
|
|
|
@ -106,6 +116,30 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
return boatStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the average wind of the race
|
|
|
|
|
* @return average wind in the race
|
|
|
|
|
*/
|
|
|
|
|
public AverageWind getAverageWind() {
|
|
|
|
|
return averageWind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns winds in the course
|
|
|
|
|
* @return winds that are in the course
|
|
|
|
|
*/
|
|
|
|
|
public CourseWinds getCourseWinds() {
|
|
|
|
|
return courseWinds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns get Mark Rounding Boat Source ID, MarkRound
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<Integer, MarkRounding> getMarkRounding() {
|
|
|
|
|
return markRounding;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Takes an inputStream and reads the first 15 bytes (the header) and gets the message length
|
|
|
|
|
* for the whole message then reads that and returns the byte array
|
|
|
|
|
@ -193,6 +227,8 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
break;
|
|
|
|
|
case RACESTARTSTATUS:
|
|
|
|
|
//System.out.println("Race Start Status Message");
|
|
|
|
|
RaceStartStatus rSS = (RaceStartStatus) data;
|
|
|
|
|
raceStartStatus = rSS;
|
|
|
|
|
break;
|
|
|
|
|
case YACHTEVENTCODE:
|
|
|
|
|
// System.out.println("Yacht Action Code!");
|
|
|
|
|
@ -219,12 +255,17 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
break;
|
|
|
|
|
case MARKROUNDING:
|
|
|
|
|
// System.out.println("Mark Rounding Message!");
|
|
|
|
|
MarkRounding mkrounding = (MarkRounding) data;
|
|
|
|
|
markRounding.put(mkrounding.getSourceID(), mkrounding);
|
|
|
|
|
break;
|
|
|
|
|
case COURSEWIND:
|
|
|
|
|
// System.out.println("Course Wind Message!");
|
|
|
|
|
courseWinds = (CourseWinds) data;
|
|
|
|
|
break;
|
|
|
|
|
case AVGWIND:
|
|
|
|
|
// System.out.println("Average Wind Message!");
|
|
|
|
|
AverageWind avgWind = (AverageWind) data;
|
|
|
|
|
averageWind = avgWind;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
System.out.println("Broken Message!");
|
|
|
|
|
|